diff --git a/light-js/index.html b/light-js/index.html index 6507e98..ee9f703 100644 --- a/light-js/index.html +++ b/light-js/index.html @@ -76,12 +76,13 @@ createDecoder, utf8ToBytes, bytesToUtf8, - } from "https://unpkg.com/@waku/sdk@0.0.24-070b625.0/bundle/index.js"; + } from "https://unpkg.com/@waku/sdk@0.0.25-fd60cc2.0/bundle/index.js"; import { enrTree, DnsNodeDiscovery, - } from "https://unpkg.com/@waku/discovery@0.0.2-070b625.0/bundle/index.js"; - import { messageHash } from "https://unpkg.com/@waku/message-hash@0.1.12-070b625.0/bundle/index.js"; + wakuDnsDiscovery, + } from "https://unpkg.com/@waku/discovery@0.0.2-fd60cc2.0/bundle/index.js"; + import { messageHash } from "https://unpkg.com/@waku/message-hash@0.1.13-fd60cc2.0/bundle/index.js"; const peerIdDiv = document.getElementById("peer-id"); const remotePeerIdDiv = document.getElementById("remote-peer-id"); @@ -99,7 +100,7 @@ const ContentTopic = "/js-waku-examples/1/chat/utf8"; const decoder = createDecoder(ContentTopic); - const encoder = createEncoder({ contentTopic: ContentTopic }); + const encoder = createEncoder({ contentTopic: ContentTopic}); // Each key is a unique identifier for the message. Each value is an obj { text, timestamp } let messages = {}; let unsubscribe; @@ -125,7 +126,12 @@ } statusDiv.innerHTML = "

Creating Waku node.

"; - const node = await createLightNode(); + const node = await createLightNode({ + shardInfo: { + contentTopics: [ContentTopic] + }, + defaultBootstrap: true, + }); statusDiv.innerHTML = "

Starting Waku node.

"; await node.start(); diff --git a/noise-js/index.js b/noise-js/index.js index bd48c7a..e729497 100644 --- a/noise-js/index.js +++ b/noise-js/index.js @@ -16,7 +16,7 @@ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _waku_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/sdk */ \"./node_modules/@waku/sdk/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _waku_noise__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/noise */ \"./node_modules/@waku/noise/dist/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs */ \"./node_modules/protobufjs/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(protobufjs__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! qrcode */ \"./node_modules/qrcode/lib/browser.js\");\n\n\n\n\n\n\n// Protobuf\nconst ProtoChatMessage = new (protobufjs__WEBPACK_IMPORTED_MODULE_3___default().Type)(\"ChatMessage\")\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_3___default().Field)(\"timestamp\", 1, \"uint64\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_3___default().Field)(\"nick\", 2, \"string\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_3___default().Field)(\"text\", 3, \"bytes\"));\n\nmain();\n\nasync function main() {\n const ui = initUI();\n ui.waku.connecting();\n\n // Starting the node\n const node = await (0,_waku_sdk__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({\n defaultBootstrap: true,\n });\n\n try {\n await node.start();\n await (0,_waku_sdk__WEBPACK_IMPORTED_MODULE_0__.waitForRemotePeer)(node, [\"filter\", \"lightpush\"]);\n\n ui.waku.connected();\n\n const myStaticKey = _waku_noise__WEBPACK_IMPORTED_MODULE_2__.generateX25519KeyPair();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_2__.WakuPairing(\n node.lightPush,\n node.filter,\n myStaticKey,\n urlPairingInfo || new _waku_noise__WEBPACK_IMPORTED_MODULE_2__.ResponderParameters()\n );\n const pExecute = pairingObj.execute(120000); // timeout after 2m\n\n scheduleHandshakeAuthConfirmation(pairingObj, ui);\n\n let encoder;\n let decoder;\n\n try {\n ui.handshake.waiting();\n\n if (!urlPairingInfo) {\n const pairingURL = buildPairingURLFromObj(pairingObj);\n ui.shareInfo.setURL(pairingURL);\n ui.shareInfo.renderQR(pairingURL);\n ui.shareInfo.show();\n }\n\n [encoder, decoder] = await pExecute;\n\n ui.handshake.connected();\n ui.shareInfo.hide();\n } catch (err) {\n ui.handshake.error(err.message);\n ui.hide();\n }\n\n ui.message.display();\n\n await node.filter.subscribe(\n [decoder],\n ui.message.onReceive.bind(ui.message)\n );\n\n ui.message.onSend(async (text, nick) => {\n const timestamp = Math.floor(Date.now() / 1000);\n const message = ProtoChatMessage.create({\n nick,\n timestamp,\n text: _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes(text),\n });\n const payload = ProtoChatMessage.encode(message).finish();\n\n await node.lightPush.send(encoder, { payload, timestamp });\n });\n } catch (err) {\n ui.waku.error(err.message);\n ui.hide();\n }\n}\n\nfunction buildPairingURLFromObj(pairingObj) {\n const pInfo = pairingObj.getPairingInfo();\n\n // Data to encode in the QR code. The qrMessageNametag too to the QR string (separated by )\n const messageNameTagParam = `messageNameTag=${_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToHex(\n pInfo.qrMessageNameTag\n )}`;\n const qrCodeParam = `qrCode=${encodeURIComponent(pInfo.qrCode)}`;\n\n return `${window.location.href}?${messageNameTagParam}&${qrCodeParam}`;\n}\n\nfunction getPairingInfoFromURL() {\n const urlParams = new URLSearchParams(window.location.search);\n\n const messageNameTag = urlParams.get(\"messageNameTag\");\n const qrCodeString = urlParams.get(\"qrCode\");\n\n if (!(messageNameTag && qrCodeString)) {\n return undefined;\n }\n\n return new _waku_noise__WEBPACK_IMPORTED_MODULE_2__.InitiatorParameters(\n decodeURIComponent(qrCodeString),\n _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(messageNameTag)\n );\n}\n\nasync function scheduleHandshakeAuthConfirmation(pairingObj, ui) {\n const authCode = await pairingObj.getAuthCode();\n ui.handshake.connecting();\n pairingObj.validateAuthCode(confirm(\"Confirm that authcode is: \" + authCode));\n}\n\nfunction initUI() {\n const messagesList = document.getElementById(\"messages\");\n const nicknameInput = document.getElementById(\"nick-input\");\n const textInput = document.getElementById(\"text-input\");\n const sendButton = document.getElementById(\"send-btn\");\n const chatArea = document.getElementById(\"chat-area\");\n const wakuStatusSpan = document.getElementById(\"waku-status\");\n const handshakeStatusSpan = document.getElementById(\"handshake-status\");\n\n const qrCanvas = document.getElementById(\"qr-canvas\");\n const qrUrlContainer = document.getElementById(\"qr-url-container\");\n const qrUrl = document.getElementById(\"qr-url\");\n const copyURLButton = document.getElementById(\"copy-url\");\n const openTabButton = document.getElementById(\"open-tab\");\n\n copyURLButton.onclick = () => {\n const copyText = document.getElementById(\"qr-url\"); // need to get it each time otherwise copying does not work\n copyText.select();\n copyText.setSelectionRange(0, 99999);\n navigator.clipboard.writeText(copyText.value);\n };\n\n openTabButton.onclick = () => {\n window.open(qrUrl.value, \"_blank\");\n };\n\n const disableChatUIStateIfNeeded = () => {\n const readyToSend = nicknameInput.value !== \"\";\n textInput.disabled = !readyToSend;\n sendButton.disabled = !readyToSend;\n };\n nicknameInput.onchange = disableChatUIStateIfNeeded;\n nicknameInput.onblur = disableChatUIStateIfNeeded;\n\n return {\n shareInfo: {\n setURL(url) {\n qrUrl.value = url;\n },\n hide() {\n qrUrlContainer.style.display = \"none\";\n },\n show() {\n qrUrlContainer.style.display = \"flex\";\n },\n renderQR(url) {\n qrcode__WEBPACK_IMPORTED_MODULE_4__.toCanvas(qrCanvas, url, (err) => {\n if (err) {\n throw err;\n }\n });\n },\n },\n waku: {\n _val(msg) {\n wakuStatusSpan.innerText = msg;\n },\n _class(name) {\n wakuStatusSpan.className = name;\n },\n connecting() {\n this._val(\"connecting...\");\n this._class(\"progress\");\n },\n connected() {\n this._val(\"connected\");\n this._class(\"success\");\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n },\n handshake: {\n _val(val) {\n handshakeStatusSpan.innerText = val;\n },\n _class(name) {\n handshakeStatusSpan.className = name;\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n waiting() {\n this._val(\"waiting for handshake...\");\n this._class(\"progress\");\n },\n generating() {\n this._val(\"generating QR code...\");\n this._class(\"progress\");\n },\n connecting() {\n this._val(\"executing handshake...\");\n this._class(\"progress\");\n },\n connected() {\n this._val(\"handshake completed!\");\n this._class(\"success\");\n },\n },\n message: {\n _render({ time, text, nick }) {\n messagesList.innerHTML += `\n
  • \n (${nick})\n ${text}\n [${new Date(time).toISOString()}]\n
  • \n `;\n },\n _status(text, className) {\n sendButton.className = className;\n },\n onReceive({ payload }) {\n const { timestamp, nick, text } = ProtoChatMessage.decode(payload);\n\n this._render({\n nick,\n time: timestamp * 1000,\n text: _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8(text),\n });\n },\n onSend(cb) {\n sendButton.addEventListener(\"click\", async () => {\n try {\n this._status(\"sending...\", \"progress\");\n await cb(textInput.value, nicknameInput.value);\n this._status(\"sent\", \"success\");\n\n this._render({\n time: Date.now(), // a bit different from what receiver will see but for the matter of example is good enough\n text: textInput.value,\n nick: nicknameInput.value,\n });\n textInput.value = \"\";\n } catch (e) {\n this._status(`error: ${e.message}`, \"error\");\n }\n });\n },\n display() {\n chatArea.style.display = \"block\";\n this._status(\"waiting for input\", \"progress\");\n },\n },\n hide() {\n this.shareInfo.hide();\n chatArea.style.display = \"none\";\n },\n };\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _waku_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/sdk */ \"./node_modules/@waku/sdk/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_noise__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/noise */ \"./node_modules/@waku/noise/dist/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs */ \"./node_modules/protobufjs/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(protobufjs__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! qrcode */ \"./node_modules/qrcode/lib/browser.js\");\n\n\n\n\n\n\n\nconst ContentTopic = \"/noise-js/1/message/proto\";\nconst PubsubTopic = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.contentTopicToPubsubTopic)(ContentTopic);\n\n// Protobuf\nconst ProtoChatMessage = new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Type)(\"ChatMessage\")\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Field)(\"timestamp\", 1, \"uint64\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Field)(\"nick\", 2, \"string\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Field)(\"text\", 3, \"bytes\"));\n\nmain();\n\nasync function main() {\n const ui = initUI();\n ui.waku.connecting();\n\n // Starting the node\n const node = await (0,_waku_sdk__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({\n defaultBootstrap: true,\n shardInfo: {\n contentTopics: [ContentTopic],\n }\n });\n\n try {\n await node.start();\n await (0,_waku_sdk__WEBPACK_IMPORTED_MODULE_0__.waitForRemotePeer)(node, [\"filter\", \"lightpush\"]);\n\n ui.waku.connected();\n\n const myStaticKey = new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.X25519DHKey();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.WakuPairing(\n PubsubTopic,\n node.lightPush,\n node.filter,\n myStaticKey.generateKeyPair(),\n urlPairingInfo || new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.ResponderParameters()\n );\n const pExecute = pairingObj.execute(120000); // timeout after 2m\n\n scheduleHandshakeAuthConfirmation(pairingObj, ui);\n\n let encoder;\n let decoder;\n\n try {\n ui.handshake.waiting();\n\n if (!urlPairingInfo) {\n const pairingURL = buildPairingURLFromObj(pairingObj);\n ui.shareInfo.setURL(pairingURL);\n ui.shareInfo.renderQR(pairingURL);\n ui.shareInfo.show();\n }\n\n [encoder, decoder] = await pExecute;\n\n ui.handshake.connected();\n ui.shareInfo.hide();\n } catch (err) {\n ui.handshake.error(err.message);\n ui.hide();\n }\n\n ui.message.display();\n\n await node.filter.subscribe(\n [decoder],\n ui.message.onReceive.bind(ui.message)\n );\n\n ui.message.onSend(async (text, nick) => {\n const timestamp = Math.floor(Date.now() / 1000);\n const message = ProtoChatMessage.create({\n nick,\n timestamp,\n text: _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes(text),\n });\n const payload = ProtoChatMessage.encode(message).finish();\n\n await node.lightPush.send(encoder, { payload, timestamp });\n });\n } catch (err) {\n ui.waku.error(err.message);\n ui.hide();\n }\n}\n\nfunction buildPairingURLFromObj(pairingObj) {\n const pInfo = pairingObj.getPairingInfo();\n\n // Data to encode in the QR code. The qrMessageNametag too to the QR string (separated by )\n const messageNameTagParam = `messageNameTag=${_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToHex(\n pInfo.qrMessageNameTag\n )}`;\n const qrCodeParam = `qrCode=${encodeURIComponent(pInfo.qrCode)}`;\n\n return `${window.location.href}?${messageNameTagParam}&${qrCodeParam}`;\n}\n\nfunction getPairingInfoFromURL() {\n const urlParams = new URLSearchParams(window.location.search);\n\n const messageNameTag = urlParams.get(\"messageNameTag\");\n const qrCodeString = urlParams.get(\"qrCode\");\n\n if (!(messageNameTag && qrCodeString)) {\n return undefined;\n }\n\n return new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.InitiatorParameters(\n decodeURIComponent(qrCodeString),\n _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(messageNameTag)\n );\n}\n\nasync function scheduleHandshakeAuthConfirmation(pairingObj, ui) {\n const authCode = await pairingObj.getAuthCode();\n ui.handshake.connecting();\n pairingObj.validateAuthCode(confirm(\"Confirm that authcode is: \" + authCode));\n}\n\nfunction initUI() {\n const messagesList = document.getElementById(\"messages\");\n const nicknameInput = document.getElementById(\"nick-input\");\n const textInput = document.getElementById(\"text-input\");\n const sendButton = document.getElementById(\"send-btn\");\n const chatArea = document.getElementById(\"chat-area\");\n const wakuStatusSpan = document.getElementById(\"waku-status\");\n const handshakeStatusSpan = document.getElementById(\"handshake-status\");\n\n const qrCanvas = document.getElementById(\"qr-canvas\");\n const qrUrlContainer = document.getElementById(\"qr-url-container\");\n const qrUrl = document.getElementById(\"qr-url\");\n const copyURLButton = document.getElementById(\"copy-url\");\n const openTabButton = document.getElementById(\"open-tab\");\n\n copyURLButton.onclick = () => {\n const copyText = document.getElementById(\"qr-url\"); // need to get it each time otherwise copying does not work\n copyText.select();\n copyText.setSelectionRange(0, 99999);\n navigator.clipboard.writeText(copyText.value);\n };\n\n openTabButton.onclick = () => {\n window.open(qrUrl.value, \"_blank\");\n };\n\n const disableChatUIStateIfNeeded = () => {\n const readyToSend = nicknameInput.value !== \"\";\n textInput.disabled = !readyToSend;\n sendButton.disabled = !readyToSend;\n };\n nicknameInput.onchange = disableChatUIStateIfNeeded;\n nicknameInput.onblur = disableChatUIStateIfNeeded;\n\n return {\n shareInfo: {\n setURL(url) {\n qrUrl.value = url;\n },\n hide() {\n qrUrlContainer.style.display = \"none\";\n },\n show() {\n qrUrlContainer.style.display = \"flex\";\n },\n renderQR(url) {\n qrcode__WEBPACK_IMPORTED_MODULE_5__.toCanvas(qrCanvas, url, (err) => {\n if (err) {\n throw err;\n }\n });\n },\n },\n waku: {\n _val(msg) {\n wakuStatusSpan.innerText = msg;\n },\n _class(name) {\n wakuStatusSpan.className = name;\n },\n connecting() {\n this._val(\"connecting...\");\n this._class(\"progress\");\n },\n connected() {\n this._val(\"connected\");\n this._class(\"success\");\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n },\n handshake: {\n _val(val) {\n handshakeStatusSpan.innerText = val;\n },\n _class(name) {\n handshakeStatusSpan.className = name;\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n waiting() {\n this._val(\"waiting for handshake...\");\n this._class(\"progress\");\n },\n generating() {\n this._val(\"generating QR code...\");\n this._class(\"progress\");\n },\n connecting() {\n this._val(\"executing handshake...\");\n this._class(\"progress\");\n },\n connected() {\n this._val(\"handshake completed!\");\n this._class(\"success\");\n },\n },\n message: {\n _render({ time, text, nick }) {\n messagesList.innerHTML += `\n
  • \n (${nick})\n ${text}\n [${new Date(time).toISOString()}]\n
  • \n `;\n },\n _status(text, className) {\n sendButton.className = className;\n },\n onReceive({ payload }) {\n const { timestamp, nick, text } = ProtoChatMessage.decode(payload);\n\n this._render({\n nick,\n time: timestamp * 1000,\n text: _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8(text),\n });\n },\n onSend(cb) {\n sendButton.addEventListener(\"click\", async () => {\n try {\n this._status(\"sending...\", \"progress\");\n await cb(textInput.value, nicknameInput.value);\n this._status(\"sent\", \"success\");\n\n this._render({\n time: Date.now(), // a bit different from what receiver will see but for the matter of example is good enough\n text: textInput.value,\n nick: nicknameInput.value,\n });\n textInput.value = \"\";\n } catch (e) {\n this._status(`error: ${e.message}`, \"error\");\n }\n });\n },\n display() {\n chatArea.style.display = \"block\";\n this._status(\"waiting for input\", \"progress\");\n },\n },\n hide() {\n this.shareInfo.hide();\n chatArea.style.display = \"none\";\n },\n };\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./index.js?"); /***/ }), @@ -383,124 +383,14 @@ eval("\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file /***/ }), -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/minimal.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/minimal.js ***! - \*********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +/***/ "./node_modules/asn1js/build/index.es.js": +/*!***********************************************!*\ + !*** ./node_modules/asn1js/build/index.es.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("// minimal library entry point.\n\n\nmodule.exports = __webpack_require__(/*! ./src/index-minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/index-minimal.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/index-minimal.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/index-minimal.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; -eval("\nvar protobuf = exports;\n\n/**\n * Build type, one of `\"full\"`, `\"light\"` or `\"minimal\"`.\n * @name build\n * @type {string}\n * @const\n */\nprotobuf.build = \"minimal\";\n\n// Serialization\nprotobuf.Writer = __webpack_require__(/*! ./writer */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/writer.js\");\nprotobuf.BufferWriter = __webpack_require__(/*! ./writer_buffer */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/writer_buffer.js\");\nprotobuf.Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/reader.js\");\nprotobuf.BufferReader = __webpack_require__(/*! ./reader_buffer */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/reader_buffer.js\");\n\n// Utility\nprotobuf.util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\nprotobuf.rpc = __webpack_require__(/*! ./rpc */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/rpc.js\");\nprotobuf.roots = __webpack_require__(/*! ./roots */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/roots.js\");\nprotobuf.configure = configure;\n\n/* istanbul ignore next */\n/**\n * Reconfigures the library according to the environment.\n * @returns {undefined}\n */\nfunction configure() {\n protobuf.util._configure();\n protobuf.Writer._configure(protobuf.BufferWriter);\n protobuf.Reader._configure(protobuf.BufferReader);\n}\n\n// Set up buffer utility according to the environment\nconfigure();\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/index-minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/reader.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/reader.js ***! - \************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = Reader;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\nvar BufferReader; // cyclic\n\nvar LongBits = util.LongBits,\n utf8 = util.utf8;\n\n/* istanbul ignore next */\nfunction indexOutOfRange(reader, writeLength) {\n return RangeError(\"index out of range: \" + reader.pos + \" + \" + (writeLength || 1) + \" > \" + reader.len);\n}\n\n/**\n * Constructs a new reader instance using the specified buffer.\n * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.\n * @constructor\n * @param {Uint8Array} buffer Buffer to read from\n */\nfunction Reader(buffer) {\n\n /**\n * Read buffer.\n * @type {Uint8Array}\n */\n this.buf = buffer;\n\n /**\n * Read buffer position.\n * @type {number}\n */\n this.pos = 0;\n\n /**\n * Read buffer length.\n * @type {number}\n */\n this.len = buffer.length;\n}\n\nvar create_array = typeof Uint8Array !== \"undefined\"\n ? function create_typed_array(buffer) {\n if (buffer instanceof Uint8Array || Array.isArray(buffer))\n return new Reader(buffer);\n throw Error(\"illegal buffer\");\n }\n /* istanbul ignore next */\n : function create_array(buffer) {\n if (Array.isArray(buffer))\n return new Reader(buffer);\n throw Error(\"illegal buffer\");\n };\n\nvar create = function create() {\n return util.Buffer\n ? function create_buffer_setup(buffer) {\n return (Reader.create = function create_buffer(buffer) {\n return util.Buffer.isBuffer(buffer)\n ? new BufferReader(buffer)\n /* istanbul ignore next */\n : create_array(buffer);\n })(buffer);\n }\n /* istanbul ignore next */\n : create_array;\n};\n\n/**\n * Creates a new reader using the specified buffer.\n * @function\n * @param {Uint8Array|Buffer} buffer Buffer to read from\n * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}\n * @throws {Error} If `buffer` is not a valid buffer\n */\nReader.create = create();\n\nReader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;\n\n/**\n * Reads a varint as an unsigned 32 bit value.\n * @function\n * @returns {number} Value read\n */\nReader.prototype.uint32 = (function read_uint32_setup() {\n var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)\n return function read_uint32() {\n value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;\n value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;\n value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;\n value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;\n value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;\n\n /* istanbul ignore if */\n if ((this.pos += 5) > this.len) {\n this.pos = this.len;\n throw indexOutOfRange(this, 10);\n }\n return value;\n };\n})();\n\n/**\n * Reads a varint as a signed 32 bit value.\n * @returns {number} Value read\n */\nReader.prototype.int32 = function read_int32() {\n return this.uint32() | 0;\n};\n\n/**\n * Reads a zig-zag encoded varint as a signed 32 bit value.\n * @returns {number} Value read\n */\nReader.prototype.sint32 = function read_sint32() {\n var value = this.uint32();\n return value >>> 1 ^ -(value & 1) | 0;\n};\n\n/* eslint-disable no-invalid-this */\n\nfunction readLongVarint() {\n // tends to deopt with local vars for octet etc.\n var bits = new LongBits(0, 0);\n var i = 0;\n if (this.len - this.pos > 4) { // fast route (lo)\n for (; i < 4; ++i) {\n // 1st..4th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128)\n return bits;\n }\n // 5th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;\n if (this.buf[this.pos++] < 128)\n return bits;\n i = 0;\n } else {\n for (; i < 3; ++i) {\n /* istanbul ignore if */\n if (this.pos >= this.len)\n throw indexOutOfRange(this);\n // 1st..3th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128)\n return bits;\n }\n // 4th\n bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;\n return bits;\n }\n if (this.len - this.pos > 4) { // fast route (hi)\n for (; i < 5; ++i) {\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128)\n return bits;\n }\n } else {\n for (; i < 5; ++i) {\n /* istanbul ignore if */\n if (this.pos >= this.len)\n throw indexOutOfRange(this);\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128)\n return bits;\n }\n }\n /* istanbul ignore next */\n throw Error(\"invalid varint encoding\");\n}\n\n/* eslint-enable no-invalid-this */\n\n/**\n * Reads a varint as a signed 64 bit value.\n * @name Reader#int64\n * @function\n * @returns {Long} Value read\n */\n\n/**\n * Reads a varint as an unsigned 64 bit value.\n * @name Reader#uint64\n * @function\n * @returns {Long} Value read\n */\n\n/**\n * Reads a zig-zag encoded varint as a signed 64 bit value.\n * @name Reader#sint64\n * @function\n * @returns {Long} Value read\n */\n\n/**\n * Reads a varint as a boolean.\n * @returns {boolean} Value read\n */\nReader.prototype.bool = function read_bool() {\n return this.uint32() !== 0;\n};\n\nfunction readFixed32_end(buf, end) { // note that this uses `end`, not `pos`\n return (buf[end - 4]\n | buf[end - 3] << 8\n | buf[end - 2] << 16\n | buf[end - 1] << 24) >>> 0;\n}\n\n/**\n * Reads fixed 32 bits as an unsigned 32 bit integer.\n * @returns {number} Value read\n */\nReader.prototype.fixed32 = function read_fixed32() {\n\n /* istanbul ignore if */\n if (this.pos + 4 > this.len)\n throw indexOutOfRange(this, 4);\n\n return readFixed32_end(this.buf, this.pos += 4);\n};\n\n/**\n * Reads fixed 32 bits as a signed 32 bit integer.\n * @returns {number} Value read\n */\nReader.prototype.sfixed32 = function read_sfixed32() {\n\n /* istanbul ignore if */\n if (this.pos + 4 > this.len)\n throw indexOutOfRange(this, 4);\n\n return readFixed32_end(this.buf, this.pos += 4) | 0;\n};\n\n/* eslint-disable no-invalid-this */\n\nfunction readFixed64(/* this: Reader */) {\n\n /* istanbul ignore if */\n if (this.pos + 8 > this.len)\n throw indexOutOfRange(this, 8);\n\n return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));\n}\n\n/* eslint-enable no-invalid-this */\n\n/**\n * Reads fixed 64 bits.\n * @name Reader#fixed64\n * @function\n * @returns {Long} Value read\n */\n\n/**\n * Reads zig-zag encoded fixed 64 bits.\n * @name Reader#sfixed64\n * @function\n * @returns {Long} Value read\n */\n\n/**\n * Reads a float (32 bit) as a number.\n * @function\n * @returns {number} Value read\n */\nReader.prototype.float = function read_float() {\n\n /* istanbul ignore if */\n if (this.pos + 4 > this.len)\n throw indexOutOfRange(this, 4);\n\n var value = util.float.readFloatLE(this.buf, this.pos);\n this.pos += 4;\n return value;\n};\n\n/**\n * Reads a double (64 bit float) as a number.\n * @function\n * @returns {number} Value read\n */\nReader.prototype.double = function read_double() {\n\n /* istanbul ignore if */\n if (this.pos + 8 > this.len)\n throw indexOutOfRange(this, 4);\n\n var value = util.float.readDoubleLE(this.buf, this.pos);\n this.pos += 8;\n return value;\n};\n\n/**\n * Reads a sequence of bytes preceeded by its length as a varint.\n * @returns {Uint8Array} Value read\n */\nReader.prototype.bytes = function read_bytes() {\n var length = this.uint32(),\n start = this.pos,\n end = this.pos + length;\n\n /* istanbul ignore if */\n if (end > this.len)\n throw indexOutOfRange(this, length);\n\n this.pos += length;\n if (Array.isArray(this.buf)) // plain array\n return this.buf.slice(start, end);\n return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1\n ? new this.buf.constructor(0)\n : this._slice.call(this.buf, start, end);\n};\n\n/**\n * Reads a string preceeded by its byte length as a varint.\n * @returns {string} Value read\n */\nReader.prototype.string = function read_string() {\n var bytes = this.bytes();\n return utf8.read(bytes, 0, bytes.length);\n};\n\n/**\n * Skips the specified number of bytes if specified, otherwise skips a varint.\n * @param {number} [length] Length if known, otherwise a varint is assumed\n * @returns {Reader} `this`\n */\nReader.prototype.skip = function skip(length) {\n if (typeof length === \"number\") {\n /* istanbul ignore if */\n if (this.pos + length > this.len)\n throw indexOutOfRange(this, length);\n this.pos += length;\n } else {\n do {\n /* istanbul ignore if */\n if (this.pos >= this.len)\n throw indexOutOfRange(this);\n } while (this.buf[this.pos++] & 128);\n }\n return this;\n};\n\n/**\n * Skips the next element of the specified wire type.\n * @param {number} wireType Wire type received\n * @returns {Reader} `this`\n */\nReader.prototype.skipType = function(wireType) {\n switch (wireType) {\n case 0:\n this.skip();\n break;\n case 1:\n this.skip(8);\n break;\n case 2:\n this.skip(this.uint32());\n break;\n case 3:\n while ((wireType = this.uint32() & 7) !== 4) {\n this.skipType(wireType);\n }\n break;\n case 5:\n this.skip(4);\n break;\n\n /* istanbul ignore next */\n default:\n throw Error(\"invalid wire type \" + wireType + \" at offset \" + this.pos);\n }\n return this;\n};\n\nReader._configure = function(BufferReader_) {\n BufferReader = BufferReader_;\n Reader.create = create();\n BufferReader._configure();\n\n var fn = util.Long ? \"toLong\" : /* istanbul ignore next */ \"toNumber\";\n util.merge(Reader.prototype, {\n\n int64: function read_int64() {\n return readLongVarint.call(this)[fn](false);\n },\n\n uint64: function read_uint64() {\n return readLongVarint.call(this)[fn](true);\n },\n\n sint64: function read_sint64() {\n return readLongVarint.call(this).zzDecode()[fn](false);\n },\n\n fixed64: function read_fixed64() {\n return readFixed64.call(this)[fn](true);\n },\n\n sfixed64: function read_sfixed64() {\n return readFixed64.call(this)[fn](false);\n }\n\n });\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/reader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/reader_buffer.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/reader_buffer.js ***! - \*******************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = BufferReader;\n\n// extends Reader\nvar Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/reader.js\");\n(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\n/**\n * Constructs a new buffer reader instance.\n * @classdesc Wire format reader using node buffers.\n * @extends Reader\n * @constructor\n * @param {Buffer} buffer Buffer to read from\n */\nfunction BufferReader(buffer) {\n Reader.call(this, buffer);\n\n /**\n * Read buffer.\n * @name BufferReader#buf\n * @type {Buffer}\n */\n}\n\nBufferReader._configure = function () {\n /* istanbul ignore else */\n if (util.Buffer)\n BufferReader.prototype._slice = util.Buffer.prototype.slice;\n};\n\n\n/**\n * @override\n */\nBufferReader.prototype.string = function read_string_buffer() {\n var len = this.uint32(); // modifies pos\n return this.buf.utf8Slice\n ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len))\n : this.buf.toString(\"utf-8\", this.pos, this.pos = Math.min(this.pos + len, this.len));\n};\n\n/**\n * Reads a sequence of bytes preceeded by its length as a varint.\n * @name BufferReader#bytes\n * @function\n * @returns {Buffer} Value read\n */\n\nBufferReader._configure();\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/reader_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/roots.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/roots.js ***! - \***********************************************************************/ -/***/ ((module) => { - -"use strict"; -eval("\nmodule.exports = {};\n\n/**\n * Named roots.\n * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).\n * Can also be used manually to make roots available accross modules.\n * @name roots\n * @type {Object.}\n * @example\n * // pbjs -r myroot -o compiled.js ...\n *\n * // in another module:\n * require(\"./compiled.js\");\n *\n * // in any subsequent module:\n * var root = protobuf.roots[\"myroot\"];\n */\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/roots.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/rpc.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/rpc.js ***! - \*********************************************************************/ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; -eval("\n\n/**\n * Streaming RPC helpers.\n * @namespace\n */\nvar rpc = exports;\n\n/**\n * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.\n * @typedef RPCImpl\n * @type {function}\n * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called\n * @param {Uint8Array} requestData Request data\n * @param {RPCImplCallback} callback Callback function\n * @returns {undefined}\n * @example\n * function rpcImpl(method, requestData, callback) {\n * if (protobuf.util.lcFirst(method.name) !== \"myMethod\") // compatible with static code\n * throw Error(\"no such method\");\n * asynchronouslyObtainAResponse(requestData, function(err, responseData) {\n * callback(err, responseData);\n * });\n * }\n */\n\n/**\n * Node-style callback as used by {@link RPCImpl}.\n * @typedef RPCImplCallback\n * @type {function}\n * @param {Error|null} error Error, if any, otherwise `null`\n * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error\n * @returns {undefined}\n */\n\nrpc.Service = __webpack_require__(/*! ./rpc/service */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/rpc/service.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/rpc/service.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/rpc/service.js ***! - \*****************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = Service;\n\nvar util = __webpack_require__(/*! ../util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\n// Extends EventEmitter\n(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;\n\n/**\n * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.\n *\n * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.\n * @typedef rpc.ServiceMethodCallback\n * @template TRes extends Message\n * @type {function}\n * @param {Error|null} error Error, if any\n * @param {TRes} [response] Response message\n * @returns {undefined}\n */\n\n/**\n * A service method part of a {@link rpc.Service} as created by {@link Service.create}.\n * @typedef rpc.ServiceMethod\n * @template TReq extends Message\n * @template TRes extends Message\n * @type {function}\n * @param {TReq|Properties} request Request message or plain object\n * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message\n * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined`\n */\n\n/**\n * Constructs a new RPC service instance.\n * @classdesc An RPC service as returned by {@link Service#create}.\n * @exports rpc.Service\n * @extends util.EventEmitter\n * @constructor\n * @param {RPCImpl} rpcImpl RPC implementation\n * @param {boolean} [requestDelimited=false] Whether requests are length-delimited\n * @param {boolean} [responseDelimited=false] Whether responses are length-delimited\n */\nfunction Service(rpcImpl, requestDelimited, responseDelimited) {\n\n if (typeof rpcImpl !== \"function\")\n throw TypeError(\"rpcImpl must be a function\");\n\n util.EventEmitter.call(this);\n\n /**\n * RPC implementation. Becomes `null` once the service is ended.\n * @type {RPCImpl|null}\n */\n this.rpcImpl = rpcImpl;\n\n /**\n * Whether requests are length-delimited.\n * @type {boolean}\n */\n this.requestDelimited = Boolean(requestDelimited);\n\n /**\n * Whether responses are length-delimited.\n * @type {boolean}\n */\n this.responseDelimited = Boolean(responseDelimited);\n}\n\n/**\n * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.\n * @param {Method|rpc.ServiceMethod} method Reflected or static method\n * @param {Constructor} requestCtor Request constructor\n * @param {Constructor} responseCtor Response constructor\n * @param {TReq|Properties} request Request message or plain object\n * @param {rpc.ServiceMethodCallback} callback Service callback\n * @returns {undefined}\n * @template TReq extends Message\n * @template TRes extends Message\n */\nService.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {\n\n if (!request)\n throw TypeError(\"request must be specified\");\n\n var self = this;\n if (!callback)\n return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);\n\n if (!self.rpcImpl) {\n setTimeout(function() { callback(Error(\"already ended\")); }, 0);\n return undefined;\n }\n\n try {\n return self.rpcImpl(\n method,\n requestCtor[self.requestDelimited ? \"encodeDelimited\" : \"encode\"](request).finish(),\n function rpcCallback(err, response) {\n\n if (err) {\n self.emit(\"error\", err, method);\n return callback(err);\n }\n\n if (response === null) {\n self.end(/* endedByRPC */ true);\n return undefined;\n }\n\n if (!(response instanceof responseCtor)) {\n try {\n response = responseCtor[self.responseDelimited ? \"decodeDelimited\" : \"decode\"](response);\n } catch (err) {\n self.emit(\"error\", err, method);\n return callback(err);\n }\n }\n\n self.emit(\"data\", response, method);\n return callback(null, response);\n }\n );\n } catch (err) {\n self.emit(\"error\", err, method);\n setTimeout(function() { callback(err); }, 0);\n return undefined;\n }\n};\n\n/**\n * Ends this service and emits the `end` event.\n * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.\n * @returns {rpc.Service} `this`\n */\nService.prototype.end = function end(endedByRPC) {\n if (this.rpcImpl) {\n if (!endedByRPC) // signal end to rpcImpl\n this.rpcImpl(null, null, null);\n this.rpcImpl = null;\n this.emit(\"end\").off();\n }\n return this;\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/rpc/service.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/util/longbits.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/util/longbits.js ***! - \*******************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = LongBits;\n\nvar util = __webpack_require__(/*! ../util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\n/**\n * Constructs new long bits.\n * @classdesc Helper class for working with the low and high bits of a 64 bit value.\n * @memberof util\n * @constructor\n * @param {number} lo Low 32 bits, unsigned\n * @param {number} hi High 32 bits, unsigned\n */\nfunction LongBits(lo, hi) {\n\n // note that the casts below are theoretically unnecessary as of today, but older statically\n // generated converter code might still call the ctor with signed 32bits. kept for compat.\n\n /**\n * Low bits.\n * @type {number}\n */\n this.lo = lo >>> 0;\n\n /**\n * High bits.\n * @type {number}\n */\n this.hi = hi >>> 0;\n}\n\n/**\n * Zero bits.\n * @memberof util.LongBits\n * @type {util.LongBits}\n */\nvar zero = LongBits.zero = new LongBits(0, 0);\n\nzero.toNumber = function() { return 0; };\nzero.zzEncode = zero.zzDecode = function() { return this; };\nzero.length = function() { return 1; };\n\n/**\n * Zero hash.\n * @memberof util.LongBits\n * @type {string}\n */\nvar zeroHash = LongBits.zeroHash = \"\\0\\0\\0\\0\\0\\0\\0\\0\";\n\n/**\n * Constructs new long bits from the specified number.\n * @param {number} value Value\n * @returns {util.LongBits} Instance\n */\nLongBits.fromNumber = function fromNumber(value) {\n if (value === 0)\n return zero;\n var sign = value < 0;\n if (sign)\n value = -value;\n var lo = value >>> 0,\n hi = (value - lo) / 4294967296 >>> 0;\n if (sign) {\n hi = ~hi >>> 0;\n lo = ~lo >>> 0;\n if (++lo > 4294967295) {\n lo = 0;\n if (++hi > 4294967295)\n hi = 0;\n }\n }\n return new LongBits(lo, hi);\n};\n\n/**\n * Constructs new long bits from a number, long or string.\n * @param {Long|number|string} value Value\n * @returns {util.LongBits} Instance\n */\nLongBits.from = function from(value) {\n if (typeof value === \"number\")\n return LongBits.fromNumber(value);\n if (util.isString(value)) {\n /* istanbul ignore else */\n if (util.Long)\n value = util.Long.fromString(value);\n else\n return LongBits.fromNumber(parseInt(value, 10));\n }\n return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;\n};\n\n/**\n * Converts this long bits to a possibly unsafe JavaScript number.\n * @param {boolean} [unsigned=false] Whether unsigned or not\n * @returns {number} Possibly unsafe number\n */\nLongBits.prototype.toNumber = function toNumber(unsigned) {\n if (!unsigned && this.hi >>> 31) {\n var lo = ~this.lo + 1 >>> 0,\n hi = ~this.hi >>> 0;\n if (!lo)\n hi = hi + 1 >>> 0;\n return -(lo + hi * 4294967296);\n }\n return this.lo + this.hi * 4294967296;\n};\n\n/**\n * Converts this long bits to a long.\n * @param {boolean} [unsigned=false] Whether unsigned or not\n * @returns {Long} Long\n */\nLongBits.prototype.toLong = function toLong(unsigned) {\n return util.Long\n ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))\n /* istanbul ignore next */\n : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };\n};\n\nvar charCodeAt = String.prototype.charCodeAt;\n\n/**\n * Constructs new long bits from the specified 8 characters long hash.\n * @param {string} hash Hash\n * @returns {util.LongBits} Bits\n */\nLongBits.fromHash = function fromHash(hash) {\n if (hash === zeroHash)\n return zero;\n return new LongBits(\n ( charCodeAt.call(hash, 0)\n | charCodeAt.call(hash, 1) << 8\n | charCodeAt.call(hash, 2) << 16\n | charCodeAt.call(hash, 3) << 24) >>> 0\n ,\n ( charCodeAt.call(hash, 4)\n | charCodeAt.call(hash, 5) << 8\n | charCodeAt.call(hash, 6) << 16\n | charCodeAt.call(hash, 7) << 24) >>> 0\n );\n};\n\n/**\n * Converts this long bits to a 8 characters long hash.\n * @returns {string} Hash\n */\nLongBits.prototype.toHash = function toHash() {\n return String.fromCharCode(\n this.lo & 255,\n this.lo >>> 8 & 255,\n this.lo >>> 16 & 255,\n this.lo >>> 24 ,\n this.hi & 255,\n this.hi >>> 8 & 255,\n this.hi >>> 16 & 255,\n this.hi >>> 24\n );\n};\n\n/**\n * Zig-zag encodes this long bits.\n * @returns {util.LongBits} `this`\n */\nLongBits.prototype.zzEncode = function zzEncode() {\n var mask = this.hi >> 31;\n this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;\n this.lo = ( this.lo << 1 ^ mask) >>> 0;\n return this;\n};\n\n/**\n * Zig-zag decodes this long bits.\n * @returns {util.LongBits} `this`\n */\nLongBits.prototype.zzDecode = function zzDecode() {\n var mask = -(this.lo & 1);\n this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;\n this.hi = ( this.hi >>> 1 ^ mask) >>> 0;\n return this;\n};\n\n/**\n * Calculates the length of this longbits when encoded as a varint.\n * @returns {number} Length\n */\nLongBits.prototype.length = function length() {\n var part0 = this.lo,\n part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,\n part2 = this.hi >>> 24;\n return part2 === 0\n ? part1 === 0\n ? part0 < 16384\n ? part0 < 128 ? 1 : 2\n : part0 < 2097152 ? 3 : 4\n : part1 < 16384\n ? part1 < 128 ? 5 : 6\n : part1 < 2097152 ? 7 : 8\n : part2 < 128 ? 9 : 10;\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/util/longbits.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js ***! - \******************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; -eval("\nvar util = exports;\n\n// used to return a Promise where callback is omitted\nutil.asPromise = __webpack_require__(/*! @protobufjs/aspromise */ \"./node_modules/@protobufjs/aspromise/index.js\");\n\n// converts to / from base64 encoded strings\nutil.base64 = __webpack_require__(/*! @protobufjs/base64 */ \"./node_modules/@protobufjs/base64/index.js\");\n\n// base class of rpc.Service\nutil.EventEmitter = __webpack_require__(/*! @protobufjs/eventemitter */ \"./node_modules/@protobufjs/eventemitter/index.js\");\n\n// float handling accross browsers\nutil.float = __webpack_require__(/*! @protobufjs/float */ \"./node_modules/@protobufjs/float/index.js\");\n\n// requires modules optionally and hides the call from bundlers\nutil.inquire = __webpack_require__(/*! @protobufjs/inquire */ \"./node_modules/@protobufjs/inquire/index.js\");\n\n// converts to / from utf8 encoded strings\nutil.utf8 = __webpack_require__(/*! @protobufjs/utf8 */ \"./node_modules/@protobufjs/utf8/index.js\");\n\n// provides a node-like buffer pool in the browser\nutil.pool = __webpack_require__(/*! @protobufjs/pool */ \"./node_modules/@protobufjs/pool/index.js\");\n\n// utility to work with the low and high bits of a 64 bit value\nutil.LongBits = __webpack_require__(/*! ./longbits */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/longbits.js\");\n\n/**\n * Whether running within node or not.\n * @memberof util\n * @type {boolean}\n */\nutil.isNode = Boolean(typeof __webpack_require__.g !== \"undefined\"\n && __webpack_require__.g\n && __webpack_require__.g.process\n && __webpack_require__.g.process.versions\n && __webpack_require__.g.process.versions.node);\n\n/**\n * Global object reference.\n * @memberof util\n * @type {Object}\n */\nutil.global = util.isNode && __webpack_require__.g\n || typeof window !== \"undefined\" && window\n || typeof self !== \"undefined\" && self\n || this; // eslint-disable-line no-invalid-this\n\n/**\n * An immuable empty array.\n * @memberof util\n * @type {Array.<*>}\n * @const\n */\nutil.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes\n\n/**\n * An immutable empty object.\n * @type {Object}\n * @const\n */\nutil.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes\n\n/**\n * Tests if the specified value is an integer.\n * @function\n * @param {*} value Value to test\n * @returns {boolean} `true` if the value is an integer\n */\nutil.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {\n return typeof value === \"number\" && isFinite(value) && Math.floor(value) === value;\n};\n\n/**\n * Tests if the specified value is a string.\n * @param {*} value Value to test\n * @returns {boolean} `true` if the value is a string\n */\nutil.isString = function isString(value) {\n return typeof value === \"string\" || value instanceof String;\n};\n\n/**\n * Tests if the specified value is a non-null object.\n * @param {*} value Value to test\n * @returns {boolean} `true` if the value is a non-null object\n */\nutil.isObject = function isObject(value) {\n return value && typeof value === \"object\";\n};\n\n/**\n * Checks if a property on a message is considered to be present.\n * This is an alias of {@link util.isSet}.\n * @function\n * @param {Object} obj Plain object or message instance\n * @param {string} prop Property name\n * @returns {boolean} `true` if considered to be present, otherwise `false`\n */\nutil.isset =\n\n/**\n * Checks if a property on a message is considered to be present.\n * @param {Object} obj Plain object or message instance\n * @param {string} prop Property name\n * @returns {boolean} `true` if considered to be present, otherwise `false`\n */\nutil.isSet = function isSet(obj, prop) {\n var value = obj[prop];\n if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins\n return typeof value !== \"object\" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;\n return false;\n};\n\n/**\n * Any compatible Buffer instance.\n * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.\n * @interface Buffer\n * @extends Uint8Array\n */\n\n/**\n * Node's Buffer class if available.\n * @type {Constructor}\n */\nutil.Buffer = (function() {\n try {\n var Buffer = util.inquire(\"buffer\").Buffer;\n // refuse to use non-node buffers if not explicitly assigned (perf reasons):\n return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;\n } catch (e) {\n /* istanbul ignore next */\n return null;\n }\n})();\n\n// Internal alias of or polyfull for Buffer.from.\nutil._Buffer_from = null;\n\n// Internal alias of or polyfill for Buffer.allocUnsafe.\nutil._Buffer_allocUnsafe = null;\n\n/**\n * Creates a new buffer of whatever type supported by the environment.\n * @param {number|number[]} [sizeOrArray=0] Buffer size or number array\n * @returns {Uint8Array|Buffer} Buffer\n */\nutil.newBuffer = function newBuffer(sizeOrArray) {\n /* istanbul ignore next */\n return typeof sizeOrArray === \"number\"\n ? util.Buffer\n ? util._Buffer_allocUnsafe(sizeOrArray)\n : new util.Array(sizeOrArray)\n : util.Buffer\n ? util._Buffer_from(sizeOrArray)\n : typeof Uint8Array === \"undefined\"\n ? sizeOrArray\n : new Uint8Array(sizeOrArray);\n};\n\n/**\n * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.\n * @type {Constructor}\n */\nutil.Array = typeof Uint8Array !== \"undefined\" ? Uint8Array /* istanbul ignore next */ : Array;\n\n/**\n * Any compatible Long instance.\n * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.\n * @interface Long\n * @property {number} low Low bits\n * @property {number} high High bits\n * @property {boolean} unsigned Whether unsigned or not\n */\n\n/**\n * Long.js's Long class if available.\n * @type {Constructor}\n */\nutil.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long\n || /* istanbul ignore next */ util.global.Long\n || util.inquire(\"long\");\n\n/**\n * Regular expression used to verify 2 bit (`bool`) map keys.\n * @type {RegExp}\n * @const\n */\nutil.key2Re = /^true|false|0|1$/;\n\n/**\n * Regular expression used to verify 32 bit (`int32` etc.) map keys.\n * @type {RegExp}\n * @const\n */\nutil.key32Re = /^-?(?:0|[1-9][0-9]*)$/;\n\n/**\n * Regular expression used to verify 64 bit (`int64` etc.) map keys.\n * @type {RegExp}\n * @const\n */\nutil.key64Re = /^(?:[\\\\x00-\\\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;\n\n/**\n * Converts a number or long to an 8 characters long hash string.\n * @param {Long|number} value Value to convert\n * @returns {string} Hash\n */\nutil.longToHash = function longToHash(value) {\n return value\n ? util.LongBits.from(value).toHash()\n : util.LongBits.zeroHash;\n};\n\n/**\n * Converts an 8 characters long hash string to a long or number.\n * @param {string} hash Hash\n * @param {boolean} [unsigned=false] Whether unsigned or not\n * @returns {Long|number} Original value\n */\nutil.longFromHash = function longFromHash(hash, unsigned) {\n var bits = util.LongBits.fromHash(hash);\n if (util.Long)\n return util.Long.fromBits(bits.lo, bits.hi, unsigned);\n return bits.toNumber(Boolean(unsigned));\n};\n\n/**\n * Merges the properties of the source object into the destination object.\n * @memberof util\n * @param {Object.} dst Destination object\n * @param {Object.} src Source object\n * @param {boolean} [ifNotSet=false] Merges only if the key is not already set\n * @returns {Object.} Destination object\n */\nfunction merge(dst, src, ifNotSet) { // used by converters\n for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)\n if (dst[keys[i]] === undefined || !ifNotSet)\n dst[keys[i]] = src[keys[i]];\n return dst;\n}\n\nutil.merge = merge;\n\n/**\n * Converts the first character of a string to lower case.\n * @param {string} str String to convert\n * @returns {string} Converted string\n */\nutil.lcFirst = function lcFirst(str) {\n return str.charAt(0).toLowerCase() + str.substring(1);\n};\n\n/**\n * Creates a custom error constructor.\n * @memberof util\n * @param {string} name Error name\n * @returns {Constructor} Custom error constructor\n */\nfunction newError(name) {\n\n function CustomError(message, properties) {\n\n if (!(this instanceof CustomError))\n return new CustomError(message, properties);\n\n // Error.call(this, message);\n // ^ just returns a new error instance because the ctor can be called as a function\n\n Object.defineProperty(this, \"message\", { get: function() { return message; } });\n\n /* istanbul ignore next */\n if (Error.captureStackTrace) // node\n Error.captureStackTrace(this, CustomError);\n else\n Object.defineProperty(this, \"stack\", { value: new Error().stack || \"\" });\n\n if (properties)\n merge(this, properties);\n }\n\n (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;\n\n Object.defineProperty(CustomError.prototype, \"name\", { get: function() { return name; } });\n\n CustomError.prototype.toString = function toString() {\n return this.name + \": \" + this.message;\n };\n\n return CustomError;\n}\n\nutil.newError = newError;\n\n/**\n * Constructs a new protocol error.\n * @classdesc Error subclass indicating a protocol specifc error.\n * @memberof util\n * @extends Error\n * @template T extends Message\n * @constructor\n * @param {string} message Error message\n * @param {Object.} [properties] Additional properties\n * @example\n * try {\n * MyMessage.decode(someBuffer); // throws if required fields are missing\n * } catch (e) {\n * if (e instanceof ProtocolError && e.instance)\n * console.log(\"decoded so far: \" + JSON.stringify(e.instance));\n * }\n */\nutil.ProtocolError = newError(\"ProtocolError\");\n\n/**\n * So far decoded message instance.\n * @name util.ProtocolError#instance\n * @type {Message}\n */\n\n/**\n * A OneOf getter as returned by {@link util.oneOfGetter}.\n * @typedef OneOfGetter\n * @type {function}\n * @returns {string|undefined} Set field name, if any\n */\n\n/**\n * Builds a getter for a oneof's present field name.\n * @param {string[]} fieldNames Field names\n * @returns {OneOfGetter} Unbound getter\n */\nutil.oneOfGetter = function getOneOf(fieldNames) {\n var fieldMap = {};\n for (var i = 0; i < fieldNames.length; ++i)\n fieldMap[fieldNames[i]] = 1;\n\n /**\n * @returns {string|undefined} Set field name, if any\n * @this Object\n * @ignore\n */\n return function() { // eslint-disable-line consistent-return\n for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)\n if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)\n return keys[i];\n };\n};\n\n/**\n * A OneOf setter as returned by {@link util.oneOfSetter}.\n * @typedef OneOfSetter\n * @type {function}\n * @param {string|undefined} value Field name\n * @returns {undefined}\n */\n\n/**\n * Builds a setter for a oneof's present field name.\n * @param {string[]} fieldNames Field names\n * @returns {OneOfSetter} Unbound setter\n */\nutil.oneOfSetter = function setOneOf(fieldNames) {\n\n /**\n * @param {string} name Field name\n * @returns {undefined}\n * @this Object\n * @ignore\n */\n return function(name) {\n for (var i = 0; i < fieldNames.length; ++i)\n if (fieldNames[i] !== name)\n delete this[fieldNames[i]];\n };\n};\n\n/**\n * Default conversion options used for {@link Message#toJSON} implementations.\n *\n * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:\n *\n * - Longs become strings\n * - Enums become string keys\n * - Bytes become base64 encoded strings\n * - (Sub-)Messages become plain objects\n * - Maps become plain objects with all string keys\n * - Repeated fields become arrays\n * - NaN and Infinity for float and double fields become strings\n *\n * @type {IConversionOptions}\n * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json\n */\nutil.toJSONOptions = {\n longs: String,\n enums: String,\n bytes: String,\n json: true\n};\n\n// Sets up buffer utility according to the environment (called in index-minimal)\nutil._configure = function() {\n var Buffer = util.Buffer;\n /* istanbul ignore if */\n if (!Buffer) {\n util._Buffer_from = util._Buffer_allocUnsafe = null;\n return;\n }\n // because node 4.x buffers are incompatible & immutable\n // see: https://github.com/dcodeIO/protobuf.js/pull/665\n util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||\n /* istanbul ignore next */\n function Buffer_from(value, encoding) {\n return new Buffer(value, encoding);\n };\n util._Buffer_allocUnsafe = Buffer.allocUnsafe ||\n /* istanbul ignore next */\n function Buffer_allocUnsafe(size) {\n return new Buffer(size);\n };\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/writer.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/writer.js ***! - \************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = Writer;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\nvar BufferWriter; // cyclic\n\nvar LongBits = util.LongBits,\n base64 = util.base64,\n utf8 = util.utf8;\n\n/**\n * Constructs a new writer operation instance.\n * @classdesc Scheduled writer operation.\n * @constructor\n * @param {function(*, Uint8Array, number)} fn Function to call\n * @param {number} len Value byte length\n * @param {*} val Value to write\n * @ignore\n */\nfunction Op(fn, len, val) {\n\n /**\n * Function to call.\n * @type {function(Uint8Array, number, *)}\n */\n this.fn = fn;\n\n /**\n * Value byte length.\n * @type {number}\n */\n this.len = len;\n\n /**\n * Next operation.\n * @type {Writer.Op|undefined}\n */\n this.next = undefined;\n\n /**\n * Value to write.\n * @type {*}\n */\n this.val = val; // type varies\n}\n\n/* istanbul ignore next */\nfunction noop() {} // eslint-disable-line no-empty-function\n\n/**\n * Constructs a new writer state instance.\n * @classdesc Copied writer state.\n * @memberof Writer\n * @constructor\n * @param {Writer} writer Writer to copy state from\n * @ignore\n */\nfunction State(writer) {\n\n /**\n * Current head.\n * @type {Writer.Op}\n */\n this.head = writer.head;\n\n /**\n * Current tail.\n * @type {Writer.Op}\n */\n this.tail = writer.tail;\n\n /**\n * Current buffer length.\n * @type {number}\n */\n this.len = writer.len;\n\n /**\n * Next state.\n * @type {State|null}\n */\n this.next = writer.states;\n}\n\n/**\n * Constructs a new writer instance.\n * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.\n * @constructor\n */\nfunction Writer() {\n\n /**\n * Current length.\n * @type {number}\n */\n this.len = 0;\n\n /**\n * Operations head.\n * @type {Object}\n */\n this.head = new Op(noop, 0, 0);\n\n /**\n * Operations tail\n * @type {Object}\n */\n this.tail = this.head;\n\n /**\n * Linked forked states.\n * @type {Object|null}\n */\n this.states = null;\n\n // When a value is written, the writer calculates its byte length and puts it into a linked\n // list of operations to perform when finish() is called. This both allows us to allocate\n // buffers of the exact required size and reduces the amount of work we have to do compared\n // to first calculating over objects and then encoding over objects. In our case, the encoding\n // part is just a linked list walk calling operations with already prepared values.\n}\n\nvar create = function create() {\n return util.Buffer\n ? function create_buffer_setup() {\n return (Writer.create = function create_buffer() {\n return new BufferWriter();\n })();\n }\n /* istanbul ignore next */\n : function create_array() {\n return new Writer();\n };\n};\n\n/**\n * Creates a new writer.\n * @function\n * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}\n */\nWriter.create = create();\n\n/**\n * Allocates a buffer of the specified size.\n * @param {number} size Buffer size\n * @returns {Uint8Array} Buffer\n */\nWriter.alloc = function alloc(size) {\n return new util.Array(size);\n};\n\n// Use Uint8Array buffer pool in the browser, just like node does with buffers\n/* istanbul ignore else */\nif (util.Array !== Array)\n Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray);\n\n/**\n * Pushes a new operation to the queue.\n * @param {function(Uint8Array, number, *)} fn Function to call\n * @param {number} len Value byte length\n * @param {number} val Value to write\n * @returns {Writer} `this`\n * @private\n */\nWriter.prototype._push = function push(fn, len, val) {\n this.tail = this.tail.next = new Op(fn, len, val);\n this.len += len;\n return this;\n};\n\nfunction writeByte(val, buf, pos) {\n buf[pos] = val & 255;\n}\n\nfunction writeVarint32(val, buf, pos) {\n while (val > 127) {\n buf[pos++] = val & 127 | 128;\n val >>>= 7;\n }\n buf[pos] = val;\n}\n\n/**\n * Constructs a new varint writer operation instance.\n * @classdesc Scheduled varint writer operation.\n * @extends Op\n * @constructor\n * @param {number} len Value byte length\n * @param {number} val Value to write\n * @ignore\n */\nfunction VarintOp(len, val) {\n this.len = len;\n this.next = undefined;\n this.val = val;\n}\n\nVarintOp.prototype = Object.create(Op.prototype);\nVarintOp.prototype.fn = writeVarint32;\n\n/**\n * Writes an unsigned 32 bit value as a varint.\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.uint32 = function write_uint32(value) {\n // here, the call to this.push has been inlined and a varint specific Op subclass is used.\n // uint32 is by far the most frequently used operation and benefits significantly from this.\n this.len += (this.tail = this.tail.next = new VarintOp(\n (value = value >>> 0)\n < 128 ? 1\n : value < 16384 ? 2\n : value < 2097152 ? 3\n : value < 268435456 ? 4\n : 5,\n value)).len;\n return this;\n};\n\n/**\n * Writes a signed 32 bit value as a varint.\n * @function\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.int32 = function write_int32(value) {\n return value < 0\n ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec\n : this.uint32(value);\n};\n\n/**\n * Writes a 32 bit value as a varint, zig-zag encoded.\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.sint32 = function write_sint32(value) {\n return this.uint32((value << 1 ^ value >> 31) >>> 0);\n};\n\nfunction writeVarint64(val, buf, pos) {\n while (val.hi) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;\n val.hi >>>= 7;\n }\n while (val.lo > 127) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = val.lo >>> 7;\n }\n buf[pos++] = val.lo;\n}\n\n/**\n * Writes an unsigned 64 bit value as a varint.\n * @param {Long|number|string} value Value to write\n * @returns {Writer} `this`\n * @throws {TypeError} If `value` is a string and no long library is present.\n */\nWriter.prototype.uint64 = function write_uint64(value) {\n var bits = LongBits.from(value);\n return this._push(writeVarint64, bits.length(), bits);\n};\n\n/**\n * Writes a signed 64 bit value as a varint.\n * @function\n * @param {Long|number|string} value Value to write\n * @returns {Writer} `this`\n * @throws {TypeError} If `value` is a string and no long library is present.\n */\nWriter.prototype.int64 = Writer.prototype.uint64;\n\n/**\n * Writes a signed 64 bit value as a varint, zig-zag encoded.\n * @param {Long|number|string} value Value to write\n * @returns {Writer} `this`\n * @throws {TypeError} If `value` is a string and no long library is present.\n */\nWriter.prototype.sint64 = function write_sint64(value) {\n var bits = LongBits.from(value).zzEncode();\n return this._push(writeVarint64, bits.length(), bits);\n};\n\n/**\n * Writes a boolish value as a varint.\n * @param {boolean} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.bool = function write_bool(value) {\n return this._push(writeByte, 1, value ? 1 : 0);\n};\n\nfunction writeFixed32(val, buf, pos) {\n buf[pos ] = val & 255;\n buf[pos + 1] = val >>> 8 & 255;\n buf[pos + 2] = val >>> 16 & 255;\n buf[pos + 3] = val >>> 24;\n}\n\n/**\n * Writes an unsigned 32 bit value as fixed 32 bits.\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.fixed32 = function write_fixed32(value) {\n return this._push(writeFixed32, 4, value >>> 0);\n};\n\n/**\n * Writes a signed 32 bit value as fixed 32 bits.\n * @function\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.sfixed32 = Writer.prototype.fixed32;\n\n/**\n * Writes an unsigned 64 bit value as fixed 64 bits.\n * @param {Long|number|string} value Value to write\n * @returns {Writer} `this`\n * @throws {TypeError} If `value` is a string and no long library is present.\n */\nWriter.prototype.fixed64 = function write_fixed64(value) {\n var bits = LongBits.from(value);\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\n};\n\n/**\n * Writes a signed 64 bit value as fixed 64 bits.\n * @function\n * @param {Long|number|string} value Value to write\n * @returns {Writer} `this`\n * @throws {TypeError} If `value` is a string and no long library is present.\n */\nWriter.prototype.sfixed64 = Writer.prototype.fixed64;\n\n/**\n * Writes a float (32 bit).\n * @function\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.float = function write_float(value) {\n return this._push(util.float.writeFloatLE, 4, value);\n};\n\n/**\n * Writes a double (64 bit float).\n * @function\n * @param {number} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.double = function write_double(value) {\n return this._push(util.float.writeDoubleLE, 8, value);\n};\n\nvar writeBytes = util.Array.prototype.set\n ? function writeBytes_set(val, buf, pos) {\n buf.set(val, pos); // also works for plain array values\n }\n /* istanbul ignore next */\n : function writeBytes_for(val, buf, pos) {\n for (var i = 0; i < val.length; ++i)\n buf[pos + i] = val[i];\n };\n\n/**\n * Writes a sequence of bytes.\n * @param {Uint8Array|string} value Buffer or base64 encoded string to write\n * @returns {Writer} `this`\n */\nWriter.prototype.bytes = function write_bytes(value) {\n var len = value.length >>> 0;\n if (!len)\n return this._push(writeByte, 1, 0);\n if (util.isString(value)) {\n var buf = Writer.alloc(len = base64.length(value));\n base64.decode(value, buf, 0);\n value = buf;\n }\n return this.uint32(len)._push(writeBytes, len, value);\n};\n\n/**\n * Writes a string.\n * @param {string} value Value to write\n * @returns {Writer} `this`\n */\nWriter.prototype.string = function write_string(value) {\n var len = utf8.length(value);\n return len\n ? this.uint32(len)._push(utf8.write, len, value)\n : this._push(writeByte, 1, 0);\n};\n\n/**\n * Forks this writer's state by pushing it to a stack.\n * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.\n * @returns {Writer} `this`\n */\nWriter.prototype.fork = function fork() {\n this.states = new State(this);\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n return this;\n};\n\n/**\n * Resets this instance to the last state.\n * @returns {Writer} `this`\n */\nWriter.prototype.reset = function reset() {\n if (this.states) {\n this.head = this.states.head;\n this.tail = this.states.tail;\n this.len = this.states.len;\n this.states = this.states.next;\n } else {\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n }\n return this;\n};\n\n/**\n * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.\n * @returns {Writer} `this`\n */\nWriter.prototype.ldelim = function ldelim() {\n var head = this.head,\n tail = this.tail,\n len = this.len;\n this.reset().uint32(len);\n if (len) {\n this.tail.next = head.next; // skip noop\n this.tail = tail;\n this.len += len;\n }\n return this;\n};\n\n/**\n * Finishes the write operation.\n * @returns {Uint8Array} Finished buffer\n */\nWriter.prototype.finish = function finish() {\n var head = this.head.next, // skip noop\n buf = this.constructor.alloc(this.len),\n pos = 0;\n while (head) {\n head.fn(head.val, buf, pos);\n pos += head.len;\n head = head.next;\n }\n // this.head = this.tail = null;\n return buf;\n};\n\nWriter._configure = function(BufferWriter_) {\n BufferWriter = BufferWriter_;\n Writer.create = create();\n BufferWriter._configure();\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/writer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/protobufjs/src/writer_buffer.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/protobufjs/src/writer_buffer.js ***! - \*******************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\nmodule.exports = BufferWriter;\n\n// extends Writer\nvar Writer = __webpack_require__(/*! ./writer */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/writer.js\");\n(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/src/util/minimal.js\");\n\n/**\n * Constructs a new buffer writer instance.\n * @classdesc Wire format writer using node buffers.\n * @extends Writer\n * @constructor\n */\nfunction BufferWriter() {\n Writer.call(this);\n}\n\nBufferWriter._configure = function () {\n /**\n * Allocates a buffer of the specified size.\n * @function\n * @param {number} size Buffer size\n * @returns {Buffer} Buffer\n */\n BufferWriter.alloc = util._Buffer_allocUnsafe;\n\n BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === \"set\"\n ? function writeBytesBuffer_set(val, buf, pos) {\n buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)\n // also works for plain array values\n }\n /* istanbul ignore next */\n : function writeBytesBuffer_copy(val, buf, pos) {\n if (val.copy) // Buffer values\n val.copy(buf, pos, 0, val.length);\n else for (var i = 0; i < val.length;) // plain array values\n buf[pos++] = val[i++];\n };\n};\n\n\n/**\n * @override\n */\nBufferWriter.prototype.bytes = function write_bytes_buffer(value) {\n if (util.isString(value))\n value = util._Buffer_from(value, \"base64\");\n var len = value.length >>> 0;\n this.uint32(len);\n if (len)\n this._push(BufferWriter.writeBytesBuffer, len, value);\n return this;\n};\n\nfunction writeStringBuffer(val, buf, pos) {\n if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)\n util.utf8.write(val, buf, pos);\n else if (buf.utf8Write)\n buf.utf8Write(val, pos);\n else\n buf.write(val, pos);\n}\n\n/**\n * @override\n */\nBufferWriter.prototype.string = function write_string_buffer(value) {\n var len = util.Buffer.byteLength(value);\n this.uint32(len);\n if (len)\n this._push(writeStringBuffer, len, value);\n return this;\n};\n\n\n/**\n * Finishes the write operation.\n * @name BufferWriter#finish\n * @function\n * @returns {Buffer} Finished buffer\n */\n\nBufferWriter._configure();\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/protobufjs/src/writer_buffer.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Any: () => (/* binding */ Any),\n/* harmony export */ BaseBlock: () => (/* binding */ BaseBlock),\n/* harmony export */ BaseStringBlock: () => (/* binding */ BaseStringBlock),\n/* harmony export */ BitString: () => (/* binding */ BitString),\n/* harmony export */ BmpString: () => (/* binding */ BmpString),\n/* harmony export */ Boolean: () => (/* binding */ Boolean),\n/* harmony export */ CharacterString: () => (/* binding */ CharacterString),\n/* harmony export */ Choice: () => (/* binding */ Choice),\n/* harmony export */ Constructed: () => (/* binding */ Constructed),\n/* harmony export */ DATE: () => (/* binding */ DATE),\n/* harmony export */ DateTime: () => (/* binding */ DateTime),\n/* harmony export */ Duration: () => (/* binding */ Duration),\n/* harmony export */ EndOfContent: () => (/* binding */ EndOfContent),\n/* harmony export */ Enumerated: () => (/* binding */ Enumerated),\n/* harmony export */ GeneralString: () => (/* binding */ GeneralString),\n/* harmony export */ GeneralizedTime: () => (/* binding */ GeneralizedTime),\n/* harmony export */ GraphicString: () => (/* binding */ GraphicString),\n/* harmony export */ HexBlock: () => (/* binding */ HexBlock),\n/* harmony export */ IA5String: () => (/* binding */ IA5String),\n/* harmony export */ Integer: () => (/* binding */ Integer),\n/* harmony export */ Null: () => (/* binding */ Null),\n/* harmony export */ NumericString: () => (/* binding */ NumericString),\n/* harmony export */ ObjectIdentifier: () => (/* binding */ ObjectIdentifier),\n/* harmony export */ OctetString: () => (/* binding */ OctetString),\n/* harmony export */ Primitive: () => (/* binding */ Primitive),\n/* harmony export */ PrintableString: () => (/* binding */ PrintableString),\n/* harmony export */ RawData: () => (/* binding */ RawData),\n/* harmony export */ RelativeObjectIdentifier: () => (/* binding */ RelativeObjectIdentifier),\n/* harmony export */ Repeated: () => (/* binding */ Repeated),\n/* harmony export */ Sequence: () => (/* binding */ Sequence),\n/* harmony export */ Set: () => (/* binding */ Set),\n/* harmony export */ TIME: () => (/* binding */ TIME),\n/* harmony export */ TeletexString: () => (/* binding */ TeletexString),\n/* harmony export */ TimeOfDay: () => (/* binding */ TimeOfDay),\n/* harmony export */ UTCTime: () => (/* binding */ UTCTime),\n/* harmony export */ UniversalString: () => (/* binding */ UniversalString),\n/* harmony export */ Utf8String: () => (/* binding */ Utf8String),\n/* harmony export */ ValueBlock: () => (/* binding */ ValueBlock),\n/* harmony export */ VideotexString: () => (/* binding */ VideotexString),\n/* harmony export */ ViewWriter: () => (/* binding */ ViewWriter),\n/* harmony export */ VisibleString: () => (/* binding */ VisibleString),\n/* harmony export */ compareSchema: () => (/* binding */ compareSchema),\n/* harmony export */ fromBER: () => (/* binding */ fromBER),\n/* harmony export */ verifySchema: () => (/* binding */ verifySchema)\n/* harmony export */ });\n/* harmony import */ var pvtsutils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! pvtsutils */ \"./node_modules/pvtsutils/build/index.js\");\n/* harmony import */ var pvutils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! pvutils */ \"./node_modules/pvutils/build/utils.es.js\");\n/*!\n * Copyright (c) 2014, GMO GlobalSign\n * Copyright (c) 2015-2022, Peculiar Ventures\n * All rights reserved.\n * \n * Author 2014-2019, Yury Strozhevsky\n * \n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * \n * * Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * \n * * Redistributions in binary form must reproduce the above copyright notice, this\n * list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * \n * * Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n * \n */\n\n\n\n\nfunction assertBigInt() {\r\n if (typeof BigInt === \"undefined\") {\r\n throw new Error(\"BigInt is not defined. Your environment doesn't implement BigInt.\");\r\n }\r\n}\r\nfunction concat(buffers) {\r\n let outputLength = 0;\r\n let prevLength = 0;\r\n for (let i = 0; i < buffers.length; i++) {\r\n const buffer = buffers[i];\r\n outputLength += buffer.byteLength;\r\n }\r\n const retView = new Uint8Array(outputLength);\r\n for (let i = 0; i < buffers.length; i++) {\r\n const buffer = buffers[i];\r\n retView.set(new Uint8Array(buffer), prevLength);\r\n prevLength += buffer.byteLength;\r\n }\r\n return retView.buffer;\r\n}\r\nfunction checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength) {\r\n if (!(inputBuffer instanceof Uint8Array)) {\r\n baseBlock.error = \"Wrong parameter: inputBuffer must be 'Uint8Array'\";\r\n return false;\r\n }\r\n if (!inputBuffer.byteLength) {\r\n baseBlock.error = \"Wrong parameter: inputBuffer has zero length\";\r\n return false;\r\n }\r\n if (inputOffset < 0) {\r\n baseBlock.error = \"Wrong parameter: inputOffset less than zero\";\r\n return false;\r\n }\r\n if (inputLength < 0) {\r\n baseBlock.error = \"Wrong parameter: inputLength less than zero\";\r\n return false;\r\n }\r\n if ((inputBuffer.byteLength - inputOffset - inputLength) < 0) {\r\n baseBlock.error = \"End of input reached before message was fully decoded (inconsistent offset and length values)\";\r\n return false;\r\n }\r\n return true;\r\n}\n\nclass ViewWriter {\r\n constructor() {\r\n this.items = [];\r\n }\r\n write(buf) {\r\n this.items.push(buf);\r\n }\r\n final() {\r\n return concat(this.items);\r\n }\r\n}\n\nconst powers2 = [new Uint8Array([1])];\r\nconst digitsString = \"0123456789\";\r\nconst NAME = \"name\";\r\nconst VALUE_HEX_VIEW = \"valueHexView\";\r\nconst IS_HEX_ONLY = \"isHexOnly\";\r\nconst ID_BLOCK = \"idBlock\";\r\nconst TAG_CLASS = \"tagClass\";\r\nconst TAG_NUMBER = \"tagNumber\";\r\nconst IS_CONSTRUCTED = \"isConstructed\";\r\nconst FROM_BER = \"fromBER\";\r\nconst TO_BER = \"toBER\";\r\nconst LOCAL = \"local\";\r\nconst EMPTY_STRING = \"\";\r\nconst EMPTY_BUFFER = new ArrayBuffer(0);\r\nconst EMPTY_VIEW = new Uint8Array(0);\r\nconst END_OF_CONTENT_NAME = \"EndOfContent\";\r\nconst OCTET_STRING_NAME = \"OCTET STRING\";\r\nconst BIT_STRING_NAME = \"BIT STRING\";\n\nfunction HexBlock(BaseClass) {\r\n var _a;\r\n return _a = class Some extends BaseClass {\r\n constructor(...args) {\r\n var _a;\r\n super(...args);\r\n const params = args[0] || {};\r\n this.isHexOnly = (_a = params.isHexOnly) !== null && _a !== void 0 ? _a : false;\r\n this.valueHexView = params.valueHex ? pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;\r\n }\r\n get valueHex() {\r\n return this.valueHexView.slice().buffer;\r\n }\r\n set valueHex(value) {\r\n this.valueHexView = new Uint8Array(value);\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;\r\n if (!checkBufferParams(this, view, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n const endLength = inputOffset + inputLength;\r\n this.valueHexView = view.subarray(inputOffset, endLength);\r\n if (!this.valueHexView.length) {\r\n this.warnings.push(\"Zero buffer length\");\r\n return inputOffset;\r\n }\r\n this.blockLength = inputLength;\r\n return endLength;\r\n }\r\n toBER(sizeOnly = false) {\r\n if (!this.isHexOnly) {\r\n this.error = \"Flag 'isHexOnly' is not set, abort\";\r\n return EMPTY_BUFFER;\r\n }\r\n if (sizeOnly) {\r\n return new ArrayBuffer(this.valueHexView.byteLength);\r\n }\r\n return (this.valueHexView.byteLength === this.valueHexView.buffer.byteLength)\r\n ? this.valueHexView.buffer\r\n : this.valueHexView.slice().buffer;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n isHexOnly: this.isHexOnly,\r\n valueHex: pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueHexView),\r\n };\r\n }\r\n },\r\n _a.NAME = \"hexBlock\",\r\n _a;\r\n}\n\nclass LocalBaseBlock {\r\n constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW, } = {}) {\r\n this.blockLength = blockLength;\r\n this.error = error;\r\n this.warnings = warnings;\r\n this.valueBeforeDecodeView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(valueBeforeDecode);\r\n }\r\n static blockName() {\r\n return this.NAME;\r\n }\r\n get valueBeforeDecode() {\r\n return this.valueBeforeDecodeView.slice().buffer;\r\n }\r\n set valueBeforeDecode(value) {\r\n this.valueBeforeDecodeView = new Uint8Array(value);\r\n }\r\n toJSON() {\r\n return {\r\n blockName: this.constructor.NAME,\r\n blockLength: this.blockLength,\r\n error: this.error,\r\n warnings: this.warnings,\r\n valueBeforeDecode: pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueBeforeDecodeView),\r\n };\r\n }\r\n}\r\nLocalBaseBlock.NAME = \"baseBlock\";\n\nclass ValueBlock extends LocalBaseBlock {\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n throw TypeError(\"User need to make a specific function in a class which extends 'ValueBlock'\");\r\n }\r\n toBER(sizeOnly, writer) {\r\n throw TypeError(\"User need to make a specific function in a class which extends 'ValueBlock'\");\r\n }\r\n}\r\nValueBlock.NAME = \"valueBlock\";\n\nclass LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {\r\n constructor({ idBlock = {}, } = {}) {\r\n var _a, _b, _c, _d;\r\n super();\r\n if (idBlock) {\r\n this.isHexOnly = (_a = idBlock.isHexOnly) !== null && _a !== void 0 ? _a : false;\r\n this.valueHexView = idBlock.valueHex ? pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(idBlock.valueHex) : EMPTY_VIEW;\r\n this.tagClass = (_b = idBlock.tagClass) !== null && _b !== void 0 ? _b : -1;\r\n this.tagNumber = (_c = idBlock.tagNumber) !== null && _c !== void 0 ? _c : -1;\r\n this.isConstructed = (_d = idBlock.isConstructed) !== null && _d !== void 0 ? _d : false;\r\n }\r\n else {\r\n this.tagClass = -1;\r\n this.tagNumber = -1;\r\n this.isConstructed = false;\r\n }\r\n }\r\n toBER(sizeOnly = false) {\r\n let firstOctet = 0;\r\n switch (this.tagClass) {\r\n case 1:\r\n firstOctet |= 0x00;\r\n break;\r\n case 2:\r\n firstOctet |= 0x40;\r\n break;\r\n case 3:\r\n firstOctet |= 0x80;\r\n break;\r\n case 4:\r\n firstOctet |= 0xC0;\r\n break;\r\n default:\r\n this.error = \"Unknown tag class\";\r\n return EMPTY_BUFFER;\r\n }\r\n if (this.isConstructed)\r\n firstOctet |= 0x20;\r\n if (this.tagNumber < 31 && !this.isHexOnly) {\r\n const retView = new Uint8Array(1);\r\n if (!sizeOnly) {\r\n let number = this.tagNumber;\r\n number &= 0x1F;\r\n firstOctet |= number;\r\n retView[0] = firstOctet;\r\n }\r\n return retView.buffer;\r\n }\r\n if (!this.isHexOnly) {\r\n const encodedBuf = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilToBase(this.tagNumber, 7);\r\n const encodedView = new Uint8Array(encodedBuf);\r\n const size = encodedBuf.byteLength;\r\n const retView = new Uint8Array(size + 1);\r\n retView[0] = (firstOctet | 0x1F);\r\n if (!sizeOnly) {\r\n for (let i = 0; i < (size - 1); i++)\r\n retView[i + 1] = encodedView[i] | 0x80;\r\n retView[size] = encodedView[size - 1];\r\n }\r\n return retView.buffer;\r\n }\r\n const retView = new Uint8Array(this.valueHexView.byteLength + 1);\r\n retView[0] = (firstOctet | 0x1F);\r\n if (!sizeOnly) {\r\n const curView = this.valueHexView;\r\n for (let i = 0; i < (curView.length - 1); i++)\r\n retView[i + 1] = curView[i] | 0x80;\r\n retView[this.valueHexView.byteLength] = curView[curView.length - 1];\r\n }\r\n return retView.buffer;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const inputView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);\r\n if (intBuffer.length === 0) {\r\n this.error = \"Zero buffer length\";\r\n return -1;\r\n }\r\n const tagClassMask = intBuffer[0] & 0xC0;\r\n switch (tagClassMask) {\r\n case 0x00:\r\n this.tagClass = (1);\r\n break;\r\n case 0x40:\r\n this.tagClass = (2);\r\n break;\r\n case 0x80:\r\n this.tagClass = (3);\r\n break;\r\n case 0xC0:\r\n this.tagClass = (4);\r\n break;\r\n default:\r\n this.error = \"Unknown tag class\";\r\n return -1;\r\n }\r\n this.isConstructed = (intBuffer[0] & 0x20) === 0x20;\r\n this.isHexOnly = false;\r\n const tagNumberMask = intBuffer[0] & 0x1F;\r\n if (tagNumberMask !== 0x1F) {\r\n this.tagNumber = (tagNumberMask);\r\n this.blockLength = 1;\r\n }\r\n else {\r\n let count = 1;\r\n let intTagNumberBuffer = this.valueHexView = new Uint8Array(255);\r\n let tagNumberBufferMaxLength = 255;\r\n while (intBuffer[count] & 0x80) {\r\n intTagNumberBuffer[count - 1] = intBuffer[count] & 0x7F;\r\n count++;\r\n if (count >= intBuffer.length) {\r\n this.error = \"End of input reached before message was fully decoded\";\r\n return -1;\r\n }\r\n if (count === tagNumberBufferMaxLength) {\r\n tagNumberBufferMaxLength += 255;\r\n const tempBufferView = new Uint8Array(tagNumberBufferMaxLength);\r\n for (let i = 0; i < intTagNumberBuffer.length; i++)\r\n tempBufferView[i] = intTagNumberBuffer[i];\r\n intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength);\r\n }\r\n }\r\n this.blockLength = (count + 1);\r\n intTagNumberBuffer[count - 1] = intBuffer[count] & 0x7F;\r\n const tempBufferView = new Uint8Array(count);\r\n for (let i = 0; i < count; i++)\r\n tempBufferView[i] = intTagNumberBuffer[i];\r\n intTagNumberBuffer = this.valueHexView = new Uint8Array(count);\r\n intTagNumberBuffer.set(tempBufferView);\r\n if (this.blockLength <= 9)\r\n this.tagNumber = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilFromBase(intTagNumberBuffer, 7);\r\n else {\r\n this.isHexOnly = true;\r\n this.warnings.push(\"Tag too long, represented as hex-coded\");\r\n }\r\n }\r\n if (((this.tagClass === 1)) &&\r\n (this.isConstructed)) {\r\n switch (this.tagNumber) {\r\n case 1:\r\n case 2:\r\n case 5:\r\n case 6:\r\n case 9:\r\n case 13:\r\n case 14:\r\n case 23:\r\n case 24:\r\n case 31:\r\n case 32:\r\n case 33:\r\n case 34:\r\n this.error = \"Constructed encoding used for primitive type\";\r\n return -1;\r\n }\r\n }\r\n return (inputOffset + this.blockLength);\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n tagClass: this.tagClass,\r\n tagNumber: this.tagNumber,\r\n isConstructed: this.isConstructed,\r\n };\r\n }\r\n}\r\nLocalIdentificationBlock.NAME = \"identificationBlock\";\n\nclass LocalLengthBlock extends LocalBaseBlock {\r\n constructor({ lenBlock = {}, } = {}) {\r\n var _a, _b, _c;\r\n super();\r\n this.isIndefiniteForm = (_a = lenBlock.isIndefiniteForm) !== null && _a !== void 0 ? _a : false;\r\n this.longFormUsed = (_b = lenBlock.longFormUsed) !== null && _b !== void 0 ? _b : false;\r\n this.length = (_c = lenBlock.length) !== null && _c !== void 0 ? _c : 0;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const view = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, view, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n const intBuffer = view.subarray(inputOffset, inputOffset + inputLength);\r\n if (intBuffer.length === 0) {\r\n this.error = \"Zero buffer length\";\r\n return -1;\r\n }\r\n if (intBuffer[0] === 0xFF) {\r\n this.error = \"Length block 0xFF is reserved by standard\";\r\n return -1;\r\n }\r\n this.isIndefiniteForm = intBuffer[0] === 0x80;\r\n if (this.isIndefiniteForm) {\r\n this.blockLength = 1;\r\n return (inputOffset + this.blockLength);\r\n }\r\n this.longFormUsed = !!(intBuffer[0] & 0x80);\r\n if (this.longFormUsed === false) {\r\n this.length = (intBuffer[0]);\r\n this.blockLength = 1;\r\n return (inputOffset + this.blockLength);\r\n }\r\n const count = intBuffer[0] & 0x7F;\r\n if (count > 8) {\r\n this.error = \"Too big integer\";\r\n return -1;\r\n }\r\n if ((count + 1) > intBuffer.length) {\r\n this.error = \"End of input reached before message was fully decoded\";\r\n return -1;\r\n }\r\n const lenOffset = inputOffset + 1;\r\n const lengthBufferView = view.subarray(lenOffset, lenOffset + count);\r\n if (lengthBufferView[count - 1] === 0x00)\r\n this.warnings.push(\"Needlessly long encoded length\");\r\n this.length = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilFromBase(lengthBufferView, 8);\r\n if (this.longFormUsed && (this.length <= 127))\r\n this.warnings.push(\"Unnecessary usage of long length form\");\r\n this.blockLength = count + 1;\r\n return (inputOffset + this.blockLength);\r\n }\r\n toBER(sizeOnly = false) {\r\n let retBuf;\r\n let retView;\r\n if (this.length > 127)\r\n this.longFormUsed = true;\r\n if (this.isIndefiniteForm) {\r\n retBuf = new ArrayBuffer(1);\r\n if (sizeOnly === false) {\r\n retView = new Uint8Array(retBuf);\r\n retView[0] = 0x80;\r\n }\r\n return retBuf;\r\n }\r\n if (this.longFormUsed) {\r\n const encodedBuf = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilToBase(this.length, 8);\r\n if (encodedBuf.byteLength > 127) {\r\n this.error = \"Too big length\";\r\n return (EMPTY_BUFFER);\r\n }\r\n retBuf = new ArrayBuffer(encodedBuf.byteLength + 1);\r\n if (sizeOnly)\r\n return retBuf;\r\n const encodedView = new Uint8Array(encodedBuf);\r\n retView = new Uint8Array(retBuf);\r\n retView[0] = encodedBuf.byteLength | 0x80;\r\n for (let i = 0; i < encodedBuf.byteLength; i++)\r\n retView[i + 1] = encodedView[i];\r\n return retBuf;\r\n }\r\n retBuf = new ArrayBuffer(1);\r\n if (sizeOnly === false) {\r\n retView = new Uint8Array(retBuf);\r\n retView[0] = this.length;\r\n }\r\n return retBuf;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n isIndefiniteForm: this.isIndefiniteForm,\r\n longFormUsed: this.longFormUsed,\r\n length: this.length,\r\n };\r\n }\r\n}\r\nLocalLengthBlock.NAME = \"lengthBlock\";\n\nconst typeStore = {};\n\nclass BaseBlock extends LocalBaseBlock {\r\n constructor({ name = EMPTY_STRING, optional = false, primitiveSchema, ...parameters } = {}, valueBlockType) {\r\n super(parameters);\r\n this.name = name;\r\n this.optional = optional;\r\n if (primitiveSchema) {\r\n this.primitiveSchema = primitiveSchema;\r\n }\r\n this.idBlock = new LocalIdentificationBlock(parameters);\r\n this.lenBlock = new LocalLengthBlock(parameters);\r\n this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, (this.lenBlock.isIndefiniteForm) ? inputLength : this.lenBlock.length);\r\n if (resultOffset === -1) {\r\n this.error = this.valueBlock.error;\r\n return resultOffset;\r\n }\r\n if (!this.idBlock.error.length)\r\n this.blockLength += this.idBlock.blockLength;\r\n if (!this.lenBlock.error.length)\r\n this.blockLength += this.lenBlock.blockLength;\r\n if (!this.valueBlock.error.length)\r\n this.blockLength += this.valueBlock.blockLength;\r\n return resultOffset;\r\n }\r\n toBER(sizeOnly, writer) {\r\n const _writer = writer || new ViewWriter();\r\n if (!writer) {\r\n prepareIndefiniteForm(this);\r\n }\r\n const idBlockBuf = this.idBlock.toBER(sizeOnly);\r\n _writer.write(idBlockBuf);\r\n if (this.lenBlock.isIndefiniteForm) {\r\n _writer.write(new Uint8Array([0x80]).buffer);\r\n this.valueBlock.toBER(sizeOnly, _writer);\r\n _writer.write(new ArrayBuffer(2));\r\n }\r\n else {\r\n const valueBlockBuf = this.valueBlock.toBER(sizeOnly);\r\n this.lenBlock.length = valueBlockBuf.byteLength;\r\n const lenBlockBuf = this.lenBlock.toBER(sizeOnly);\r\n _writer.write(lenBlockBuf);\r\n _writer.write(valueBlockBuf);\r\n }\r\n if (!writer) {\r\n return _writer.final();\r\n }\r\n return EMPTY_BUFFER;\r\n }\r\n toJSON() {\r\n const object = {\r\n ...super.toJSON(),\r\n idBlock: this.idBlock.toJSON(),\r\n lenBlock: this.lenBlock.toJSON(),\r\n valueBlock: this.valueBlock.toJSON(),\r\n name: this.name,\r\n optional: this.optional,\r\n };\r\n if (this.primitiveSchema)\r\n object.primitiveSchema = this.primitiveSchema.toJSON();\r\n return object;\r\n }\r\n toString(encoding = \"ascii\") {\r\n if (encoding === \"ascii\") {\r\n return this.onAsciiEncoding();\r\n }\r\n return pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.toBER());\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`;\r\n }\r\n isEqual(other) {\r\n if (this === other) {\r\n return true;\r\n }\r\n if (!(other instanceof this.constructor)) {\r\n return false;\r\n }\r\n const thisRaw = this.toBER();\r\n const otherRaw = other.toBER();\r\n return pvutils__WEBPACK_IMPORTED_MODULE_1__.isEqualBuffer(thisRaw, otherRaw);\r\n }\r\n}\r\nBaseBlock.NAME = \"BaseBlock\";\r\nfunction prepareIndefiniteForm(baseBlock) {\r\n if (baseBlock instanceof typeStore.Constructed) {\r\n for (const value of baseBlock.valueBlock.value) {\r\n if (prepareIndefiniteForm(value)) {\r\n baseBlock.lenBlock.isIndefiniteForm = true;\r\n }\r\n }\r\n }\r\n return !!baseBlock.lenBlock.isIndefiniteForm;\r\n}\n\nclass BaseStringBlock extends BaseBlock {\r\n constructor({ value = EMPTY_STRING, ...parameters } = {}, stringValueBlockType) {\r\n super(parameters, stringValueBlockType);\r\n if (value) {\r\n this.fromString(value);\r\n }\r\n }\r\n getValue() {\r\n return this.valueBlock.value;\r\n }\r\n setValue(value) {\r\n this.valueBlock.value = value;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, (this.lenBlock.isIndefiniteForm) ? inputLength : this.lenBlock.length);\r\n if (resultOffset === -1) {\r\n this.error = this.valueBlock.error;\r\n return resultOffset;\r\n }\r\n this.fromBuffer(this.valueBlock.valueHexView);\r\n if (!this.idBlock.error.length)\r\n this.blockLength += this.idBlock.blockLength;\r\n if (!this.lenBlock.error.length)\r\n this.blockLength += this.lenBlock.blockLength;\r\n if (!this.valueBlock.error.length)\r\n this.blockLength += this.valueBlock.blockLength;\r\n return resultOffset;\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : '${this.valueBlock.value}'`;\r\n }\r\n}\r\nBaseStringBlock.NAME = \"BaseStringBlock\";\n\nclass LocalPrimitiveValueBlock extends HexBlock(ValueBlock) {\r\n constructor({ isHexOnly = true, ...parameters } = {}) {\r\n super(parameters);\r\n this.isHexOnly = isHexOnly;\r\n }\r\n}\r\nLocalPrimitiveValueBlock.NAME = \"PrimitiveValueBlock\";\n\nvar _a$w;\r\nclass Primitive extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalPrimitiveValueBlock);\r\n this.idBlock.isConstructed = false;\r\n }\r\n}\r\n_a$w = Primitive;\r\n(() => {\r\n typeStore.Primitive = _a$w;\r\n})();\r\nPrimitive.NAME = \"PRIMITIVE\";\n\nfunction localChangeType(inputObject, newType) {\r\n if (inputObject instanceof newType) {\r\n return inputObject;\r\n }\r\n const newObject = new newType();\r\n newObject.idBlock = inputObject.idBlock;\r\n newObject.lenBlock = inputObject.lenBlock;\r\n newObject.warnings = inputObject.warnings;\r\n newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView;\r\n return newObject;\r\n}\r\nfunction localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) {\r\n const incomingOffset = inputOffset;\r\n let returnObject = new BaseBlock({}, ValueBlock);\r\n const baseBlock = new LocalBaseBlock();\r\n if (!checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength)) {\r\n returnObject.error = baseBlock.error;\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n const intBuffer = inputBuffer.subarray(inputOffset, inputOffset + inputLength);\r\n if (!intBuffer.length) {\r\n returnObject.error = \"Zero buffer length\";\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);\r\n if (returnObject.idBlock.warnings.length) {\r\n returnObject.warnings.concat(returnObject.idBlock.warnings);\r\n }\r\n if (resultOffset === -1) {\r\n returnObject.error = returnObject.idBlock.error;\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n inputOffset = resultOffset;\r\n inputLength -= returnObject.idBlock.blockLength;\r\n resultOffset = returnObject.lenBlock.fromBER(inputBuffer, inputOffset, inputLength);\r\n if (returnObject.lenBlock.warnings.length) {\r\n returnObject.warnings.concat(returnObject.lenBlock.warnings);\r\n }\r\n if (resultOffset === -1) {\r\n returnObject.error = returnObject.lenBlock.error;\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n inputOffset = resultOffset;\r\n inputLength -= returnObject.lenBlock.blockLength;\r\n if (!returnObject.idBlock.isConstructed &&\r\n returnObject.lenBlock.isIndefiniteForm) {\r\n returnObject.error = \"Indefinite length form used for primitive encoding form\";\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n let newASN1Type = BaseBlock;\r\n switch (returnObject.idBlock.tagClass) {\r\n case 1:\r\n if ((returnObject.idBlock.tagNumber >= 37) &&\r\n (returnObject.idBlock.isHexOnly === false)) {\r\n returnObject.error = \"UNIVERSAL 37 and upper tags are reserved by ASN.1 standard\";\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n switch (returnObject.idBlock.tagNumber) {\r\n case 0:\r\n if ((returnObject.idBlock.isConstructed) &&\r\n (returnObject.lenBlock.length > 0)) {\r\n returnObject.error = \"Type [UNIVERSAL 0] is reserved\";\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n }\r\n newASN1Type = typeStore.EndOfContent;\r\n break;\r\n case 1:\r\n newASN1Type = typeStore.Boolean;\r\n break;\r\n case 2:\r\n newASN1Type = typeStore.Integer;\r\n break;\r\n case 3:\r\n newASN1Type = typeStore.BitString;\r\n break;\r\n case 4:\r\n newASN1Type = typeStore.OctetString;\r\n break;\r\n case 5:\r\n newASN1Type = typeStore.Null;\r\n break;\r\n case 6:\r\n newASN1Type = typeStore.ObjectIdentifier;\r\n break;\r\n case 10:\r\n newASN1Type = typeStore.Enumerated;\r\n break;\r\n case 12:\r\n newASN1Type = typeStore.Utf8String;\r\n break;\r\n case 13:\r\n newASN1Type = typeStore.RelativeObjectIdentifier;\r\n break;\r\n case 14:\r\n newASN1Type = typeStore.TIME;\r\n break;\r\n case 15:\r\n returnObject.error = \"[UNIVERSAL 15] is reserved by ASN.1 standard\";\r\n return {\r\n offset: -1,\r\n result: returnObject\r\n };\r\n case 16:\r\n newASN1Type = typeStore.Sequence;\r\n break;\r\n case 17:\r\n newASN1Type = typeStore.Set;\r\n break;\r\n case 18:\r\n newASN1Type = typeStore.NumericString;\r\n break;\r\n case 19:\r\n newASN1Type = typeStore.PrintableString;\r\n break;\r\n case 20:\r\n newASN1Type = typeStore.TeletexString;\r\n break;\r\n case 21:\r\n newASN1Type = typeStore.VideotexString;\r\n break;\r\n case 22:\r\n newASN1Type = typeStore.IA5String;\r\n break;\r\n case 23:\r\n newASN1Type = typeStore.UTCTime;\r\n break;\r\n case 24:\r\n newASN1Type = typeStore.GeneralizedTime;\r\n break;\r\n case 25:\r\n newASN1Type = typeStore.GraphicString;\r\n break;\r\n case 26:\r\n newASN1Type = typeStore.VisibleString;\r\n break;\r\n case 27:\r\n newASN1Type = typeStore.GeneralString;\r\n break;\r\n case 28:\r\n newASN1Type = typeStore.UniversalString;\r\n break;\r\n case 29:\r\n newASN1Type = typeStore.CharacterString;\r\n break;\r\n case 30:\r\n newASN1Type = typeStore.BmpString;\r\n break;\r\n case 31:\r\n newASN1Type = typeStore.DATE;\r\n break;\r\n case 32:\r\n newASN1Type = typeStore.TimeOfDay;\r\n break;\r\n case 33:\r\n newASN1Type = typeStore.DateTime;\r\n break;\r\n case 34:\r\n newASN1Type = typeStore.Duration;\r\n break;\r\n default: {\r\n const newObject = returnObject.idBlock.isConstructed\r\n ? new typeStore.Constructed()\r\n : new typeStore.Primitive();\r\n newObject.idBlock = returnObject.idBlock;\r\n newObject.lenBlock = returnObject.lenBlock;\r\n newObject.warnings = returnObject.warnings;\r\n returnObject = newObject;\r\n }\r\n }\r\n break;\r\n case 2:\r\n case 3:\r\n case 4:\r\n default: {\r\n newASN1Type = returnObject.idBlock.isConstructed\r\n ? typeStore.Constructed\r\n : typeStore.Primitive;\r\n }\r\n }\r\n returnObject = localChangeType(returnObject, newASN1Type);\r\n resultOffset = returnObject.fromBER(inputBuffer, inputOffset, returnObject.lenBlock.isIndefiniteForm ? inputLength : returnObject.lenBlock.length);\r\n returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);\r\n return {\r\n offset: resultOffset,\r\n result: returnObject\r\n };\r\n}\r\nfunction fromBER(inputBuffer) {\r\n if (!inputBuffer.byteLength) {\r\n const result = new BaseBlock({}, ValueBlock);\r\n result.error = \"Input buffer has zero length\";\r\n return {\r\n offset: -1,\r\n result\r\n };\r\n }\r\n return localFromBER(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength);\r\n}\n\nfunction checkLen(indefiniteLength, length) {\r\n if (indefiniteLength) {\r\n return 1;\r\n }\r\n return length;\r\n}\r\nclass LocalConstructedValueBlock extends ValueBlock {\r\n constructor({ value = [], isIndefiniteForm = false, ...parameters } = {}) {\r\n super(parameters);\r\n this.value = value;\r\n this.isIndefiniteForm = isIndefiniteForm;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const view = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, view, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n this.valueBeforeDecodeView = view.subarray(inputOffset, inputOffset + inputLength);\r\n if (this.valueBeforeDecodeView.length === 0) {\r\n this.warnings.push(\"Zero buffer length\");\r\n return inputOffset;\r\n }\r\n let currentOffset = inputOffset;\r\n while (checkLen(this.isIndefiniteForm, inputLength) > 0) {\r\n const returnObject = localFromBER(view, currentOffset, inputLength);\r\n if (returnObject.offset === -1) {\r\n this.error = returnObject.result.error;\r\n this.warnings.concat(returnObject.result.warnings);\r\n return -1;\r\n }\r\n currentOffset = returnObject.offset;\r\n this.blockLength += returnObject.result.blockLength;\r\n inputLength -= returnObject.result.blockLength;\r\n this.value.push(returnObject.result);\r\n if (this.isIndefiniteForm && returnObject.result.constructor.NAME === END_OF_CONTENT_NAME) {\r\n break;\r\n }\r\n }\r\n if (this.isIndefiniteForm) {\r\n if (this.value[this.value.length - 1].constructor.NAME === END_OF_CONTENT_NAME) {\r\n this.value.pop();\r\n }\r\n else {\r\n this.warnings.push(\"No EndOfContent block encoded\");\r\n }\r\n }\r\n return currentOffset;\r\n }\r\n toBER(sizeOnly, writer) {\r\n const _writer = writer || new ViewWriter();\r\n for (let i = 0; i < this.value.length; i++) {\r\n this.value[i].toBER(sizeOnly, _writer);\r\n }\r\n if (!writer) {\r\n return _writer.final();\r\n }\r\n return EMPTY_BUFFER;\r\n }\r\n toJSON() {\r\n const object = {\r\n ...super.toJSON(),\r\n isIndefiniteForm: this.isIndefiniteForm,\r\n value: [],\r\n };\r\n for (const value of this.value) {\r\n object.value.push(value.toJSON());\r\n }\r\n return object;\r\n }\r\n}\r\nLocalConstructedValueBlock.NAME = \"ConstructedValueBlock\";\n\nvar _a$v;\r\nclass Constructed extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalConstructedValueBlock);\r\n this.idBlock.isConstructed = true;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;\r\n const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, (this.lenBlock.isIndefiniteForm) ? inputLength : this.lenBlock.length);\r\n if (resultOffset === -1) {\r\n this.error = this.valueBlock.error;\r\n return resultOffset;\r\n }\r\n if (!this.idBlock.error.length)\r\n this.blockLength += this.idBlock.blockLength;\r\n if (!this.lenBlock.error.length)\r\n this.blockLength += this.lenBlock.blockLength;\r\n if (!this.valueBlock.error.length)\r\n this.blockLength += this.valueBlock.blockLength;\r\n return resultOffset;\r\n }\r\n onAsciiEncoding() {\r\n const values = [];\r\n for (const value of this.valueBlock.value) {\r\n values.push(value.toString(\"ascii\").split(\"\\n\").map(o => ` ${o}`).join(\"\\n\"));\r\n }\r\n const blockName = this.idBlock.tagClass === 3\r\n ? `[${this.idBlock.tagNumber}]`\r\n : this.constructor.NAME;\r\n return values.length\r\n ? `${blockName} :\\n${values.join(\"\\n\")}`\r\n : `${blockName} :`;\r\n }\r\n}\r\n_a$v = Constructed;\r\n(() => {\r\n typeStore.Constructed = _a$v;\r\n})();\r\nConstructed.NAME = \"CONSTRUCTED\";\n\nclass LocalEndOfContentValueBlock extends ValueBlock {\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n return inputOffset;\r\n }\r\n toBER(sizeOnly) {\r\n return EMPTY_BUFFER;\r\n }\r\n}\r\nLocalEndOfContentValueBlock.override = \"EndOfContentValueBlock\";\n\nvar _a$u;\r\nclass EndOfContent extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalEndOfContentValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 0;\r\n }\r\n}\r\n_a$u = EndOfContent;\r\n(() => {\r\n typeStore.EndOfContent = _a$u;\r\n})();\r\nEndOfContent.NAME = END_OF_CONTENT_NAME;\n\nvar _a$t;\r\nclass Null extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, ValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 5;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n if (this.lenBlock.length > 0)\r\n this.warnings.push(\"Non-zero length of value block for Null type\");\r\n if (!this.idBlock.error.length)\r\n this.blockLength += this.idBlock.blockLength;\r\n if (!this.lenBlock.error.length)\r\n this.blockLength += this.lenBlock.blockLength;\r\n this.blockLength += inputLength;\r\n if ((inputOffset + inputLength) > inputBuffer.byteLength) {\r\n this.error = \"End of input reached before message was fully decoded (inconsistent offset and length values)\";\r\n return -1;\r\n }\r\n return (inputOffset + inputLength);\r\n }\r\n toBER(sizeOnly, writer) {\r\n const retBuf = new ArrayBuffer(2);\r\n if (!sizeOnly) {\r\n const retView = new Uint8Array(retBuf);\r\n retView[0] = 0x05;\r\n retView[1] = 0x00;\r\n }\r\n if (writer) {\r\n writer.write(retBuf);\r\n }\r\n return retBuf;\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME}`;\r\n }\r\n}\r\n_a$t = Null;\r\n(() => {\r\n typeStore.Null = _a$t;\r\n})();\r\nNull.NAME = \"NULL\";\n\nclass LocalBooleanValueBlock extends HexBlock(ValueBlock) {\r\n constructor({ value, ...parameters } = {}) {\r\n super(parameters);\r\n if (parameters.valueHex) {\r\n this.valueHexView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(parameters.valueHex);\r\n }\r\n else {\r\n this.valueHexView = new Uint8Array(1);\r\n }\r\n if (value) {\r\n this.value = value;\r\n }\r\n }\r\n get value() {\r\n for (const octet of this.valueHexView) {\r\n if (octet > 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n set value(value) {\r\n this.valueHexView[0] = value ? 0xFF : 0x00;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const inputView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n this.valueHexView = inputView.subarray(inputOffset, inputOffset + inputLength);\r\n if (inputLength > 1)\r\n this.warnings.push(\"Boolean value encoded in more then 1 octet\");\r\n this.isHexOnly = true;\r\n pvutils__WEBPACK_IMPORTED_MODULE_1__.utilDecodeTC.call(this);\r\n this.blockLength = inputLength;\r\n return (inputOffset + inputLength);\r\n }\r\n toBER() {\r\n return this.valueHexView.slice();\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n value: this.value,\r\n };\r\n }\r\n}\r\nLocalBooleanValueBlock.NAME = \"BooleanValueBlock\";\n\nvar _a$s;\r\nclass Boolean extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalBooleanValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 1;\r\n }\r\n getValue() {\r\n return this.valueBlock.value;\r\n }\r\n setValue(value) {\r\n this.valueBlock.value = value;\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${this.getValue}`;\r\n }\r\n}\r\n_a$s = Boolean;\r\n(() => {\r\n typeStore.Boolean = _a$s;\r\n})();\r\nBoolean.NAME = \"BOOLEAN\";\n\nclass LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBlock) {\r\n constructor({ isConstructed = false, ...parameters } = {}) {\r\n super(parameters);\r\n this.isConstructed = isConstructed;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n let resultOffset = 0;\r\n if (this.isConstructed) {\r\n this.isHexOnly = false;\r\n resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);\r\n if (resultOffset === -1)\r\n return resultOffset;\r\n for (let i = 0; i < this.value.length; i++) {\r\n const currentBlockName = this.value[i].constructor.NAME;\r\n if (currentBlockName === END_OF_CONTENT_NAME) {\r\n if (this.isIndefiniteForm)\r\n break;\r\n else {\r\n this.error = \"EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only\";\r\n return -1;\r\n }\r\n }\r\n if (currentBlockName !== OCTET_STRING_NAME) {\r\n this.error = \"OCTET STRING may consists of OCTET STRINGs only\";\r\n return -1;\r\n }\r\n }\r\n }\r\n else {\r\n this.isHexOnly = true;\r\n resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength);\r\n this.blockLength = inputLength;\r\n }\r\n return resultOffset;\r\n }\r\n toBER(sizeOnly, writer) {\r\n if (this.isConstructed)\r\n return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer);\r\n return sizeOnly\r\n ? new ArrayBuffer(this.valueHexView.byteLength)\r\n : this.valueHexView.slice().buffer;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n isConstructed: this.isConstructed,\r\n };\r\n }\r\n}\r\nLocalOctetStringValueBlock.NAME = \"OctetStringValueBlock\";\n\nvar _a$r;\r\nclass OctetString extends BaseBlock {\r\n constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {\r\n var _b, _c;\r\n (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : (parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length));\r\n super({\r\n idBlock: {\r\n isConstructed: parameters.isConstructed,\r\n ...idBlock,\r\n },\r\n lenBlock: {\r\n ...lenBlock,\r\n isIndefiniteForm: !!parameters.isIndefiniteForm,\r\n },\r\n ...parameters,\r\n }, LocalOctetStringValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 4;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n this.valueBlock.isConstructed = this.idBlock.isConstructed;\r\n this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;\r\n if (inputLength === 0) {\r\n if (this.idBlock.error.length === 0)\r\n this.blockLength += this.idBlock.blockLength;\r\n if (this.lenBlock.error.length === 0)\r\n this.blockLength += this.lenBlock.blockLength;\r\n return inputOffset;\r\n }\r\n if (!this.valueBlock.isConstructed) {\r\n const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;\r\n const buf = view.subarray(inputOffset, inputOffset + inputLength);\r\n try {\r\n if (buf.byteLength) {\r\n const asn = localFromBER(buf, 0, buf.byteLength);\r\n if (asn.offset !== -1 && asn.offset === inputLength) {\r\n this.valueBlock.value = [asn.result];\r\n }\r\n }\r\n }\r\n catch (e) {\r\n }\r\n }\r\n return super.fromBER(inputBuffer, inputOffset, inputLength);\r\n }\r\n onAsciiEncoding() {\r\n if (this.valueBlock.isConstructed || (this.valueBlock.value && this.valueBlock.value.length)) {\r\n return Constructed.prototype.onAsciiEncoding.call(this);\r\n }\r\n return `${this.constructor.NAME} : ${pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueBlock.valueHexView)}`;\r\n }\r\n getValue() {\r\n if (!this.idBlock.isConstructed) {\r\n return this.valueBlock.valueHexView.slice().buffer;\r\n }\r\n const array = [];\r\n for (const content of this.valueBlock.value) {\r\n if (content instanceof OctetString) {\r\n array.push(content.valueBlock.valueHexView);\r\n }\r\n }\r\n return pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.concat(array);\r\n }\r\n}\r\n_a$r = OctetString;\r\n(() => {\r\n typeStore.OctetString = _a$r;\r\n})();\r\nOctetString.NAME = OCTET_STRING_NAME;\n\nclass LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBlock) {\r\n constructor({ unusedBits = 0, isConstructed = false, ...parameters } = {}) {\r\n super(parameters);\r\n this.unusedBits = unusedBits;\r\n this.isConstructed = isConstructed;\r\n this.blockLength = this.valueHexView.byteLength;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n if (!inputLength) {\r\n return inputOffset;\r\n }\r\n let resultOffset = -1;\r\n if (this.isConstructed) {\r\n resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);\r\n if (resultOffset === -1)\r\n return resultOffset;\r\n for (const value of this.value) {\r\n const currentBlockName = value.constructor.NAME;\r\n if (currentBlockName === END_OF_CONTENT_NAME) {\r\n if (this.isIndefiniteForm)\r\n break;\r\n else {\r\n this.error = \"EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only\";\r\n return -1;\r\n }\r\n }\r\n if (currentBlockName !== BIT_STRING_NAME) {\r\n this.error = \"BIT STRING may consists of BIT STRINGs only\";\r\n return -1;\r\n }\r\n const valueBlock = value.valueBlock;\r\n if ((this.unusedBits > 0) && (valueBlock.unusedBits > 0)) {\r\n this.error = \"Using of \\\"unused bits\\\" inside constructive BIT STRING allowed for least one only\";\r\n return -1;\r\n }\r\n this.unusedBits = valueBlock.unusedBits;\r\n }\r\n return resultOffset;\r\n }\r\n const inputView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);\r\n this.unusedBits = intBuffer[0];\r\n if (this.unusedBits > 7) {\r\n this.error = \"Unused bits for BitString must be in range 0-7\";\r\n return -1;\r\n }\r\n if (!this.unusedBits) {\r\n const buf = intBuffer.subarray(1);\r\n try {\r\n if (buf.byteLength) {\r\n const asn = localFromBER(buf, 0, buf.byteLength);\r\n if (asn.offset !== -1 && asn.offset === (inputLength - 1)) {\r\n this.value = [asn.result];\r\n }\r\n }\r\n }\r\n catch (e) {\r\n }\r\n }\r\n this.valueHexView = intBuffer.subarray(1);\r\n this.blockLength = intBuffer.length;\r\n return (inputOffset + inputLength);\r\n }\r\n toBER(sizeOnly, writer) {\r\n if (this.isConstructed) {\r\n return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer);\r\n }\r\n if (sizeOnly) {\r\n return new ArrayBuffer(this.valueHexView.byteLength + 1);\r\n }\r\n if (!this.valueHexView.byteLength) {\r\n return EMPTY_BUFFER;\r\n }\r\n const retView = new Uint8Array(this.valueHexView.length + 1);\r\n retView[0] = this.unusedBits;\r\n retView.set(this.valueHexView, 1);\r\n return retView.buffer;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n unusedBits: this.unusedBits,\r\n isConstructed: this.isConstructed,\r\n };\r\n }\r\n}\r\nLocalBitStringValueBlock.NAME = \"BitStringValueBlock\";\n\nvar _a$q;\r\nclass BitString extends BaseBlock {\r\n constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {\r\n var _b, _c;\r\n (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : (parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length));\r\n super({\r\n idBlock: {\r\n isConstructed: parameters.isConstructed,\r\n ...idBlock,\r\n },\r\n lenBlock: {\r\n ...lenBlock,\r\n isIndefiniteForm: !!parameters.isIndefiniteForm,\r\n },\r\n ...parameters,\r\n }, LocalBitStringValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 3;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n this.valueBlock.isConstructed = this.idBlock.isConstructed;\r\n this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;\r\n return super.fromBER(inputBuffer, inputOffset, inputLength);\r\n }\r\n onAsciiEncoding() {\r\n if (this.valueBlock.isConstructed || (this.valueBlock.value && this.valueBlock.value.length)) {\r\n return Constructed.prototype.onAsciiEncoding.call(this);\r\n }\r\n else {\r\n const bits = [];\r\n const valueHex = this.valueBlock.valueHexView;\r\n for (const byte of valueHex) {\r\n bits.push(byte.toString(2).padStart(8, \"0\"));\r\n }\r\n const bitsStr = bits.join(\"\");\r\n return `${this.constructor.NAME} : ${bitsStr.substring(0, bitsStr.length - this.valueBlock.unusedBits)}`;\r\n }\r\n }\r\n}\r\n_a$q = BitString;\r\n(() => {\r\n typeStore.BitString = _a$q;\r\n})();\r\nBitString.NAME = BIT_STRING_NAME;\n\nvar _a$p;\r\nfunction viewAdd(first, second) {\r\n const c = new Uint8Array([0]);\r\n const firstView = new Uint8Array(first);\r\n const secondView = new Uint8Array(second);\r\n let firstViewCopy = firstView.slice(0);\r\n const firstViewCopyLength = firstViewCopy.length - 1;\r\n const secondViewCopy = secondView.slice(0);\r\n const secondViewCopyLength = secondViewCopy.length - 1;\r\n let value = 0;\r\n const max = (secondViewCopyLength < firstViewCopyLength) ? firstViewCopyLength : secondViewCopyLength;\r\n let counter = 0;\r\n for (let i = max; i >= 0; i--, counter++) {\r\n switch (true) {\r\n case (counter < secondViewCopy.length):\r\n value = firstViewCopy[firstViewCopyLength - counter] + secondViewCopy[secondViewCopyLength - counter] + c[0];\r\n break;\r\n default:\r\n value = firstViewCopy[firstViewCopyLength - counter] + c[0];\r\n }\r\n c[0] = value / 10;\r\n switch (true) {\r\n case (counter >= firstViewCopy.length):\r\n firstViewCopy = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilConcatView(new Uint8Array([value % 10]), firstViewCopy);\r\n break;\r\n default:\r\n firstViewCopy[firstViewCopyLength - counter] = value % 10;\r\n }\r\n }\r\n if (c[0] > 0)\r\n firstViewCopy = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilConcatView(c, firstViewCopy);\r\n return firstViewCopy;\r\n}\r\nfunction power2(n) {\r\n if (n >= powers2.length) {\r\n for (let p = powers2.length; p <= n; p++) {\r\n const c = new Uint8Array([0]);\r\n let digits = (powers2[p - 1]).slice(0);\r\n for (let i = (digits.length - 1); i >= 0; i--) {\r\n const newValue = new Uint8Array([(digits[i] << 1) + c[0]]);\r\n c[0] = newValue[0] / 10;\r\n digits[i] = newValue[0] % 10;\r\n }\r\n if (c[0] > 0)\r\n digits = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilConcatView(c, digits);\r\n powers2.push(digits);\r\n }\r\n }\r\n return powers2[n];\r\n}\r\nfunction viewSub(first, second) {\r\n let b = 0;\r\n const firstView = new Uint8Array(first);\r\n const secondView = new Uint8Array(second);\r\n const firstViewCopy = firstView.slice(0);\r\n const firstViewCopyLength = firstViewCopy.length - 1;\r\n const secondViewCopy = secondView.slice(0);\r\n const secondViewCopyLength = secondViewCopy.length - 1;\r\n let value;\r\n let counter = 0;\r\n for (let i = secondViewCopyLength; i >= 0; i--, counter++) {\r\n value = firstViewCopy[firstViewCopyLength - counter] - secondViewCopy[secondViewCopyLength - counter] - b;\r\n switch (true) {\r\n case (value < 0):\r\n b = 1;\r\n firstViewCopy[firstViewCopyLength - counter] = value + 10;\r\n break;\r\n default:\r\n b = 0;\r\n firstViewCopy[firstViewCopyLength - counter] = value;\r\n }\r\n }\r\n if (b > 0) {\r\n for (let i = (firstViewCopyLength - secondViewCopyLength + 1); i >= 0; i--, counter++) {\r\n value = firstViewCopy[firstViewCopyLength - counter] - b;\r\n if (value < 0) {\r\n b = 1;\r\n firstViewCopy[firstViewCopyLength - counter] = value + 10;\r\n }\r\n else {\r\n b = 0;\r\n firstViewCopy[firstViewCopyLength - counter] = value;\r\n break;\r\n }\r\n }\r\n }\r\n return firstViewCopy.slice();\r\n}\r\nclass LocalIntegerValueBlock extends HexBlock(ValueBlock) {\r\n constructor({ value, ...parameters } = {}) {\r\n super(parameters);\r\n this._valueDec = 0;\r\n if (parameters.valueHex) {\r\n this.setValueHex();\r\n }\r\n if (value !== undefined) {\r\n this.valueDec = value;\r\n }\r\n }\r\n setValueHex() {\r\n if (this.valueHexView.length >= 4) {\r\n this.warnings.push(\"Too big Integer for decoding, hex only\");\r\n this.isHexOnly = true;\r\n this._valueDec = 0;\r\n }\r\n else {\r\n this.isHexOnly = false;\r\n if (this.valueHexView.length > 0) {\r\n this._valueDec = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilDecodeTC.call(this);\r\n }\r\n }\r\n }\r\n set valueDec(v) {\r\n this._valueDec = v;\r\n this.isHexOnly = false;\r\n this.valueHexView = new Uint8Array(pvutils__WEBPACK_IMPORTED_MODULE_1__.utilEncodeTC(v));\r\n }\r\n get valueDec() {\r\n return this._valueDec;\r\n }\r\n fromDER(inputBuffer, inputOffset, inputLength, expectedLength = 0) {\r\n const offset = this.fromBER(inputBuffer, inputOffset, inputLength);\r\n if (offset === -1)\r\n return offset;\r\n const view = this.valueHexView;\r\n if ((view[0] === 0x00) && ((view[1] & 0x80) !== 0)) {\r\n this.valueHexView = view.subarray(1);\r\n }\r\n else {\r\n if (expectedLength !== 0) {\r\n if (view.length < expectedLength) {\r\n if ((expectedLength - view.length) > 1)\r\n expectedLength = view.length + 1;\r\n this.valueHexView = view.subarray(expectedLength - view.length);\r\n }\r\n }\r\n }\r\n return offset;\r\n }\r\n toDER(sizeOnly = false) {\r\n const view = this.valueHexView;\r\n switch (true) {\r\n case ((view[0] & 0x80) !== 0):\r\n {\r\n const updatedView = new Uint8Array(this.valueHexView.length + 1);\r\n updatedView[0] = 0x00;\r\n updatedView.set(view, 1);\r\n this.valueHexView = updatedView;\r\n }\r\n break;\r\n case ((view[0] === 0x00) && ((view[1] & 0x80) === 0)):\r\n {\r\n this.valueHexView = this.valueHexView.subarray(1);\r\n }\r\n break;\r\n }\r\n return this.toBER(sizeOnly);\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength);\r\n if (resultOffset === -1) {\r\n return resultOffset;\r\n }\r\n this.setValueHex();\r\n return resultOffset;\r\n }\r\n toBER(sizeOnly) {\r\n return sizeOnly\r\n ? new ArrayBuffer(this.valueHexView.length)\r\n : this.valueHexView.slice().buffer;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n valueDec: this.valueDec,\r\n };\r\n }\r\n toString() {\r\n const firstBit = (this.valueHexView.length * 8) - 1;\r\n let digits = new Uint8Array((this.valueHexView.length * 8) / 3);\r\n let bitNumber = 0;\r\n let currentByte;\r\n const asn1View = this.valueHexView;\r\n let result = \"\";\r\n let flag = false;\r\n for (let byteNumber = (asn1View.byteLength - 1); byteNumber >= 0; byteNumber--) {\r\n currentByte = asn1View[byteNumber];\r\n for (let i = 0; i < 8; i++) {\r\n if ((currentByte & 1) === 1) {\r\n switch (bitNumber) {\r\n case firstBit:\r\n digits = viewSub(power2(bitNumber), digits);\r\n result = \"-\";\r\n break;\r\n default:\r\n digits = viewAdd(digits, power2(bitNumber));\r\n }\r\n }\r\n bitNumber++;\r\n currentByte >>= 1;\r\n }\r\n }\r\n for (let i = 0; i < digits.length; i++) {\r\n if (digits[i])\r\n flag = true;\r\n if (flag)\r\n result += digitsString.charAt(digits[i]);\r\n }\r\n if (flag === false)\r\n result += digitsString.charAt(0);\r\n return result;\r\n }\r\n}\r\n_a$p = LocalIntegerValueBlock;\r\nLocalIntegerValueBlock.NAME = \"IntegerValueBlock\";\r\n(() => {\r\n Object.defineProperty(_a$p.prototype, \"valueHex\", {\r\n set: function (v) {\r\n this.valueHexView = new Uint8Array(v);\r\n this.setValueHex();\r\n },\r\n get: function () {\r\n return this.valueHexView.slice().buffer;\r\n },\r\n });\r\n})();\n\nvar _a$o;\r\nclass Integer extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalIntegerValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 2;\r\n }\r\n toBigInt() {\r\n assertBigInt();\r\n return BigInt(this.valueBlock.toString());\r\n }\r\n static fromBigInt(value) {\r\n assertBigInt();\r\n const bigIntValue = BigInt(value);\r\n const writer = new ViewWriter();\r\n const hex = bigIntValue.toString(16).replace(/^-/, \"\");\r\n const view = new Uint8Array(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.FromHex(hex));\r\n if (bigIntValue < 0) {\r\n const first = new Uint8Array(view.length + (view[0] & 0x80 ? 1 : 0));\r\n first[0] |= 0x80;\r\n const firstInt = BigInt(`0x${pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(first)}`);\r\n const secondInt = firstInt + bigIntValue;\r\n const second = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.FromHex(secondInt.toString(16)));\r\n second[0] |= 0x80;\r\n writer.write(second);\r\n }\r\n else {\r\n if (view[0] & 0x80) {\r\n writer.write(new Uint8Array([0]));\r\n }\r\n writer.write(view);\r\n }\r\n const res = new Integer({\r\n valueHex: writer.final(),\r\n });\r\n return res;\r\n }\r\n convertToDER() {\r\n const integer = new Integer({ valueHex: this.valueBlock.valueHexView });\r\n integer.valueBlock.toDER();\r\n return integer;\r\n }\r\n convertFromDER() {\r\n return new Integer({\r\n valueHex: this.valueBlock.valueHexView[0] === 0\r\n ? this.valueBlock.valueHexView.subarray(1)\r\n : this.valueBlock.valueHexView,\r\n });\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${this.valueBlock.toString()}`;\r\n }\r\n}\r\n_a$o = Integer;\r\n(() => {\r\n typeStore.Integer = _a$o;\r\n})();\r\nInteger.NAME = \"INTEGER\";\n\nvar _a$n;\r\nclass Enumerated extends Integer {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 10;\r\n }\r\n}\r\n_a$n = Enumerated;\r\n(() => {\r\n typeStore.Enumerated = _a$n;\r\n})();\r\nEnumerated.NAME = \"ENUMERATED\";\n\nclass LocalSidValueBlock extends HexBlock(ValueBlock) {\r\n constructor({ valueDec = -1, isFirstSid = false, ...parameters } = {}) {\r\n super(parameters);\r\n this.valueDec = valueDec;\r\n this.isFirstSid = isFirstSid;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n if (!inputLength) {\r\n return inputOffset;\r\n }\r\n const inputView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {\r\n return -1;\r\n }\r\n const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);\r\n this.valueHexView = new Uint8Array(inputLength);\r\n for (let i = 0; i < inputLength; i++) {\r\n this.valueHexView[i] = intBuffer[i] & 0x7F;\r\n this.blockLength++;\r\n if ((intBuffer[i] & 0x80) === 0x00)\r\n break;\r\n }\r\n const tempView = new Uint8Array(this.blockLength);\r\n for (let i = 0; i < this.blockLength; i++) {\r\n tempView[i] = this.valueHexView[i];\r\n }\r\n this.valueHexView = tempView;\r\n if ((intBuffer[this.blockLength - 1] & 0x80) !== 0x00) {\r\n this.error = \"End of input reached before message was fully decoded\";\r\n return -1;\r\n }\r\n if (this.valueHexView[0] === 0x00)\r\n this.warnings.push(\"Needlessly long format of SID encoding\");\r\n if (this.blockLength <= 8)\r\n this.valueDec = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilFromBase(this.valueHexView, 7);\r\n else {\r\n this.isHexOnly = true;\r\n this.warnings.push(\"Too big SID for decoding, hex only\");\r\n }\r\n return (inputOffset + this.blockLength);\r\n }\r\n set valueBigInt(value) {\r\n assertBigInt();\r\n let bits = BigInt(value).toString(2);\r\n while (bits.length % 7) {\r\n bits = \"0\" + bits;\r\n }\r\n const bytes = new Uint8Array(bits.length / 7);\r\n for (let i = 0; i < bytes.length; i++) {\r\n bytes[i] = parseInt(bits.slice(i * 7, i * 7 + 7), 2) + (i + 1 < bytes.length ? 0x80 : 0);\r\n }\r\n this.fromBER(bytes.buffer, 0, bytes.length);\r\n }\r\n toBER(sizeOnly) {\r\n if (this.isHexOnly) {\r\n if (sizeOnly)\r\n return (new ArrayBuffer(this.valueHexView.byteLength));\r\n const curView = this.valueHexView;\r\n const retView = new Uint8Array(this.blockLength);\r\n for (let i = 0; i < (this.blockLength - 1); i++)\r\n retView[i] = curView[i] | 0x80;\r\n retView[this.blockLength - 1] = curView[this.blockLength - 1];\r\n return retView.buffer;\r\n }\r\n const encodedBuf = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilToBase(this.valueDec, 7);\r\n if (encodedBuf.byteLength === 0) {\r\n this.error = \"Error during encoding SID value\";\r\n return EMPTY_BUFFER;\r\n }\r\n const retView = new Uint8Array(encodedBuf.byteLength);\r\n if (!sizeOnly) {\r\n const encodedView = new Uint8Array(encodedBuf);\r\n const len = encodedBuf.byteLength - 1;\r\n for (let i = 0; i < len; i++)\r\n retView[i] = encodedView[i] | 0x80;\r\n retView[len] = encodedView[len];\r\n }\r\n return retView;\r\n }\r\n toString() {\r\n let result = \"\";\r\n if (this.isHexOnly)\r\n result = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueHexView);\r\n else {\r\n if (this.isFirstSid) {\r\n let sidValue = this.valueDec;\r\n if (this.valueDec <= 39)\r\n result = \"0.\";\r\n else {\r\n if (this.valueDec <= 79) {\r\n result = \"1.\";\r\n sidValue -= 40;\r\n }\r\n else {\r\n result = \"2.\";\r\n sidValue -= 80;\r\n }\r\n }\r\n result += sidValue.toString();\r\n }\r\n else\r\n result = this.valueDec.toString();\r\n }\r\n return result;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n valueDec: this.valueDec,\r\n isFirstSid: this.isFirstSid,\r\n };\r\n }\r\n}\r\nLocalSidValueBlock.NAME = \"sidBlock\";\n\nclass LocalObjectIdentifierValueBlock extends ValueBlock {\r\n constructor({ value = EMPTY_STRING, ...parameters } = {}) {\r\n super(parameters);\r\n this.value = [];\r\n if (value) {\r\n this.fromString(value);\r\n }\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n let resultOffset = inputOffset;\r\n while (inputLength > 0) {\r\n const sidBlock = new LocalSidValueBlock();\r\n resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength);\r\n if (resultOffset === -1) {\r\n this.blockLength = 0;\r\n this.error = sidBlock.error;\r\n return resultOffset;\r\n }\r\n if (this.value.length === 0)\r\n sidBlock.isFirstSid = true;\r\n this.blockLength += sidBlock.blockLength;\r\n inputLength -= sidBlock.blockLength;\r\n this.value.push(sidBlock);\r\n }\r\n return resultOffset;\r\n }\r\n toBER(sizeOnly) {\r\n const retBuffers = [];\r\n for (let i = 0; i < this.value.length; i++) {\r\n const valueBuf = this.value[i].toBER(sizeOnly);\r\n if (valueBuf.byteLength === 0) {\r\n this.error = this.value[i].error;\r\n return EMPTY_BUFFER;\r\n }\r\n retBuffers.push(valueBuf);\r\n }\r\n return concat(retBuffers);\r\n }\r\n fromString(string) {\r\n this.value = [];\r\n let pos1 = 0;\r\n let pos2 = 0;\r\n let sid = \"\";\r\n let flag = false;\r\n do {\r\n pos2 = string.indexOf(\".\", pos1);\r\n if (pos2 === -1)\r\n sid = string.substring(pos1);\r\n else\r\n sid = string.substring(pos1, pos2);\r\n pos1 = pos2 + 1;\r\n if (flag) {\r\n const sidBlock = this.value[0];\r\n let plus = 0;\r\n switch (sidBlock.valueDec) {\r\n case 0:\r\n break;\r\n case 1:\r\n plus = 40;\r\n break;\r\n case 2:\r\n plus = 80;\r\n break;\r\n default:\r\n this.value = [];\r\n return;\r\n }\r\n const parsedSID = parseInt(sid, 10);\r\n if (isNaN(parsedSID))\r\n return;\r\n sidBlock.valueDec = parsedSID + plus;\r\n flag = false;\r\n }\r\n else {\r\n const sidBlock = new LocalSidValueBlock();\r\n if (sid > Number.MAX_SAFE_INTEGER) {\r\n assertBigInt();\r\n const sidValue = BigInt(sid);\r\n sidBlock.valueBigInt = sidValue;\r\n }\r\n else {\r\n sidBlock.valueDec = parseInt(sid, 10);\r\n if (isNaN(sidBlock.valueDec))\r\n return;\r\n }\r\n if (!this.value.length) {\r\n sidBlock.isFirstSid = true;\r\n flag = true;\r\n }\r\n this.value.push(sidBlock);\r\n }\r\n } while (pos2 !== -1);\r\n }\r\n toString() {\r\n let result = \"\";\r\n let isHexOnly = false;\r\n for (let i = 0; i < this.value.length; i++) {\r\n isHexOnly = this.value[i].isHexOnly;\r\n let sidStr = this.value[i].toString();\r\n if (i !== 0)\r\n result = `${result}.`;\r\n if (isHexOnly) {\r\n sidStr = `{${sidStr}}`;\r\n if (this.value[i].isFirstSid)\r\n result = `2.{${sidStr} - 80}`;\r\n else\r\n result += sidStr;\r\n }\r\n else\r\n result += sidStr;\r\n }\r\n return result;\r\n }\r\n toJSON() {\r\n const object = {\r\n ...super.toJSON(),\r\n value: this.toString(),\r\n sidArray: [],\r\n };\r\n for (let i = 0; i < this.value.length; i++) {\r\n object.sidArray.push(this.value[i].toJSON());\r\n }\r\n return object;\r\n }\r\n}\r\nLocalObjectIdentifierValueBlock.NAME = \"ObjectIdentifierValueBlock\";\n\nvar _a$m;\r\nclass ObjectIdentifier extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalObjectIdentifierValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 6;\r\n }\r\n getValue() {\r\n return this.valueBlock.toString();\r\n }\r\n setValue(value) {\r\n this.valueBlock.fromString(value);\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${this.valueBlock.toString() || \"empty\"}`;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n value: this.getValue(),\r\n };\r\n }\r\n}\r\n_a$m = ObjectIdentifier;\r\n(() => {\r\n typeStore.ObjectIdentifier = _a$m;\r\n})();\r\nObjectIdentifier.NAME = \"OBJECT IDENTIFIER\";\n\nclass LocalRelativeSidValueBlock extends HexBlock(LocalBaseBlock) {\r\n constructor({ valueDec = 0, ...parameters } = {}) {\r\n super(parameters);\r\n this.valueDec = valueDec;\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n if (inputLength === 0)\r\n return inputOffset;\r\n const inputView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n if (!checkBufferParams(this, inputView, inputOffset, inputLength))\r\n return -1;\r\n const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);\r\n this.valueHexView = new Uint8Array(inputLength);\r\n for (let i = 0; i < inputLength; i++) {\r\n this.valueHexView[i] = intBuffer[i] & 0x7F;\r\n this.blockLength++;\r\n if ((intBuffer[i] & 0x80) === 0x00)\r\n break;\r\n }\r\n const tempView = new Uint8Array(this.blockLength);\r\n for (let i = 0; i < this.blockLength; i++)\r\n tempView[i] = this.valueHexView[i];\r\n this.valueHexView = tempView;\r\n if ((intBuffer[this.blockLength - 1] & 0x80) !== 0x00) {\r\n this.error = \"End of input reached before message was fully decoded\";\r\n return -1;\r\n }\r\n if (this.valueHexView[0] === 0x00)\r\n this.warnings.push(\"Needlessly long format of SID encoding\");\r\n if (this.blockLength <= 8)\r\n this.valueDec = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilFromBase(this.valueHexView, 7);\r\n else {\r\n this.isHexOnly = true;\r\n this.warnings.push(\"Too big SID for decoding, hex only\");\r\n }\r\n return (inputOffset + this.blockLength);\r\n }\r\n toBER(sizeOnly) {\r\n if (this.isHexOnly) {\r\n if (sizeOnly)\r\n return (new ArrayBuffer(this.valueHexView.byteLength));\r\n const curView = this.valueHexView;\r\n const retView = new Uint8Array(this.blockLength);\r\n for (let i = 0; i < (this.blockLength - 1); i++)\r\n retView[i] = curView[i] | 0x80;\r\n retView[this.blockLength - 1] = curView[this.blockLength - 1];\r\n return retView.buffer;\r\n }\r\n const encodedBuf = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilToBase(this.valueDec, 7);\r\n if (encodedBuf.byteLength === 0) {\r\n this.error = \"Error during encoding SID value\";\r\n return EMPTY_BUFFER;\r\n }\r\n const retView = new Uint8Array(encodedBuf.byteLength);\r\n if (!sizeOnly) {\r\n const encodedView = new Uint8Array(encodedBuf);\r\n const len = encodedBuf.byteLength - 1;\r\n for (let i = 0; i < len; i++)\r\n retView[i] = encodedView[i] | 0x80;\r\n retView[len] = encodedView[len];\r\n }\r\n return retView.buffer;\r\n }\r\n toString() {\r\n let result = \"\";\r\n if (this.isHexOnly)\r\n result = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToHex(this.valueHexView);\r\n else {\r\n result = this.valueDec.toString();\r\n }\r\n return result;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n valueDec: this.valueDec,\r\n };\r\n }\r\n}\r\nLocalRelativeSidValueBlock.NAME = \"relativeSidBlock\";\n\nclass LocalRelativeObjectIdentifierValueBlock extends ValueBlock {\r\n constructor({ value = EMPTY_STRING, ...parameters } = {}) {\r\n super(parameters);\r\n this.value = [];\r\n if (value) {\r\n this.fromString(value);\r\n }\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n let resultOffset = inputOffset;\r\n while (inputLength > 0) {\r\n const sidBlock = new LocalRelativeSidValueBlock();\r\n resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength);\r\n if (resultOffset === -1) {\r\n this.blockLength = 0;\r\n this.error = sidBlock.error;\r\n return resultOffset;\r\n }\r\n this.blockLength += sidBlock.blockLength;\r\n inputLength -= sidBlock.blockLength;\r\n this.value.push(sidBlock);\r\n }\r\n return resultOffset;\r\n }\r\n toBER(sizeOnly, writer) {\r\n const retBuffers = [];\r\n for (let i = 0; i < this.value.length; i++) {\r\n const valueBuf = this.value[i].toBER(sizeOnly);\r\n if (valueBuf.byteLength === 0) {\r\n this.error = this.value[i].error;\r\n return EMPTY_BUFFER;\r\n }\r\n retBuffers.push(valueBuf);\r\n }\r\n return concat(retBuffers);\r\n }\r\n fromString(string) {\r\n this.value = [];\r\n let pos1 = 0;\r\n let pos2 = 0;\r\n let sid = \"\";\r\n do {\r\n pos2 = string.indexOf(\".\", pos1);\r\n if (pos2 === -1)\r\n sid = string.substring(pos1);\r\n else\r\n sid = string.substring(pos1, pos2);\r\n pos1 = pos2 + 1;\r\n const sidBlock = new LocalRelativeSidValueBlock();\r\n sidBlock.valueDec = parseInt(sid, 10);\r\n if (isNaN(sidBlock.valueDec))\r\n return true;\r\n this.value.push(sidBlock);\r\n } while (pos2 !== -1);\r\n return true;\r\n }\r\n toString() {\r\n let result = \"\";\r\n let isHexOnly = false;\r\n for (let i = 0; i < this.value.length; i++) {\r\n isHexOnly = this.value[i].isHexOnly;\r\n let sidStr = this.value[i].toString();\r\n if (i !== 0)\r\n result = `${result}.`;\r\n if (isHexOnly) {\r\n sidStr = `{${sidStr}}`;\r\n result += sidStr;\r\n }\r\n else\r\n result += sidStr;\r\n }\r\n return result;\r\n }\r\n toJSON() {\r\n const object = {\r\n ...super.toJSON(),\r\n value: this.toString(),\r\n sidArray: [],\r\n };\r\n for (let i = 0; i < this.value.length; i++)\r\n object.sidArray.push(this.value[i].toJSON());\r\n return object;\r\n }\r\n}\r\nLocalRelativeObjectIdentifierValueBlock.NAME = \"RelativeObjectIdentifierValueBlock\";\n\nvar _a$l;\r\nclass RelativeObjectIdentifier extends BaseBlock {\r\n constructor(parameters = {}) {\r\n super(parameters, LocalRelativeObjectIdentifierValueBlock);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 13;\r\n }\r\n getValue() {\r\n return this.valueBlock.toString();\r\n }\r\n setValue(value) {\r\n this.valueBlock.fromString(value);\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${this.valueBlock.toString() || \"empty\"}`;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n value: this.getValue(),\r\n };\r\n }\r\n}\r\n_a$l = RelativeObjectIdentifier;\r\n(() => {\r\n typeStore.RelativeObjectIdentifier = _a$l;\r\n})();\r\nRelativeObjectIdentifier.NAME = \"RelativeObjectIdentifier\";\n\nvar _a$k;\r\nclass Sequence extends Constructed {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 16;\r\n }\r\n}\r\n_a$k = Sequence;\r\n(() => {\r\n typeStore.Sequence = _a$k;\r\n})();\r\nSequence.NAME = \"SEQUENCE\";\n\nvar _a$j;\r\nclass Set extends Constructed {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 17;\r\n }\r\n}\r\n_a$j = Set;\r\n(() => {\r\n typeStore.Set = _a$j;\r\n})();\r\nSet.NAME = \"SET\";\n\nclass LocalStringValueBlock extends HexBlock(ValueBlock) {\r\n constructor({ ...parameters } = {}) {\r\n super(parameters);\r\n this.isHexOnly = true;\r\n this.value = EMPTY_STRING;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n value: this.value,\r\n };\r\n }\r\n}\r\nLocalStringValueBlock.NAME = \"StringValueBlock\";\n\nclass LocalSimpleStringValueBlock extends LocalStringValueBlock {\r\n}\r\nLocalSimpleStringValueBlock.NAME = \"SimpleStringValueBlock\";\n\nclass LocalSimpleStringBlock extends BaseStringBlock {\r\n constructor({ ...parameters } = {}) {\r\n super(parameters, LocalSimpleStringValueBlock);\r\n }\r\n fromBuffer(inputBuffer) {\r\n this.valueBlock.value = String.fromCharCode.apply(null, pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer));\r\n }\r\n fromString(inputString) {\r\n const strLen = inputString.length;\r\n const view = this.valueBlock.valueHexView = new Uint8Array(strLen);\r\n for (let i = 0; i < strLen; i++)\r\n view[i] = inputString.charCodeAt(i);\r\n this.valueBlock.value = inputString;\r\n }\r\n}\r\nLocalSimpleStringBlock.NAME = \"SIMPLE STRING\";\n\nclass LocalUtf8StringValueBlock extends LocalSimpleStringBlock {\r\n fromBuffer(inputBuffer) {\r\n this.valueBlock.valueHexView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n try {\r\n this.valueBlock.value = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToUtf8String(inputBuffer);\r\n }\r\n catch (ex) {\r\n this.warnings.push(`Error during \"decodeURIComponent\": ${ex}, using raw string`);\r\n this.valueBlock.value = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToBinary(inputBuffer);\r\n }\r\n }\r\n fromString(inputString) {\r\n this.valueBlock.valueHexView = new Uint8Array(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.FromUtf8String(inputString));\r\n this.valueBlock.value = inputString;\r\n }\r\n}\r\nLocalUtf8StringValueBlock.NAME = \"Utf8StringValueBlock\";\n\nvar _a$i;\r\nclass Utf8String extends LocalUtf8StringValueBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 12;\r\n }\r\n}\r\n_a$i = Utf8String;\r\n(() => {\r\n typeStore.Utf8String = _a$i;\r\n})();\r\nUtf8String.NAME = \"UTF8String\";\n\nclass LocalBmpStringValueBlock extends LocalSimpleStringBlock {\r\n fromBuffer(inputBuffer) {\r\n this.valueBlock.value = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.ToUtf16String(inputBuffer);\r\n this.valueBlock.valueHexView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer);\r\n }\r\n fromString(inputString) {\r\n this.valueBlock.value = inputString;\r\n this.valueBlock.valueHexView = new Uint8Array(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.Convert.FromUtf16String(inputString));\r\n }\r\n}\r\nLocalBmpStringValueBlock.NAME = \"BmpStringValueBlock\";\n\nvar _a$h;\r\nclass BmpString extends LocalBmpStringValueBlock {\r\n constructor({ ...parameters } = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 30;\r\n }\r\n}\r\n_a$h = BmpString;\r\n(() => {\r\n typeStore.BmpString = _a$h;\r\n})();\r\nBmpString.NAME = \"BMPString\";\n\nclass LocalUniversalStringValueBlock extends LocalSimpleStringBlock {\r\n fromBuffer(inputBuffer) {\r\n const copyBuffer = ArrayBuffer.isView(inputBuffer) ? inputBuffer.slice().buffer : inputBuffer.slice(0);\r\n const valueView = new Uint8Array(copyBuffer);\r\n for (let i = 0; i < valueView.length; i += 4) {\r\n valueView[i] = valueView[i + 3];\r\n valueView[i + 1] = valueView[i + 2];\r\n valueView[i + 2] = 0x00;\r\n valueView[i + 3] = 0x00;\r\n }\r\n this.valueBlock.value = String.fromCharCode.apply(null, new Uint32Array(copyBuffer));\r\n }\r\n fromString(inputString) {\r\n const strLength = inputString.length;\r\n const valueHexView = this.valueBlock.valueHexView = new Uint8Array(strLength * 4);\r\n for (let i = 0; i < strLength; i++) {\r\n const codeBuf = pvutils__WEBPACK_IMPORTED_MODULE_1__.utilToBase(inputString.charCodeAt(i), 8);\r\n const codeView = new Uint8Array(codeBuf);\r\n if (codeView.length > 4)\r\n continue;\r\n const dif = 4 - codeView.length;\r\n for (let j = (codeView.length - 1); j >= 0; j--)\r\n valueHexView[i * 4 + j + dif] = codeView[j];\r\n }\r\n this.valueBlock.value = inputString;\r\n }\r\n}\r\nLocalUniversalStringValueBlock.NAME = \"UniversalStringValueBlock\";\n\nvar _a$g;\r\nclass UniversalString extends LocalUniversalStringValueBlock {\r\n constructor({ ...parameters } = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 28;\r\n }\r\n}\r\n_a$g = UniversalString;\r\n(() => {\r\n typeStore.UniversalString = _a$g;\r\n})();\r\nUniversalString.NAME = \"UniversalString\";\n\nvar _a$f;\r\nclass NumericString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 18;\r\n }\r\n}\r\n_a$f = NumericString;\r\n(() => {\r\n typeStore.NumericString = _a$f;\r\n})();\r\nNumericString.NAME = \"NumericString\";\n\nvar _a$e;\r\nclass PrintableString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 19;\r\n }\r\n}\r\n_a$e = PrintableString;\r\n(() => {\r\n typeStore.PrintableString = _a$e;\r\n})();\r\nPrintableString.NAME = \"PrintableString\";\n\nvar _a$d;\r\nclass TeletexString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 20;\r\n }\r\n}\r\n_a$d = TeletexString;\r\n(() => {\r\n typeStore.TeletexString = _a$d;\r\n})();\r\nTeletexString.NAME = \"TeletexString\";\n\nvar _a$c;\r\nclass VideotexString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 21;\r\n }\r\n}\r\n_a$c = VideotexString;\r\n(() => {\r\n typeStore.VideotexString = _a$c;\r\n})();\r\nVideotexString.NAME = \"VideotexString\";\n\nvar _a$b;\r\nclass IA5String extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 22;\r\n }\r\n}\r\n_a$b = IA5String;\r\n(() => {\r\n typeStore.IA5String = _a$b;\r\n})();\r\nIA5String.NAME = \"IA5String\";\n\nvar _a$a;\r\nclass GraphicString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 25;\r\n }\r\n}\r\n_a$a = GraphicString;\r\n(() => {\r\n typeStore.GraphicString = _a$a;\r\n})();\r\nGraphicString.NAME = \"GraphicString\";\n\nvar _a$9;\r\nclass VisibleString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 26;\r\n }\r\n}\r\n_a$9 = VisibleString;\r\n(() => {\r\n typeStore.VisibleString = _a$9;\r\n})();\r\nVisibleString.NAME = \"VisibleString\";\n\nvar _a$8;\r\nclass GeneralString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 27;\r\n }\r\n}\r\n_a$8 = GeneralString;\r\n(() => {\r\n typeStore.GeneralString = _a$8;\r\n})();\r\nGeneralString.NAME = \"GeneralString\";\n\nvar _a$7;\r\nclass CharacterString extends LocalSimpleStringBlock {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 29;\r\n }\r\n}\r\n_a$7 = CharacterString;\r\n(() => {\r\n typeStore.CharacterString = _a$7;\r\n})();\r\nCharacterString.NAME = \"CharacterString\";\n\nvar _a$6;\r\nclass UTCTime extends VisibleString {\r\n constructor({ value, valueDate, ...parameters } = {}) {\r\n super(parameters);\r\n this.year = 0;\r\n this.month = 0;\r\n this.day = 0;\r\n this.hour = 0;\r\n this.minute = 0;\r\n this.second = 0;\r\n if (value) {\r\n this.fromString(value);\r\n this.valueBlock.valueHexView = new Uint8Array(value.length);\r\n for (let i = 0; i < value.length; i++)\r\n this.valueBlock.valueHexView[i] = value.charCodeAt(i);\r\n }\r\n if (valueDate) {\r\n this.fromDate(valueDate);\r\n this.valueBlock.valueHexView = new Uint8Array(this.toBuffer());\r\n }\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 23;\r\n }\r\n fromBuffer(inputBuffer) {\r\n this.fromString(String.fromCharCode.apply(null, pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer)));\r\n }\r\n toBuffer() {\r\n const str = this.toString();\r\n const buffer = new ArrayBuffer(str.length);\r\n const view = new Uint8Array(buffer);\r\n for (let i = 0; i < str.length; i++)\r\n view[i] = str.charCodeAt(i);\r\n return buffer;\r\n }\r\n fromDate(inputDate) {\r\n this.year = inputDate.getUTCFullYear();\r\n this.month = inputDate.getUTCMonth() + 1;\r\n this.day = inputDate.getUTCDate();\r\n this.hour = inputDate.getUTCHours();\r\n this.minute = inputDate.getUTCMinutes();\r\n this.second = inputDate.getUTCSeconds();\r\n }\r\n toDate() {\r\n return (new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second)));\r\n }\r\n fromString(inputString) {\r\n const parser = /(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})Z/ig;\r\n const parserArray = parser.exec(inputString);\r\n if (parserArray === null) {\r\n this.error = \"Wrong input string for conversion\";\r\n return;\r\n }\r\n const year = parseInt(parserArray[1], 10);\r\n if (year >= 50)\r\n this.year = 1900 + year;\r\n else\r\n this.year = 2000 + year;\r\n this.month = parseInt(parserArray[2], 10);\r\n this.day = parseInt(parserArray[3], 10);\r\n this.hour = parseInt(parserArray[4], 10);\r\n this.minute = parseInt(parserArray[5], 10);\r\n this.second = parseInt(parserArray[6], 10);\r\n }\r\n toString(encoding = \"iso\") {\r\n if (encoding === \"iso\") {\r\n const outputArray = new Array(7);\r\n outputArray[0] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(((this.year < 2000) ? (this.year - 1900) : (this.year - 2000)), 2);\r\n outputArray[1] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.month, 2);\r\n outputArray[2] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.day, 2);\r\n outputArray[3] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.hour, 2);\r\n outputArray[4] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.minute, 2);\r\n outputArray[5] = pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.second, 2);\r\n outputArray[6] = \"Z\";\r\n return outputArray.join(\"\");\r\n }\r\n return super.toString(encoding);\r\n }\r\n onAsciiEncoding() {\r\n return `${this.constructor.NAME} : ${this.toDate().toISOString()}`;\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n year: this.year,\r\n month: this.month,\r\n day: this.day,\r\n hour: this.hour,\r\n minute: this.minute,\r\n second: this.second,\r\n };\r\n }\r\n}\r\n_a$6 = UTCTime;\r\n(() => {\r\n typeStore.UTCTime = _a$6;\r\n})();\r\nUTCTime.NAME = \"UTCTime\";\n\nvar _a$5;\r\nclass GeneralizedTime extends UTCTime {\r\n constructor(parameters = {}) {\r\n var _b;\r\n super(parameters);\r\n (_b = this.millisecond) !== null && _b !== void 0 ? _b : (this.millisecond = 0);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 24;\r\n }\r\n fromDate(inputDate) {\r\n super.fromDate(inputDate);\r\n this.millisecond = inputDate.getUTCMilliseconds();\r\n }\r\n toDate() {\r\n return (new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)));\r\n }\r\n fromString(inputString) {\r\n let isUTC = false;\r\n let timeString = \"\";\r\n let dateTimeString = \"\";\r\n let fractionPart = 0;\r\n let parser;\r\n let hourDifference = 0;\r\n let minuteDifference = 0;\r\n if (inputString[inputString.length - 1] === \"Z\") {\r\n timeString = inputString.substring(0, inputString.length - 1);\r\n isUTC = true;\r\n }\r\n else {\r\n const number = new Number(inputString[inputString.length - 1]);\r\n if (isNaN(number.valueOf()))\r\n throw new Error(\"Wrong input string for conversion\");\r\n timeString = inputString;\r\n }\r\n if (isUTC) {\r\n if (timeString.indexOf(\"+\") !== -1)\r\n throw new Error(\"Wrong input string for conversion\");\r\n if (timeString.indexOf(\"-\") !== -1)\r\n throw new Error(\"Wrong input string for conversion\");\r\n }\r\n else {\r\n let multiplier = 1;\r\n let differencePosition = timeString.indexOf(\"+\");\r\n let differenceString = \"\";\r\n if (differencePosition === -1) {\r\n differencePosition = timeString.indexOf(\"-\");\r\n multiplier = -1;\r\n }\r\n if (differencePosition !== -1) {\r\n differenceString = timeString.substring(differencePosition + 1);\r\n timeString = timeString.substring(0, differencePosition);\r\n if ((differenceString.length !== 2) && (differenceString.length !== 4))\r\n throw new Error(\"Wrong input string for conversion\");\r\n let number = parseInt(differenceString.substring(0, 2), 10);\r\n if (isNaN(number.valueOf()))\r\n throw new Error(\"Wrong input string for conversion\");\r\n hourDifference = multiplier * number;\r\n if (differenceString.length === 4) {\r\n number = parseInt(differenceString.substring(2, 4), 10);\r\n if (isNaN(number.valueOf()))\r\n throw new Error(\"Wrong input string for conversion\");\r\n minuteDifference = multiplier * number;\r\n }\r\n }\r\n }\r\n let fractionPointPosition = timeString.indexOf(\".\");\r\n if (fractionPointPosition === -1)\r\n fractionPointPosition = timeString.indexOf(\",\");\r\n if (fractionPointPosition !== -1) {\r\n const fractionPartCheck = new Number(`0${timeString.substring(fractionPointPosition)}`);\r\n if (isNaN(fractionPartCheck.valueOf()))\r\n throw new Error(\"Wrong input string for conversion\");\r\n fractionPart = fractionPartCheck.valueOf();\r\n dateTimeString = timeString.substring(0, fractionPointPosition);\r\n }\r\n else\r\n dateTimeString = timeString;\r\n switch (true) {\r\n case (dateTimeString.length === 8):\r\n parser = /(\\d{4})(\\d{2})(\\d{2})/ig;\r\n if (fractionPointPosition !== -1)\r\n throw new Error(\"Wrong input string for conversion\");\r\n break;\r\n case (dateTimeString.length === 10):\r\n parser = /(\\d{4})(\\d{2})(\\d{2})(\\d{2})/ig;\r\n if (fractionPointPosition !== -1) {\r\n let fractionResult = 60 * fractionPart;\r\n this.minute = Math.floor(fractionResult);\r\n fractionResult = 60 * (fractionResult - this.minute);\r\n this.second = Math.floor(fractionResult);\r\n fractionResult = 1000 * (fractionResult - this.second);\r\n this.millisecond = Math.floor(fractionResult);\r\n }\r\n break;\r\n case (dateTimeString.length === 12):\r\n parser = /(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/ig;\r\n if (fractionPointPosition !== -1) {\r\n let fractionResult = 60 * fractionPart;\r\n this.second = Math.floor(fractionResult);\r\n fractionResult = 1000 * (fractionResult - this.second);\r\n this.millisecond = Math.floor(fractionResult);\r\n }\r\n break;\r\n case (dateTimeString.length === 14):\r\n parser = /(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/ig;\r\n if (fractionPointPosition !== -1) {\r\n const fractionResult = 1000 * fractionPart;\r\n this.millisecond = Math.floor(fractionResult);\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Wrong input string for conversion\");\r\n }\r\n const parserArray = parser.exec(dateTimeString);\r\n if (parserArray === null)\r\n throw new Error(\"Wrong input string for conversion\");\r\n for (let j = 1; j < parserArray.length; j++) {\r\n switch (j) {\r\n case 1:\r\n this.year = parseInt(parserArray[j], 10);\r\n break;\r\n case 2:\r\n this.month = parseInt(parserArray[j], 10);\r\n break;\r\n case 3:\r\n this.day = parseInt(parserArray[j], 10);\r\n break;\r\n case 4:\r\n this.hour = parseInt(parserArray[j], 10) + hourDifference;\r\n break;\r\n case 5:\r\n this.minute = parseInt(parserArray[j], 10) + minuteDifference;\r\n break;\r\n case 6:\r\n this.second = parseInt(parserArray[j], 10);\r\n break;\r\n default:\r\n throw new Error(\"Wrong input string for conversion\");\r\n }\r\n }\r\n if (isUTC === false) {\r\n const tempDate = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);\r\n this.year = tempDate.getUTCFullYear();\r\n this.month = tempDate.getUTCMonth();\r\n this.day = tempDate.getUTCDay();\r\n this.hour = tempDate.getUTCHours();\r\n this.minute = tempDate.getUTCMinutes();\r\n this.second = tempDate.getUTCSeconds();\r\n this.millisecond = tempDate.getUTCMilliseconds();\r\n }\r\n }\r\n toString(encoding = \"iso\") {\r\n if (encoding === \"iso\") {\r\n const outputArray = [];\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.year, 4));\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.month, 2));\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.day, 2));\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.hour, 2));\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.minute, 2));\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.second, 2));\r\n if (this.millisecond !== 0) {\r\n outputArray.push(\".\");\r\n outputArray.push(pvutils__WEBPACK_IMPORTED_MODULE_1__.padNumber(this.millisecond, 3));\r\n }\r\n outputArray.push(\"Z\");\r\n return outputArray.join(\"\");\r\n }\r\n return super.toString(encoding);\r\n }\r\n toJSON() {\r\n return {\r\n ...super.toJSON(),\r\n millisecond: this.millisecond,\r\n };\r\n }\r\n}\r\n_a$5 = GeneralizedTime;\r\n(() => {\r\n typeStore.GeneralizedTime = _a$5;\r\n})();\r\nGeneralizedTime.NAME = \"GeneralizedTime\";\n\nvar _a$4;\r\nclass DATE extends Utf8String {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 31;\r\n }\r\n}\r\n_a$4 = DATE;\r\n(() => {\r\n typeStore.DATE = _a$4;\r\n})();\r\nDATE.NAME = \"DATE\";\n\nvar _a$3;\r\nclass TimeOfDay extends Utf8String {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 32;\r\n }\r\n}\r\n_a$3 = TimeOfDay;\r\n(() => {\r\n typeStore.TimeOfDay = _a$3;\r\n})();\r\nTimeOfDay.NAME = \"TimeOfDay\";\n\nvar _a$2;\r\nclass DateTime extends Utf8String {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 33;\r\n }\r\n}\r\n_a$2 = DateTime;\r\n(() => {\r\n typeStore.DateTime = _a$2;\r\n})();\r\nDateTime.NAME = \"DateTime\";\n\nvar _a$1;\r\nclass Duration extends Utf8String {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 34;\r\n }\r\n}\r\n_a$1 = Duration;\r\n(() => {\r\n typeStore.Duration = _a$1;\r\n})();\r\nDuration.NAME = \"Duration\";\n\nvar _a;\r\nclass TIME extends Utf8String {\r\n constructor(parameters = {}) {\r\n super(parameters);\r\n this.idBlock.tagClass = 1;\r\n this.idBlock.tagNumber = 14;\r\n }\r\n}\r\n_a = TIME;\r\n(() => {\r\n typeStore.TIME = _a;\r\n})();\r\nTIME.NAME = \"TIME\";\n\nclass Any {\r\n constructor({ name = EMPTY_STRING, optional = false, } = {}) {\r\n this.name = name;\r\n this.optional = optional;\r\n }\r\n}\n\nclass Choice extends Any {\r\n constructor({ value = [], ...parameters } = {}) {\r\n super(parameters);\r\n this.value = value;\r\n }\r\n}\n\nclass Repeated extends Any {\r\n constructor({ value = new Any(), local = false, ...parameters } = {}) {\r\n super(parameters);\r\n this.value = value;\r\n this.local = local;\r\n }\r\n}\n\nclass RawData {\r\n constructor({ data = EMPTY_VIEW } = {}) {\r\n this.dataView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(data);\r\n }\r\n get data() {\r\n return this.dataView.slice().buffer;\r\n }\r\n set data(value) {\r\n this.dataView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(value);\r\n }\r\n fromBER(inputBuffer, inputOffset, inputLength) {\r\n const endLength = inputOffset + inputLength;\r\n this.dataView = pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer).subarray(inputOffset, endLength);\r\n return endLength;\r\n }\r\n toBER(sizeOnly) {\r\n return this.dataView.slice().buffer;\r\n }\r\n}\n\nfunction compareSchema(root, inputData, inputSchema) {\r\n if (inputSchema instanceof Choice) {\r\n for (let j = 0; j < inputSchema.value.length; j++) {\r\n const result = compareSchema(root, inputData, inputSchema.value[j]);\r\n if (result.verified) {\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n }\r\n }\r\n {\r\n const _result = {\r\n verified: false,\r\n result: {\r\n error: \"Wrong values for Choice type\"\r\n },\r\n };\r\n if (inputSchema.hasOwnProperty(NAME))\r\n _result.name = inputSchema.name;\r\n return _result;\r\n }\r\n }\r\n if (inputSchema instanceof Any) {\r\n if (inputSchema.hasOwnProperty(NAME))\r\n root[inputSchema.name] = inputData;\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n }\r\n if ((root instanceof Object) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong root object\" }\r\n };\r\n }\r\n if ((inputData instanceof Object) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 data\" }\r\n };\r\n }\r\n if ((inputSchema instanceof Object) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if ((ID_BLOCK in inputSchema) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if ((FROM_BER in inputSchema.idBlock) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if ((TO_BER in inputSchema.idBlock) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n const encodedId = inputSchema.idBlock.toBER(false);\r\n if (encodedId.byteLength === 0) {\r\n return {\r\n verified: false,\r\n result: { error: \"Error encoding idBlock for ASN.1 schema\" }\r\n };\r\n }\r\n const decodedOffset = inputSchema.idBlock.fromBER(encodedId, 0, encodedId.byteLength);\r\n if (decodedOffset === -1) {\r\n return {\r\n verified: false,\r\n result: { error: \"Error decoding idBlock for ASN.1 schema\" }\r\n };\r\n }\r\n if (inputSchema.idBlock.hasOwnProperty(TAG_CLASS) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if (inputSchema.idBlock.tagClass !== inputData.idBlock.tagClass) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n if (inputSchema.idBlock.hasOwnProperty(TAG_NUMBER) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if (inputSchema.idBlock.tagNumber !== inputData.idBlock.tagNumber) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n if (inputSchema.idBlock.hasOwnProperty(IS_CONSTRUCTED) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if (inputSchema.idBlock.isConstructed !== inputData.idBlock.isConstructed) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n if (!(IS_HEX_ONLY in inputSchema.idBlock)) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n if (inputSchema.idBlock.isHexOnly !== inputData.idBlock.isHexOnly) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n if (inputSchema.idBlock.isHexOnly) {\r\n if ((VALUE_HEX_VIEW in inputSchema.idBlock) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema\" }\r\n };\r\n }\r\n const schemaView = inputSchema.idBlock.valueHexView;\r\n const asn1View = inputData.idBlock.valueHexView;\r\n if (schemaView.length !== asn1View.length) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n for (let i = 0; i < schemaView.length; i++) {\r\n if (schemaView[i] !== asn1View[1]) {\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n }\r\n }\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name)\r\n root[inputSchema.name] = inputData;\r\n }\r\n if (inputSchema instanceof typeStore.Constructed) {\r\n let admission = 0;\r\n let result = {\r\n verified: false,\r\n result: {\r\n error: \"Unknown error\",\r\n }\r\n };\r\n let maxLength = inputSchema.valueBlock.value.length;\r\n if (maxLength > 0) {\r\n if (inputSchema.valueBlock.value[0] instanceof Repeated) {\r\n maxLength = inputData.valueBlock.value.length;\r\n }\r\n }\r\n if (maxLength === 0) {\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n }\r\n if ((inputData.valueBlock.value.length === 0) &&\r\n (inputSchema.valueBlock.value.length !== 0)) {\r\n let _optional = true;\r\n for (let i = 0; i < inputSchema.valueBlock.value.length; i++)\r\n _optional = _optional && (inputSchema.valueBlock.value[i].optional || false);\r\n if (_optional) {\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n }\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name)\r\n delete root[inputSchema.name];\r\n }\r\n root.error = \"Inconsistent object length\";\r\n return {\r\n verified: false,\r\n result: root\r\n };\r\n }\r\n for (let i = 0; i < maxLength; i++) {\r\n if ((i - admission) >= inputData.valueBlock.value.length) {\r\n if (inputSchema.valueBlock.value[i].optional === false) {\r\n const _result = {\r\n verified: false,\r\n result: root\r\n };\r\n root.error = \"Inconsistent length between ASN.1 data and schema\";\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name) {\r\n delete root[inputSchema.name];\r\n _result.name = inputSchema.name;\r\n }\r\n }\r\n return _result;\r\n }\r\n }\r\n else {\r\n if (inputSchema.valueBlock.value[0] instanceof Repeated) {\r\n result = compareSchema(root, inputData.valueBlock.value[i], inputSchema.valueBlock.value[0].value);\r\n if (result.verified === false) {\r\n if (inputSchema.valueBlock.value[0].optional)\r\n admission++;\r\n else {\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name)\r\n delete root[inputSchema.name];\r\n }\r\n return result;\r\n }\r\n }\r\n if ((NAME in inputSchema.valueBlock.value[0]) && (inputSchema.valueBlock.value[0].name.length > 0)) {\r\n let arrayRoot = {};\r\n if ((LOCAL in inputSchema.valueBlock.value[0]) && (inputSchema.valueBlock.value[0].local))\r\n arrayRoot = inputData;\r\n else\r\n arrayRoot = root;\r\n if (typeof arrayRoot[inputSchema.valueBlock.value[0].name] === \"undefined\")\r\n arrayRoot[inputSchema.valueBlock.value[0].name] = [];\r\n arrayRoot[inputSchema.valueBlock.value[0].name].push(inputData.valueBlock.value[i]);\r\n }\r\n }\r\n else {\r\n result = compareSchema(root, inputData.valueBlock.value[i - admission], inputSchema.valueBlock.value[i]);\r\n if (result.verified === false) {\r\n if (inputSchema.valueBlock.value[i].optional)\r\n admission++;\r\n else {\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name)\r\n delete root[inputSchema.name];\r\n }\r\n return result;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n if (result.verified === false) {\r\n const _result = {\r\n verified: false,\r\n result: root\r\n };\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name) {\r\n delete root[inputSchema.name];\r\n _result.name = inputSchema.name;\r\n }\r\n }\r\n return _result;\r\n }\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n }\r\n if (inputSchema.primitiveSchema &&\r\n (VALUE_HEX_VIEW in inputData.valueBlock)) {\r\n const asn1 = localFromBER(inputData.valueBlock.valueHexView);\r\n if (asn1.offset === -1) {\r\n const _result = {\r\n verified: false,\r\n result: asn1.result\r\n };\r\n if (inputSchema.name) {\r\n inputSchema.name = inputSchema.name.replace(/^\\s+|\\s+$/g, EMPTY_STRING);\r\n if (inputSchema.name) {\r\n delete root[inputSchema.name];\r\n _result.name = inputSchema.name;\r\n }\r\n }\r\n return _result;\r\n }\r\n return compareSchema(root, asn1.result, inputSchema.primitiveSchema);\r\n }\r\n return {\r\n verified: true,\r\n result: root\r\n };\r\n}\r\nfunction verifySchema(inputBuffer, inputSchema) {\r\n if ((inputSchema instanceof Object) === false) {\r\n return {\r\n verified: false,\r\n result: { error: \"Wrong ASN.1 schema type\" }\r\n };\r\n }\r\n const asn1 = localFromBER(pvtsutils__WEBPACK_IMPORTED_MODULE_0__.BufferSourceConverter.toUint8Array(inputBuffer));\r\n if (asn1.offset === -1) {\r\n return {\r\n verified: false,\r\n result: asn1.result\r\n };\r\n }\r\n return compareSchema(asn1.result, asn1.result, inputSchema);\r\n}\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/asn1js/build/index.es.js?"); /***/ }), @@ -541,7 +431,7 @@ eval("\n/**\n * This is the common logic for both the Node.js and web browser\n /***/ ((module) => { "use strict"; -eval("\n\n/**\n * Custom implementation of a double ended queue.\n */\nfunction Denque(array, options) {\n var options = options || {};\n\n this._head = 0;\n this._tail = 0;\n this._capacity = options.capacity;\n this._capacityMask = 0x3;\n this._list = new Array(4);\n if (Array.isArray(array)) {\n this._fromArray(array);\n }\n}\n\n/**\n * -------------\n * PUBLIC API\n * -------------\n */\n\n/**\n * Returns the item at the specified index from the list.\n * 0 is the first element, 1 is the second, and so on...\n * Elements at negative values are that many from the end: -1 is one before the end\n * (the last element), -2 is two before the end (one before last), etc.\n * @param index\n * @returns {*}\n */\nDenque.prototype.peekAt = function peekAt(index) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n var len = this.size();\n if (i >= len || i < -len) return undefined;\n if (i < 0) i += len;\n i = (this._head + i) & this._capacityMask;\n return this._list[i];\n};\n\n/**\n * Alias for peekAt()\n * @param i\n * @returns {*}\n */\nDenque.prototype.get = function get(i) {\n return this.peekAt(i);\n};\n\n/**\n * Returns the first item in the list without removing it.\n * @returns {*}\n */\nDenque.prototype.peek = function peek() {\n if (this._head === this._tail) return undefined;\n return this._list[this._head];\n};\n\n/**\n * Alias for peek()\n * @returns {*}\n */\nDenque.prototype.peekFront = function peekFront() {\n return this.peek();\n};\n\n/**\n * Returns the item that is at the back of the queue without removing it.\n * Uses peekAt(-1)\n */\nDenque.prototype.peekBack = function peekBack() {\n return this.peekAt(-1);\n};\n\n/**\n * Returns the current length of the queue\n * @return {Number}\n */\nObject.defineProperty(Denque.prototype, 'length', {\n get: function length() {\n return this.size();\n }\n});\n\n/**\n * Return the number of items on the list, or 0 if empty.\n * @returns {number}\n */\nDenque.prototype.size = function size() {\n if (this._head === this._tail) return 0;\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Add an item at the beginning of the list.\n * @param item\n */\nDenque.prototype.unshift = function unshift(item) {\n if (item === undefined) return this.size();\n var len = this._list.length;\n this._head = (this._head - 1 + len) & this._capacityMask;\n this._list[this._head] = item;\n if (this._tail === this._head) this._growArray();\n if (this._capacity && this.size() > this._capacity) this.pop();\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Remove and return the first item on the list,\n * Returns undefined if the list is empty.\n * @returns {*}\n */\nDenque.prototype.shift = function shift() {\n var head = this._head;\n if (head === this._tail) return undefined;\n var item = this._list[head];\n this._list[head] = undefined;\n this._head = (head + 1) & this._capacityMask;\n if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray();\n return item;\n};\n\n/**\n * Add an item to the bottom of the list.\n * @param item\n */\nDenque.prototype.push = function push(item) {\n if (item === undefined) return this.size();\n var tail = this._tail;\n this._list[tail] = item;\n this._tail = (tail + 1) & this._capacityMask;\n if (this._tail === this._head) {\n this._growArray();\n }\n if (this._capacity && this.size() > this._capacity) {\n this.shift();\n }\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Remove and return the last item on the list.\n * Returns undefined if the list is empty.\n * @returns {*}\n */\nDenque.prototype.pop = function pop() {\n var tail = this._tail;\n if (tail === this._head) return undefined;\n var len = this._list.length;\n this._tail = (tail - 1 + len) & this._capacityMask;\n var item = this._list[this._tail];\n this._list[this._tail] = undefined;\n if (this._head < 2 && tail > 10000 && tail <= len >>> 2) this._shrinkArray();\n return item;\n};\n\n/**\n * Remove and return the item at the specified index from the list.\n * Returns undefined if the list is empty.\n * @param index\n * @returns {*}\n */\nDenque.prototype.removeOne = function removeOne(index) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n if (this._head === this._tail) return void 0;\n var size = this.size();\n var len = this._list.length;\n if (i >= size || i < -size) return void 0;\n if (i < 0) i += size;\n i = (this._head + i) & this._capacityMask;\n var item = this._list[i];\n var k;\n if (index < size / 2) {\n for (k = index; k > 0; k--) {\n this._list[i] = this._list[i = (i - 1 + len) & this._capacityMask];\n }\n this._list[i] = void 0;\n this._head = (this._head + 1 + len) & this._capacityMask;\n } else {\n for (k = size - 1 - index; k > 0; k--) {\n this._list[i] = this._list[i = ( i + 1 + len) & this._capacityMask];\n }\n this._list[i] = void 0;\n this._tail = (this._tail - 1 + len) & this._capacityMask;\n }\n return item;\n};\n\n/**\n * Remove number of items from the specified index from the list.\n * Returns array of removed items.\n * Returns undefined if the list is empty.\n * @param index\n * @param count\n * @returns {array}\n */\nDenque.prototype.remove = function remove(index, count) {\n var i = index;\n var removed;\n var del_count = count;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n if (this._head === this._tail) return void 0;\n var size = this.size();\n var len = this._list.length;\n if (i >= size || i < -size || count < 1) return void 0;\n if (i < 0) i += size;\n if (count === 1 || !count) {\n removed = new Array(1);\n removed[0] = this.removeOne(i);\n return removed;\n }\n if (i === 0 && i + count >= size) {\n removed = this.toArray();\n this.clear();\n return removed;\n }\n if (i + count > size) count = size - i;\n var k;\n removed = new Array(count);\n for (k = 0; k < count; k++) {\n removed[k] = this._list[(this._head + i + k) & this._capacityMask];\n }\n i = (this._head + i) & this._capacityMask;\n if (index + count === size) {\n this._tail = (this._tail - count + len) & this._capacityMask;\n for (k = count; k > 0; k--) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n }\n return removed;\n }\n if (index === 0) {\n this._head = (this._head + count + len) & this._capacityMask;\n for (k = count - 1; k > 0; k--) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n }\n return removed;\n }\n if (i < size / 2) {\n this._head = (this._head + index + count + len) & this._capacityMask;\n for (k = index; k > 0; k--) {\n this.unshift(this._list[i = (i - 1 + len) & this._capacityMask]);\n }\n i = (this._head - 1 + len) & this._capacityMask;\n while (del_count > 0) {\n this._list[i = (i - 1 + len) & this._capacityMask] = void 0;\n del_count--;\n }\n if (index < 0) this._tail = i;\n } else {\n this._tail = i;\n i = (i + count + len) & this._capacityMask;\n for (k = size - (count + index); k > 0; k--) {\n this.push(this._list[i++]);\n }\n i = this._tail;\n while (del_count > 0) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n del_count--;\n }\n }\n if (this._head < 2 && this._tail > 10000 && this._tail <= len >>> 2) this._shrinkArray();\n return removed;\n};\n\n/**\n * Native splice implementation.\n * Remove number of items from the specified index from the list and/or add new elements.\n * Returns array of removed items or empty array if count == 0.\n * Returns undefined if the list is empty.\n *\n * @param index\n * @param count\n * @param {...*} [elements]\n * @returns {array}\n */\nDenque.prototype.splice = function splice(index, count) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n var size = this.size();\n if (i < 0) i += size;\n if (i > size) return void 0;\n if (arguments.length > 2) {\n var k;\n var temp;\n var removed;\n var arg_len = arguments.length;\n var len = this._list.length;\n var arguments_index = 2;\n if (!size || i < size / 2) {\n temp = new Array(i);\n for (k = 0; k < i; k++) {\n temp[k] = this._list[(this._head + k) & this._capacityMask];\n }\n if (count === 0) {\n removed = [];\n if (i > 0) {\n this._head = (this._head + i + len) & this._capacityMask;\n }\n } else {\n removed = this.remove(i, count);\n this._head = (this._head + i + len) & this._capacityMask;\n }\n while (arg_len > arguments_index) {\n this.unshift(arguments[--arg_len]);\n }\n for (k = i; k > 0; k--) {\n this.unshift(temp[k - 1]);\n }\n } else {\n temp = new Array(size - (i + count));\n var leng = temp.length;\n for (k = 0; k < leng; k++) {\n temp[k] = this._list[(this._head + i + count + k) & this._capacityMask];\n }\n if (count === 0) {\n removed = [];\n if (i != size) {\n this._tail = (this._head + i + len) & this._capacityMask;\n }\n } else {\n removed = this.remove(i, count);\n this._tail = (this._tail - leng + len) & this._capacityMask;\n }\n while (arguments_index < arg_len) {\n this.push(arguments[arguments_index++]);\n }\n for (k = 0; k < leng; k++) {\n this.push(temp[k]);\n }\n }\n return removed;\n } else {\n return this.remove(i, count);\n }\n};\n\n/**\n * Soft clear - does not reset capacity.\n */\nDenque.prototype.clear = function clear() {\n this._head = 0;\n this._tail = 0;\n};\n\n/**\n * Returns true or false whether the list is empty.\n * @returns {boolean}\n */\nDenque.prototype.isEmpty = function isEmpty() {\n return this._head === this._tail;\n};\n\n/**\n * Returns an array of all queue items.\n * @returns {Array}\n */\nDenque.prototype.toArray = function toArray() {\n return this._copyArray(false);\n};\n\n/**\n * -------------\n * INTERNALS\n * -------------\n */\n\n/**\n * Fills the queue with items from an array\n * For use in the constructor\n * @param array\n * @private\n */\nDenque.prototype._fromArray = function _fromArray(array) {\n for (var i = 0; i < array.length; i++) this.push(array[i]);\n};\n\n/**\n *\n * @param fullCopy\n * @returns {Array}\n * @private\n */\nDenque.prototype._copyArray = function _copyArray(fullCopy) {\n var newArray = [];\n var list = this._list;\n var len = list.length;\n var i;\n if (fullCopy || this._head > this._tail) {\n for (i = this._head; i < len; i++) newArray.push(list[i]);\n for (i = 0; i < this._tail; i++) newArray.push(list[i]);\n } else {\n for (i = this._head; i < this._tail; i++) newArray.push(list[i]);\n }\n return newArray;\n};\n\n/**\n * Grows the internal list array.\n * @private\n */\nDenque.prototype._growArray = function _growArray() {\n if (this._head) {\n // copy existing data, head to end, then beginning to tail.\n this._list = this._copyArray(true);\n this._head = 0;\n }\n\n // head is at 0 and array is now full, safe to extend\n this._tail = this._list.length;\n\n this._list.length <<= 1;\n this._capacityMask = (this._capacityMask << 1) | 1;\n};\n\n/**\n * Shrinks the internal list array.\n * @private\n */\nDenque.prototype._shrinkArray = function _shrinkArray() {\n this._list.length >>>= 1;\n this._capacityMask >>>= 1;\n};\n\n\nmodule.exports = Denque;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/denque/index.js?"); +eval("\n\n/**\n * Custom implementation of a double ended queue.\n */\nfunction Denque(array, options) {\n var options = options || {};\n this._capacity = options.capacity;\n\n this._head = 0;\n this._tail = 0;\n\n if (Array.isArray(array)) {\n this._fromArray(array);\n } else {\n this._capacityMask = 0x3;\n this._list = new Array(4);\n }\n}\n\n/**\n * --------------\n * PUBLIC API\n * -------------\n */\n\n/**\n * Returns the item at the specified index from the list.\n * 0 is the first element, 1 is the second, and so on...\n * Elements at negative values are that many from the end: -1 is one before the end\n * (the last element), -2 is two before the end (one before last), etc.\n * @param index\n * @returns {*}\n */\nDenque.prototype.peekAt = function peekAt(index) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n var len = this.size();\n if (i >= len || i < -len) return undefined;\n if (i < 0) i += len;\n i = (this._head + i) & this._capacityMask;\n return this._list[i];\n};\n\n/**\n * Alias for peekAt()\n * @param i\n * @returns {*}\n */\nDenque.prototype.get = function get(i) {\n return this.peekAt(i);\n};\n\n/**\n * Returns the first item in the list without removing it.\n * @returns {*}\n */\nDenque.prototype.peek = function peek() {\n if (this._head === this._tail) return undefined;\n return this._list[this._head];\n};\n\n/**\n * Alias for peek()\n * @returns {*}\n */\nDenque.prototype.peekFront = function peekFront() {\n return this.peek();\n};\n\n/**\n * Returns the item that is at the back of the queue without removing it.\n * Uses peekAt(-1)\n */\nDenque.prototype.peekBack = function peekBack() {\n return this.peekAt(-1);\n};\n\n/**\n * Returns the current length of the queue\n * @return {Number}\n */\nObject.defineProperty(Denque.prototype, 'length', {\n get: function length() {\n return this.size();\n }\n});\n\n/**\n * Return the number of items on the list, or 0 if empty.\n * @returns {number}\n */\nDenque.prototype.size = function size() {\n if (this._head === this._tail) return 0;\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Add an item at the beginning of the list.\n * @param item\n */\nDenque.prototype.unshift = function unshift(item) {\n if (arguments.length === 0) return this.size();\n var len = this._list.length;\n this._head = (this._head - 1 + len) & this._capacityMask;\n this._list[this._head] = item;\n if (this._tail === this._head) this._growArray();\n if (this._capacity && this.size() > this._capacity) this.pop();\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Remove and return the first item on the list,\n * Returns undefined if the list is empty.\n * @returns {*}\n */\nDenque.prototype.shift = function shift() {\n var head = this._head;\n if (head === this._tail) return undefined;\n var item = this._list[head];\n this._list[head] = undefined;\n this._head = (head + 1) & this._capacityMask;\n if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray();\n return item;\n};\n\n/**\n * Add an item to the bottom of the list.\n * @param item\n */\nDenque.prototype.push = function push(item) {\n if (arguments.length === 0) return this.size();\n var tail = this._tail;\n this._list[tail] = item;\n this._tail = (tail + 1) & this._capacityMask;\n if (this._tail === this._head) {\n this._growArray();\n }\n if (this._capacity && this.size() > this._capacity) {\n this.shift();\n }\n if (this._head < this._tail) return this._tail - this._head;\n else return this._capacityMask + 1 - (this._head - this._tail);\n};\n\n/**\n * Remove and return the last item on the list.\n * Returns undefined if the list is empty.\n * @returns {*}\n */\nDenque.prototype.pop = function pop() {\n var tail = this._tail;\n if (tail === this._head) return undefined;\n var len = this._list.length;\n this._tail = (tail - 1 + len) & this._capacityMask;\n var item = this._list[this._tail];\n this._list[this._tail] = undefined;\n if (this._head < 2 && tail > 10000 && tail <= len >>> 2) this._shrinkArray();\n return item;\n};\n\n/**\n * Remove and return the item at the specified index from the list.\n * Returns undefined if the list is empty.\n * @param index\n * @returns {*}\n */\nDenque.prototype.removeOne = function removeOne(index) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n if (this._head === this._tail) return void 0;\n var size = this.size();\n var len = this._list.length;\n if (i >= size || i < -size) return void 0;\n if (i < 0) i += size;\n i = (this._head + i) & this._capacityMask;\n var item = this._list[i];\n var k;\n if (index < size / 2) {\n for (k = index; k > 0; k--) {\n this._list[i] = this._list[i = (i - 1 + len) & this._capacityMask];\n }\n this._list[i] = void 0;\n this._head = (this._head + 1 + len) & this._capacityMask;\n } else {\n for (k = size - 1 - index; k > 0; k--) {\n this._list[i] = this._list[i = (i + 1 + len) & this._capacityMask];\n }\n this._list[i] = void 0;\n this._tail = (this._tail - 1 + len) & this._capacityMask;\n }\n return item;\n};\n\n/**\n * Remove number of items from the specified index from the list.\n * Returns array of removed items.\n * Returns undefined if the list is empty.\n * @param index\n * @param count\n * @returns {array}\n */\nDenque.prototype.remove = function remove(index, count) {\n var i = index;\n var removed;\n var del_count = count;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n if (this._head === this._tail) return void 0;\n var size = this.size();\n var len = this._list.length;\n if (i >= size || i < -size || count < 1) return void 0;\n if (i < 0) i += size;\n if (count === 1 || !count) {\n removed = new Array(1);\n removed[0] = this.removeOne(i);\n return removed;\n }\n if (i === 0 && i + count >= size) {\n removed = this.toArray();\n this.clear();\n return removed;\n }\n if (i + count > size) count = size - i;\n var k;\n removed = new Array(count);\n for (k = 0; k < count; k++) {\n removed[k] = this._list[(this._head + i + k) & this._capacityMask];\n }\n i = (this._head + i) & this._capacityMask;\n if (index + count === size) {\n this._tail = (this._tail - count + len) & this._capacityMask;\n for (k = count; k > 0; k--) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n }\n return removed;\n }\n if (index === 0) {\n this._head = (this._head + count + len) & this._capacityMask;\n for (k = count - 1; k > 0; k--) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n }\n return removed;\n }\n if (i < size / 2) {\n this._head = (this._head + index + count + len) & this._capacityMask;\n for (k = index; k > 0; k--) {\n this.unshift(this._list[i = (i - 1 + len) & this._capacityMask]);\n }\n i = (this._head - 1 + len) & this._capacityMask;\n while (del_count > 0) {\n this._list[i = (i - 1 + len) & this._capacityMask] = void 0;\n del_count--;\n }\n if (index < 0) this._tail = i;\n } else {\n this._tail = i;\n i = (i + count + len) & this._capacityMask;\n for (k = size - (count + index); k > 0; k--) {\n this.push(this._list[i++]);\n }\n i = this._tail;\n while (del_count > 0) {\n this._list[i = (i + 1 + len) & this._capacityMask] = void 0;\n del_count--;\n }\n }\n if (this._head < 2 && this._tail > 10000 && this._tail <= len >>> 2) this._shrinkArray();\n return removed;\n};\n\n/**\n * Native splice implementation.\n * Remove number of items from the specified index from the list and/or add new elements.\n * Returns array of removed items or empty array if count == 0.\n * Returns undefined if the list is empty.\n *\n * @param index\n * @param count\n * @param {...*} [elements]\n * @returns {array}\n */\nDenque.prototype.splice = function splice(index, count) {\n var i = index;\n // expect a number or return undefined\n if ((i !== (i | 0))) {\n return void 0;\n }\n var size = this.size();\n if (i < 0) i += size;\n if (i > size) return void 0;\n if (arguments.length > 2) {\n var k;\n var temp;\n var removed;\n var arg_len = arguments.length;\n var len = this._list.length;\n var arguments_index = 2;\n if (!size || i < size / 2) {\n temp = new Array(i);\n for (k = 0; k < i; k++) {\n temp[k] = this._list[(this._head + k) & this._capacityMask];\n }\n if (count === 0) {\n removed = [];\n if (i > 0) {\n this._head = (this._head + i + len) & this._capacityMask;\n }\n } else {\n removed = this.remove(i, count);\n this._head = (this._head + i + len) & this._capacityMask;\n }\n while (arg_len > arguments_index) {\n this.unshift(arguments[--arg_len]);\n }\n for (k = i; k > 0; k--) {\n this.unshift(temp[k - 1]);\n }\n } else {\n temp = new Array(size - (i + count));\n var leng = temp.length;\n for (k = 0; k < leng; k++) {\n temp[k] = this._list[(this._head + i + count + k) & this._capacityMask];\n }\n if (count === 0) {\n removed = [];\n if (i != size) {\n this._tail = (this._head + i + len) & this._capacityMask;\n }\n } else {\n removed = this.remove(i, count);\n this._tail = (this._tail - leng + len) & this._capacityMask;\n }\n while (arguments_index < arg_len) {\n this.push(arguments[arguments_index++]);\n }\n for (k = 0; k < leng; k++) {\n this.push(temp[k]);\n }\n }\n return removed;\n } else {\n return this.remove(i, count);\n }\n};\n\n/**\n * Soft clear - does not reset capacity.\n */\nDenque.prototype.clear = function clear() {\n this._list = new Array(this._list.length);\n this._head = 0;\n this._tail = 0;\n};\n\n/**\n * Returns true or false whether the list is empty.\n * @returns {boolean}\n */\nDenque.prototype.isEmpty = function isEmpty() {\n return this._head === this._tail;\n};\n\n/**\n * Returns an array of all queue items.\n * @returns {Array}\n */\nDenque.prototype.toArray = function toArray() {\n return this._copyArray(false);\n};\n\n/**\n * -------------\n * INTERNALS\n * -------------\n */\n\n/**\n * Fills the queue with items from an array\n * For use in the constructor\n * @param array\n * @private\n */\nDenque.prototype._fromArray = function _fromArray(array) {\n var length = array.length;\n var capacity = this._nextPowerOf2(length);\n\n this._list = new Array(capacity);\n this._capacityMask = capacity - 1;\n this._tail = length;\n\n for (var i = 0; i < length; i++) this._list[i] = array[i];\n};\n\n/**\n *\n * @param fullCopy\n * @param size Initialize the array with a specific size. Will default to the current list size\n * @returns {Array}\n * @private\n */\nDenque.prototype._copyArray = function _copyArray(fullCopy, size) {\n var src = this._list;\n var capacity = src.length;\n var length = this.length;\n size = size | length;\n\n // No prealloc requested and the buffer is contiguous\n if (size == length && this._head < this._tail) {\n // Simply do a fast slice copy\n return this._list.slice(this._head, this._tail);\n }\n\n var dest = new Array(size);\n\n var k = 0;\n var i;\n if (fullCopy || this._head > this._tail) {\n for (i = this._head; i < capacity; i++) dest[k++] = src[i];\n for (i = 0; i < this._tail; i++) dest[k++] = src[i];\n } else {\n for (i = this._head; i < this._tail; i++) dest[k++] = src[i];\n }\n\n return dest;\n}\n\n/**\n * Grows the internal list array.\n * @private\n */\nDenque.prototype._growArray = function _growArray() {\n if (this._head != 0) {\n // double array size and copy existing data, head to end, then beginning to tail.\n var newList = this._copyArray(true, this._list.length << 1);\n\n this._tail = this._list.length;\n this._head = 0;\n\n this._list = newList;\n } else {\n this._tail = this._list.length;\n this._list.length <<= 1;\n }\n\n this._capacityMask = (this._capacityMask << 1) | 1;\n};\n\n/**\n * Shrinks the internal list array.\n * @private\n */\nDenque.prototype._shrinkArray = function _shrinkArray() {\n this._list.length >>>= 1;\n this._capacityMask >>>= 1;\n};\n\n/**\n * Find the next power of 2, at least 4\n * @private\n * @param {number} num \n * @returns {number}\n */\nDenque.prototype._nextPowerOf2 = function _nextPowerOf2(num) {\n var log2 = Math.log(num) / Math.log(2);\n var nextPow2 = 1 << (log2 + 1);\n\n return Math.max(nextPow2, 4);\n}\n\nmodule.exports = Denque;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/denque/index.js?"); /***/ }), @@ -611,17 +501,6 @@ eval("\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n /***/ }), -/***/ "./node_modules/events/events.js": -/*!***************************************!*\ - !*** ./node_modules/events/events.js ***! - \***************************************/ -/***/ ((module) => { - -"use strict"; -eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/events/events.js?"); - -/***/ }), - /***/ "./node_modules/hashlru/index.js": /*!***************************************!*\ !*** ./node_modules/hashlru/index.js ***! @@ -642,16 +521,6 @@ eval("var __WEBPACK_AMD_DEFINE_RESULT__;/*\n * [hi-base32]{@link https://github. /***/ }), -/***/ "./node_modules/ipaddr.js/lib/ipaddr.js": -/*!**********************************************!*\ - !*** ./node_modules/ipaddr.js/lib/ipaddr.js ***! - \**********************************************/ -/***/ (function(module) { - -eval("(function (root) {\n 'use strict';\n // A list of regular expressions that match arbitrary IPv4 addresses,\n // for which a number of weird notations exist.\n // Note that an address like 0010.0xa5.1.1 is considered legal.\n const ipv4Part = '(0?\\\\d+|0x[a-f0-9]+)';\n const ipv4Regexes = {\n fourOctet: new RegExp(`^${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}$`, 'i'),\n threeOctet: new RegExp(`^${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}$`, 'i'),\n twoOctet: new RegExp(`^${ipv4Part}\\\\.${ipv4Part}$`, 'i'),\n longValue: new RegExp(`^${ipv4Part}$`, 'i')\n };\n\n // Regular Expression for checking Octal numbers\n const octalRegex = new RegExp(`^0[0-7]+$`, 'i');\n const hexRegex = new RegExp(`^0x[a-f0-9]+$`, 'i');\n\n const zoneIndex = '%[0-9a-z]{1,}';\n\n // IPv6-matching regular expressions.\n // For IPv6, the task is simpler: it is enough to match the colon-delimited\n // hexadecimal IPv6 and a transitional variant with dotted-decimal IPv4 at\n // the end.\n const ipv6Part = '(?:[0-9a-f]+::?)+';\n const ipv6Regexes = {\n zoneIndex: new RegExp(zoneIndex, 'i'),\n 'native': new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, 'i'),\n deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}(${zoneIndex})?)$`, 'i'),\n transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}\\\\.${ipv4Part}(${zoneIndex})?$`, 'i')\n };\n\n // Expand :: in an IPv6 address or address part consisting of `parts` groups.\n function expandIPv6 (string, parts) {\n // More than one '::' means invalid adddress\n if (string.indexOf('::') !== string.lastIndexOf('::')) {\n return null;\n }\n\n let colonCount = 0;\n let lastColon = -1;\n let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];\n let replacement, replacementCount;\n\n // Remove zone index and save it for later\n if (zoneId) {\n zoneId = zoneId.substring(1);\n string = string.replace(/%.+$/, '');\n }\n\n // How many parts do we already have?\n while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {\n colonCount++;\n }\n\n // 0::0 is two parts more than ::\n if (string.substr(0, 2) === '::') {\n colonCount--;\n }\n\n if (string.substr(-2, 2) === '::') {\n colonCount--;\n }\n\n // The following loop would hang if colonCount > parts\n if (colonCount > parts) {\n return null;\n }\n\n // replacement = ':' + '0:' * (parts - colonCount)\n replacementCount = parts - colonCount;\n replacement = ':';\n while (replacementCount--) {\n replacement += '0:';\n }\n\n // Insert the missing zeroes\n string = string.replace('::', replacement);\n\n // Trim any garbage which may be hanging around if :: was at the edge in\n // the source strin\n if (string[0] === ':') {\n string = string.slice(1);\n }\n\n if (string[string.length - 1] === ':') {\n string = string.slice(0, -1);\n }\n\n parts = (function () {\n const ref = string.split(':');\n const results = [];\n\n for (let i = 0; i < ref.length; i++) {\n results.push(parseInt(ref[i], 16));\n }\n\n return results;\n })();\n\n return {\n parts: parts,\n zoneId: zoneId\n };\n }\n\n // A generic CIDR (Classless Inter-Domain Routing) RFC1518 range matcher.\n function matchCIDR (first, second, partSize, cidrBits) {\n if (first.length !== second.length) {\n throw new Error('ipaddr: cannot match CIDR for objects with different lengths');\n }\n\n let part = 0;\n let shift;\n\n while (cidrBits > 0) {\n shift = partSize - cidrBits;\n if (shift < 0) {\n shift = 0;\n }\n\n if (first[part] >> shift !== second[part] >> shift) {\n return false;\n }\n\n cidrBits -= partSize;\n part += 1;\n }\n\n return true;\n }\n\n function parseIntAuto (string) {\n // Hexadedimal base 16 (0x#)\n if (hexRegex.test(string)) {\n return parseInt(string, 16);\n }\n // While octal representation is discouraged by ECMAScript 3\n // and forbidden by ECMAScript 5, we silently allow it to\n // work only if the rest of the string has numbers less than 8.\n if (string[0] === '0' && !isNaN(parseInt(string[1], 10))) {\n if (octalRegex.test(string)) {\n return parseInt(string, 8);\n }\n throw new Error(`ipaddr: cannot parse ${string} as octal`);\n }\n // Always include the base 10 radix!\n return parseInt(string, 10);\n }\n\n function padPart (part, length) {\n while (part.length < length) {\n part = `0${part}`;\n }\n\n return part;\n }\n\n const ipaddr = {};\n\n // An IPv4 address (RFC791).\n ipaddr.IPv4 = (function () {\n // Constructs a new IPv4 address from an array of four octets\n // in network order (MSB first)\n // Verifies the input.\n function IPv4 (octets) {\n if (octets.length !== 4) {\n throw new Error('ipaddr: ipv4 octet count should be 4');\n }\n\n let i, octet;\n\n for (i = 0; i < octets.length; i++) {\n octet = octets[i];\n if (!((0 <= octet && octet <= 255))) {\n throw new Error('ipaddr: ipv4 octet should fit in 8 bits');\n }\n }\n\n this.octets = octets;\n }\n\n // Special IPv4 address ranges.\n // See also https://en.wikipedia.org/wiki/Reserved_IP_addresses\n IPv4.prototype.SpecialRanges = {\n unspecified: [[new IPv4([0, 0, 0, 0]), 8]],\n broadcast: [[new IPv4([255, 255, 255, 255]), 32]],\n // RFC3171\n multicast: [[new IPv4([224, 0, 0, 0]), 4]],\n // RFC3927\n linkLocal: [[new IPv4([169, 254, 0, 0]), 16]],\n // RFC5735\n loopback: [[new IPv4([127, 0, 0, 0]), 8]],\n // RFC6598\n carrierGradeNat: [[new IPv4([100, 64, 0, 0]), 10]],\n // RFC1918\n 'private': [\n [new IPv4([10, 0, 0, 0]), 8],\n [new IPv4([172, 16, 0, 0]), 12],\n [new IPv4([192, 168, 0, 0]), 16]\n ],\n // Reserved and testing-only ranges; RFCs 5735, 5737, 2544, 1700\n reserved: [\n [new IPv4([192, 0, 0, 0]), 24],\n [new IPv4([192, 0, 2, 0]), 24],\n [new IPv4([192, 88, 99, 0]), 24],\n [new IPv4([198, 18, 0, 0]), 15],\n [new IPv4([198, 51, 100, 0]), 24],\n [new IPv4([203, 0, 113, 0]), 24],\n [new IPv4([240, 0, 0, 0]), 4]\n ]\n };\n\n // The 'kind' method exists on both IPv4 and IPv6 classes.\n IPv4.prototype.kind = function () {\n return 'ipv4';\n };\n\n // Checks if this address matches other one within given CIDR range.\n IPv4.prototype.match = function (other, cidrRange) {\n let ref;\n if (cidrRange === undefined) {\n ref = other;\n other = ref[0];\n cidrRange = ref[1];\n }\n\n if (other.kind() !== 'ipv4') {\n throw new Error('ipaddr: cannot match ipv4 address with non-ipv4 one');\n }\n\n return matchCIDR(this.octets, other.octets, 8, cidrRange);\n };\n\n // returns a number of leading ones in IPv4 address, making sure that\n // the rest is a solid sequence of 0's (valid netmask)\n // returns either the CIDR length or null if mask is not valid\n IPv4.prototype.prefixLengthFromSubnetMask = function () {\n let cidr = 0;\n // non-zero encountered stop scanning for zeroes\n let stop = false;\n // number of zeroes in octet\n const zerotable = {\n 0: 8,\n 128: 7,\n 192: 6,\n 224: 5,\n 240: 4,\n 248: 3,\n 252: 2,\n 254: 1,\n 255: 0\n };\n let i, octet, zeros;\n\n for (i = 3; i >= 0; i -= 1) {\n octet = this.octets[i];\n if (octet in zerotable) {\n zeros = zerotable[octet];\n if (stop && zeros !== 0) {\n return null;\n }\n\n if (zeros !== 8) {\n stop = true;\n }\n\n cidr += zeros;\n } else {\n return null;\n }\n }\n\n return 32 - cidr;\n };\n\n // Checks if the address corresponds to one of the special ranges.\n IPv4.prototype.range = function () {\n return ipaddr.subnetMatch(this, this.SpecialRanges);\n };\n\n // Returns an array of byte-sized values in network order (MSB first)\n IPv4.prototype.toByteArray = function () {\n return this.octets.slice(0);\n };\n\n // Converts this IPv4 address to an IPv4-mapped IPv6 address.\n IPv4.prototype.toIPv4MappedAddress = function () {\n return ipaddr.IPv6.parse(`::ffff:${this.toString()}`);\n };\n\n // Symmetrical method strictly for aligning with the IPv6 methods.\n IPv4.prototype.toNormalizedString = function () {\n return this.toString();\n };\n\n // Returns the address in convenient, decimal-dotted format.\n IPv4.prototype.toString = function () {\n return this.octets.join('.');\n };\n\n return IPv4;\n })();\n\n // A utility function to return broadcast address given the IPv4 interface and prefix length in CIDR notation\n ipaddr.IPv4.broadcastAddressFromCIDR = function (string) {\n\n try {\n const cidr = this.parseCIDR(string);\n const ipInterfaceOctets = cidr[0].toByteArray();\n const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n const octets = [];\n let i = 0;\n while (i < 4) {\n // Broadcast address is bitwise OR between ip interface and inverted mask\n octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);\n i++;\n }\n\n return new this(octets);\n } catch (e) {\n throw new Error('ipaddr: the address does not have IPv4 CIDR format');\n }\n };\n\n // Checks if a given string is formatted like IPv4 address.\n ipaddr.IPv4.isIPv4 = function (string) {\n return this.parser(string) !== null;\n };\n\n // Checks if a given string is a valid IPv4 address.\n ipaddr.IPv4.isValid = function (string) {\n try {\n new this(this.parser(string));\n return true;\n } catch (e) {\n return false;\n }\n };\n\n // Checks if a given string is a full four-part IPv4 Address.\n ipaddr.IPv4.isValidFourPartDecimal = function (string) {\n if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\\d*)(\\.(0|[1-9]\\d*)){3}$/)) {\n return true;\n } else {\n return false;\n }\n };\n\n // A utility function to return network address given the IPv4 interface and prefix length in CIDR notation\n ipaddr.IPv4.networkAddressFromCIDR = function (string) {\n let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;\n\n try {\n cidr = this.parseCIDR(string);\n ipInterfaceOctets = cidr[0].toByteArray();\n subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n octets = [];\n i = 0;\n while (i < 4) {\n // Network address is bitwise AND between ip interface and mask\n octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));\n i++;\n }\n\n return new this(octets);\n } catch (e) {\n throw new Error('ipaddr: the address does not have IPv4 CIDR format');\n }\n };\n\n // Tries to parse and validate a string with IPv4 address.\n // Throws an error if it fails.\n ipaddr.IPv4.parse = function (string) {\n const parts = this.parser(string);\n\n if (parts === null) {\n throw new Error('ipaddr: string is not formatted like an IPv4 Address');\n }\n\n return new this(parts);\n };\n\n // Parses the string as an IPv4 Address with CIDR Notation.\n ipaddr.IPv4.parseCIDR = function (string) {\n let match;\n\n if ((match = string.match(/^(.+)\\/(\\d+)$/))) {\n const maskLength = parseInt(match[2]);\n if (maskLength >= 0 && maskLength <= 32) {\n const parsed = [this.parse(match[1]), maskLength];\n Object.defineProperty(parsed, 'toString', {\n value: function () {\n return this.join('/');\n }\n });\n return parsed;\n }\n }\n\n throw new Error('ipaddr: string is not formatted like an IPv4 CIDR range');\n };\n\n // Classful variants (like a.b, where a is an octet, and b is a 24-bit\n // value representing last three octets; this corresponds to a class C\n // address) are omitted due to classless nature of modern Internet.\n ipaddr.IPv4.parser = function (string) {\n let match, part, value;\n\n // parseInt recognizes all that octal & hexadecimal weirdness for us\n if ((match = string.match(ipv4Regexes.fourOctet))) {\n return (function () {\n const ref = match.slice(1, 6);\n const results = [];\n\n for (let i = 0; i < ref.length; i++) {\n part = ref[i];\n results.push(parseIntAuto(part));\n }\n\n return results;\n })();\n } else if ((match = string.match(ipv4Regexes.longValue))) {\n value = parseIntAuto(match[1]);\n if (value > 0xffffffff || value < 0) {\n throw new Error('ipaddr: address outside defined range');\n }\n\n return ((function () {\n const results = [];\n let shift;\n\n for (shift = 0; shift <= 24; shift += 8) {\n results.push((value >> shift) & 0xff);\n }\n\n return results;\n })()).reverse();\n } else if ((match = string.match(ipv4Regexes.twoOctet))) {\n return (function () {\n const ref = match.slice(1, 4);\n const results = [];\n\n value = parseIntAuto(ref[1]);\n if (value > 0xffffff || value < 0) {\n throw new Error('ipaddr: address outside defined range');\n }\n\n results.push(parseIntAuto(ref[0]));\n results.push((value >> 16) & 0xff);\n results.push((value >> 8) & 0xff);\n results.push( value & 0xff);\n\n return results;\n })();\n } else if ((match = string.match(ipv4Regexes.threeOctet))) {\n return (function () {\n const ref = match.slice(1, 5);\n const results = [];\n\n value = parseIntAuto(ref[2]);\n if (value > 0xffff || value < 0) {\n throw new Error('ipaddr: address outside defined range');\n }\n\n results.push(parseIntAuto(ref[0]));\n results.push(parseIntAuto(ref[1]));\n results.push((value >> 8) & 0xff);\n results.push( value & 0xff);\n\n return results;\n })();\n } else {\n return null;\n }\n };\n\n // A utility function to return subnet mask in IPv4 format given the prefix length\n ipaddr.IPv4.subnetMaskFromPrefixLength = function (prefix) {\n prefix = parseInt(prefix);\n if (prefix < 0 || prefix > 32) {\n throw new Error('ipaddr: invalid IPv4 prefix length');\n }\n\n const octets = [0, 0, 0, 0];\n let j = 0;\n const filledOctetCount = Math.floor(prefix / 8);\n\n while (j < filledOctetCount) {\n octets[j] = 255;\n j++;\n }\n\n if (filledOctetCount < 4) {\n octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - (prefix % 8);\n }\n\n return new this(octets);\n };\n\n // An IPv6 address (RFC2460)\n ipaddr.IPv6 = (function () {\n // Constructs an IPv6 address from an array of eight 16 - bit parts\n // or sixteen 8 - bit parts in network order(MSB first).\n // Throws an error if the input is invalid.\n function IPv6 (parts, zoneId) {\n let i, part;\n\n if (parts.length === 16) {\n this.parts = [];\n for (i = 0; i <= 14; i += 2) {\n this.parts.push((parts[i] << 8) | parts[i + 1]);\n }\n } else if (parts.length === 8) {\n this.parts = parts;\n } else {\n throw new Error('ipaddr: ipv6 part count should be 8 or 16');\n }\n\n for (i = 0; i < this.parts.length; i++) {\n part = this.parts[i];\n if (!((0 <= part && part <= 0xffff))) {\n throw new Error('ipaddr: ipv6 part should fit in 16 bits');\n }\n }\n\n if (zoneId) {\n this.zoneId = zoneId;\n }\n }\n\n // Special IPv6 ranges\n IPv6.prototype.SpecialRanges = {\n // RFC4291, here and after\n unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128],\n linkLocal: [new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10],\n multicast: [new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8],\n loopback: [new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128],\n uniqueLocal: [new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7],\n ipv4Mapped: [new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96],\n // RFC6145\n rfc6145: [new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96],\n // RFC6052\n rfc6052: [new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96],\n // RFC3056\n '6to4': [new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16],\n // RFC6052, RFC6146\n teredo: [new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32],\n // RFC4291\n reserved: [[new IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32]],\n benchmarking: [new IPv6([0x2001, 0x2, 0, 0, 0, 0, 0, 0]), 48],\n amt: [new IPv6([0x2001, 0x3, 0, 0, 0, 0, 0, 0]), 32],\n as112v6: [new IPv6([0x2001, 0x4, 0x112, 0, 0, 0, 0, 0]), 48],\n deprecated: [new IPv6([0x2001, 0x10, 0, 0, 0, 0, 0, 0]), 28],\n orchid2: [new IPv6([0x2001, 0x20, 0, 0, 0, 0, 0, 0]), 28]\n };\n\n // Checks if this address is an IPv4-mapped IPv6 address.\n IPv6.prototype.isIPv4MappedAddress = function () {\n return this.range() === 'ipv4Mapped';\n };\n\n // The 'kind' method exists on both IPv4 and IPv6 classes.\n IPv6.prototype.kind = function () {\n return 'ipv6';\n };\n\n // Checks if this address matches other one within given CIDR range.\n IPv6.prototype.match = function (other, cidrRange) {\n let ref;\n\n if (cidrRange === undefined) {\n ref = other;\n other = ref[0];\n cidrRange = ref[1];\n }\n\n if (other.kind() !== 'ipv6') {\n throw new Error('ipaddr: cannot match ipv6 address with non-ipv6 one');\n }\n\n return matchCIDR(this.parts, other.parts, 16, cidrRange);\n };\n\n // returns a number of leading ones in IPv6 address, making sure that\n // the rest is a solid sequence of 0's (valid netmask)\n // returns either the CIDR length or null if mask is not valid\n IPv6.prototype.prefixLengthFromSubnetMask = function () {\n let cidr = 0;\n // non-zero encountered stop scanning for zeroes\n let stop = false;\n // number of zeroes in octet\n const zerotable = {\n 0: 16,\n 32768: 15,\n 49152: 14,\n 57344: 13,\n 61440: 12,\n 63488: 11,\n 64512: 10,\n 65024: 9,\n 65280: 8,\n 65408: 7,\n 65472: 6,\n 65504: 5,\n 65520: 4,\n 65528: 3,\n 65532: 2,\n 65534: 1,\n 65535: 0\n };\n let part, zeros;\n\n for (let i = 7; i >= 0; i -= 1) {\n part = this.parts[i];\n if (part in zerotable) {\n zeros = zerotable[part];\n if (stop && zeros !== 0) {\n return null;\n }\n\n if (zeros !== 16) {\n stop = true;\n }\n\n cidr += zeros;\n } else {\n return null;\n }\n }\n\n return 128 - cidr;\n };\n\n\n // Checks if the address corresponds to one of the special ranges.\n IPv6.prototype.range = function () {\n return ipaddr.subnetMatch(this, this.SpecialRanges);\n };\n\n // Returns an array of byte-sized values in network order (MSB first)\n IPv6.prototype.toByteArray = function () {\n let part;\n const bytes = [];\n const ref = this.parts;\n for (let i = 0; i < ref.length; i++) {\n part = ref[i];\n bytes.push(part >> 8);\n bytes.push(part & 0xff);\n }\n\n return bytes;\n };\n\n // Returns the address in expanded format with all zeroes included, like\n // 2001:0db8:0008:0066:0000:0000:0000:0001\n IPv6.prototype.toFixedLengthString = function () {\n const addr = ((function () {\n const results = [];\n for (let i = 0; i < this.parts.length; i++) {\n results.push(padPart(this.parts[i].toString(16), 4));\n }\n\n return results;\n }).call(this)).join(':');\n\n let suffix = '';\n\n if (this.zoneId) {\n suffix = `%${this.zoneId}`;\n }\n\n return addr + suffix;\n };\n\n // Converts this address to IPv4 address if it is an IPv4-mapped IPv6 address.\n // Throws an error otherwise.\n IPv6.prototype.toIPv4Address = function () {\n if (!this.isIPv4MappedAddress()) {\n throw new Error('ipaddr: trying to convert a generic ipv6 address to ipv4');\n }\n\n const ref = this.parts.slice(-2);\n const high = ref[0];\n const low = ref[1];\n\n return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]);\n };\n\n // Returns the address in expanded format with all zeroes included, like\n // 2001:db8:8:66:0:0:0:1\n //\n // Deprecated: use toFixedLengthString() instead.\n IPv6.prototype.toNormalizedString = function () {\n const addr = ((function () {\n const results = [];\n\n for (let i = 0; i < this.parts.length; i++) {\n results.push(this.parts[i].toString(16));\n }\n\n return results;\n }).call(this)).join(':');\n\n let suffix = '';\n\n if (this.zoneId) {\n suffix = `%${this.zoneId}`;\n }\n\n return addr + suffix;\n };\n\n // Returns the address in compact, human-readable format like\n // 2001:db8:8:66::1\n // in line with RFC 5952 (see https://tools.ietf.org/html/rfc5952#section-4)\n IPv6.prototype.toRFC5952String = function () {\n const regex = /((^|:)(0(:|$)){2,})/g;\n const string = this.toNormalizedString();\n let bestMatchIndex = 0;\n let bestMatchLength = -1;\n let match;\n\n while ((match = regex.exec(string))) {\n if (match[0].length > bestMatchLength) {\n bestMatchIndex = match.index;\n bestMatchLength = match[0].length;\n }\n }\n\n if (bestMatchLength < 0) {\n return string;\n }\n\n return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}`;\n };\n\n // Returns the address in compact, human-readable format like\n // 2001:db8:8:66::1\n // Calls toRFC5952String under the hood.\n IPv6.prototype.toString = function () {\n return this.toRFC5952String();\n };\n\n return IPv6;\n\n })();\n\n // A utility function to return broadcast address given the IPv6 interface and prefix length in CIDR notation\n ipaddr.IPv6.broadcastAddressFromCIDR = function (string) {\n try {\n const cidr = this.parseCIDR(string);\n const ipInterfaceOctets = cidr[0].toByteArray();\n const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n const octets = [];\n let i = 0;\n while (i < 16) {\n // Broadcast address is bitwise OR between ip interface and inverted mask\n octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);\n i++;\n }\n\n return new this(octets);\n } catch (e) {\n throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);\n }\n };\n\n // Checks if a given string is formatted like IPv6 address.\n ipaddr.IPv6.isIPv6 = function (string) {\n return this.parser(string) !== null;\n };\n\n // Checks to see if string is a valid IPv6 Address\n ipaddr.IPv6.isValid = function (string) {\n\n // Since IPv6.isValid is always called first, this shortcut\n // provides a substantial performance gain.\n if (typeof string === 'string' && string.indexOf(':') === -1) {\n return false;\n }\n\n try {\n const addr = this.parser(string);\n new this(addr.parts, addr.zoneId);\n return true;\n } catch (e) {\n return false;\n }\n };\n\n // A utility function to return network address given the IPv6 interface and prefix length in CIDR notation\n ipaddr.IPv6.networkAddressFromCIDR = function (string) {\n let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;\n\n try {\n cidr = this.parseCIDR(string);\n ipInterfaceOctets = cidr[0].toByteArray();\n subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n octets = [];\n i = 0;\n while (i < 16) {\n // Network address is bitwise AND between ip interface and mask\n octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));\n i++;\n }\n\n return new this(octets);\n } catch (e) {\n throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);\n }\n };\n\n // Tries to parse and validate a string with IPv6 address.\n // Throws an error if it fails.\n ipaddr.IPv6.parse = function (string) {\n const addr = this.parser(string);\n\n if (addr.parts === null) {\n throw new Error('ipaddr: string is not formatted like an IPv6 Address');\n }\n\n return new this(addr.parts, addr.zoneId);\n };\n\n ipaddr.IPv6.parseCIDR = function (string) {\n let maskLength, match, parsed;\n\n if ((match = string.match(/^(.+)\\/(\\d+)$/))) {\n maskLength = parseInt(match[2]);\n if (maskLength >= 0 && maskLength <= 128) {\n parsed = [this.parse(match[1]), maskLength];\n Object.defineProperty(parsed, 'toString', {\n value: function () {\n return this.join('/');\n }\n });\n return parsed;\n }\n }\n\n throw new Error('ipaddr: string is not formatted like an IPv6 CIDR range');\n };\n\n // Parse an IPv6 address.\n ipaddr.IPv6.parser = function (string) {\n let addr, i, match, octet, octets, zoneId;\n\n if ((match = string.match(ipv6Regexes.deprecatedTransitional))) {\n return this.parser(`::ffff:${match[1]}`);\n }\n if (ipv6Regexes.native.test(string)) {\n return expandIPv6(string, 8);\n }\n if ((match = string.match(ipv6Regexes.transitional))) {\n zoneId = match[6] || '';\n addr = expandIPv6(match[1].slice(0, -1) + zoneId, 6);\n if (addr.parts) {\n octets = [\n parseInt(match[2]),\n parseInt(match[3]),\n parseInt(match[4]),\n parseInt(match[5])\n ];\n for (i = 0; i < octets.length; i++) {\n octet = octets[i];\n if (!((0 <= octet && octet <= 255))) {\n return null;\n }\n }\n\n addr.parts.push(octets[0] << 8 | octets[1]);\n addr.parts.push(octets[2] << 8 | octets[3]);\n return {\n parts: addr.parts,\n zoneId: addr.zoneId\n };\n }\n }\n\n return null;\n };\n\n // A utility function to return subnet mask in IPv6 format given the prefix length\n ipaddr.IPv6.subnetMaskFromPrefixLength = function (prefix) {\n prefix = parseInt(prefix);\n if (prefix < 0 || prefix > 128) {\n throw new Error('ipaddr: invalid IPv6 prefix length');\n }\n\n const octets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n let j = 0;\n const filledOctetCount = Math.floor(prefix / 8);\n\n while (j < filledOctetCount) {\n octets[j] = 255;\n j++;\n }\n\n if (filledOctetCount < 16) {\n octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - (prefix % 8);\n }\n\n return new this(octets);\n };\n\n // Try to parse an array in network order (MSB first) for IPv4 and IPv6\n ipaddr.fromByteArray = function (bytes) {\n const length = bytes.length;\n\n if (length === 4) {\n return new ipaddr.IPv4(bytes);\n } else if (length === 16) {\n return new ipaddr.IPv6(bytes);\n } else {\n throw new Error('ipaddr: the binary input is neither an IPv6 nor IPv4 address');\n }\n };\n\n // Checks if the address is valid IP address\n ipaddr.isValid = function (string) {\n return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);\n };\n\n\n // Attempts to parse an IP Address, first through IPv6 then IPv4.\n // Throws an error if it could not be parsed.\n ipaddr.parse = function (string) {\n if (ipaddr.IPv6.isValid(string)) {\n return ipaddr.IPv6.parse(string);\n } else if (ipaddr.IPv4.isValid(string)) {\n return ipaddr.IPv4.parse(string);\n } else {\n throw new Error('ipaddr: the address has neither IPv6 nor IPv4 format');\n }\n };\n\n // Attempt to parse CIDR notation, first through IPv6 then IPv4.\n // Throws an error if it could not be parsed.\n ipaddr.parseCIDR = function (string) {\n try {\n return ipaddr.IPv6.parseCIDR(string);\n } catch (e) {\n try {\n return ipaddr.IPv4.parseCIDR(string);\n } catch (e2) {\n throw new Error('ipaddr: the address has neither IPv6 nor IPv4 CIDR format');\n }\n }\n };\n\n // Parse an address and return plain IPv4 address if it is an IPv4-mapped address\n ipaddr.process = function (string) {\n const addr = this.parse(string);\n\n if (addr.kind() === 'ipv6' && addr.isIPv4MappedAddress()) {\n return addr.toIPv4Address();\n } else {\n return addr;\n }\n };\n\n // An utility function to ease named range matching. See examples below.\n // rangeList can contain both IPv4 and IPv6 subnet entries and will not throw errors\n // on matching IPv4 addresses to IPv6 ranges or vice versa.\n ipaddr.subnetMatch = function (address, rangeList, defaultName) {\n let i, rangeName, rangeSubnets, subnet;\n\n if (defaultName === undefined || defaultName === null) {\n defaultName = 'unicast';\n }\n\n for (rangeName in rangeList) {\n if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {\n rangeSubnets = rangeList[rangeName];\n // ECMA5 Array.isArray isn't available everywhere\n if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) {\n rangeSubnets = [rangeSubnets];\n }\n\n for (i = 0; i < rangeSubnets.length; i++) {\n subnet = rangeSubnets[i];\n if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) {\n return rangeName;\n }\n }\n }\n }\n\n return defaultName;\n };\n\n // Export for both the CommonJS and browser-like environment\n if ( true && module.exports) {\n module.exports = ipaddr;\n\n } else {\n root.ipaddr = ipaddr;\n }\n\n}(this));\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/ipaddr.js/lib/ipaddr.js?"); - -/***/ }), - /***/ "./node_modules/is-electron/index.js": /*!*******************************************!*\ !*** ./node_modules/is-electron/index.js ***! @@ -679,7 +548,7 @@ eval("\n\nmodule.exports = value => {\n\tif (Object.prototype.toString.call(valu \******************************************/ /***/ ((module, exports, __webpack_require__) => { -eval("var __WEBPACK_AMD_DEFINE_RESULT__;/**\n * [js-sha3]{@link https://github.com/emn178/js-sha3}\n *\n * @version 0.8.0\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2015-2018\n * @license MIT\n */\n/*jslint bitwise: true */\n(function () {\n 'use strict';\n\n var INPUT_ERROR = 'input is invalid type';\n var FINALIZE_ERROR = 'finalize already called';\n var WINDOW = typeof window === 'object';\n var root = WINDOW ? window : {};\n if (root.JS_SHA3_NO_WINDOW) {\n WINDOW = false;\n }\n var WEB_WORKER = !WINDOW && typeof self === 'object';\n var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;\n if (NODE_JS) {\n root = __webpack_require__.g;\n } else if (WEB_WORKER) {\n root = self;\n }\n var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && \"object\" === 'object' && module.exports;\n var AMD = true && __webpack_require__.amdO;\n var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';\n var HEX_CHARS = '0123456789abcdef'.split('');\n var SHAKE_PADDING = [31, 7936, 2031616, 520093696];\n var CSHAKE_PADDING = [4, 1024, 262144, 67108864];\n var KECCAK_PADDING = [1, 256, 65536, 16777216];\n var PADDING = [6, 1536, 393216, 100663296];\n var SHIFT = [0, 8, 16, 24];\n var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,\n 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,\n 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,\n 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,\n 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];\n var BITS = [224, 256, 384, 512];\n var SHAKE_BITS = [128, 256];\n var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];\n var CSHAKE_BYTEPAD = {\n '128': 168,\n '256': 136\n };\n\n if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) {\n Array.isArray = function (obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n };\n }\n\n if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {\n ArrayBuffer.isView = function (obj) {\n return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;\n };\n }\n\n var createOutputMethod = function (bits, padding, outputType) {\n return function (message) {\n return new Keccak(bits, padding, bits).update(message)[outputType]();\n };\n };\n\n var createShakeOutputMethod = function (bits, padding, outputType) {\n return function (message, outputBits) {\n return new Keccak(bits, padding, outputBits).update(message)[outputType]();\n };\n };\n\n var createCshakeOutputMethod = function (bits, padding, outputType) {\n return function (message, outputBits, n, s) {\n return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();\n };\n };\n\n var createKmacOutputMethod = function (bits, padding, outputType) {\n return function (key, message, outputBits, s) {\n return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();\n };\n };\n\n var createOutputMethods = function (method, createMethod, bits, padding) {\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createMethod(bits, padding, type);\n }\n return method;\n };\n\n var createMethod = function (bits, padding) {\n var method = createOutputMethod(bits, padding, 'hex');\n method.create = function () {\n return new Keccak(bits, padding, bits);\n };\n method.update = function (message) {\n return method.create().update(message);\n };\n return createOutputMethods(method, createOutputMethod, bits, padding);\n };\n\n var createShakeMethod = function (bits, padding) {\n var method = createShakeOutputMethod(bits, padding, 'hex');\n method.create = function (outputBits) {\n return new Keccak(bits, padding, outputBits);\n };\n method.update = function (message, outputBits) {\n return method.create(outputBits).update(message);\n };\n return createOutputMethods(method, createShakeOutputMethod, bits, padding);\n };\n\n var createCshakeMethod = function (bits, padding) {\n var w = CSHAKE_BYTEPAD[bits];\n var method = createCshakeOutputMethod(bits, padding, 'hex');\n method.create = function (outputBits, n, s) {\n if (!n && !s) {\n return methods['shake' + bits].create(outputBits);\n } else {\n return new Keccak(bits, padding, outputBits).bytepad([n, s], w);\n }\n };\n method.update = function (message, outputBits, n, s) {\n return method.create(outputBits, n, s).update(message);\n };\n return createOutputMethods(method, createCshakeOutputMethod, bits, padding);\n };\n\n var createKmacMethod = function (bits, padding) {\n var w = CSHAKE_BYTEPAD[bits];\n var method = createKmacOutputMethod(bits, padding, 'hex');\n method.create = function (key, outputBits, s) {\n return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);\n };\n method.update = function (key, message, outputBits, s) {\n return method.create(key, outputBits, s).update(message);\n };\n return createOutputMethods(method, createKmacOutputMethod, bits, padding);\n };\n\n var algorithms = [\n { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },\n { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },\n { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },\n { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },\n { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }\n ];\n\n var methods = {}, methodNames = [];\n\n for (var i = 0; i < algorithms.length; ++i) {\n var algorithm = algorithms[i];\n var bits = algorithm.bits;\n for (var j = 0; j < bits.length; ++j) {\n var methodName = algorithm.name + '_' + bits[j];\n methodNames.push(methodName);\n methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);\n if (algorithm.name !== 'sha3') {\n var newMethodName = algorithm.name + bits[j];\n methodNames.push(newMethodName);\n methods[newMethodName] = methods[methodName];\n }\n }\n }\n\n function Keccak(bits, padding, outputBits) {\n this.blocks = [];\n this.s = [];\n this.padding = padding;\n this.outputBits = outputBits;\n this.reset = true;\n this.finalized = false;\n this.block = 0;\n this.start = 0;\n this.blockCount = (1600 - (bits << 1)) >> 5;\n this.byteCount = this.blockCount << 2;\n this.outputBlocks = outputBits >> 5;\n this.extraBytes = (outputBits & 31) >> 3;\n\n for (var i = 0; i < 50; ++i) {\n this.s[i] = 0;\n }\n }\n\n Keccak.prototype.update = function (message) {\n if (this.finalized) {\n throw new Error(FINALIZE_ERROR);\n }\n var notString, type = typeof message;\n if (type !== 'string') {\n if (type === 'object') {\n if (message === null) {\n throw new Error(INPUT_ERROR);\n } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n } else if (!Array.isArray(message)) {\n if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {\n throw new Error(INPUT_ERROR);\n }\n }\n } else {\n throw new Error(INPUT_ERROR);\n }\n notString = true;\n }\n var blocks = this.blocks, byteCount = this.byteCount, length = message.length,\n blockCount = this.blockCount, index = 0, s = this.s, i, code;\n\n while (index < length) {\n if (this.reset) {\n this.reset = false;\n blocks[0] = this.block;\n for (i = 1; i < blockCount + 1; ++i) {\n blocks[i] = 0;\n }\n }\n if (notString) {\n for (i = this.start; index < length && i < byteCount; ++index) {\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\n }\n } else {\n for (i = this.start; index < length && i < byteCount; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n this.lastByteIndex = i;\n if (i >= byteCount) {\n this.start = i - byteCount;\n this.block = blocks[blockCount];\n for (i = 0; i < blockCount; ++i) {\n s[i] ^= blocks[i];\n }\n f(s);\n this.reset = true;\n } else {\n this.start = i;\n }\n }\n return this;\n };\n\n Keccak.prototype.encode = function (x, right) {\n var o = x & 255, n = 1;\n var bytes = [o];\n x = x >> 8;\n o = x & 255;\n while (o > 0) {\n bytes.unshift(o);\n x = x >> 8;\n o = x & 255;\n ++n;\n }\n if (right) {\n bytes.push(n);\n } else {\n bytes.unshift(n);\n }\n this.update(bytes);\n return bytes.length;\n };\n\n Keccak.prototype.encodeString = function (str) {\n var notString, type = typeof str;\n if (type !== 'string') {\n if (type === 'object') {\n if (str === null) {\n throw new Error(INPUT_ERROR);\n } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) {\n str = new Uint8Array(str);\n } else if (!Array.isArray(str)) {\n if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) {\n throw new Error(INPUT_ERROR);\n }\n }\n } else {\n throw new Error(INPUT_ERROR);\n }\n notString = true;\n }\n var bytes = 0, length = str.length;\n if (notString) {\n bytes = length;\n } else {\n for (var i = 0; i < str.length; ++i) {\n var code = str.charCodeAt(i);\n if (code < 0x80) {\n bytes += 1;\n } else if (code < 0x800) {\n bytes += 2;\n } else if (code < 0xd800 || code >= 0xe000) {\n bytes += 3;\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));\n bytes += 4;\n }\n }\n }\n bytes += this.encode(bytes * 8);\n this.update(str);\n return bytes;\n };\n\n Keccak.prototype.bytepad = function (strs, w) {\n var bytes = this.encode(w);\n for (var i = 0; i < strs.length; ++i) {\n bytes += this.encodeString(strs[i]);\n }\n var paddingBytes = w - bytes % w;\n var zeros = [];\n zeros.length = paddingBytes;\n this.update(zeros);\n return this;\n };\n\n Keccak.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;\n blocks[i >> 2] |= this.padding[i & 3];\n if (this.lastByteIndex === this.byteCount) {\n blocks[0] = blocks[blockCount];\n for (i = 1; i < blockCount + 1; ++i) {\n blocks[i] = 0;\n }\n }\n blocks[blockCount - 1] |= 0x80000000;\n for (i = 0; i < blockCount; ++i) {\n s[i] ^= blocks[i];\n }\n f(s);\n };\n\n Keccak.prototype.toString = Keccak.prototype.hex = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var hex = '', block;\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n block = s[i];\n hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +\n HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +\n HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +\n HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];\n }\n if (j % blockCount === 0) {\n f(s);\n i = 0;\n }\n }\n if (extraBytes) {\n block = s[i];\n hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];\n if (extraBytes > 1) {\n hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];\n }\n if (extraBytes > 2) {\n hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];\n }\n }\n return hex;\n };\n\n Keccak.prototype.arrayBuffer = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var bytes = this.outputBits >> 3;\n var buffer;\n if (extraBytes) {\n buffer = new ArrayBuffer((outputBlocks + 1) << 2);\n } else {\n buffer = new ArrayBuffer(bytes);\n }\n var array = new Uint32Array(buffer);\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n array[j] = s[i];\n }\n if (j % blockCount === 0) {\n f(s);\n }\n }\n if (extraBytes) {\n array[i] = s[i];\n buffer = buffer.slice(0, bytes);\n }\n return buffer;\n };\n\n Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;\n\n Keccak.prototype.digest = Keccak.prototype.array = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var array = [], offset, block;\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n offset = j << 2;\n block = s[i];\n array[offset] = block & 0xFF;\n array[offset + 1] = (block >> 8) & 0xFF;\n array[offset + 2] = (block >> 16) & 0xFF;\n array[offset + 3] = (block >> 24) & 0xFF;\n }\n if (j % blockCount === 0) {\n f(s);\n }\n }\n if (extraBytes) {\n offset = j << 2;\n block = s[i];\n array[offset] = block & 0xFF;\n if (extraBytes > 1) {\n array[offset + 1] = (block >> 8) & 0xFF;\n }\n if (extraBytes > 2) {\n array[offset + 2] = (block >> 16) & 0xFF;\n }\n }\n return array;\n };\n\n function Kmac(bits, padding, outputBits) {\n Keccak.call(this, bits, padding, outputBits);\n }\n\n Kmac.prototype = new Keccak();\n\n Kmac.prototype.finalize = function () {\n this.encode(this.outputBits, true);\n return Keccak.prototype.finalize.call(this);\n };\n\n var f = function (s) {\n var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,\n b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,\n b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,\n b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;\n for (n = 0; n < 48; n += 2) {\n c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];\n c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];\n c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];\n c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];\n c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];\n c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];\n c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];\n c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];\n c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];\n c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];\n\n h = c8 ^ ((c2 << 1) | (c3 >>> 31));\n l = c9 ^ ((c3 << 1) | (c2 >>> 31));\n s[0] ^= h;\n s[1] ^= l;\n s[10] ^= h;\n s[11] ^= l;\n s[20] ^= h;\n s[21] ^= l;\n s[30] ^= h;\n s[31] ^= l;\n s[40] ^= h;\n s[41] ^= l;\n h = c0 ^ ((c4 << 1) | (c5 >>> 31));\n l = c1 ^ ((c5 << 1) | (c4 >>> 31));\n s[2] ^= h;\n s[3] ^= l;\n s[12] ^= h;\n s[13] ^= l;\n s[22] ^= h;\n s[23] ^= l;\n s[32] ^= h;\n s[33] ^= l;\n s[42] ^= h;\n s[43] ^= l;\n h = c2 ^ ((c6 << 1) | (c7 >>> 31));\n l = c3 ^ ((c7 << 1) | (c6 >>> 31));\n s[4] ^= h;\n s[5] ^= l;\n s[14] ^= h;\n s[15] ^= l;\n s[24] ^= h;\n s[25] ^= l;\n s[34] ^= h;\n s[35] ^= l;\n s[44] ^= h;\n s[45] ^= l;\n h = c4 ^ ((c8 << 1) | (c9 >>> 31));\n l = c5 ^ ((c9 << 1) | (c8 >>> 31));\n s[6] ^= h;\n s[7] ^= l;\n s[16] ^= h;\n s[17] ^= l;\n s[26] ^= h;\n s[27] ^= l;\n s[36] ^= h;\n s[37] ^= l;\n s[46] ^= h;\n s[47] ^= l;\n h = c6 ^ ((c0 << 1) | (c1 >>> 31));\n l = c7 ^ ((c1 << 1) | (c0 >>> 31));\n s[8] ^= h;\n s[9] ^= l;\n s[18] ^= h;\n s[19] ^= l;\n s[28] ^= h;\n s[29] ^= l;\n s[38] ^= h;\n s[39] ^= l;\n s[48] ^= h;\n s[49] ^= l;\n\n b0 = s[0];\n b1 = s[1];\n b32 = (s[11] << 4) | (s[10] >>> 28);\n b33 = (s[10] << 4) | (s[11] >>> 28);\n b14 = (s[20] << 3) | (s[21] >>> 29);\n b15 = (s[21] << 3) | (s[20] >>> 29);\n b46 = (s[31] << 9) | (s[30] >>> 23);\n b47 = (s[30] << 9) | (s[31] >>> 23);\n b28 = (s[40] << 18) | (s[41] >>> 14);\n b29 = (s[41] << 18) | (s[40] >>> 14);\n b20 = (s[2] << 1) | (s[3] >>> 31);\n b21 = (s[3] << 1) | (s[2] >>> 31);\n b2 = (s[13] << 12) | (s[12] >>> 20);\n b3 = (s[12] << 12) | (s[13] >>> 20);\n b34 = (s[22] << 10) | (s[23] >>> 22);\n b35 = (s[23] << 10) | (s[22] >>> 22);\n b16 = (s[33] << 13) | (s[32] >>> 19);\n b17 = (s[32] << 13) | (s[33] >>> 19);\n b48 = (s[42] << 2) | (s[43] >>> 30);\n b49 = (s[43] << 2) | (s[42] >>> 30);\n b40 = (s[5] << 30) | (s[4] >>> 2);\n b41 = (s[4] << 30) | (s[5] >>> 2);\n b22 = (s[14] << 6) | (s[15] >>> 26);\n b23 = (s[15] << 6) | (s[14] >>> 26);\n b4 = (s[25] << 11) | (s[24] >>> 21);\n b5 = (s[24] << 11) | (s[25] >>> 21);\n b36 = (s[34] << 15) | (s[35] >>> 17);\n b37 = (s[35] << 15) | (s[34] >>> 17);\n b18 = (s[45] << 29) | (s[44] >>> 3);\n b19 = (s[44] << 29) | (s[45] >>> 3);\n b10 = (s[6] << 28) | (s[7] >>> 4);\n b11 = (s[7] << 28) | (s[6] >>> 4);\n b42 = (s[17] << 23) | (s[16] >>> 9);\n b43 = (s[16] << 23) | (s[17] >>> 9);\n b24 = (s[26] << 25) | (s[27] >>> 7);\n b25 = (s[27] << 25) | (s[26] >>> 7);\n b6 = (s[36] << 21) | (s[37] >>> 11);\n b7 = (s[37] << 21) | (s[36] >>> 11);\n b38 = (s[47] << 24) | (s[46] >>> 8);\n b39 = (s[46] << 24) | (s[47] >>> 8);\n b30 = (s[8] << 27) | (s[9] >>> 5);\n b31 = (s[9] << 27) | (s[8] >>> 5);\n b12 = (s[18] << 20) | (s[19] >>> 12);\n b13 = (s[19] << 20) | (s[18] >>> 12);\n b44 = (s[29] << 7) | (s[28] >>> 25);\n b45 = (s[28] << 7) | (s[29] >>> 25);\n b26 = (s[38] << 8) | (s[39] >>> 24);\n b27 = (s[39] << 8) | (s[38] >>> 24);\n b8 = (s[48] << 14) | (s[49] >>> 18);\n b9 = (s[49] << 14) | (s[48] >>> 18);\n\n s[0] = b0 ^ (~b2 & b4);\n s[1] = b1 ^ (~b3 & b5);\n s[10] = b10 ^ (~b12 & b14);\n s[11] = b11 ^ (~b13 & b15);\n s[20] = b20 ^ (~b22 & b24);\n s[21] = b21 ^ (~b23 & b25);\n s[30] = b30 ^ (~b32 & b34);\n s[31] = b31 ^ (~b33 & b35);\n s[40] = b40 ^ (~b42 & b44);\n s[41] = b41 ^ (~b43 & b45);\n s[2] = b2 ^ (~b4 & b6);\n s[3] = b3 ^ (~b5 & b7);\n s[12] = b12 ^ (~b14 & b16);\n s[13] = b13 ^ (~b15 & b17);\n s[22] = b22 ^ (~b24 & b26);\n s[23] = b23 ^ (~b25 & b27);\n s[32] = b32 ^ (~b34 & b36);\n s[33] = b33 ^ (~b35 & b37);\n s[42] = b42 ^ (~b44 & b46);\n s[43] = b43 ^ (~b45 & b47);\n s[4] = b4 ^ (~b6 & b8);\n s[5] = b5 ^ (~b7 & b9);\n s[14] = b14 ^ (~b16 & b18);\n s[15] = b15 ^ (~b17 & b19);\n s[24] = b24 ^ (~b26 & b28);\n s[25] = b25 ^ (~b27 & b29);\n s[34] = b34 ^ (~b36 & b38);\n s[35] = b35 ^ (~b37 & b39);\n s[44] = b44 ^ (~b46 & b48);\n s[45] = b45 ^ (~b47 & b49);\n s[6] = b6 ^ (~b8 & b0);\n s[7] = b7 ^ (~b9 & b1);\n s[16] = b16 ^ (~b18 & b10);\n s[17] = b17 ^ (~b19 & b11);\n s[26] = b26 ^ (~b28 & b20);\n s[27] = b27 ^ (~b29 & b21);\n s[36] = b36 ^ (~b38 & b30);\n s[37] = b37 ^ (~b39 & b31);\n s[46] = b46 ^ (~b48 & b40);\n s[47] = b47 ^ (~b49 & b41);\n s[8] = b8 ^ (~b0 & b2);\n s[9] = b9 ^ (~b1 & b3);\n s[18] = b18 ^ (~b10 & b12);\n s[19] = b19 ^ (~b11 & b13);\n s[28] = b28 ^ (~b20 & b22);\n s[29] = b29 ^ (~b21 & b23);\n s[38] = b38 ^ (~b30 & b32);\n s[39] = b39 ^ (~b31 & b33);\n s[48] = b48 ^ (~b40 & b42);\n s[49] = b49 ^ (~b41 & b43);\n\n s[0] ^= RC[n];\n s[1] ^= RC[n + 1];\n }\n };\n\n if (COMMON_JS) {\n module.exports = methods;\n } else {\n for (i = 0; i < methodNames.length; ++i) {\n root[methodNames[i]] = methods[methodNames[i]];\n }\n if (AMD) {\n !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {\n return methods;\n }).call(exports, __webpack_require__, exports, module),\n\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n }\n})();\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/js-sha3/src/sha3.js?"); +eval("var __WEBPACK_AMD_DEFINE_RESULT__;/**\n * [js-sha3]{@link https://github.com/emn178/js-sha3}\n *\n * @version 0.9.3\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2015-2023\n * @license MIT\n */\n/*jslint bitwise: true */\n(function () {\n 'use strict';\n\n var INPUT_ERROR = 'input is invalid type';\n var FINALIZE_ERROR = 'finalize already called';\n var WINDOW = typeof window === 'object';\n var root = WINDOW ? window : {};\n if (root.JS_SHA3_NO_WINDOW) {\n WINDOW = false;\n }\n var WEB_WORKER = !WINDOW && typeof self === 'object';\n var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;\n if (NODE_JS) {\n root = __webpack_require__.g;\n } else if (WEB_WORKER) {\n root = self;\n }\n var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && \"object\" === 'object' && module.exports;\n var AMD = true && __webpack_require__.amdO;\n var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';\n var HEX_CHARS = '0123456789abcdef'.split('');\n var SHAKE_PADDING = [31, 7936, 2031616, 520093696];\n var CSHAKE_PADDING = [4, 1024, 262144, 67108864];\n var KECCAK_PADDING = [1, 256, 65536, 16777216];\n var PADDING = [6, 1536, 393216, 100663296];\n var SHIFT = [0, 8, 16, 24];\n var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,\n 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,\n 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,\n 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,\n 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];\n var BITS = [224, 256, 384, 512];\n var SHAKE_BITS = [128, 256];\n var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];\n var CSHAKE_BYTEPAD = {\n '128': 168,\n '256': 136\n };\n\n\n var isArray = root.JS_SHA3_NO_NODE_JS || !Array.isArray\n ? function (obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n }\n : Array.isArray;\n\n var isView = (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView))\n ? function (obj) {\n return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;\n }\n : ArrayBuffer.isView;\n\n // [message: string, isString: bool]\n var formatMessage = function (message) {\n var type = typeof message;\n if (type === 'string') {\n return [message, true];\n }\n if (type !== 'object' || message === null) {\n throw new Error(INPUT_ERROR);\n }\n if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n return [new Uint8Array(message), false];\n }\n if (!isArray(message) && !isView(message)) {\n throw new Error(INPUT_ERROR);\n }\n return [message, false];\n }\n\n var empty = function (message) {\n return formatMessage(message)[0].length === 0;\n };\n\n var cloneArray = function (array) {\n var newArray = [];\n for (var i = 0; i < array.length; ++i) {\n newArray[i] = array[i];\n }\n return newArray;\n }\n\n var createOutputMethod = function (bits, padding, outputType) {\n return function (message) {\n return new Keccak(bits, padding, bits).update(message)[outputType]();\n };\n };\n\n var createShakeOutputMethod = function (bits, padding, outputType) {\n return function (message, outputBits) {\n return new Keccak(bits, padding, outputBits).update(message)[outputType]();\n };\n };\n\n var createCshakeOutputMethod = function (bits, padding, outputType) {\n return function (message, outputBits, n, s) {\n return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();\n };\n };\n\n var createKmacOutputMethod = function (bits, padding, outputType) {\n return function (key, message, outputBits, s) {\n return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();\n };\n };\n\n var createOutputMethods = function (method, createMethod, bits, padding) {\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createMethod(bits, padding, type);\n }\n return method;\n };\n\n var createMethod = function (bits, padding) {\n var method = createOutputMethod(bits, padding, 'hex');\n method.create = function () {\n return new Keccak(bits, padding, bits);\n };\n method.update = function (message) {\n return method.create().update(message);\n };\n return createOutputMethods(method, createOutputMethod, bits, padding);\n };\n\n var createShakeMethod = function (bits, padding) {\n var method = createShakeOutputMethod(bits, padding, 'hex');\n method.create = function (outputBits) {\n return new Keccak(bits, padding, outputBits);\n };\n method.update = function (message, outputBits) {\n return method.create(outputBits).update(message);\n };\n return createOutputMethods(method, createShakeOutputMethod, bits, padding);\n };\n\n var createCshakeMethod = function (bits, padding) {\n var w = CSHAKE_BYTEPAD[bits];\n var method = createCshakeOutputMethod(bits, padding, 'hex');\n method.create = function (outputBits, n, s) {\n if (empty(n) && empty(s)) {\n return methods['shake' + bits].create(outputBits);\n } else {\n return new Keccak(bits, padding, outputBits).bytepad([n, s], w);\n }\n };\n method.update = function (message, outputBits, n, s) {\n return method.create(outputBits, n, s).update(message);\n };\n return createOutputMethods(method, createCshakeOutputMethod, bits, padding);\n };\n\n var createKmacMethod = function (bits, padding) {\n var w = CSHAKE_BYTEPAD[bits];\n var method = createKmacOutputMethod(bits, padding, 'hex');\n method.create = function (key, outputBits, s) {\n return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);\n };\n method.update = function (key, message, outputBits, s) {\n return method.create(key, outputBits, s).update(message);\n };\n return createOutputMethods(method, createKmacOutputMethod, bits, padding);\n };\n\n var algorithms = [\n { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },\n { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },\n { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },\n { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },\n { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }\n ];\n\n var methods = {}, methodNames = [];\n\n for (var i = 0; i < algorithms.length; ++i) {\n var algorithm = algorithms[i];\n var bits = algorithm.bits;\n for (var j = 0; j < bits.length; ++j) {\n var methodName = algorithm.name + '_' + bits[j];\n methodNames.push(methodName);\n methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);\n if (algorithm.name !== 'sha3') {\n var newMethodName = algorithm.name + bits[j];\n methodNames.push(newMethodName);\n methods[newMethodName] = methods[methodName];\n }\n }\n }\n\n function Keccak(bits, padding, outputBits) {\n this.blocks = [];\n this.s = [];\n this.padding = padding;\n this.outputBits = outputBits;\n this.reset = true;\n this.finalized = false;\n this.block = 0;\n this.start = 0;\n this.blockCount = (1600 - (bits << 1)) >> 5;\n this.byteCount = this.blockCount << 2;\n this.outputBlocks = outputBits >> 5;\n this.extraBytes = (outputBits & 31) >> 3;\n\n for (var i = 0; i < 50; ++i) {\n this.s[i] = 0;\n }\n }\n\n Keccak.prototype.update = function (message) {\n if (this.finalized) {\n throw new Error(FINALIZE_ERROR);\n }\n var result = formatMessage(message);\n message = result[0];\n var isString = result[1];\n var blocks = this.blocks, byteCount = this.byteCount, length = message.length,\n blockCount = this.blockCount, index = 0, s = this.s, i, code;\n\n while (index < length) {\n if (this.reset) {\n this.reset = false;\n blocks[0] = this.block;\n for (i = 1; i < blockCount + 1; ++i) {\n blocks[i] = 0;\n }\n }\n if (isString) {\n for (i = this.start; index < length && i < byteCount; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n } else {\n for (i = this.start; index < length && i < byteCount; ++index) {\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\n }\n }\n this.lastByteIndex = i;\n if (i >= byteCount) {\n this.start = i - byteCount;\n this.block = blocks[blockCount];\n for (i = 0; i < blockCount; ++i) {\n s[i] ^= blocks[i];\n }\n f(s);\n this.reset = true;\n } else {\n this.start = i;\n }\n }\n return this;\n };\n\n Keccak.prototype.encode = function (x, right) {\n var o = x & 255, n = 1;\n var bytes = [o];\n x = x >> 8;\n o = x & 255;\n while (o > 0) {\n bytes.unshift(o);\n x = x >> 8;\n o = x & 255;\n ++n;\n }\n if (right) {\n bytes.push(n);\n } else {\n bytes.unshift(n);\n }\n this.update(bytes);\n return bytes.length;\n };\n\n Keccak.prototype.encodeString = function (str) {\n var result = formatMessage(str);\n str = result[0];\n var isString = result[1];\n var bytes = 0, length = str.length;\n if (isString) {\n for (var i = 0; i < str.length; ++i) {\n var code = str.charCodeAt(i);\n if (code < 0x80) {\n bytes += 1;\n } else if (code < 0x800) {\n bytes += 2;\n } else if (code < 0xd800 || code >= 0xe000) {\n bytes += 3;\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));\n bytes += 4;\n }\n }\n } else {\n bytes = length;\n }\n bytes += this.encode(bytes * 8);\n this.update(str);\n return bytes;\n };\n\n Keccak.prototype.bytepad = function (strs, w) {\n var bytes = this.encode(w);\n for (var i = 0; i < strs.length; ++i) {\n bytes += this.encodeString(strs[i]);\n }\n var paddingBytes = (w - bytes % w) % w;\n var zeros = [];\n zeros.length = paddingBytes;\n this.update(zeros);\n return this;\n };\n\n Keccak.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;\n blocks[i >> 2] |= this.padding[i & 3];\n if (this.lastByteIndex === this.byteCount) {\n blocks[0] = blocks[blockCount];\n for (i = 1; i < blockCount + 1; ++i) {\n blocks[i] = 0;\n }\n }\n blocks[blockCount - 1] |= 0x80000000;\n for (i = 0; i < blockCount; ++i) {\n s[i] ^= blocks[i];\n }\n f(s);\n };\n\n Keccak.prototype.toString = Keccak.prototype.hex = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var hex = '', block;\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n block = s[i];\n hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +\n HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +\n HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +\n HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];\n }\n if (j % blockCount === 0) {\n s = cloneArray(s);\n f(s);\n i = 0;\n }\n }\n if (extraBytes) {\n block = s[i];\n hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];\n if (extraBytes > 1) {\n hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];\n }\n if (extraBytes > 2) {\n hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];\n }\n }\n return hex;\n };\n\n Keccak.prototype.arrayBuffer = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var bytes = this.outputBits >> 3;\n var buffer;\n if (extraBytes) {\n buffer = new ArrayBuffer((outputBlocks + 1) << 2);\n } else {\n buffer = new ArrayBuffer(bytes);\n }\n var array = new Uint32Array(buffer);\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n array[j] = s[i];\n }\n if (j % blockCount === 0) {\n s = cloneArray(s);\n f(s);\n }\n }\n if (extraBytes) {\n array[j] = s[i];\n buffer = buffer.slice(0, bytes);\n }\n return buffer;\n };\n\n Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;\n\n Keccak.prototype.digest = Keccak.prototype.array = function () {\n this.finalize();\n\n var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,\n extraBytes = this.extraBytes, i = 0, j = 0;\n var array = [], offset, block;\n while (j < outputBlocks) {\n for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {\n offset = j << 2;\n block = s[i];\n array[offset] = block & 0xFF;\n array[offset + 1] = (block >> 8) & 0xFF;\n array[offset + 2] = (block >> 16) & 0xFF;\n array[offset + 3] = (block >> 24) & 0xFF;\n }\n if (j % blockCount === 0) {\n s = cloneArray(s);\n f(s);\n }\n }\n if (extraBytes) {\n offset = j << 2;\n block = s[i];\n array[offset] = block & 0xFF;\n if (extraBytes > 1) {\n array[offset + 1] = (block >> 8) & 0xFF;\n }\n if (extraBytes > 2) {\n array[offset + 2] = (block >> 16) & 0xFF;\n }\n }\n return array;\n };\n\n function Kmac(bits, padding, outputBits) {\n Keccak.call(this, bits, padding, outputBits);\n }\n\n Kmac.prototype = new Keccak();\n\n Kmac.prototype.finalize = function () {\n this.encode(this.outputBits, true);\n return Keccak.prototype.finalize.call(this);\n };\n\n var f = function (s) {\n var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,\n b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,\n b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,\n b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;\n for (n = 0; n < 48; n += 2) {\n c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];\n c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];\n c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];\n c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];\n c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];\n c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];\n c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];\n c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];\n c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];\n c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];\n\n h = c8 ^ ((c2 << 1) | (c3 >>> 31));\n l = c9 ^ ((c3 << 1) | (c2 >>> 31));\n s[0] ^= h;\n s[1] ^= l;\n s[10] ^= h;\n s[11] ^= l;\n s[20] ^= h;\n s[21] ^= l;\n s[30] ^= h;\n s[31] ^= l;\n s[40] ^= h;\n s[41] ^= l;\n h = c0 ^ ((c4 << 1) | (c5 >>> 31));\n l = c1 ^ ((c5 << 1) | (c4 >>> 31));\n s[2] ^= h;\n s[3] ^= l;\n s[12] ^= h;\n s[13] ^= l;\n s[22] ^= h;\n s[23] ^= l;\n s[32] ^= h;\n s[33] ^= l;\n s[42] ^= h;\n s[43] ^= l;\n h = c2 ^ ((c6 << 1) | (c7 >>> 31));\n l = c3 ^ ((c7 << 1) | (c6 >>> 31));\n s[4] ^= h;\n s[5] ^= l;\n s[14] ^= h;\n s[15] ^= l;\n s[24] ^= h;\n s[25] ^= l;\n s[34] ^= h;\n s[35] ^= l;\n s[44] ^= h;\n s[45] ^= l;\n h = c4 ^ ((c8 << 1) | (c9 >>> 31));\n l = c5 ^ ((c9 << 1) | (c8 >>> 31));\n s[6] ^= h;\n s[7] ^= l;\n s[16] ^= h;\n s[17] ^= l;\n s[26] ^= h;\n s[27] ^= l;\n s[36] ^= h;\n s[37] ^= l;\n s[46] ^= h;\n s[47] ^= l;\n h = c6 ^ ((c0 << 1) | (c1 >>> 31));\n l = c7 ^ ((c1 << 1) | (c0 >>> 31));\n s[8] ^= h;\n s[9] ^= l;\n s[18] ^= h;\n s[19] ^= l;\n s[28] ^= h;\n s[29] ^= l;\n s[38] ^= h;\n s[39] ^= l;\n s[48] ^= h;\n s[49] ^= l;\n\n b0 = s[0];\n b1 = s[1];\n b32 = (s[11] << 4) | (s[10] >>> 28);\n b33 = (s[10] << 4) | (s[11] >>> 28);\n b14 = (s[20] << 3) | (s[21] >>> 29);\n b15 = (s[21] << 3) | (s[20] >>> 29);\n b46 = (s[31] << 9) | (s[30] >>> 23);\n b47 = (s[30] << 9) | (s[31] >>> 23);\n b28 = (s[40] << 18) | (s[41] >>> 14);\n b29 = (s[41] << 18) | (s[40] >>> 14);\n b20 = (s[2] << 1) | (s[3] >>> 31);\n b21 = (s[3] << 1) | (s[2] >>> 31);\n b2 = (s[13] << 12) | (s[12] >>> 20);\n b3 = (s[12] << 12) | (s[13] >>> 20);\n b34 = (s[22] << 10) | (s[23] >>> 22);\n b35 = (s[23] << 10) | (s[22] >>> 22);\n b16 = (s[33] << 13) | (s[32] >>> 19);\n b17 = (s[32] << 13) | (s[33] >>> 19);\n b48 = (s[42] << 2) | (s[43] >>> 30);\n b49 = (s[43] << 2) | (s[42] >>> 30);\n b40 = (s[5] << 30) | (s[4] >>> 2);\n b41 = (s[4] << 30) | (s[5] >>> 2);\n b22 = (s[14] << 6) | (s[15] >>> 26);\n b23 = (s[15] << 6) | (s[14] >>> 26);\n b4 = (s[25] << 11) | (s[24] >>> 21);\n b5 = (s[24] << 11) | (s[25] >>> 21);\n b36 = (s[34] << 15) | (s[35] >>> 17);\n b37 = (s[35] << 15) | (s[34] >>> 17);\n b18 = (s[45] << 29) | (s[44] >>> 3);\n b19 = (s[44] << 29) | (s[45] >>> 3);\n b10 = (s[6] << 28) | (s[7] >>> 4);\n b11 = (s[7] << 28) | (s[6] >>> 4);\n b42 = (s[17] << 23) | (s[16] >>> 9);\n b43 = (s[16] << 23) | (s[17] >>> 9);\n b24 = (s[26] << 25) | (s[27] >>> 7);\n b25 = (s[27] << 25) | (s[26] >>> 7);\n b6 = (s[36] << 21) | (s[37] >>> 11);\n b7 = (s[37] << 21) | (s[36] >>> 11);\n b38 = (s[47] << 24) | (s[46] >>> 8);\n b39 = (s[46] << 24) | (s[47] >>> 8);\n b30 = (s[8] << 27) | (s[9] >>> 5);\n b31 = (s[9] << 27) | (s[8] >>> 5);\n b12 = (s[18] << 20) | (s[19] >>> 12);\n b13 = (s[19] << 20) | (s[18] >>> 12);\n b44 = (s[29] << 7) | (s[28] >>> 25);\n b45 = (s[28] << 7) | (s[29] >>> 25);\n b26 = (s[38] << 8) | (s[39] >>> 24);\n b27 = (s[39] << 8) | (s[38] >>> 24);\n b8 = (s[48] << 14) | (s[49] >>> 18);\n b9 = (s[49] << 14) | (s[48] >>> 18);\n\n s[0] = b0 ^ (~b2 & b4);\n s[1] = b1 ^ (~b3 & b5);\n s[10] = b10 ^ (~b12 & b14);\n s[11] = b11 ^ (~b13 & b15);\n s[20] = b20 ^ (~b22 & b24);\n s[21] = b21 ^ (~b23 & b25);\n s[30] = b30 ^ (~b32 & b34);\n s[31] = b31 ^ (~b33 & b35);\n s[40] = b40 ^ (~b42 & b44);\n s[41] = b41 ^ (~b43 & b45);\n s[2] = b2 ^ (~b4 & b6);\n s[3] = b3 ^ (~b5 & b7);\n s[12] = b12 ^ (~b14 & b16);\n s[13] = b13 ^ (~b15 & b17);\n s[22] = b22 ^ (~b24 & b26);\n s[23] = b23 ^ (~b25 & b27);\n s[32] = b32 ^ (~b34 & b36);\n s[33] = b33 ^ (~b35 & b37);\n s[42] = b42 ^ (~b44 & b46);\n s[43] = b43 ^ (~b45 & b47);\n s[4] = b4 ^ (~b6 & b8);\n s[5] = b5 ^ (~b7 & b9);\n s[14] = b14 ^ (~b16 & b18);\n s[15] = b15 ^ (~b17 & b19);\n s[24] = b24 ^ (~b26 & b28);\n s[25] = b25 ^ (~b27 & b29);\n s[34] = b34 ^ (~b36 & b38);\n s[35] = b35 ^ (~b37 & b39);\n s[44] = b44 ^ (~b46 & b48);\n s[45] = b45 ^ (~b47 & b49);\n s[6] = b6 ^ (~b8 & b0);\n s[7] = b7 ^ (~b9 & b1);\n s[16] = b16 ^ (~b18 & b10);\n s[17] = b17 ^ (~b19 & b11);\n s[26] = b26 ^ (~b28 & b20);\n s[27] = b27 ^ (~b29 & b21);\n s[36] = b36 ^ (~b38 & b30);\n s[37] = b37 ^ (~b39 & b31);\n s[46] = b46 ^ (~b48 & b40);\n s[47] = b47 ^ (~b49 & b41);\n s[8] = b8 ^ (~b0 & b2);\n s[9] = b9 ^ (~b1 & b3);\n s[18] = b18 ^ (~b10 & b12);\n s[19] = b19 ^ (~b11 & b13);\n s[28] = b28 ^ (~b20 & b22);\n s[29] = b29 ^ (~b21 & b23);\n s[38] = b38 ^ (~b30 & b32);\n s[39] = b39 ^ (~b31 & b33);\n s[48] = b48 ^ (~b40 & b42);\n s[49] = b49 ^ (~b41 & b43);\n\n s[0] ^= RC[n];\n s[1] ^= RC[n + 1];\n }\n };\n\n if (COMMON_JS) {\n module.exports = methods;\n } else {\n for (i = 0; i < methodNames.length; ++i) {\n root[methodNames[i]] = methods[methodNames[i]];\n }\n if (AMD) {\n !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {\n return methods;\n }).call(exports, __webpack_require__, exports, module),\n\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n }\n})();\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/js-sha3/src/sha3.js?"); /***/ }), @@ -1338,6 +1207,28 @@ eval("\nmodule.exports = BufferWriter;\n\n// extends Writer\nvar Writer = __webp /***/ }), +/***/ "./node_modules/pvtsutils/build/index.js": +/*!***********************************************!*\ + !*** ./node_modules/pvtsutils/build/index.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; +eval("/*!\n * MIT License\n * \n * Copyright (c) 2017-2022 Peculiar Ventures, LLC\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n */\n\n\n\nconst ARRAY_BUFFER_NAME = \"[object ArrayBuffer]\";\nclass BufferSourceConverter {\n static isArrayBuffer(data) {\n return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME;\n }\n static toArrayBuffer(data) {\n if (this.isArrayBuffer(data)) {\n return data;\n }\n if (data.byteLength === data.buffer.byteLength) {\n return data.buffer;\n }\n if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {\n return data.buffer;\n }\n return this.toUint8Array(data.buffer)\n .slice(data.byteOffset, data.byteOffset + data.byteLength)\n .buffer;\n }\n static toUint8Array(data) {\n return this.toView(data, Uint8Array);\n }\n static toView(data, type) {\n if (data.constructor === type) {\n return data;\n }\n if (this.isArrayBuffer(data)) {\n return new type(data);\n }\n if (this.isArrayBufferView(data)) {\n return new type(data.buffer, data.byteOffset, data.byteLength);\n }\n throw new TypeError(\"The provided value is not of type '(ArrayBuffer or ArrayBufferView)'\");\n }\n static isBufferSource(data) {\n return this.isArrayBufferView(data)\n || this.isArrayBuffer(data);\n }\n static isArrayBufferView(data) {\n return ArrayBuffer.isView(data)\n || (data && this.isArrayBuffer(data.buffer));\n }\n static isEqual(a, b) {\n const aView = BufferSourceConverter.toUint8Array(a);\n const bView = BufferSourceConverter.toUint8Array(b);\n if (aView.length !== bView.byteLength) {\n return false;\n }\n for (let i = 0; i < aView.length; i++) {\n if (aView[i] !== bView[i]) {\n return false;\n }\n }\n return true;\n }\n static concat(...args) {\n let buffers;\n if (Array.isArray(args[0]) && !(args[1] instanceof Function)) {\n buffers = args[0];\n }\n else if (Array.isArray(args[0]) && args[1] instanceof Function) {\n buffers = args[0];\n }\n else {\n if (args[args.length - 1] instanceof Function) {\n buffers = args.slice(0, args.length - 1);\n }\n else {\n buffers = args;\n }\n }\n let size = 0;\n for (const buffer of buffers) {\n size += buffer.byteLength;\n }\n const res = new Uint8Array(size);\n let offset = 0;\n for (const buffer of buffers) {\n const view = this.toUint8Array(buffer);\n res.set(view, offset);\n offset += view.length;\n }\n if (args[args.length - 1] instanceof Function) {\n return this.toView(res, args[args.length - 1]);\n }\n return res.buffer;\n }\n}\n\nconst STRING_TYPE = \"string\";\nconst HEX_REGEX = /^[0-9a-f]+$/i;\nconst BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;\nconst BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;\nclass Utf8Converter {\n static fromString(text) {\n const s = unescape(encodeURIComponent(text));\n const uintArray = new Uint8Array(s.length);\n for (let i = 0; i < s.length; i++) {\n uintArray[i] = s.charCodeAt(i);\n }\n return uintArray.buffer;\n }\n static toString(buffer) {\n const buf = BufferSourceConverter.toUint8Array(buffer);\n let encodedString = \"\";\n for (let i = 0; i < buf.length; i++) {\n encodedString += String.fromCharCode(buf[i]);\n }\n const decodedString = decodeURIComponent(escape(encodedString));\n return decodedString;\n }\n}\nclass Utf16Converter {\n static toString(buffer, littleEndian = false) {\n const arrayBuffer = BufferSourceConverter.toArrayBuffer(buffer);\n const dataView = new DataView(arrayBuffer);\n let res = \"\";\n for (let i = 0; i < arrayBuffer.byteLength; i += 2) {\n const code = dataView.getUint16(i, littleEndian);\n res += String.fromCharCode(code);\n }\n return res;\n }\n static fromString(text, littleEndian = false) {\n const res = new ArrayBuffer(text.length * 2);\n const dataView = new DataView(res);\n for (let i = 0; i < text.length; i++) {\n dataView.setUint16(i * 2, text.charCodeAt(i), littleEndian);\n }\n return res;\n }\n}\nclass Convert {\n static isHex(data) {\n return typeof data === STRING_TYPE\n && HEX_REGEX.test(data);\n }\n static isBase64(data) {\n return typeof data === STRING_TYPE\n && BASE64_REGEX.test(data);\n }\n static isBase64Url(data) {\n return typeof data === STRING_TYPE\n && BASE64URL_REGEX.test(data);\n }\n static ToString(buffer, enc = \"utf8\") {\n const buf = BufferSourceConverter.toUint8Array(buffer);\n switch (enc.toLowerCase()) {\n case \"utf8\":\n return this.ToUtf8String(buf);\n case \"binary\":\n return this.ToBinary(buf);\n case \"hex\":\n return this.ToHex(buf);\n case \"base64\":\n return this.ToBase64(buf);\n case \"base64url\":\n return this.ToBase64Url(buf);\n case \"utf16le\":\n return Utf16Converter.toString(buf, true);\n case \"utf16\":\n case \"utf16be\":\n return Utf16Converter.toString(buf);\n default:\n throw new Error(`Unknown type of encoding '${enc}'`);\n }\n }\n static FromString(str, enc = \"utf8\") {\n if (!str) {\n return new ArrayBuffer(0);\n }\n switch (enc.toLowerCase()) {\n case \"utf8\":\n return this.FromUtf8String(str);\n case \"binary\":\n return this.FromBinary(str);\n case \"hex\":\n return this.FromHex(str);\n case \"base64\":\n return this.FromBase64(str);\n case \"base64url\":\n return this.FromBase64Url(str);\n case \"utf16le\":\n return Utf16Converter.fromString(str, true);\n case \"utf16\":\n case \"utf16be\":\n return Utf16Converter.fromString(str);\n default:\n throw new Error(`Unknown type of encoding '${enc}'`);\n }\n }\n static ToBase64(buffer) {\n const buf = BufferSourceConverter.toUint8Array(buffer);\n if (typeof btoa !== \"undefined\") {\n const binary = this.ToString(buf, \"binary\");\n return btoa(binary);\n }\n else {\n return Buffer.from(buf).toString(\"base64\");\n }\n }\n static FromBase64(base64) {\n const formatted = this.formatString(base64);\n if (!formatted) {\n return new ArrayBuffer(0);\n }\n if (!Convert.isBase64(formatted)) {\n throw new TypeError(\"Argument 'base64Text' is not Base64 encoded\");\n }\n if (typeof atob !== \"undefined\") {\n return this.FromBinary(atob(formatted));\n }\n else {\n return new Uint8Array(Buffer.from(formatted, \"base64\")).buffer;\n }\n }\n static FromBase64Url(base64url) {\n const formatted = this.formatString(base64url);\n if (!formatted) {\n return new ArrayBuffer(0);\n }\n if (!Convert.isBase64Url(formatted)) {\n throw new TypeError(\"Argument 'base64url' is not Base64Url encoded\");\n }\n return this.FromBase64(this.Base64Padding(formatted.replace(/\\-/g, \"+\").replace(/\\_/g, \"/\")));\n }\n static ToBase64Url(data) {\n return this.ToBase64(data).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/\\=/g, \"\");\n }\n static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) {\n switch (encoding) {\n case \"ascii\":\n return this.FromBinary(text);\n case \"utf8\":\n return Utf8Converter.fromString(text);\n case \"utf16\":\n case \"utf16be\":\n return Utf16Converter.fromString(text);\n case \"utf16le\":\n case \"usc2\":\n return Utf16Converter.fromString(text, true);\n default:\n throw new Error(`Unknown type of encoding '${encoding}'`);\n }\n }\n static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) {\n switch (encoding) {\n case \"ascii\":\n return this.ToBinary(buffer);\n case \"utf8\":\n return Utf8Converter.toString(buffer);\n case \"utf16\":\n case \"utf16be\":\n return Utf16Converter.toString(buffer);\n case \"utf16le\":\n case \"usc2\":\n return Utf16Converter.toString(buffer, true);\n default:\n throw new Error(`Unknown type of encoding '${encoding}'`);\n }\n }\n static FromBinary(text) {\n const stringLength = text.length;\n const resultView = new Uint8Array(stringLength);\n for (let i = 0; i < stringLength; i++) {\n resultView[i] = text.charCodeAt(i);\n }\n return resultView.buffer;\n }\n static ToBinary(buffer) {\n const buf = BufferSourceConverter.toUint8Array(buffer);\n let res = \"\";\n for (let i = 0; i < buf.length; i++) {\n res += String.fromCharCode(buf[i]);\n }\n return res;\n }\n static ToHex(buffer) {\n const buf = BufferSourceConverter.toUint8Array(buffer);\n let result = \"\";\n const len = buf.length;\n for (let i = 0; i < len; i++) {\n const byte = buf[i];\n if (byte < 16) {\n result += \"0\";\n }\n result += byte.toString(16);\n }\n return result;\n }\n static FromHex(hexString) {\n let formatted = this.formatString(hexString);\n if (!formatted) {\n return new ArrayBuffer(0);\n }\n if (!Convert.isHex(formatted)) {\n throw new TypeError(\"Argument 'hexString' is not HEX encoded\");\n }\n if (formatted.length % 2) {\n formatted = `0${formatted}`;\n }\n const res = new Uint8Array(formatted.length / 2);\n for (let i = 0; i < formatted.length; i = i + 2) {\n const c = formatted.slice(i, i + 2);\n res[i / 2] = parseInt(c, 16);\n }\n return res.buffer;\n }\n static ToUtf16String(buffer, littleEndian = false) {\n return Utf16Converter.toString(buffer, littleEndian);\n }\n static FromUtf16String(text, littleEndian = false) {\n return Utf16Converter.fromString(text, littleEndian);\n }\n static Base64Padding(base64) {\n const padCount = 4 - (base64.length % 4);\n if (padCount < 4) {\n for (let i = 0; i < padCount; i++) {\n base64 += \"=\";\n }\n }\n return base64;\n }\n static formatString(data) {\n return (data === null || data === void 0 ? void 0 : data.replace(/[\\n\\r\\t ]/g, \"\")) || \"\";\n }\n}\nConvert.DEFAULT_UTF8_ENCODING = \"utf8\";\n\nfunction assign(target, ...sources) {\n const res = arguments[0];\n for (let i = 1; i < arguments.length; i++) {\n const obj = arguments[i];\n for (const prop in obj) {\n res[prop] = obj[prop];\n }\n }\n return res;\n}\nfunction combine(...buf) {\n const totalByteLength = buf.map((item) => item.byteLength).reduce((prev, cur) => prev + cur);\n const res = new Uint8Array(totalByteLength);\n let currentPos = 0;\n buf.map((item) => new Uint8Array(item)).forEach((arr) => {\n for (const item2 of arr) {\n res[currentPos++] = item2;\n }\n });\n return res.buffer;\n}\nfunction isEqual(bytes1, bytes2) {\n if (!(bytes1 && bytes2)) {\n return false;\n }\n if (bytes1.byteLength !== bytes2.byteLength) {\n return false;\n }\n const b1 = new Uint8Array(bytes1);\n const b2 = new Uint8Array(bytes2);\n for (let i = 0; i < bytes1.byteLength; i++) {\n if (b1[i] !== b2[i]) {\n return false;\n }\n }\n return true;\n}\n\nexports.BufferSourceConverter = BufferSourceConverter;\nexports.Convert = Convert;\nexports.assign = assign;\nexports.combine = combine;\nexports.isEqual = isEqual;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/pvtsutils/build/index.js?"); + +/***/ }), + +/***/ "./node_modules/pvutils/build/utils.es.js": +/*!************************************************!*\ + !*** ./node_modules/pvutils/build/utils.es.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ arrayBufferToString: () => (/* binding */ arrayBufferToString),\n/* harmony export */ bufferToHexCodes: () => (/* binding */ bufferToHexCodes),\n/* harmony export */ checkBufferParams: () => (/* binding */ checkBufferParams),\n/* harmony export */ clearProps: () => (/* binding */ clearProps),\n/* harmony export */ fromBase64: () => (/* binding */ fromBase64),\n/* harmony export */ getParametersValue: () => (/* binding */ getParametersValue),\n/* harmony export */ getUTCDate: () => (/* binding */ getUTCDate),\n/* harmony export */ isEqualBuffer: () => (/* binding */ isEqualBuffer),\n/* harmony export */ nearestPowerOf2: () => (/* binding */ nearestPowerOf2),\n/* harmony export */ padNumber: () => (/* binding */ padNumber),\n/* harmony export */ stringToArrayBuffer: () => (/* binding */ stringToArrayBuffer),\n/* harmony export */ toBase64: () => (/* binding */ toBase64),\n/* harmony export */ utilConcatBuf: () => (/* binding */ utilConcatBuf),\n/* harmony export */ utilConcatView: () => (/* binding */ utilConcatView),\n/* harmony export */ utilDecodeTC: () => (/* binding */ utilDecodeTC),\n/* harmony export */ utilEncodeTC: () => (/* binding */ utilEncodeTC),\n/* harmony export */ utilFromBase: () => (/* binding */ utilFromBase),\n/* harmony export */ utilToBase: () => (/* binding */ utilToBase)\n/* harmony export */ });\n/*!\n Copyright (c) Peculiar Ventures, LLC\n*/\n\nfunction getUTCDate(date) {\r\n return new Date(date.getTime() + (date.getTimezoneOffset() * 60000));\r\n}\r\nfunction getParametersValue(parameters, name, defaultValue) {\r\n var _a;\r\n if ((parameters instanceof Object) === false) {\r\n return defaultValue;\r\n }\r\n return (_a = parameters[name]) !== null && _a !== void 0 ? _a : defaultValue;\r\n}\r\nfunction bufferToHexCodes(inputBuffer, inputOffset = 0, inputLength = (inputBuffer.byteLength - inputOffset), insertSpace = false) {\r\n let result = \"\";\r\n for (const item of (new Uint8Array(inputBuffer, inputOffset, inputLength))) {\r\n const str = item.toString(16).toUpperCase();\r\n if (str.length === 1) {\r\n result += \"0\";\r\n }\r\n result += str;\r\n if (insertSpace) {\r\n result += \" \";\r\n }\r\n }\r\n return result.trim();\r\n}\r\nfunction checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength) {\r\n if (!(inputBuffer instanceof ArrayBuffer)) {\r\n baseBlock.error = \"Wrong parameter: inputBuffer must be \\\"ArrayBuffer\\\"\";\r\n return false;\r\n }\r\n if (!inputBuffer.byteLength) {\r\n baseBlock.error = \"Wrong parameter: inputBuffer has zero length\";\r\n return false;\r\n }\r\n if (inputOffset < 0) {\r\n baseBlock.error = \"Wrong parameter: inputOffset less than zero\";\r\n return false;\r\n }\r\n if (inputLength < 0) {\r\n baseBlock.error = \"Wrong parameter: inputLength less than zero\";\r\n return false;\r\n }\r\n if ((inputBuffer.byteLength - inputOffset - inputLength) < 0) {\r\n baseBlock.error = \"End of input reached before message was fully decoded (inconsistent offset and length values)\";\r\n return false;\r\n }\r\n return true;\r\n}\r\nfunction utilFromBase(inputBuffer, inputBase) {\r\n let result = 0;\r\n if (inputBuffer.length === 1) {\r\n return inputBuffer[0];\r\n }\r\n for (let i = (inputBuffer.length - 1); i >= 0; i--) {\r\n result += inputBuffer[(inputBuffer.length - 1) - i] * Math.pow(2, inputBase * i);\r\n }\r\n return result;\r\n}\r\nfunction utilToBase(value, base, reserved = (-1)) {\r\n const internalReserved = reserved;\r\n let internalValue = value;\r\n let result = 0;\r\n let biggest = Math.pow(2, base);\r\n for (let i = 1; i < 8; i++) {\r\n if (value < biggest) {\r\n let retBuf;\r\n if (internalReserved < 0) {\r\n retBuf = new ArrayBuffer(i);\r\n result = i;\r\n }\r\n else {\r\n if (internalReserved < i) {\r\n return (new ArrayBuffer(0));\r\n }\r\n retBuf = new ArrayBuffer(internalReserved);\r\n result = internalReserved;\r\n }\r\n const retView = new Uint8Array(retBuf);\r\n for (let j = (i - 1); j >= 0; j--) {\r\n const basis = Math.pow(2, j * base);\r\n retView[result - j - 1] = Math.floor(internalValue / basis);\r\n internalValue -= (retView[result - j - 1]) * basis;\r\n }\r\n return retBuf;\r\n }\r\n biggest *= Math.pow(2, base);\r\n }\r\n return new ArrayBuffer(0);\r\n}\r\nfunction utilConcatBuf(...buffers) {\r\n let outputLength = 0;\r\n let prevLength = 0;\r\n for (const buffer of buffers) {\r\n outputLength += buffer.byteLength;\r\n }\r\n const retBuf = new ArrayBuffer(outputLength);\r\n const retView = new Uint8Array(retBuf);\r\n for (const buffer of buffers) {\r\n retView.set(new Uint8Array(buffer), prevLength);\r\n prevLength += buffer.byteLength;\r\n }\r\n return retBuf;\r\n}\r\nfunction utilConcatView(...views) {\r\n let outputLength = 0;\r\n let prevLength = 0;\r\n for (const view of views) {\r\n outputLength += view.length;\r\n }\r\n const retBuf = new ArrayBuffer(outputLength);\r\n const retView = new Uint8Array(retBuf);\r\n for (const view of views) {\r\n retView.set(view, prevLength);\r\n prevLength += view.length;\r\n }\r\n return retView;\r\n}\r\nfunction utilDecodeTC() {\r\n const buf = new Uint8Array(this.valueHex);\r\n if (this.valueHex.byteLength >= 2) {\r\n const condition1 = (buf[0] === 0xFF) && (buf[1] & 0x80);\r\n const condition2 = (buf[0] === 0x00) && ((buf[1] & 0x80) === 0x00);\r\n if (condition1 || condition2) {\r\n this.warnings.push(\"Needlessly long format\");\r\n }\r\n }\r\n const bigIntBuffer = new ArrayBuffer(this.valueHex.byteLength);\r\n const bigIntView = new Uint8Array(bigIntBuffer);\r\n for (let i = 0; i < this.valueHex.byteLength; i++) {\r\n bigIntView[i] = 0;\r\n }\r\n bigIntView[0] = (buf[0] & 0x80);\r\n const bigInt = utilFromBase(bigIntView, 8);\r\n const smallIntBuffer = new ArrayBuffer(this.valueHex.byteLength);\r\n const smallIntView = new Uint8Array(smallIntBuffer);\r\n for (let j = 0; j < this.valueHex.byteLength; j++) {\r\n smallIntView[j] = buf[j];\r\n }\r\n smallIntView[0] &= 0x7F;\r\n const smallInt = utilFromBase(smallIntView, 8);\r\n return (smallInt - bigInt);\r\n}\r\nfunction utilEncodeTC(value) {\r\n const modValue = (value < 0) ? (value * (-1)) : value;\r\n let bigInt = 128;\r\n for (let i = 1; i < 8; i++) {\r\n if (modValue <= bigInt) {\r\n if (value < 0) {\r\n const smallInt = bigInt - modValue;\r\n const retBuf = utilToBase(smallInt, 8, i);\r\n const retView = new Uint8Array(retBuf);\r\n retView[0] |= 0x80;\r\n return retBuf;\r\n }\r\n let retBuf = utilToBase(modValue, 8, i);\r\n let retView = new Uint8Array(retBuf);\r\n if (retView[0] & 0x80) {\r\n const tempBuf = retBuf.slice(0);\r\n const tempView = new Uint8Array(tempBuf);\r\n retBuf = new ArrayBuffer(retBuf.byteLength + 1);\r\n retView = new Uint8Array(retBuf);\r\n for (let k = 0; k < tempBuf.byteLength; k++) {\r\n retView[k + 1] = tempView[k];\r\n }\r\n retView[0] = 0x00;\r\n }\r\n return retBuf;\r\n }\r\n bigInt *= Math.pow(2, 8);\r\n }\r\n return (new ArrayBuffer(0));\r\n}\r\nfunction isEqualBuffer(inputBuffer1, inputBuffer2) {\r\n if (inputBuffer1.byteLength !== inputBuffer2.byteLength) {\r\n return false;\r\n }\r\n const view1 = new Uint8Array(inputBuffer1);\r\n const view2 = new Uint8Array(inputBuffer2);\r\n for (let i = 0; i < view1.length; i++) {\r\n if (view1[i] !== view2[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\nfunction padNumber(inputNumber, fullLength) {\r\n const str = inputNumber.toString(10);\r\n if (fullLength < str.length) {\r\n return \"\";\r\n }\r\n const dif = fullLength - str.length;\r\n const padding = new Array(dif);\r\n for (let i = 0; i < dif; i++) {\r\n padding[i] = \"0\";\r\n }\r\n const paddingString = padding.join(\"\");\r\n return paddingString.concat(str);\r\n}\r\nconst base64Template = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\nconst base64UrlTemplate = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=\";\r\nfunction toBase64(input, useUrlTemplate = false, skipPadding = false, skipLeadingZeros = false) {\r\n let i = 0;\r\n let flag1 = 0;\r\n let flag2 = 0;\r\n let output = \"\";\r\n const template = (useUrlTemplate) ? base64UrlTemplate : base64Template;\r\n if (skipLeadingZeros) {\r\n let nonZeroPosition = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n if (input.charCodeAt(i) !== 0) {\r\n nonZeroPosition = i;\r\n break;\r\n }\r\n }\r\n input = input.slice(nonZeroPosition);\r\n }\r\n while (i < input.length) {\r\n const chr1 = input.charCodeAt(i++);\r\n if (i >= input.length) {\r\n flag1 = 1;\r\n }\r\n const chr2 = input.charCodeAt(i++);\r\n if (i >= input.length) {\r\n flag2 = 1;\r\n }\r\n const chr3 = input.charCodeAt(i++);\r\n const enc1 = chr1 >> 2;\r\n const enc2 = ((chr1 & 0x03) << 4) | (chr2 >> 4);\r\n let enc3 = ((chr2 & 0x0F) << 2) | (chr3 >> 6);\r\n let enc4 = chr3 & 0x3F;\r\n if (flag1 === 1) {\r\n enc3 = enc4 = 64;\r\n }\r\n else {\r\n if (flag2 === 1) {\r\n enc4 = 64;\r\n }\r\n }\r\n if (skipPadding) {\r\n if (enc3 === 64) {\r\n output += `${template.charAt(enc1)}${template.charAt(enc2)}`;\r\n }\r\n else {\r\n if (enc4 === 64) {\r\n output += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}`;\r\n }\r\n else {\r\n output += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}${template.charAt(enc4)}`;\r\n }\r\n }\r\n }\r\n else {\r\n output += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}${template.charAt(enc4)}`;\r\n }\r\n }\r\n return output;\r\n}\r\nfunction fromBase64(input, useUrlTemplate = false, cutTailZeros = false) {\r\n const template = (useUrlTemplate) ? base64UrlTemplate : base64Template;\r\n function indexOf(toSearch) {\r\n for (let i = 0; i < 64; i++) {\r\n if (template.charAt(i) === toSearch)\r\n return i;\r\n }\r\n return 64;\r\n }\r\n function test(incoming) {\r\n return ((incoming === 64) ? 0x00 : incoming);\r\n }\r\n let i = 0;\r\n let output = \"\";\r\n while (i < input.length) {\r\n const enc1 = indexOf(input.charAt(i++));\r\n const enc2 = (i >= input.length) ? 0x00 : indexOf(input.charAt(i++));\r\n const enc3 = (i >= input.length) ? 0x00 : indexOf(input.charAt(i++));\r\n const enc4 = (i >= input.length) ? 0x00 : indexOf(input.charAt(i++));\r\n const chr1 = (test(enc1) << 2) | (test(enc2) >> 4);\r\n const chr2 = ((test(enc2) & 0x0F) << 4) | (test(enc3) >> 2);\r\n const chr3 = ((test(enc3) & 0x03) << 6) | test(enc4);\r\n output += String.fromCharCode(chr1);\r\n if (enc3 !== 64) {\r\n output += String.fromCharCode(chr2);\r\n }\r\n if (enc4 !== 64) {\r\n output += String.fromCharCode(chr3);\r\n }\r\n }\r\n if (cutTailZeros) {\r\n const outputLength = output.length;\r\n let nonZeroStart = (-1);\r\n for (let i = (outputLength - 1); i >= 0; i--) {\r\n if (output.charCodeAt(i) !== 0) {\r\n nonZeroStart = i;\r\n break;\r\n }\r\n }\r\n if (nonZeroStart !== (-1)) {\r\n output = output.slice(0, nonZeroStart + 1);\r\n }\r\n else {\r\n output = \"\";\r\n }\r\n }\r\n return output;\r\n}\r\nfunction arrayBufferToString(buffer) {\r\n let resultString = \"\";\r\n const view = new Uint8Array(buffer);\r\n for (const element of view) {\r\n resultString += String.fromCharCode(element);\r\n }\r\n return resultString;\r\n}\r\nfunction stringToArrayBuffer(str) {\r\n const stringLength = str.length;\r\n const resultBuffer = new ArrayBuffer(stringLength);\r\n const resultView = new Uint8Array(resultBuffer);\r\n for (let i = 0; i < stringLength; i++) {\r\n resultView[i] = str.charCodeAt(i);\r\n }\r\n return resultBuffer;\r\n}\r\nconst log2 = Math.log(2);\r\nfunction nearestPowerOf2(length) {\r\n const base = (Math.log(length) / log2);\r\n const floor = Math.floor(base);\r\n const round = Math.round(base);\r\n return ((floor === round) ? floor : round);\r\n}\r\nfunction clearProps(object, propsArray) {\r\n for (const prop of propsArray) {\r\n delete object[prop];\r\n }\r\n}\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/pvutils/build/utils.es.js?"); + +/***/ }), + /***/ "./node_modules/qrcode/lib/browser.js": /*!********************************************!*\ !*** ./node_modules/qrcode/lib/browser.js ***! @@ -1608,250 +1499,6 @@ eval("function hex2rgba (hex) {\n if (typeof hex === 'number') {\n hex = hex /***/ }), -/***/ "./node_modules/rate-limiter-flexible/index.js": -/*!*****************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/index.js ***! - \*****************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterRedis = __webpack_require__(/*! ./lib/RateLimiterRedis */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRedis.js\");\nconst RateLimiterMongo = __webpack_require__(/*! ./lib/RateLimiterMongo */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterMongo.js\");\nconst RateLimiterMySQL = __webpack_require__(/*! ./lib/RateLimiterMySQL */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterMySQL.js\");\nconst RateLimiterPostgres = __webpack_require__(/*! ./lib/RateLimiterPostgres */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterPostgres.js\");\nconst {RateLimiterClusterMaster, RateLimiterClusterMasterPM2, RateLimiterCluster} = __webpack_require__(/*! ./lib/RateLimiterCluster */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js\");\nconst RateLimiterMemory = __webpack_require__(/*! ./lib/RateLimiterMemory */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterMemory.js\");\nconst RateLimiterMemcache = __webpack_require__(/*! ./lib/RateLimiterMemcache */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterMemcache.js\");\nconst RLWrapperBlackAndWhite = __webpack_require__(/*! ./lib/RLWrapperBlackAndWhite */ \"./node_modules/rate-limiter-flexible/lib/RLWrapperBlackAndWhite.js\");\nconst RateLimiterUnion = __webpack_require__(/*! ./lib/RateLimiterUnion */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterUnion.js\");\nconst RateLimiterQueue = __webpack_require__(/*! ./lib/RateLimiterQueue */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterQueue.js\");\nconst BurstyRateLimiter = __webpack_require__(/*! ./lib/BurstyRateLimiter */ \"./node_modules/rate-limiter-flexible/lib/BurstyRateLimiter.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./lib/RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nmodule.exports = {\n RateLimiterRedis,\n RateLimiterMongo,\n RateLimiterMySQL,\n RateLimiterPostgres,\n RateLimiterMemory,\n RateLimiterMemcache,\n RateLimiterClusterMaster,\n RateLimiterClusterMasterPM2,\n RateLimiterCluster,\n RLWrapperBlackAndWhite,\n RateLimiterUnion,\n RateLimiterQueue,\n BurstyRateLimiter,\n RateLimiterRes,\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/index.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/BurstyRateLimiter.js": -/*!*********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/BurstyRateLimiter.js ***! - \*********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\n/**\n * Bursty rate limiter exposes only msBeforeNext time and doesn't expose points from bursty limiter by default\n * @type {BurstyRateLimiter}\n */\nmodule.exports = class BurstyRateLimiter {\n constructor(rateLimiter, burstLimiter) {\n this._rateLimiter = rateLimiter;\n this._burstLimiter = burstLimiter\n }\n\n /**\n * Merge rate limiter response objects. Responses can be null\n *\n * @param {RateLimiterRes} [rlRes] Rate limiter response\n * @param {RateLimiterRes} [blRes] Bursty limiter response\n */\n _combineRes(rlRes, blRes) {\n if (!rlRes) {\n return null\n }\n\n return new RateLimiterRes(\n rlRes.remainingPoints,\n Math.min(rlRes.msBeforeNext, blRes ? blRes.msBeforeNext : 0),\n rlRes.consumedPoints,\n rlRes.isFirstInDuration\n )\n }\n\n /**\n * @param key\n * @param pointsToConsume\n * @param options\n * @returns {Promise}\n */\n consume(key, pointsToConsume = 1, options = {}) {\n return this._rateLimiter.consume(key, pointsToConsume, options)\n .catch((rlRej) => {\n if (rlRej instanceof RateLimiterRes) {\n return this._burstLimiter.consume(key, pointsToConsume, options)\n .then((blRes) => {\n return Promise.resolve(this._combineRes(rlRej, blRes))\n })\n .catch((blRej) => {\n if (blRej instanceof RateLimiterRes) {\n return Promise.reject(this._combineRes(rlRej, blRej))\n } else {\n return Promise.reject(blRej)\n }\n }\n )\n } else {\n return Promise.reject(rlRej)\n }\n })\n }\n\n /**\n * It doesn't expose available points from burstLimiter\n *\n * @param key\n * @returns {Promise}\n */\n get(key) {\n return Promise.all([\n this._rateLimiter.get(key),\n this._burstLimiter.get(key),\n ]).then(([rlRes, blRes]) => {\n return this._combineRes(rlRes, blRes);\n });\n }\n\n get points() {\n return this._rateLimiter.points;\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/BurstyRateLimiter.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RLWrapperBlackAndWhite.js": -/*!**************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RLWrapperBlackAndWhite.js ***! - \**************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nmodule.exports = class RLWrapperBlackAndWhite {\n constructor(opts = {}) {\n this.limiter = opts.limiter;\n this.blackList = opts.blackList;\n this.whiteList = opts.whiteList;\n this.isBlackListed = opts.isBlackListed;\n this.isWhiteListed = opts.isWhiteListed;\n this.runActionAnyway = opts.runActionAnyway;\n }\n\n get limiter() {\n return this._limiter;\n }\n\n set limiter(value) {\n if (typeof value === 'undefined') {\n throw new Error('limiter is not set');\n }\n\n this._limiter = value;\n }\n\n get runActionAnyway() {\n return this._runActionAnyway;\n }\n\n set runActionAnyway(value) {\n this._runActionAnyway = typeof value === 'undefined' ? false : value;\n }\n\n get blackList() {\n return this._blackList;\n }\n\n set blackList(value) {\n this._blackList = Array.isArray(value) ? value : [];\n }\n\n get isBlackListed() {\n return this._isBlackListed;\n }\n\n set isBlackListed(func) {\n if (typeof func === 'undefined') {\n func = () => false;\n }\n if (typeof func !== 'function') {\n throw new Error('isBlackListed must be function');\n }\n this._isBlackListed = func;\n }\n\n get whiteList() {\n return this._whiteList;\n }\n\n set whiteList(value) {\n this._whiteList = Array.isArray(value) ? value : [];\n }\n\n get isWhiteListed() {\n return this._isWhiteListed;\n }\n\n set isWhiteListed(func) {\n if (typeof func === 'undefined') {\n func = () => false;\n }\n if (typeof func !== 'function') {\n throw new Error('isWhiteListed must be function');\n }\n this._isWhiteListed = func;\n }\n\n isBlackListedSomewhere(key) {\n return this.blackList.indexOf(key) >= 0 || this.isBlackListed(key);\n }\n\n isWhiteListedSomewhere(key) {\n return this.whiteList.indexOf(key) >= 0 || this.isWhiteListed(key);\n }\n\n getBlackRes() {\n return new RateLimiterRes(0, Number.MAX_SAFE_INTEGER, 0, false);\n }\n\n getWhiteRes() {\n return new RateLimiterRes(Number.MAX_SAFE_INTEGER, 0, 0, false);\n }\n\n rejectBlack() {\n return Promise.reject(this.getBlackRes());\n }\n\n resolveBlack() {\n return Promise.resolve(this.getBlackRes());\n }\n\n resolveWhite() {\n return Promise.resolve(this.getWhiteRes());\n }\n\n consume(key, pointsToConsume = 1) {\n let res;\n if (this.isWhiteListedSomewhere(key)) {\n res = this.resolveWhite();\n } else if (this.isBlackListedSomewhere(key)) {\n res = this.rejectBlack();\n }\n\n if (typeof res === 'undefined') {\n return this.limiter.consume(key, pointsToConsume);\n }\n\n if (this.runActionAnyway) {\n this.limiter.consume(key, pointsToConsume).catch(() => {});\n }\n return res;\n }\n\n block(key, secDuration) {\n let res;\n if (this.isWhiteListedSomewhere(key)) {\n res = this.resolveWhite();\n } else if (this.isBlackListedSomewhere(key)) {\n res = this.resolveBlack();\n }\n\n if (typeof res === 'undefined') {\n return this.limiter.block(key, secDuration);\n }\n\n if (this.runActionAnyway) {\n this.limiter.block(key, secDuration).catch(() => {});\n }\n return res;\n }\n\n penalty(key, points) {\n let res;\n if (this.isWhiteListedSomewhere(key)) {\n res = this.resolveWhite();\n } else if (this.isBlackListedSomewhere(key)) {\n res = this.resolveBlack();\n }\n\n if (typeof res === 'undefined') {\n return this.limiter.penalty(key, points);\n }\n\n if (this.runActionAnyway) {\n this.limiter.penalty(key, points).catch(() => {});\n }\n return res;\n }\n\n reward(key, points) {\n let res;\n if (this.isWhiteListedSomewhere(key)) {\n res = this.resolveWhite();\n } else if (this.isBlackListedSomewhere(key)) {\n res = this.resolveBlack();\n }\n\n if (typeof res === 'undefined') {\n return this.limiter.reward(key, points);\n }\n\n if (this.runActionAnyway) {\n this.limiter.reward(key, points).catch(() => {});\n }\n return res;\n }\n\n get(key) {\n let res;\n if (this.isWhiteListedSomewhere(key)) {\n res = this.resolveWhite();\n } else if (this.isBlackListedSomewhere(key)) {\n res = this.resolveBlack();\n }\n\n if (typeof res === 'undefined' || this.runActionAnyway) {\n return this.limiter.get(key);\n }\n\n return res;\n }\n\n delete(key) {\n return this.limiter.delete(key);\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RLWrapperBlackAndWhite.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js": -/*!***********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js ***! - \***********************************************************************/ -/***/ ((module) => { - -eval("module.exports = class RateLimiterAbstract {\n /**\n *\n * @param opts Object Defaults {\n * points: 4, // Number of points\n * duration: 1, // Per seconds\n * blockDuration: 0, // Block if consumed more than points in current duration for blockDuration seconds\n * execEvenly: false, // Execute allowed actions evenly over duration\n * execEvenlyMinDelayMs: duration * 1000 / points, // ms, works with execEvenly=true option\n * keyPrefix: 'rlflx',\n * }\n */\n constructor(opts = {}) {\n this.points = opts.points;\n this.duration = opts.duration;\n this.blockDuration = opts.blockDuration;\n this.execEvenly = opts.execEvenly;\n this.execEvenlyMinDelayMs = opts.execEvenlyMinDelayMs;\n this.keyPrefix = opts.keyPrefix;\n }\n\n get points() {\n return this._points;\n }\n\n set points(value) {\n this._points = value >= 0 ? value : 4;\n }\n\n get duration() {\n return this._duration;\n }\n\n set duration(value) {\n this._duration = typeof value === 'undefined' ? 1 : value;\n }\n\n get msDuration() {\n return this.duration * 1000;\n }\n\n get blockDuration() {\n return this._blockDuration;\n }\n\n set blockDuration(value) {\n this._blockDuration = typeof value === 'undefined' ? 0 : value;\n }\n\n get msBlockDuration() {\n return this.blockDuration * 1000;\n }\n\n get execEvenly() {\n return this._execEvenly;\n }\n\n set execEvenly(value) {\n this._execEvenly = typeof value === 'undefined' ? false : Boolean(value);\n }\n\n get execEvenlyMinDelayMs() {\n return this._execEvenlyMinDelayMs;\n }\n\n set execEvenlyMinDelayMs(value) {\n this._execEvenlyMinDelayMs = typeof value === 'undefined' ? Math.ceil(this.msDuration / this.points) : value;\n }\n\n get keyPrefix() {\n return this._keyPrefix;\n }\n\n set keyPrefix(value) {\n if (typeof value === 'undefined') {\n value = 'rlflx';\n }\n if (typeof value !== 'string') {\n throw new Error('keyPrefix must be string');\n }\n this._keyPrefix = value;\n }\n\n _getKeySecDuration(options = {}) {\n return options && options.customDuration >= 0\n ? options.customDuration\n : this.duration;\n }\n\n getKey(key) {\n return this.keyPrefix.length > 0 ? `${this.keyPrefix}:${key}` : key;\n }\n\n parseKey(rlKey) {\n return rlKey.substring(this.keyPrefix.length);\n }\n\n consume() {\n throw new Error(\"You have to implement the method 'consume'!\");\n }\n\n penalty() {\n throw new Error(\"You have to implement the method 'penalty'!\");\n }\n\n reward() {\n throw new Error(\"You have to implement the method 'reward'!\");\n }\n\n get() {\n throw new Error(\"You have to implement the method 'get'!\");\n }\n\n set() {\n throw new Error(\"You have to implement the method 'set'!\");\n }\n\n block() {\n throw new Error(\"You have to implement the method 'block'!\");\n }\n\n delete() {\n throw new Error(\"You have to implement the method 'delete'!\");\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js": -/*!**********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js ***! - \**********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("/**\n * Implements rate limiting in cluster using built-in IPC\n *\n * Two classes are described here: master and worker\n * Master have to be create in the master process without any options.\n * Any number of rate limiters can be created in workers, but each rate limiter must be with unique keyPrefix\n *\n * Workflow:\n * 1. master rate limiter created in master process\n * 2. worker rate limiter sends 'init' message with necessary options during creating\n * 3. master receives options and adds new rate limiter by keyPrefix if it isn't created yet\n * 4. master sends 'init' back to worker's rate limiter\n * 5. worker can process requests immediately,\n * but they will be postponed by 'workerWaitInit' until master sends 'init' to worker\n * 6. every request to worker rate limiter creates a promise\n * 7. if master doesn't response for 'timeout', promise is rejected\n * 8. master sends 'resolve' or 'reject' command to worker\n * 9. worker resolves or rejects promise depending on message from master\n *\n */\n\nconst cluster = __webpack_require__(/*! cluster */ \"?76c6\");\nconst crypto = __webpack_require__(/*! crypto */ \"?4a7d\");\nconst RateLimiterAbstract = __webpack_require__(/*! ./RateLimiterAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js\");\nconst RateLimiterMemory = __webpack_require__(/*! ./RateLimiterMemory */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterMemory.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nconst channel = 'rate_limiter_flexible';\nlet masterInstance = null;\n\nconst masterSendToWorker = function (worker, msg, type, res) {\n let data;\n if (res === null || res === true || res === false) {\n data = res;\n } else {\n data = {\n remainingPoints: res.remainingPoints,\n msBeforeNext: res.msBeforeNext,\n consumedPoints: res.consumedPoints,\n isFirstInDuration: res.isFirstInDuration,\n };\n }\n worker.send({\n channel,\n keyPrefix: msg.keyPrefix, // which rate limiter exactly\n promiseId: msg.promiseId,\n type,\n data,\n });\n};\n\nconst workerWaitInit = function (payload) {\n setTimeout(() => {\n if (this._initiated) {\n process.send(payload);\n // Promise will be removed by timeout if too long\n } else if (typeof this._promises[payload.promiseId] !== 'undefined') {\n workerWaitInit.call(this, payload);\n }\n }, 30);\n};\n\nconst workerSendToMaster = function (func, promiseId, key, arg, opts) {\n const payload = {\n channel,\n keyPrefix: this.keyPrefix,\n func,\n promiseId,\n data: {\n key,\n arg,\n opts,\n },\n };\n\n if (!this._initiated) {\n // Wait init before sending messages to master\n workerWaitInit.call(this, payload);\n } else {\n process.send(payload);\n }\n};\n\nconst masterProcessMsg = function (worker, msg) {\n if (!msg || msg.channel !== channel || typeof this._rateLimiters[msg.keyPrefix] === 'undefined') {\n return false;\n }\n\n let promise;\n\n switch (msg.func) {\n case 'consume':\n promise = this._rateLimiters[msg.keyPrefix].consume(msg.data.key, msg.data.arg, msg.data.opts);\n break;\n case 'penalty':\n promise = this._rateLimiters[msg.keyPrefix].penalty(msg.data.key, msg.data.arg, msg.data.opts);\n break;\n case 'reward':\n promise = this._rateLimiters[msg.keyPrefix].reward(msg.data.key, msg.data.arg, msg.data.opts);\n break;\n case 'block':\n promise = this._rateLimiters[msg.keyPrefix].block(msg.data.key, msg.data.arg, msg.data.opts);\n break;\n case 'get':\n promise = this._rateLimiters[msg.keyPrefix].get(msg.data.key, msg.data.opts);\n break;\n case 'delete':\n promise = this._rateLimiters[msg.keyPrefix].delete(msg.data.key, msg.data.opts);\n break;\n default:\n return false;\n }\n\n if (promise) {\n promise\n .then((res) => {\n masterSendToWorker(worker, msg, 'resolve', res);\n })\n .catch((rejRes) => {\n masterSendToWorker(worker, msg, 'reject', rejRes);\n });\n }\n};\n\nconst workerProcessMsg = function (msg) {\n if (!msg || msg.channel !== channel || msg.keyPrefix !== this.keyPrefix) {\n return false;\n }\n\n if (this._promises[msg.promiseId]) {\n clearTimeout(this._promises[msg.promiseId].timeoutId);\n let res;\n if (msg.data === null || msg.data === true || msg.data === false) {\n res = msg.data;\n } else {\n res = new RateLimiterRes(\n msg.data.remainingPoints,\n msg.data.msBeforeNext,\n msg.data.consumedPoints,\n msg.data.isFirstInDuration // eslint-disable-line comma-dangle\n );\n }\n\n switch (msg.type) {\n case 'resolve':\n this._promises[msg.promiseId].resolve(res);\n break;\n case 'reject':\n this._promises[msg.promiseId].reject(res);\n break;\n default:\n throw new Error(`RateLimiterCluster: no such message type '${msg.type}'`);\n }\n\n delete this._promises[msg.promiseId];\n }\n};\n/**\n * Prepare options to send to master\n * Master will create rate limiter depending on options\n *\n * @returns {{points: *, duration: *, blockDuration: *, execEvenly: *, execEvenlyMinDelayMs: *, keyPrefix: *}}\n */\nconst getOpts = function () {\n return {\n points: this.points,\n duration: this.duration,\n blockDuration: this.blockDuration,\n execEvenly: this.execEvenly,\n execEvenlyMinDelayMs: this.execEvenlyMinDelayMs,\n keyPrefix: this.keyPrefix,\n };\n};\n\nconst savePromise = function (resolve, reject) {\n const hrtime = process.hrtime();\n let promiseId = hrtime[0].toString() + hrtime[1].toString();\n\n if (typeof this._promises[promiseId] !== 'undefined') {\n promiseId += crypto.randomBytes(12).toString('base64');\n }\n\n this._promises[promiseId] = {\n resolve,\n reject,\n timeoutId: setTimeout(() => {\n delete this._promises[promiseId];\n reject(new Error('RateLimiterCluster timeout: no answer from master in time'));\n }, this.timeoutMs),\n };\n\n return promiseId;\n};\n\nclass RateLimiterClusterMaster {\n constructor() {\n if (masterInstance) {\n return masterInstance;\n }\n\n this._rateLimiters = {};\n\n cluster.setMaxListeners(0);\n\n cluster.on('message', (worker, msg) => {\n if (msg && msg.channel === channel && msg.type === 'init') {\n // If init request, check or create rate limiter by key prefix and send 'init' back to worker\n if (typeof this._rateLimiters[msg.opts.keyPrefix] === 'undefined') {\n this._rateLimiters[msg.opts.keyPrefix] = new RateLimiterMemory(msg.opts);\n }\n\n worker.send({\n channel,\n type: 'init',\n keyPrefix: msg.opts.keyPrefix,\n });\n } else {\n masterProcessMsg.call(this, worker, msg);\n }\n });\n\n masterInstance = this;\n }\n}\n\nclass RateLimiterClusterMasterPM2 {\n constructor(pm2) {\n if (masterInstance) {\n return masterInstance;\n }\n\n this._rateLimiters = {};\n\n pm2.launchBus((err, pm2Bus) => {\n pm2Bus.on('process:msg', (packet) => {\n const msg = packet.raw;\n if (msg && msg.channel === channel && msg.type === 'init') {\n // If init request, check or create rate limiter by key prefix and send 'init' back to worker\n if (typeof this._rateLimiters[msg.opts.keyPrefix] === 'undefined') {\n this._rateLimiters[msg.opts.keyPrefix] = new RateLimiterMemory(msg.opts);\n }\n\n pm2.sendDataToProcessId(packet.process.pm_id, {\n data: {},\n topic: channel,\n channel,\n type: 'init',\n keyPrefix: msg.opts.keyPrefix,\n }, (sendErr, res) => {\n if (sendErr) {\n console.log(sendErr, res);\n }\n });\n } else {\n const worker = {\n send: (msgData) => {\n const pm2Message = msgData;\n pm2Message.topic = channel;\n if (typeof pm2Message.data === 'undefined') {\n pm2Message.data = {};\n }\n pm2.sendDataToProcessId(packet.process.pm_id, pm2Message, (sendErr, res) => {\n if (sendErr) {\n console.log(sendErr, res);\n }\n });\n },\n };\n masterProcessMsg.call(this, worker, msg);\n }\n });\n });\n\n masterInstance = this;\n }\n}\n\nclass RateLimiterClusterWorker extends RateLimiterAbstract {\n get timeoutMs() {\n return this._timeoutMs;\n }\n\n set timeoutMs(value) {\n this._timeoutMs = typeof value === 'undefined' ? 5000 : Math.abs(parseInt(value));\n }\n\n constructor(opts = {}) {\n super(opts);\n\n process.setMaxListeners(0);\n\n this.timeoutMs = opts.timeoutMs;\n\n this._initiated = false;\n\n process.on('message', (msg) => {\n if (msg && msg.channel === channel && msg.type === 'init' && msg.keyPrefix === this.keyPrefix) {\n this._initiated = true;\n } else {\n workerProcessMsg.call(this, msg);\n }\n });\n\n // Create limiter on master with specific options\n process.send({\n channel,\n type: 'init',\n opts: getOpts.call(this),\n });\n\n this._promises = {};\n }\n\n consume(key, pointsToConsume = 1, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'consume', promiseId, key, pointsToConsume, options);\n });\n }\n\n penalty(key, points = 1, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'penalty', promiseId, key, points, options);\n });\n }\n\n reward(key, points = 1, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'reward', promiseId, key, points, options);\n });\n }\n\n block(key, secDuration, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'block', promiseId, key, secDuration, options);\n });\n }\n\n get(key, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'get', promiseId, key, options);\n });\n }\n\n delete(key, options = {}) {\n return new Promise((resolve, reject) => {\n const promiseId = savePromise.call(this, resolve, reject);\n\n workerSendToMaster.call(this, 'delete', promiseId, key, options);\n });\n }\n}\n\nmodule.exports = {\n RateLimiterClusterMaster,\n RateLimiterClusterMasterPM2,\n RateLimiterCluster: RateLimiterClusterWorker,\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterMemcache.js": -/*!***********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterMemcache.js ***! - \***********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterStoreAbstract = __webpack_require__(/*! ./RateLimiterStoreAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nclass RateLimiterMemcache extends RateLimiterStoreAbstract {\n /**\n *\n * @param {Object} opts\n * Defaults {\n * ... see other in RateLimiterStoreAbstract\n *\n * storeClient: memcacheClient\n * }\n */\n constructor(opts) {\n super(opts);\n\n this.client = opts.storeClient;\n }\n\n _getRateLimiterRes(rlKey, changedPoints, result) {\n const res = new RateLimiterRes();\n res.consumedPoints = parseInt(result.consumedPoints);\n res.isFirstInDuration = result.consumedPoints === changedPoints;\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n res.msBeforeNext = result.msBeforeNext;\n\n return res;\n }\n\n _upsert(rlKey, points, msDuration, forceExpire = false, options = {}) {\n return new Promise((resolve, reject) => {\n const nowMs = Date.now();\n const secDuration = Math.floor(msDuration / 1000);\n\n if (forceExpire) {\n this.client.set(rlKey, points, secDuration, (err) => {\n if (!err) {\n this.client.set(\n `${rlKey}_expire`,\n secDuration > 0 ? nowMs + (secDuration * 1000) : -1,\n secDuration,\n () => {\n const res = {\n consumedPoints: points,\n msBeforeNext: secDuration > 0 ? secDuration * 1000 : -1,\n };\n resolve(res);\n }\n );\n } else {\n reject(err);\n }\n });\n } else {\n this.client.incr(rlKey, points, (err, consumedPoints) => {\n if (err || consumedPoints === false) {\n this.client.add(rlKey, points, secDuration, (errAddKey, createdNew) => {\n if (errAddKey || !createdNew) {\n // Try to upsert again in case of race condition\n if (typeof options.attemptNumber === 'undefined' || options.attemptNumber < 3) {\n const nextOptions = Object.assign({}, options);\n nextOptions.attemptNumber = nextOptions.attemptNumber ? (nextOptions.attemptNumber + 1) : 1;\n\n this._upsert(rlKey, points, msDuration, forceExpire, nextOptions)\n .then(resUpsert => resolve(resUpsert))\n .catch(errUpsert => reject(errUpsert));\n } else {\n reject(new Error('Can not add key'));\n }\n } else {\n this.client.add(\n `${rlKey}_expire`,\n secDuration > 0 ? nowMs + (secDuration * 1000) : -1,\n secDuration,\n () => {\n const res = {\n consumedPoints: points,\n msBeforeNext: secDuration > 0 ? secDuration * 1000 : -1,\n };\n resolve(res);\n }\n );\n }\n });\n } else {\n this.client.get(`${rlKey}_expire`, (errGetExpire, resGetExpireMs) => {\n if (errGetExpire) {\n reject(errGetExpire);\n } else {\n const expireMs = resGetExpireMs === false ? 0 : resGetExpireMs;\n const res = {\n consumedPoints,\n msBeforeNext: expireMs >= 0 ? Math.max(expireMs - nowMs, 0) : -1,\n };\n resolve(res);\n }\n });\n }\n });\n }\n });\n }\n\n _get(rlKey) {\n return new Promise((resolve, reject) => {\n const nowMs = Date.now();\n\n this.client.get(rlKey, (err, consumedPoints) => {\n if (!consumedPoints) {\n resolve(null);\n } else {\n this.client.get(`${rlKey}_expire`, (errGetExpire, resGetExpireMs) => {\n if (errGetExpire) {\n reject(errGetExpire);\n } else {\n const expireMs = resGetExpireMs === false ? 0 : resGetExpireMs;\n const res = {\n consumedPoints,\n msBeforeNext: expireMs >= 0 ? Math.max(expireMs - nowMs, 0) : -1,\n };\n resolve(res);\n }\n });\n }\n });\n });\n }\n\n _delete(rlKey) {\n return new Promise((resolve, reject) => {\n this.client.del(rlKey, (err, res) => {\n if (err) {\n reject(err);\n } else if (res === false) {\n resolve(res);\n } else {\n this.client.del(`${rlKey}_expire`, (errDelExpire) => {\n if (errDelExpire) {\n reject(errDelExpire);\n } else {\n resolve(res);\n }\n });\n }\n });\n });\n }\n}\n\nmodule.exports = RateLimiterMemcache;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterMemcache.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterMemory.js": -/*!*********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterMemory.js ***! - \*********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterAbstract = __webpack_require__(/*! ./RateLimiterAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js\");\nconst MemoryStorage = __webpack_require__(/*! ./component/MemoryStorage/MemoryStorage */ \"./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/MemoryStorage.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nclass RateLimiterMemory extends RateLimiterAbstract {\n constructor(opts = {}) {\n super(opts);\n\n this._memoryStorage = new MemoryStorage();\n }\n /**\n *\n * @param key\n * @param pointsToConsume\n * @param {Object} options\n * @returns {Promise}\n */\n consume(key, pointsToConsume = 1, options = {}) {\n return new Promise((resolve, reject) => {\n const rlKey = this.getKey(key);\n const secDuration = this._getKeySecDuration(options);\n let res = this._memoryStorage.incrby(rlKey, pointsToConsume, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n\n if (res.consumedPoints > this.points) {\n // Block only first time when consumed more than points\n if (this.blockDuration > 0 && res.consumedPoints <= (this.points + pointsToConsume)) {\n // Block key\n res = this._memoryStorage.set(rlKey, res.consumedPoints, this.blockDuration);\n }\n reject(res);\n } else if (this.execEvenly && res.msBeforeNext > 0 && !res.isFirstInDuration) {\n // Execute evenly\n let delay = Math.ceil(res.msBeforeNext / (res.remainingPoints + 2));\n if (delay < this.execEvenlyMinDelayMs) {\n delay = res.consumedPoints * this.execEvenlyMinDelayMs;\n }\n\n setTimeout(resolve, delay, res);\n } else {\n resolve(res);\n }\n });\n }\n\n penalty(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve) => {\n const secDuration = this._getKeySecDuration(options);\n const res = this._memoryStorage.incrby(rlKey, points, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n resolve(res);\n });\n }\n\n reward(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve) => {\n const secDuration = this._getKeySecDuration(options);\n const res = this._memoryStorage.incrby(rlKey, -points, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n resolve(res);\n });\n }\n\n /**\n * Block any key for secDuration seconds\n *\n * @param key\n * @param secDuration\n */\n block(key, secDuration) {\n const msDuration = secDuration * 1000;\n const initPoints = this.points + 1;\n\n this._memoryStorage.set(this.getKey(key), initPoints, secDuration);\n return Promise.resolve(\n new RateLimiterRes(0, msDuration === 0 ? -1 : msDuration, initPoints)\n );\n }\n\n set(key, points, secDuration) {\n const msDuration = (secDuration >= 0 ? secDuration : this.duration) * 1000;\n\n this._memoryStorage.set(this.getKey(key), points, secDuration);\n return Promise.resolve(\n new RateLimiterRes(0, msDuration === 0 ? -1 : msDuration, points)\n );\n }\n\n get(key) {\n const res = this._memoryStorage.get(this.getKey(key));\n if (res !== null) {\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n }\n\n return Promise.resolve(res);\n }\n\n delete(key) {\n return Promise.resolve(this._memoryStorage.delete(this.getKey(key)));\n }\n}\n\nmodule.exports = RateLimiterMemory;\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterMemory.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterMongo.js": -/*!********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterMongo.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterStoreAbstract = __webpack_require__(/*! ./RateLimiterStoreAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\n/**\n * Get MongoDB driver version as upsert options differ\n * @params {Object} Client instance\n * @returns {Object} Version Object containing major, feature & minor versions.\n */\nfunction getDriverVersion(client) {\n try {\n const _client = client.client ? client.client : client;\n\n const { version } = _client.topology.s.options.metadata.driver;\n const _v = version.split('.').map(v => parseInt(v));\n\n return {\n major: _v[0],\n feature: _v[1],\n patch: _v[2],\n };\n } catch (err) {\n return { major: 0, feature: 0, patch: 0 };\n }\n}\n\nclass RateLimiterMongo extends RateLimiterStoreAbstract {\n /**\n *\n * @param {Object} opts\n * Defaults {\n * indexKeyPrefix: {attr1: 1, attr2: 1}\n * ... see other in RateLimiterStoreAbstract\n *\n * mongo: MongoClient\n * }\n */\n constructor(opts) {\n super(opts);\n\n this.dbName = opts.dbName;\n this.tableName = opts.tableName;\n this.indexKeyPrefix = opts.indexKeyPrefix;\n\n if (opts.mongo) {\n this.client = opts.mongo;\n } else {\n this.client = opts.storeClient;\n }\n if (typeof this.client.then === 'function') {\n // If Promise\n this.client\n .then((conn) => {\n this.client = conn;\n this._initCollection();\n this._driverVersion = getDriverVersion(this.client);\n });\n } else {\n this._initCollection();\n this._driverVersion = getDriverVersion(this.client);\n }\n }\n\n get dbName() {\n return this._dbName;\n }\n\n set dbName(value) {\n this._dbName = typeof value === 'undefined' ? RateLimiterMongo.getDbName() : value;\n }\n\n static getDbName() {\n return 'node-rate-limiter-flexible';\n }\n\n get tableName() {\n return this._tableName;\n }\n\n set tableName(value) {\n this._tableName = typeof value === 'undefined' ? this.keyPrefix : value;\n }\n\n get client() {\n return this._client;\n }\n\n set client(value) {\n if (typeof value === 'undefined') {\n throw new Error('mongo is not set');\n }\n this._client = value;\n }\n\n get indexKeyPrefix() {\n return this._indexKeyPrefix;\n }\n\n set indexKeyPrefix(obj) {\n this._indexKeyPrefix = obj || {};\n }\n\n _initCollection() {\n const db = typeof this.client.db === 'function'\n ? this.client.db(this.dbName)\n : this.client;\n\n const collection = db.collection(this.tableName);\n collection.createIndex({ expire: -1 }, { expireAfterSeconds: 0 });\n collection.createIndex(Object.assign({}, this.indexKeyPrefix, { key: 1 }), { unique: true });\n\n this._collection = collection;\n }\n\n _getRateLimiterRes(rlKey, changedPoints, result) {\n const res = new RateLimiterRes();\n\n let doc;\n if (typeof result.value === 'undefined') {\n doc = result;\n } else {\n doc = result.value;\n }\n\n res.isFirstInDuration = doc.points === changedPoints;\n res.consumedPoints = doc.points;\n\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n res.msBeforeNext = doc.expire !== null\n ? Math.max(new Date(doc.expire).getTime() - Date.now(), 0)\n : -1;\n\n return res;\n }\n\n _upsert(key, points, msDuration, forceExpire = false, options = {}) {\n if (!this._collection) {\n return Promise.reject(Error('Mongo connection is not established'));\n }\n\n const docAttrs = options.attrs || {};\n\n let where;\n let upsertData;\n if (forceExpire) {\n where = { key };\n where = Object.assign(where, docAttrs);\n upsertData = {\n $set: {\n key,\n points,\n expire: msDuration > 0 ? new Date(Date.now() + msDuration) : null,\n },\n };\n upsertData.$set = Object.assign(upsertData.$set, docAttrs);\n } else {\n where = {\n $or: [\n { expire: { $gt: new Date() } },\n { expire: { $eq: null } },\n ],\n key,\n };\n where = Object.assign(where, docAttrs);\n upsertData = {\n $setOnInsert: {\n key,\n expire: msDuration > 0 ? new Date(Date.now() + msDuration) : null,\n },\n $inc: { points },\n };\n upsertData.$setOnInsert = Object.assign(upsertData.$setOnInsert, docAttrs);\n }\n\n // Options for collection updates differ between driver versions\n const upsertOptions = {\n upsert: true,\n };\n if ((this._driverVersion.major >= 4) ||\n (this._driverVersion.major === 3 &&\n (this._driverVersion.feature >=7) || \n (this._driverVersion.feature >= 6 && \n this._driverVersion.patch >= 7 ))) \n {\n upsertOptions.returnDocument = 'after';\n } else {\n upsertOptions.returnOriginal = false;\n }\n\n /*\n * 1. Find actual limit and increment points\n * 2. If limit expired, but Mongo doesn't clean doc by TTL yet, try to replace limit doc completely\n * 3. If 2 or more Mongo threads try to insert the new limit doc, only the first succeed\n * 4. Try to upsert from step 1. Actual limit is created now, points are incremented without problems\n */\n return new Promise((resolve, reject) => {\n this._collection.findOneAndUpdate(\n where,\n upsertData,\n upsertOptions\n ).then((res) => {\n resolve(res);\n }).catch((errUpsert) => {\n if (errUpsert && errUpsert.code === 11000) { // E11000 duplicate key error collection\n const replaceWhere = Object.assign({ // try to replace OLD limit doc\n $or: [\n { expire: { $lte: new Date() } },\n { expire: { $eq: null } },\n ],\n key,\n }, docAttrs);\n\n const replaceTo = {\n $set: Object.assign({\n key,\n points,\n expire: msDuration > 0 ? new Date(Date.now() + msDuration) : null,\n }, docAttrs)\n };\n\n this._collection.findOneAndUpdate(\n replaceWhere,\n replaceTo,\n upsertOptions\n ).then((res) => {\n resolve(res);\n }).catch((errReplace) => {\n if (errReplace && errReplace.code === 11000) { // E11000 duplicate key error collection\n this._upsert(key, points, msDuration, forceExpire)\n .then(res => resolve(res))\n .catch(err => reject(err));\n } else {\n reject(errReplace);\n }\n });\n } else {\n reject(errUpsert);\n }\n });\n });\n }\n\n _get(rlKey, options = {}) {\n if (!this._collection) {\n return Promise.reject(Error('Mongo connection is not established'));\n }\n\n const docAttrs = options.attrs || {};\n\n const where = Object.assign({\n key: rlKey,\n $or: [\n { expire: { $gt: new Date() } },\n { expire: { $eq: null } },\n ],\n }, docAttrs);\n\n return this._collection.findOne(where);\n }\n\n _delete(rlKey, options = {}) {\n if (!this._collection) {\n return Promise.reject(Error('Mongo connection is not established'));\n }\n\n const docAttrs = options.attrs || {};\n const where = Object.assign({ key: rlKey }, docAttrs);\n\n return this._collection.deleteOne(where)\n .then(res => res.deletedCount > 0);\n }\n}\n\nmodule.exports = RateLimiterMongo;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterMongo.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterMySQL.js": -/*!********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterMySQL.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterStoreAbstract = __webpack_require__(/*! ./RateLimiterStoreAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nclass RateLimiterMySQL extends RateLimiterStoreAbstract {\n /**\n * @callback callback\n * @param {Object} err\n *\n * @param {Object} opts\n * @param {callback} cb\n * Defaults {\n * ... see other in RateLimiterStoreAbstract\n *\n * storeClient: anySqlClient,\n * storeType: 'knex', // required only for Knex instance\n * dbName: 'string',\n * tableName: 'string',\n * }\n */\n constructor(opts, cb = null) {\n super(opts);\n\n this.client = opts.storeClient;\n this.clientType = opts.storeType;\n\n this.dbName = opts.dbName;\n this.tableName = opts.tableName;\n\n this.clearExpiredByTimeout = opts.clearExpiredByTimeout;\n\n this.tableCreated = opts.tableCreated;\n if (!this.tableCreated) {\n this._createDbAndTable()\n .then(() => {\n this.tableCreated = true;\n if (this.clearExpiredByTimeout) {\n this._clearExpiredHourAgo();\n }\n if (typeof cb === 'function') {\n cb();\n }\n })\n .catch((err) => {\n if (typeof cb === 'function') {\n cb(err);\n } else {\n throw err;\n }\n });\n } else {\n if (this.clearExpiredByTimeout) {\n this._clearExpiredHourAgo();\n }\n if (typeof cb === 'function') {\n cb();\n }\n }\n }\n\n clearExpired(expire) {\n return new Promise((resolve) => {\n this._getConnection()\n .then((conn) => {\n conn.query(`DELETE FROM ??.?? WHERE expire < ?`, [this.dbName, this.tableName, expire], () => {\n this._releaseConnection(conn);\n resolve();\n });\n })\n .catch(() => {\n resolve();\n });\n });\n }\n\n _clearExpiredHourAgo() {\n if (this._clearExpiredTimeoutId) {\n clearTimeout(this._clearExpiredTimeoutId);\n }\n this._clearExpiredTimeoutId = setTimeout(() => {\n this.clearExpired(Date.now() - 3600000) // Never rejected\n .then(() => {\n this._clearExpiredHourAgo();\n });\n }, 300000);\n this._clearExpiredTimeoutId.unref();\n }\n\n /**\n *\n * @return Promise\n * @private\n */\n _getConnection() {\n switch (this.clientType) {\n case 'pool':\n return new Promise((resolve, reject) => {\n this.client.getConnection((errConn, conn) => {\n if (errConn) {\n return reject(errConn);\n }\n\n resolve(conn);\n });\n });\n case 'sequelize':\n return this.client.connectionManager.getConnection();\n case 'knex':\n return this.client.client.acquireConnection();\n default:\n return Promise.resolve(this.client);\n }\n }\n\n _releaseConnection(conn) {\n switch (this.clientType) {\n case 'pool':\n return conn.release();\n case 'sequelize':\n return this.client.connectionManager.releaseConnection(conn);\n case 'knex':\n return this.client.client.releaseConnection(conn);\n default:\n return true;\n }\n }\n\n /**\n *\n * @returns {Promise}\n * @private\n */\n _createDbAndTable() {\n return new Promise((resolve, reject) => {\n this._getConnection()\n .then((conn) => {\n conn.query(`CREATE DATABASE IF NOT EXISTS \\`${this.dbName}\\`;`, (errDb) => {\n if (errDb) {\n this._releaseConnection(conn);\n return reject(errDb);\n }\n conn.query(this._getCreateTableStmt(), (err) => {\n if (err) {\n this._releaseConnection(conn);\n return reject(err);\n }\n this._releaseConnection(conn);\n resolve();\n });\n });\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n\n _getCreateTableStmt() {\n return `CREATE TABLE IF NOT EXISTS \\`${this.dbName}\\`.\\`${this.tableName}\\` (` +\n '`key` VARCHAR(255) CHARACTER SET utf8 NOT NULL,' +\n '`points` INT(9) NOT NULL default 0,' +\n '`expire` BIGINT UNSIGNED,' +\n 'PRIMARY KEY (`key`)' +\n ') ENGINE = INNODB;';\n }\n\n get clientType() {\n return this._clientType;\n }\n\n set clientType(value) {\n if (typeof value === 'undefined') {\n if (this.client.constructor.name === 'Connection') {\n value = 'connection';\n } else if (this.client.constructor.name === 'Pool') {\n value = 'pool';\n } else if (this.client.constructor.name === 'Sequelize') {\n value = 'sequelize';\n } else {\n throw new Error('storeType is not defined');\n }\n }\n this._clientType = value.toLowerCase();\n }\n\n get dbName() {\n return this._dbName;\n }\n\n set dbName(value) {\n this._dbName = typeof value === 'undefined' ? 'rtlmtrflx' : value;\n }\n\n get tableName() {\n return this._tableName;\n }\n\n set tableName(value) {\n this._tableName = typeof value === 'undefined' ? this.keyPrefix : value;\n }\n\n get tableCreated() {\n return this._tableCreated\n }\n\n set tableCreated(value) {\n this._tableCreated = typeof value === 'undefined' ? false : !!value;\n }\n\n get clearExpiredByTimeout() {\n return this._clearExpiredByTimeout;\n }\n\n set clearExpiredByTimeout(value) {\n this._clearExpiredByTimeout = typeof value === 'undefined' ? true : Boolean(value);\n }\n\n _getRateLimiterRes(rlKey, changedPoints, result) {\n const res = new RateLimiterRes();\n const [row] = result;\n\n res.isFirstInDuration = changedPoints === row.points;\n res.consumedPoints = res.isFirstInDuration ? changedPoints : row.points;\n\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n res.msBeforeNext = row.expire\n ? Math.max(row.expire - Date.now(), 0)\n : -1;\n\n return res;\n }\n\n _upsertTransaction(conn, key, points, msDuration, forceExpire) {\n return new Promise((resolve, reject) => {\n conn.query('BEGIN', (errBegin) => {\n if (errBegin) {\n conn.rollback();\n\n return reject(errBegin);\n }\n\n const dateNow = Date.now();\n const newExpire = msDuration > 0 ? dateNow + msDuration : null;\n\n let q;\n let values;\n if (forceExpire) {\n q = `INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;`;\n values = [\n this.dbName, this.tableName, key, points, newExpire,\n points,\n newExpire,\n ];\n } else {\n q = `INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);`;\n values = [\n this.dbName, this.tableName, key, points, newExpire,\n dateNow, points, points,\n dateNow, newExpire,\n ];\n }\n\n conn.query(q, values, (errUpsert) => {\n if (errUpsert) {\n conn.rollback();\n\n return reject(errUpsert);\n }\n conn.query('SELECT points, expire FROM ??.?? WHERE `key` = ?;', [this.dbName, this.tableName, key], (errSelect, res) => {\n if (errSelect) {\n conn.rollback();\n\n return reject(errSelect);\n }\n\n conn.query('COMMIT', (err) => {\n if (err) {\n conn.rollback();\n\n return reject(err);\n }\n\n resolve(res);\n });\n });\n });\n });\n });\n }\n\n _upsert(key, points, msDuration, forceExpire = false) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n return new Promise((resolve, reject) => {\n this._getConnection()\n .then((conn) => {\n this._upsertTransaction(conn, key, points, msDuration, forceExpire)\n .then((res) => {\n resolve(res);\n this._releaseConnection(conn);\n })\n .catch((err) => {\n reject(err);\n this._releaseConnection(conn);\n });\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n\n _get(rlKey) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n return new Promise((resolve, reject) => {\n this._getConnection()\n .then((conn) => {\n conn.query(\n 'SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)',\n [this.dbName, this.tableName, rlKey, Date.now()],\n (err, res) => {\n if (err) {\n reject(err);\n } else if (res.length === 0) {\n resolve(null);\n } else {\n resolve(res);\n }\n\n this._releaseConnection(conn);\n } // eslint-disable-line\n );\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n\n _delete(rlKey) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n return new Promise((resolve, reject) => {\n this._getConnection()\n .then((conn) => {\n conn.query(\n 'DELETE FROM ??.?? WHERE `key` = ?',\n [this.dbName, this.tableName, rlKey],\n (err, res) => {\n if (err) {\n reject(err);\n } else {\n resolve(res.affectedRows > 0);\n }\n\n this._releaseConnection(conn);\n } // eslint-disable-line\n );\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n}\n\nmodule.exports = RateLimiterMySQL;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterMySQL.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterPostgres.js": -/*!***********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterPostgres.js ***! - \***********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterStoreAbstract = __webpack_require__(/*! ./RateLimiterStoreAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nclass RateLimiterPostgres extends RateLimiterStoreAbstract {\n /**\n * @callback callback\n * @param {Object} err\n *\n * @param {Object} opts\n * @param {callback} cb\n * Defaults {\n * ... see other in RateLimiterStoreAbstract\n *\n * storeClient: postgresClient,\n * storeType: 'knex', // required only for Knex instance\n * tableName: 'string',\n * }\n */\n constructor(opts, cb = null) {\n super(opts);\n\n this.client = opts.storeClient;\n this.clientType = opts.storeType;\n\n this.tableName = opts.tableName;\n\n this.clearExpiredByTimeout = opts.clearExpiredByTimeout;\n\n this.tableCreated = opts.tableCreated;\n if (!this.tableCreated) {\n this._createTable()\n .then(() => {\n this.tableCreated = true;\n if (this.clearExpiredByTimeout) {\n this._clearExpiredHourAgo();\n }\n if (typeof cb === 'function') {\n cb();\n }\n })\n .catch((err) => {\n if (typeof cb === 'function') {\n cb(err);\n } else {\n throw err;\n }\n });\n } else {\n if (typeof cb === 'function') {\n cb();\n }\n }\n }\n\n clearExpired(expire) {\n return new Promise((resolve) => {\n const q = {\n name: 'rlflx-clear-expired',\n text: `DELETE FROM ${this.tableName} WHERE expire < $1`,\n values: [expire],\n };\n this._query(q)\n .then(() => {\n resolve();\n })\n .catch(() => {\n // Deleting expired query is not critical\n resolve();\n });\n });\n }\n\n /**\n * Delete all rows expired 1 hour ago once per 5 minutes\n *\n * @private\n */\n _clearExpiredHourAgo() {\n if (this._clearExpiredTimeoutId) {\n clearTimeout(this._clearExpiredTimeoutId);\n }\n this._clearExpiredTimeoutId = setTimeout(() => {\n this.clearExpired(Date.now() - 3600000) // Never rejected\n .then(() => {\n this._clearExpiredHourAgo();\n });\n }, 300000);\n this._clearExpiredTimeoutId.unref();\n }\n\n /**\n *\n * @return Promise\n * @private\n */\n _getConnection() {\n switch (this.clientType) {\n case 'pool':\n return Promise.resolve(this.client);\n case 'sequelize':\n return this.client.connectionManager.getConnection();\n case 'knex':\n return this.client.client.acquireConnection();\n case 'typeorm':\n return Promise.resolve(this.client.driver.master);\n default:\n return Promise.resolve(this.client);\n }\n }\n\n _releaseConnection(conn) {\n switch (this.clientType) {\n case 'pool':\n return true;\n case 'sequelize':\n return this.client.connectionManager.releaseConnection(conn);\n case 'knex':\n return this.client.client.releaseConnection(conn);\n case 'typeorm':\n return true;\n default:\n return true;\n }\n }\n\n /**\n *\n * @returns {Promise}\n * @private\n */\n _createTable() {\n return new Promise((resolve, reject) => {\n this._query({\n text: this._getCreateTableStmt(),\n })\n .then(() => {\n resolve();\n })\n .catch((err) => {\n if (err.code === '23505') {\n // Error: duplicate key value violates unique constraint \"pg_type_typname_nsp_index\"\n // Postgres doesn't handle concurrent table creation\n // It is supposed, that table is created by another worker\n resolve();\n } else {\n reject(err);\n }\n });\n });\n }\n\n _getCreateTableStmt() {\n return `CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`;\n }\n\n get clientType() {\n return this._clientType;\n }\n\n set clientType(value) {\n const constructorName = this.client.constructor.name;\n\n if (typeof value === 'undefined') {\n if (constructorName === 'Client') {\n value = 'client';\n } else if (\n constructorName === 'Pool' ||\n constructorName === 'BoundPool'\n ) {\n value = 'pool';\n } else if (constructorName === 'Sequelize') {\n value = 'sequelize';\n } else {\n throw new Error('storeType is not defined');\n }\n }\n\n this._clientType = value.toLowerCase();\n }\n\n get tableName() {\n return this._tableName;\n }\n\n set tableName(value) {\n this._tableName = typeof value === 'undefined' ? this.keyPrefix : value;\n }\n\n get tableCreated() {\n return this._tableCreated\n }\n\n set tableCreated(value) {\n this._tableCreated = typeof value === 'undefined' ? false : !!value;\n }\n\n get clearExpiredByTimeout() {\n return this._clearExpiredByTimeout;\n }\n\n set clearExpiredByTimeout(value) {\n this._clearExpiredByTimeout = typeof value === 'undefined' ? true : Boolean(value);\n }\n\n _getRateLimiterRes(rlKey, changedPoints, result) {\n const res = new RateLimiterRes();\n const row = result.rows[0];\n\n res.isFirstInDuration = changedPoints === row.points;\n res.consumedPoints = res.isFirstInDuration ? changedPoints : row.points;\n\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n res.msBeforeNext = row.expire\n ? Math.max(row.expire - Date.now(), 0)\n : -1;\n\n return res;\n }\n\n _query(q) {\n const prefix = this.tableName.toLowerCase();\n const queryObj = { name: `${prefix}:${q.name}`, text: q.text, values: q.values };\n return new Promise((resolve, reject) => {\n this._getConnection()\n .then((conn) => {\n conn.query(queryObj)\n .then((res) => {\n resolve(res);\n this._releaseConnection(conn);\n })\n .catch((err) => {\n reject(err);\n this._releaseConnection(conn);\n });\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n\n _upsert(key, points, msDuration, forceExpire = false) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n const newExpire = msDuration > 0 ? Date.now() + msDuration : null;\n const expireQ = forceExpire\n ? ' $3 '\n : ` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `;\n\n return this._query({\n name: forceExpire ? 'rlflx-upsert-force' : 'rlflx-upsert',\n text: `\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${forceExpire ? 1 : 0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${expireQ}\n RETURNING points, expire;`,\n values: [key, points, newExpire, Date.now()],\n });\n }\n\n _get(rlKey) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n return new Promise((resolve, reject) => {\n this._query({\n name: 'rlflx-get',\n text: `\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,\n values: [rlKey, Date.now()],\n })\n .then((res) => {\n if (res.rowCount === 0) {\n res = null;\n }\n resolve(res);\n })\n .catch((err) => {\n reject(err);\n });\n });\n }\n\n _delete(rlKey) {\n if (!this.tableCreated) {\n return Promise.reject(Error('Table is not created yet'));\n }\n\n return this._query({\n name: 'rlflx-delete',\n text: `DELETE FROM ${this.tableName} WHERE key = $1`,\n values: [rlKey],\n })\n .then(res => res.rowCount > 0);\n }\n}\n\nmodule.exports = RateLimiterPostgres;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterPostgres.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterQueue.js": -/*!********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterQueue.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterQueueError = __webpack_require__(/*! ./component/RateLimiterQueueError */ \"./node_modules/rate-limiter-flexible/lib/component/RateLimiterQueueError.js\")\nconst MAX_QUEUE_SIZE = 4294967295;\nconst KEY_DEFAULT = 'limiter';\n\nmodule.exports = class RateLimiterQueue {\n constructor(limiterFlexible, opts = {\n maxQueueSize: MAX_QUEUE_SIZE,\n }) {\n this._queueLimiters = {\n KEY_DEFAULT: new RateLimiterQueueInternal(limiterFlexible, opts)\n };\n this._limiterFlexible = limiterFlexible;\n this._maxQueueSize = opts.maxQueueSize\n }\n\n getTokensRemaining(key = KEY_DEFAULT) {\n if (this._queueLimiters[key]) {\n return this._queueLimiters[key].getTokensRemaining()\n } else {\n return Promise.resolve(this._limiterFlexible.points)\n }\n }\n\n removeTokens(tokens, key = KEY_DEFAULT) {\n if (!this._queueLimiters[key]) {\n this._queueLimiters[key] = new RateLimiterQueueInternal(\n this._limiterFlexible, {\n key,\n maxQueueSize: this._maxQueueSize,\n })\n }\n\n return this._queueLimiters[key].removeTokens(tokens)\n }\n};\n\nclass RateLimiterQueueInternal {\n\n constructor(limiterFlexible, opts = {\n maxQueueSize: MAX_QUEUE_SIZE,\n key: KEY_DEFAULT,\n }) {\n this._key = opts.key;\n this._waitTimeout = null;\n this._queue = [];\n this._limiterFlexible = limiterFlexible;\n\n this._maxQueueSize = opts.maxQueueSize\n }\n\n getTokensRemaining() {\n return this._limiterFlexible.get(this._key)\n .then((rlRes) => {\n return rlRes !== null ? rlRes.remainingPoints : this._limiterFlexible.points;\n })\n }\n\n removeTokens(tokens) {\n const _this = this;\n\n return new Promise((resolve, reject) => {\n if (tokens > _this._limiterFlexible.points) {\n reject(new RateLimiterQueueError(`Requested tokens ${tokens} exceeds maximum ${_this._limiterFlexible.points} tokens per interval`));\n return\n }\n\n if (_this._queue.length > 0) {\n _this._queueRequest.call(_this, resolve, reject, tokens);\n } else {\n _this._limiterFlexible.consume(_this._key, tokens)\n .then((res) => {\n resolve(res.remainingPoints);\n })\n .catch((rej) => {\n if (rej instanceof Error) {\n reject(rej);\n } else {\n _this._queueRequest.call(_this, resolve, reject, tokens);\n if (_this._waitTimeout === null) {\n _this._waitTimeout = setTimeout(_this._processFIFO.bind(_this), rej.msBeforeNext);\n }\n }\n });\n }\n })\n }\n\n _queueRequest(resolve, reject, tokens) {\n const _this = this;\n if (_this._queue.length < _this._maxQueueSize) {\n _this._queue.push({resolve, reject, tokens});\n } else {\n reject(new RateLimiterQueueError(`Number of requests reached it's maximum ${_this._maxQueueSize}`))\n }\n }\n\n _processFIFO() {\n const _this = this;\n\n if (_this._waitTimeout !== null) {\n clearTimeout(_this._waitTimeout);\n _this._waitTimeout = null;\n }\n\n if (_this._queue.length === 0) {\n return;\n }\n\n const item = _this._queue.shift();\n _this._limiterFlexible.consume(_this._key, item.tokens)\n .then((res) => {\n item.resolve(res.remainingPoints);\n _this._processFIFO.call(_this);\n })\n .catch((rej) => {\n if (rej instanceof Error) {\n item.reject(rej);\n _this._processFIFO.call(_this);\n } else {\n _this._queue.unshift(item);\n if (_this._waitTimeout === null) {\n _this._waitTimeout = setTimeout(_this._processFIFO.bind(_this), rej.msBeforeNext);\n }\n }\n });\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterQueue.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterRedis.js": -/*!********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterRedis.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterStoreAbstract = __webpack_require__(/*! ./RateLimiterStoreAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nconst incrTtlLuaScript = `redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') \\\nlocal consumed = redis.call('incrby', KEYS[1], ARGV[1]) \\\nlocal ttl = redis.call('pttl', KEYS[1]) \\\nif ttl == -1 then \\\n redis.call('expire', KEYS[1], ARGV[2]) \\\n ttl = 1000 * ARGV[2] \\\nend \\\nreturn {consumed, ttl} \\\n`;\n\nclass RateLimiterRedis extends RateLimiterStoreAbstract {\n /**\n *\n * @param {Object} opts\n * Defaults {\n * ... see other in RateLimiterStoreAbstract\n *\n * redis: RedisClient\n * rejectIfRedisNotReady: boolean = false - reject / invoke insuranceLimiter immediately when redis connection is not \"ready\"\n * }\n */\n constructor(opts) {\n super(opts);\n if (opts.redis) {\n this.client = opts.redis;\n } else {\n this.client = opts.storeClient;\n }\n\n this._rejectIfRedisNotReady = !!opts.rejectIfRedisNotReady;\n\n if (typeof this.client.defineCommand === 'function') {\n this.client.defineCommand(\"rlflxIncr\", {\n numberOfKeys: 1,\n lua: incrTtlLuaScript,\n });\n }\n }\n\n /**\n * Prevent actual redis call if redis connection is not ready\n * Because of different connection state checks for ioredis and node-redis, only this clients would be actually checked.\n * For any other clients all the requests would be passed directly to redis client\n * @return {boolean}\n * @private\n */\n _isRedisReady() {\n if (!this._rejectIfRedisNotReady) {\n return true;\n }\n // ioredis client\n if (this.client.status && this.client.status !== 'ready') {\n return false;\n }\n // node-redis client\n if (typeof this.client.isReady === 'function' && !this.client.isReady()) {\n return false;\n }\n return true;\n }\n\n _getRateLimiterRes(rlKey, changedPoints, result) {\n let [consumed, resTtlMs] = result;\n // Support ioredis results format\n if (Array.isArray(consumed)) {\n [, consumed] = consumed;\n [, resTtlMs] = resTtlMs;\n }\n\n const res = new RateLimiterRes();\n res.consumedPoints = parseInt(consumed);\n res.isFirstInDuration = res.consumedPoints === changedPoints;\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n res.msBeforeNext = resTtlMs;\n\n return res;\n }\n\n _upsert(rlKey, points, msDuration, forceExpire = false) {\n return new Promise((resolve, reject) => {\n if (!this._isRedisReady()) {\n return reject(new Error('Redis connection is not ready'));\n }\n\n const secDuration = Math.floor(msDuration / 1000);\n const multi = this.client.multi();\n if (forceExpire) {\n if (secDuration > 0) {\n multi.set(rlKey, points, 'EX', secDuration);\n } else {\n multi.set(rlKey, points);\n }\n\n multi.pttl(rlKey)\n .exec((err, res) => {\n if (err) {\n return reject(err);\n }\n\n return resolve(res);\n });\n } else {\n if (secDuration > 0) {\n const incrCallback = function(err, result) {\n if (err) {\n return reject(err);\n }\n\n return resolve(result);\n };\n\n if (typeof this.client.rlflxIncr === 'function') {\n this.client.rlflxIncr(rlKey, points, secDuration, incrCallback);\n } else {\n this.client.eval(incrTtlLuaScript, 1, rlKey, points, secDuration, incrCallback);\n }\n } else {\n multi.incrby(rlKey, points)\n .pttl(rlKey)\n .exec((err, res) => {\n if (err) {\n return reject(err);\n }\n\n return resolve(res);\n });\n }\n }\n });\n }\n\n _get(rlKey) {\n return new Promise((resolve, reject) => {\n if (!this._isRedisReady()) {\n return reject(new Error('Redis connection is not ready'));\n }\n\n this.client\n .multi()\n .get(rlKey)\n .pttl(rlKey)\n .exec((err, res) => {\n if (err) {\n reject(err);\n } else {\n const [points] = res;\n if (points === null) {\n return resolve(null)\n }\n\n resolve(res);\n }\n });\n });\n }\n\n _delete(rlKey) {\n return new Promise((resolve, reject) => {\n this.client.del(rlKey, (err, res) => {\n if (err) {\n reject(err);\n } else {\n resolve(res > 0);\n }\n });\n });\n }\n}\n\nmodule.exports = RateLimiterRedis;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterRedis.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js": -/*!******************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js ***! - \******************************************************************/ -/***/ ((module) => { - -eval("module.exports = class RateLimiterRes {\n constructor(remainingPoints, msBeforeNext, consumedPoints, isFirstInDuration) {\n this.remainingPoints = typeof remainingPoints === 'undefined' ? 0 : remainingPoints; // Remaining points in current duration\n this.msBeforeNext = typeof msBeforeNext === 'undefined' ? 0 : msBeforeNext; // Milliseconds before next action\n this.consumedPoints = typeof consumedPoints === 'undefined' ? 0 : consumedPoints; // Consumed points in current duration\n this.isFirstInDuration = typeof isFirstInDuration === 'undefined' ? false : isFirstInDuration;\n }\n\n get msBeforeNext() {\n return this._msBeforeNext;\n }\n\n set msBeforeNext(ms) {\n this._msBeforeNext = ms;\n return this;\n }\n\n get remainingPoints() {\n return this._remainingPoints;\n }\n\n set remainingPoints(p) {\n this._remainingPoints = p;\n return this;\n }\n\n get consumedPoints() {\n return this._consumedPoints;\n }\n\n set consumedPoints(p) {\n this._consumedPoints = p;\n return this;\n }\n\n get isFirstInDuration() {\n return this._isFirstInDuration;\n }\n\n set isFirstInDuration(value) {\n this._isFirstInDuration = Boolean(value);\n }\n\n _getDecoratedProperties() {\n return {\n remainingPoints: this.remainingPoints,\n msBeforeNext: this.msBeforeNext,\n consumedPoints: this.consumedPoints,\n isFirstInDuration: this.isFirstInDuration,\n };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this._getDecoratedProperties();\n }\n\n toString() {\n return JSON.stringify(this._getDecoratedProperties());\n }\n\n toJSON() {\n return this._getDecoratedProperties();\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js": -/*!****************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js ***! - \****************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterAbstract = __webpack_require__(/*! ./RateLimiterAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js\");\nconst BlockedKeys = __webpack_require__(/*! ./component/BlockedKeys */ \"./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/index.js\");\nconst RateLimiterRes = __webpack_require__(/*! ./RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nmodule.exports = class RateLimiterStoreAbstract extends RateLimiterAbstract {\n /**\n *\n * @param opts Object Defaults {\n * ... see other in RateLimiterAbstract\n *\n * inMemoryBlockOnConsumed: 40, // Number of points when key is blocked\n * inMemoryBlockDuration: 10, // Block duration in seconds\n * insuranceLimiter: RateLimiterAbstract\n * }\n */\n constructor(opts = {}) {\n super(opts);\n\n this.inMemoryBlockOnConsumed = opts.inMemoryBlockOnConsumed || opts.inmemoryBlockOnConsumed;\n this.inMemoryBlockDuration = opts.inMemoryBlockDuration || opts.inmemoryBlockDuration;\n this.insuranceLimiter = opts.insuranceLimiter;\n this._inMemoryBlockedKeys = new BlockedKeys();\n }\n\n get client() {\n return this._client;\n }\n\n set client(value) {\n if (typeof value === 'undefined') {\n throw new Error('storeClient is not set');\n }\n this._client = value;\n }\n\n /**\n * Have to be launched after consume\n * It blocks key and execute evenly depending on result from store\n *\n * It uses _getRateLimiterRes function to prepare RateLimiterRes from store result\n *\n * @param resolve\n * @param reject\n * @param rlKey\n * @param changedPoints\n * @param storeResult\n * @param {Object} options\n * @private\n */\n _afterConsume(resolve, reject, rlKey, changedPoints, storeResult, options = {}) {\n const res = this._getRateLimiterRes(rlKey, changedPoints, storeResult);\n\n if (this.inMemoryBlockOnConsumed > 0 && !(this.inMemoryBlockDuration > 0)\n && res.consumedPoints >= this.inMemoryBlockOnConsumed\n ) {\n this._inMemoryBlockedKeys.addMs(rlKey, res.msBeforeNext);\n if (res.consumedPoints > this.points) {\n return reject(res);\n } else {\n return resolve(res)\n }\n } else if (res.consumedPoints > this.points) {\n let blockPromise = Promise.resolve();\n // Block only first time when consumed more than points\n if (this.blockDuration > 0 && res.consumedPoints <= (this.points + changedPoints)) {\n res.msBeforeNext = this.msBlockDuration;\n blockPromise = this._block(rlKey, res.consumedPoints, this.msBlockDuration, options);\n }\n\n if (this.inMemoryBlockOnConsumed > 0 && res.consumedPoints >= this.inMemoryBlockOnConsumed) {\n // Block key for this.inMemoryBlockDuration seconds\n this._inMemoryBlockedKeys.add(rlKey, this.inMemoryBlockDuration);\n res.msBeforeNext = this.msInMemoryBlockDuration;\n }\n\n blockPromise\n .then(() => {\n reject(res);\n })\n .catch((err) => {\n reject(err);\n });\n } else if (this.execEvenly && res.msBeforeNext > 0 && !res.isFirstInDuration) {\n let delay = Math.ceil(res.msBeforeNext / (res.remainingPoints + 2));\n if (delay < this.execEvenlyMinDelayMs) {\n delay = res.consumedPoints * this.execEvenlyMinDelayMs;\n }\n\n setTimeout(resolve, delay, res);\n } else {\n resolve(res);\n }\n }\n\n _handleError(err, funcName, resolve, reject, key, data = false, options = {}) {\n if (!(this.insuranceLimiter instanceof RateLimiterAbstract)) {\n reject(err);\n } else {\n this.insuranceLimiter[funcName](key, data, options)\n .then((res) => {\n resolve(res);\n })\n .catch((res) => {\n reject(res);\n });\n }\n }\n\n /**\n * @deprecated Use camelCase version\n * @returns {BlockedKeys}\n * @private\n */\n get _inmemoryBlockedKeys() {\n return this._inMemoryBlockedKeys\n }\n\n /**\n * @deprecated Use camelCase version\n * @param rlKey\n * @returns {number}\n */\n getInmemoryBlockMsBeforeExpire(rlKey) {\n return this.getInMemoryBlockMsBeforeExpire(rlKey)\n }\n\n /**\n * @deprecated Use camelCase version\n * @returns {number|number}\n */\n get inmemoryBlockOnConsumed() {\n return this.inMemoryBlockOnConsumed;\n }\n\n /**\n * @deprecated Use camelCase version\n * @param value\n */\n set inmemoryBlockOnConsumed(value) {\n this.inMemoryBlockOnConsumed = value;\n }\n\n /**\n * @deprecated Use camelCase version\n * @returns {number|number}\n */\n get inmemoryBlockDuration() {\n return this.inMemoryBlockDuration;\n }\n\n /**\n * @deprecated Use camelCase version\n * @param value\n */\n set inmemoryBlockDuration(value) {\n this.inMemoryBlockDuration = value\n }\n\n /**\n * @deprecated Use camelCase version\n * @returns {number}\n */\n get msInmemoryBlockDuration() {\n return this.inMemoryBlockDuration * 1000;\n }\n\n getInMemoryBlockMsBeforeExpire(rlKey) {\n if (this.inMemoryBlockOnConsumed > 0) {\n return this._inMemoryBlockedKeys.msBeforeExpire(rlKey);\n }\n\n return 0;\n }\n\n get inMemoryBlockOnConsumed() {\n return this._inMemoryBlockOnConsumed;\n }\n\n set inMemoryBlockOnConsumed(value) {\n this._inMemoryBlockOnConsumed = value ? parseInt(value) : 0;\n if (this.inMemoryBlockOnConsumed > 0 && this.points > this.inMemoryBlockOnConsumed) {\n throw new Error('inMemoryBlockOnConsumed option must be greater or equal \"points\" option');\n }\n }\n\n get inMemoryBlockDuration() {\n return this._inMemoryBlockDuration;\n }\n\n set inMemoryBlockDuration(value) {\n this._inMemoryBlockDuration = value ? parseInt(value) : 0;\n if (this.inMemoryBlockDuration > 0 && this.inMemoryBlockOnConsumed === 0) {\n throw new Error('inMemoryBlockOnConsumed option must be set up');\n }\n }\n\n get msInMemoryBlockDuration() {\n return this._inMemoryBlockDuration * 1000;\n }\n\n get insuranceLimiter() {\n return this._insuranceLimiter;\n }\n\n set insuranceLimiter(value) {\n if (typeof value !== 'undefined' && !(value instanceof RateLimiterAbstract)) {\n throw new Error('insuranceLimiter must be instance of RateLimiterAbstract');\n }\n this._insuranceLimiter = value;\n if (this._insuranceLimiter) {\n this._insuranceLimiter.blockDuration = this.blockDuration;\n this._insuranceLimiter.execEvenly = this.execEvenly;\n }\n }\n\n /**\n * Block any key for secDuration seconds\n *\n * @param key\n * @param secDuration\n * @param {Object} options\n *\n * @return Promise\n */\n block(key, secDuration, options = {}) {\n const msDuration = secDuration * 1000;\n return this._block(this.getKey(key), this.points + 1, msDuration, options);\n }\n\n /**\n * Set points by key for any duration\n *\n * @param key\n * @param points\n * @param secDuration\n * @param {Object} options\n *\n * @return Promise\n */\n set(key, points, secDuration, options = {}) {\n const msDuration = (secDuration >= 0 ? secDuration : this.duration) * 1000;\n return this._block(this.getKey(key), points, msDuration, options);\n }\n\n /**\n *\n * @param key\n * @param pointsToConsume\n * @param {Object} options\n * @returns Promise\n */\n consume(key, pointsToConsume = 1, options = {}) {\n return new Promise((resolve, reject) => {\n const rlKey = this.getKey(key);\n\n const inMemoryBlockMsBeforeExpire = this.getInMemoryBlockMsBeforeExpire(rlKey);\n if (inMemoryBlockMsBeforeExpire > 0) {\n return reject(new RateLimiterRes(0, inMemoryBlockMsBeforeExpire));\n }\n\n this._upsert(rlKey, pointsToConsume, this._getKeySecDuration(options) * 1000, false, options)\n .then((res) => {\n this._afterConsume(resolve, reject, rlKey, pointsToConsume, res);\n })\n .catch((err) => {\n this._handleError(err, 'consume', resolve, reject, key, pointsToConsume, options);\n });\n });\n }\n\n /**\n *\n * @param key\n * @param points\n * @param {Object} options\n * @returns Promise\n */\n penalty(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve, reject) => {\n this._upsert(rlKey, points, this._getKeySecDuration(options) * 1000, false, options)\n .then((res) => {\n resolve(this._getRateLimiterRes(rlKey, points, res));\n })\n .catch((err) => {\n this._handleError(err, 'penalty', resolve, reject, key, points, options);\n });\n });\n }\n\n /**\n *\n * @param key\n * @param points\n * @param {Object} options\n * @returns Promise\n */\n reward(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve, reject) => {\n this._upsert(rlKey, -points, this._getKeySecDuration(options) * 1000, false, options)\n .then((res) => {\n resolve(this._getRateLimiterRes(rlKey, -points, res));\n })\n .catch((err) => {\n this._handleError(err, 'reward', resolve, reject, key, points, options);\n });\n });\n }\n\n /**\n *\n * @param key\n * @param {Object} options\n * @returns Promise|null\n */\n get(key, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve, reject) => {\n this._get(rlKey, options)\n .then((res) => {\n if (res === null || typeof res === 'undefined') {\n resolve(null);\n } else {\n resolve(this._getRateLimiterRes(rlKey, 0, res));\n }\n })\n .catch((err) => {\n this._handleError(err, 'get', resolve, reject, key, options);\n });\n });\n }\n\n /**\n *\n * @param key\n * @param {Object} options\n * @returns Promise\n */\n delete(key, options = {}) {\n const rlKey = this.getKey(key);\n return new Promise((resolve, reject) => {\n this._delete(rlKey, options)\n .then((res) => {\n this._inMemoryBlockedKeys.delete(rlKey);\n resolve(res);\n })\n .catch((err) => {\n this._handleError(err, 'delete', resolve, reject, key, options);\n });\n });\n }\n\n /**\n * Cleanup keys no-matter expired or not.\n */\n deleteInMemoryBlockedAll() {\n this._inMemoryBlockedKeys.delete();\n }\n\n /**\n * Get RateLimiterRes object filled depending on storeResult, which specific for exact store\n *\n * @param rlKey\n * @param changedPoints\n * @param storeResult\n * @private\n */\n _getRateLimiterRes(rlKey, changedPoints, storeResult) { // eslint-disable-line no-unused-vars\n throw new Error(\"You have to implement the method '_getRateLimiterRes'!\");\n }\n\n /**\n * Block key for this.msBlockDuration milliseconds\n * Usually, it just prolongs lifetime of key\n *\n * @param rlKey\n * @param initPoints\n * @param msDuration\n * @param {Object} options\n *\n * @return Promise\n */\n _block(rlKey, initPoints, msDuration, options = {}) {\n return new Promise((resolve, reject) => {\n this._upsert(rlKey, initPoints, msDuration, true, options)\n .then(() => {\n resolve(new RateLimiterRes(0, msDuration > 0 ? msDuration : -1, initPoints));\n })\n .catch((err) => {\n this._handleError(err, 'block', resolve, reject, this.parseKey(rlKey), msDuration / 1000, options);\n });\n });\n }\n\n /**\n * Have to be implemented in every limiter\n * Resolve with raw result from Store OR null if rlKey is not set\n * or Reject with error\n *\n * @param rlKey\n * @param {Object} options\n * @private\n *\n * @return Promise\n */\n _get(rlKey, options = {}) { // eslint-disable-line no-unused-vars\n throw new Error(\"You have to implement the method '_get'!\");\n }\n\n /**\n * Have to be implemented\n * Resolve with true OR false if rlKey doesn't exist\n * or Reject with error\n *\n * @param rlKey\n * @param {Object} options\n * @private\n *\n * @return Promise\n */\n _delete(rlKey, options = {}) { // eslint-disable-line no-unused-vars\n throw new Error(\"You have to implement the method '_delete'!\");\n }\n\n /**\n * Have to be implemented\n * Resolve with object used for {@link _getRateLimiterRes} to generate {@link RateLimiterRes}\n *\n * @param {string} rlKey\n * @param {number} points\n * @param {number} msDuration\n * @param {boolean} forceExpire\n * @param {Object} options\n * @abstract\n *\n * @return Promise\n */\n _upsert(rlKey, points, msDuration, forceExpire = false, options = {}) {\n throw new Error(\"You have to implement the method '_upsert'!\");\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterStoreAbstract.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/RateLimiterUnion.js": -/*!********************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/RateLimiterUnion.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const RateLimiterAbstract = __webpack_require__(/*! ./RateLimiterAbstract */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterAbstract.js\");\n\nmodule.exports = class RateLimiterUnion {\n constructor(...limiters) {\n if (limiters.length < 1) {\n throw new Error('RateLimiterUnion: at least one limiter have to be passed');\n }\n limiters.forEach((limiter) => {\n if (!(limiter instanceof RateLimiterAbstract)) {\n throw new Error('RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract');\n }\n });\n\n this._limiters = limiters;\n }\n\n consume(key, points = 1) {\n return new Promise((resolve, reject) => {\n const promises = [];\n this._limiters.forEach((limiter) => {\n promises.push(limiter.consume(key, points).catch(rej => ({ rejected: true, rej })));\n });\n\n Promise.all(promises)\n .then((res) => {\n const resObj = {};\n let rejected = false;\n\n res.forEach((item) => {\n if (item.rejected === true) {\n rejected = true;\n }\n });\n\n for (let i = 0; i < res.length; i++) {\n if (rejected && res[i].rejected === true) {\n resObj[this._limiters[i].keyPrefix] = res[i].rej;\n } else if (!rejected) {\n resObj[this._limiters[i].keyPrefix] = res[i];\n }\n }\n\n if (rejected) {\n reject(resObj);\n } else {\n resolve(resObj);\n }\n });\n });\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/RateLimiterUnion.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/BlockedKeys.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/BlockedKeys.js ***! - \*************************************************************************************/ -/***/ ((module) => { - -eval("module.exports = class BlockedKeys {\n constructor() {\n this._keys = {}; // {'key': 1526279430331}\n this._addedKeysAmount = 0;\n }\n\n collectExpired() {\n const now = Date.now();\n\n Object.keys(this._keys).forEach((key) => {\n if (this._keys[key] <= now) {\n delete this._keys[key];\n }\n });\n\n this._addedKeysAmount = Object.keys(this._keys).length;\n }\n\n /**\n * Add new blocked key\n *\n * @param key String\n * @param sec Number\n */\n add(key, sec) {\n this.addMs(key, sec * 1000);\n }\n\n /**\n * Add new blocked key for ms\n *\n * @param key String\n * @param ms Number\n */\n addMs(key, ms) {\n this._keys[key] = Date.now() + ms;\n this._addedKeysAmount++;\n if (this._addedKeysAmount > 999) {\n this.collectExpired();\n }\n }\n\n /**\n * 0 means not blocked\n *\n * @param key\n * @returns {number}\n */\n msBeforeExpire(key) {\n const expire = this._keys[key];\n\n if (expire && expire >= Date.now()) {\n this.collectExpired();\n const now = Date.now();\n return expire >= now ? expire - now : 0;\n }\n\n return 0;\n }\n\n /**\n * If key is not given, delete all data in memory\n * \n * @param {string|undefined} key\n */\n delete(key) {\n if (key) {\n delete this._keys[key];\n } else {\n Object.keys(this._keys).forEach((key) => {\n delete this._keys[key];\n });\n }\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/BlockedKeys.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/index.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/index.js ***! - \*******************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const BlockedKeys = __webpack_require__(/*! ./BlockedKeys */ \"./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/BlockedKeys.js\");\n\nmodule.exports = BlockedKeys;\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/component/BlockedKeys/index.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/MemoryStorage.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/MemoryStorage.js ***! - \*****************************************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("const Record = __webpack_require__(/*! ./Record */ \"./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/Record.js\");\nconst RateLimiterRes = __webpack_require__(/*! ../../RateLimiterRes */ \"./node_modules/rate-limiter-flexible/lib/RateLimiterRes.js\");\n\nmodule.exports = class MemoryStorage {\n constructor() {\n /**\n * @type {Object.}\n * @private\n */\n this._storage = {};\n }\n\n incrby(key, value, durationSec) {\n if (this._storage[key]) {\n const msBeforeExpires = this._storage[key].expiresAt\n ? this._storage[key].expiresAt.getTime() - new Date().getTime()\n : -1;\n if (msBeforeExpires !== 0) {\n // Change value\n this._storage[key].value = this._storage[key].value + value;\n\n return new RateLimiterRes(0, msBeforeExpires, this._storage[key].value, false);\n }\n\n return this.set(key, value, durationSec);\n }\n return this.set(key, value, durationSec);\n }\n\n set(key, value, durationSec) {\n const durationMs = durationSec * 1000;\n\n if (this._storage[key] && this._storage[key].timeoutId) {\n clearTimeout(this._storage[key].timeoutId);\n }\n\n this._storage[key] = new Record(\n value,\n durationMs > 0 ? new Date(Date.now() + durationMs) : null\n );\n if (durationMs > 0) {\n this._storage[key].timeoutId = setTimeout(() => {\n delete this._storage[key];\n }, durationMs);\n if (this._storage[key].timeoutId.unref) {\n this._storage[key].timeoutId.unref();\n }\n }\n\n return new RateLimiterRes(0, durationMs === 0 ? -1 : durationMs, this._storage[key].value, true);\n }\n\n /**\n *\n * @param key\n * @returns {*}\n */\n get(key) {\n if (this._storage[key]) {\n const msBeforeExpires = this._storage[key].expiresAt\n ? this._storage[key].expiresAt.getTime() - new Date().getTime()\n : -1;\n return new RateLimiterRes(0, msBeforeExpires, this._storage[key].value, false);\n }\n return null;\n }\n\n /**\n *\n * @param key\n * @returns {boolean}\n */\n delete(key) {\n if (this._storage[key]) {\n if (this._storage[key].timeoutId) {\n clearTimeout(this._storage[key].timeoutId);\n }\n delete this._storage[key];\n return true;\n }\n return false;\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/MemoryStorage.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/Record.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/Record.js ***! - \**********************************************************************************/ -/***/ ((module) => { - -eval("module.exports = class Record {\n /**\n *\n * @param value int\n * @param expiresAt Date|int\n * @param timeoutId\n */\n constructor(value, expiresAt, timeoutId = null) {\n this.value = value;\n this.expiresAt = expiresAt;\n this.timeoutId = timeoutId;\n }\n\n get value() {\n return this._value;\n }\n\n set value(value) {\n this._value = parseInt(value);\n }\n\n get expiresAt() {\n return this._expiresAt;\n }\n\n set expiresAt(value) {\n if (!(value instanceof Date) && Number.isInteger(value)) {\n value = new Date(value);\n }\n this._expiresAt = value;\n }\n\n get timeoutId() {\n return this._timeoutId;\n }\n\n set timeoutId(value) {\n this._timeoutId = value;\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/component/MemoryStorage/Record.js?"); - -/***/ }), - -/***/ "./node_modules/rate-limiter-flexible/lib/component/RateLimiterQueueError.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/rate-limiter-flexible/lib/component/RateLimiterQueueError.js ***! - \***********************************************************************************/ -/***/ ((module) => { - -eval("module.exports = class RateLimiterQueueError extends Error {\n constructor(message, extra) {\n super();\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n this.name = 'CustomError';\n this.message = message;\n if (extra) {\n this.extra = extra;\n }\n }\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/rate-limiter-flexible/lib/component/RateLimiterQueueError.js?"); - -/***/ }), - -/***/ "./node_modules/sanitize-filename/index.js": -/*!*************************************************!*\ - !*** ./node_modules/sanitize-filename/index.js ***! - \*************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("/*jshint node:true*/\n\n\n/**\n * Replaces characters in strings that are illegal/unsafe for filenames.\n * Unsafe characters are either removed or replaced by a substitute set\n * in the optional `options` object.\n *\n * Illegal Characters on Various Operating Systems\n * / ? < > \\ : * | \"\n * https://kb.acronis.com/content/39790\n *\n * Unicode Control codes\n * C0 0x00-0x1f & C1 (0x80-0x9f)\n * http://en.wikipedia.org/wiki/C0_and_C1_control_codes\n *\n * Reserved filenames on Unix-based systems (\".\", \"..\")\n * Reserved filenames in Windows (\"CON\", \"PRN\", \"AUX\", \"NUL\", \"COM1\",\n * \"COM2\", \"COM3\", \"COM4\", \"COM5\", \"COM6\", \"COM7\", \"COM8\", \"COM9\",\n * \"LPT1\", \"LPT2\", \"LPT3\", \"LPT4\", \"LPT5\", \"LPT6\", \"LPT7\", \"LPT8\", and\n * \"LPT9\") case-insesitively and with or without filename extensions.\n *\n * Capped at 255 characters in length.\n * http://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs\n *\n * @param {String} input Original filename\n * @param {Object} options {replacement: String | Function }\n * @return {String} Sanitized filename\n */\n\nvar truncate = __webpack_require__(/*! truncate-utf8-bytes */ \"./node_modules/truncate-utf8-bytes/browser.js\");\n\nvar illegalRe = /[\\/\\?<>\\\\:\\*\\|\"]/g;\nvar controlRe = /[\\x00-\\x1f\\x80-\\x9f]/g;\nvar reservedRe = /^\\.+$/;\nvar windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\\..*)?$/i;\nvar windowsTrailingRe = /[\\. ]+$/;\n\nfunction sanitize(input, replacement) {\n if (typeof input !== 'string') {\n throw new Error('Input must be string');\n }\n var sanitized = input\n .replace(illegalRe, replacement)\n .replace(controlRe, replacement)\n .replace(reservedRe, replacement)\n .replace(windowsReservedRe, replacement)\n .replace(windowsTrailingRe, replacement);\n return truncate(sanitized, 255);\n}\n\nmodule.exports = function (input, options) {\n var replacement = (options && options.replacement) || '';\n var output = sanitize(input, replacement);\n if (replacement === '') {\n return output;\n }\n return sanitize(output, '');\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/sanitize-filename/index.js?"); - -/***/ }), - -/***/ "./node_modules/truncate-utf8-bytes/browser.js": -/*!*****************************************************!*\ - !*** ./node_modules/truncate-utf8-bytes/browser.js ***! - \*****************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("\n\nvar truncate = __webpack_require__(/*! ./lib/truncate */ \"./node_modules/truncate-utf8-bytes/lib/truncate.js\");\nvar getLength = __webpack_require__(/*! utf8-byte-length/browser */ \"./node_modules/utf8-byte-length/browser.js\");\nmodule.exports = truncate.bind(null, getLength);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/truncate-utf8-bytes/browser.js?"); - -/***/ }), - -/***/ "./node_modules/truncate-utf8-bytes/lib/truncate.js": -/*!**********************************************************!*\ - !*** ./node_modules/truncate-utf8-bytes/lib/truncate.js ***! - \**********************************************************/ -/***/ ((module) => { - -"use strict"; -eval("\n\nfunction isHighSurrogate(codePoint) {\n return codePoint >= 0xd800 && codePoint <= 0xdbff;\n}\n\nfunction isLowSurrogate(codePoint) {\n return codePoint >= 0xdc00 && codePoint <= 0xdfff;\n}\n\n// Truncate string by size in bytes\nmodule.exports = function truncate(getLength, string, byteLength) {\n if (typeof string !== \"string\") {\n throw new Error(\"Input must be string\");\n }\n\n var charLength = string.length;\n var curByteLength = 0;\n var codePoint;\n var segment;\n\n for (var i = 0; i < charLength; i += 1) {\n codePoint = string.charCodeAt(i);\n segment = string[i];\n\n if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {\n i += 1;\n segment += string[i];\n }\n\n curByteLength += getLength(segment);\n\n if (curByteLength === byteLength) {\n return string.slice(0, i + 1);\n }\n else if (curByteLength > byteLength) {\n return string.slice(0, i - segment.length + 1);\n }\n }\n\n return string;\n};\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/truncate-utf8-bytes/lib/truncate.js?"); - -/***/ }), - -/***/ "./node_modules/utf8-byte-length/browser.js": -/*!**************************************************!*\ - !*** ./node_modules/utf8-byte-length/browser.js ***! - \**************************************************/ -/***/ ((module) => { - -"use strict"; -eval("\n\nfunction isHighSurrogate(codePoint) {\n return codePoint >= 0xd800 && codePoint <= 0xdbff;\n}\n\nfunction isLowSurrogate(codePoint) {\n return codePoint >= 0xdc00 && codePoint <= 0xdfff;\n}\n\n// Truncate string by size in bytes\nmodule.exports = function getByteLength(string) {\n if (typeof string !== \"string\") {\n throw new Error(\"Input must be string\");\n }\n\n var charLength = string.length;\n var byteLength = 0;\n var codePoint = null;\n var prevCodePoint = null;\n for (var i = 0; i < charLength; i++) {\n codePoint = string.charCodeAt(i);\n // handle 4-byte non-BMP chars\n // low surrogate\n if (isLowSurrogate(codePoint)) {\n // when parsing previous hi-surrogate, 3 is added to byteLength\n if (prevCodePoint != null && isHighSurrogate(prevCodePoint)) {\n byteLength += 1;\n }\n else {\n byteLength += 3;\n }\n }\n else if (codePoint <= 0x7f ) {\n byteLength += 1;\n }\n else if (codePoint >= 0x80 && codePoint <= 0x7ff) {\n byteLength += 2;\n }\n else if (codePoint >= 0x800 && codePoint <= 0xffff) {\n byteLength += 3;\n }\n prevCodePoint = codePoint;\n }\n\n return byteLength;\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/utf8-byte-length/browser.js?"); - -/***/ }), - /***/ "./node_modules/uuid/dist/esm-browser/native.js": /*!******************************************************!*\ !*** ./node_modules/uuid/dist/esm-browser/native.js ***! @@ -1918,56 +1565,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/varint/decode.js": -/*!***************************************!*\ - !*** ./node_modules/varint/decode.js ***! - \***************************************/ -/***/ ((module) => { - -eval("module.exports = read\n\nvar MSB = 0x80\n , REST = 0x7F\n\nfunction read(buf, offset) {\n var res = 0\n , offset = offset || 0\n , shift = 0\n , counter = offset\n , b\n , l = buf.length\n\n do {\n if (counter >= l || shift > 49) {\n read.bytes = 0\n throw new RangeError('Could not decode varint')\n }\n b = buf[counter++]\n res += shift < 28\n ? (b & REST) << shift\n : (b & REST) * Math.pow(2, shift)\n shift += 7\n } while (b >= MSB)\n\n read.bytes = counter - offset\n\n return res\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/varint/decode.js?"); - -/***/ }), - -/***/ "./node_modules/varint/encode.js": -/*!***************************************!*\ - !*** ./node_modules/varint/encode.js ***! - \***************************************/ -/***/ ((module) => { - -eval("module.exports = encode\n\nvar MSB = 0x80\n , REST = 0x7F\n , MSBALL = ~REST\n , INT = Math.pow(2, 31)\n\nfunction encode(num, out, offset) {\n if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) {\n encode.bytes = 0\n throw new RangeError('Could not encode varint')\n }\n out = out || []\n offset = offset || 0\n var oldOffset = offset\n\n while(num >= INT) {\n out[offset++] = (num & 0xFF) | MSB\n num /= 128\n }\n while(num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB\n num >>>= 7\n }\n out[offset] = num | 0\n \n encode.bytes = offset - oldOffset + 1\n \n return out\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/varint/encode.js?"); - -/***/ }), - -/***/ "./node_modules/varint/index.js": -/*!**************************************!*\ - !*** ./node_modules/varint/index.js ***! - \**************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -eval("module.exports = {\n encode: __webpack_require__(/*! ./encode.js */ \"./node_modules/varint/encode.js\")\n , decode: __webpack_require__(/*! ./decode.js */ \"./node_modules/varint/decode.js\")\n , encodingLength: __webpack_require__(/*! ./length.js */ \"./node_modules/varint/length.js\")\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/varint/index.js?"); - -/***/ }), - -/***/ "./node_modules/varint/length.js": -/*!***************************************!*\ - !*** ./node_modules/varint/length.js ***! - \***************************************/ -/***/ ((module) => { - -eval("\nvar N1 = Math.pow(2, 7)\nvar N2 = Math.pow(2, 14)\nvar N3 = Math.pow(2, 21)\nvar N4 = Math.pow(2, 28)\nvar N5 = Math.pow(2, 35)\nvar N6 = Math.pow(2, 42)\nvar N7 = Math.pow(2, 49)\nvar N8 = Math.pow(2, 56)\nvar N9 = Math.pow(2, 63)\n\nmodule.exports = function (value) {\n return (\n value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10\n )\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/varint/length.js?"); - -/***/ }), - -/***/ "?51ea": -/*!************************!*\ - !*** crypto (ignored) ***! - \************************/ -/***/ (() => { - -eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-example/crypto_(ignored)?"); - -/***/ }), - /***/ "?ce41": /*!************************!*\ !*** crypto (ignored) ***! @@ -2008,36 +1605,6 @@ eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-example/crypto_(ign /***/ }), -/***/ "?76c6": -/*!*************************!*\ - !*** cluster (ignored) ***! - \*************************/ -/***/ (() => { - -eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-example/cluster_(ignored)?"); - -/***/ }), - -/***/ "?4a7d": -/*!************************!*\ - !*** crypto (ignored) ***! - \************************/ -/***/ (() => { - -eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-example/crypto_(ignored)?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs ***! - \****************************************************************************************************/ -/***/ (function(module, exports, __webpack_require__) { - -eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// @ts-nocheck\n/*eslint-disable*/\n(function(global, factory) { /* global define, require, module */\n\n /* AMD */ if (true)\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! protobufjs/minimal */ \"./node_modules/@waku/relay/node_modules/protobufjs/minimal.js\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n\n /* CommonJS */ else {}\n\n})(this, function($protobuf) {\n \"use strict\";\n\n // Common aliases\n var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;\n\n // Exported root namespace\n var $root = $protobuf.roots[\"default\"] || ($protobuf.roots[\"default\"] = {});\n\n $root.RPC = (function() {\n\n /**\n * Properties of a RPC.\n * @exports IRPC\n * @interface IRPC\n * @property {Array.|null} [subscriptions] RPC subscriptions\n * @property {Array.|null} [messages] RPC messages\n * @property {RPC.IControlMessage|null} [control] RPC control\n */\n\n /**\n * Constructs a new RPC.\n * @exports RPC\n * @classdesc Represents a RPC.\n * @implements IRPC\n * @constructor\n * @param {IRPC=} [p] Properties to set\n */\n function RPC(p) {\n this.subscriptions = [];\n this.messages = [];\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * RPC subscriptions.\n * @member {Array.} subscriptions\n * @memberof RPC\n * @instance\n */\n RPC.prototype.subscriptions = $util.emptyArray;\n\n /**\n * RPC messages.\n * @member {Array.} messages\n * @memberof RPC\n * @instance\n */\n RPC.prototype.messages = $util.emptyArray;\n\n /**\n * RPC control.\n * @member {RPC.IControlMessage|null|undefined} control\n * @memberof RPC\n * @instance\n */\n RPC.prototype.control = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * RPC _control.\n * @member {\"control\"|undefined} _control\n * @memberof RPC\n * @instance\n */\n Object.defineProperty(RPC.prototype, \"_control\", {\n get: $util.oneOfGetter($oneOfFields = [\"control\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified RPC message. Does not implicitly {@link RPC.verify|verify} messages.\n * @function encode\n * @memberof RPC\n * @static\n * @param {IRPC} m RPC message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n RPC.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.subscriptions != null && m.subscriptions.length) {\n for (var i = 0; i < m.subscriptions.length; ++i)\n $root.RPC.SubOpts.encode(m.subscriptions[i], w.uint32(10).fork()).ldelim();\n }\n if (m.messages != null && m.messages.length) {\n for (var i = 0; i < m.messages.length; ++i)\n $root.RPC.Message.encode(m.messages[i], w.uint32(18).fork()).ldelim();\n }\n if (m.control != null && Object.hasOwnProperty.call(m, \"control\"))\n $root.RPC.ControlMessage.encode(m.control, w.uint32(26).fork()).ldelim();\n return w;\n };\n\n /**\n * Decodes a RPC message from the specified reader or buffer.\n * @function decode\n * @memberof RPC\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC} RPC\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n RPC.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.subscriptions && m.subscriptions.length))\n m.subscriptions = [];\n m.subscriptions.push($root.RPC.SubOpts.decode(r, r.uint32()));\n break;\n case 2:\n if (!(m.messages && m.messages.length))\n m.messages = [];\n m.messages.push($root.RPC.Message.decode(r, r.uint32()));\n break;\n case 3:\n m.control = $root.RPC.ControlMessage.decode(r, r.uint32());\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a RPC message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC} RPC\n */\n RPC.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC)\n return d;\n var m = new $root.RPC();\n if (d.subscriptions) {\n if (!Array.isArray(d.subscriptions))\n throw TypeError(\".RPC.subscriptions: array expected\");\n m.subscriptions = [];\n for (var i = 0; i < d.subscriptions.length; ++i) {\n if (typeof d.subscriptions[i] !== \"object\")\n throw TypeError(\".RPC.subscriptions: object expected\");\n m.subscriptions[i] = $root.RPC.SubOpts.fromObject(d.subscriptions[i]);\n }\n }\n if (d.messages) {\n if (!Array.isArray(d.messages))\n throw TypeError(\".RPC.messages: array expected\");\n m.messages = [];\n for (var i = 0; i < d.messages.length; ++i) {\n if (typeof d.messages[i] !== \"object\")\n throw TypeError(\".RPC.messages: object expected\");\n m.messages[i] = $root.RPC.Message.fromObject(d.messages[i]);\n }\n }\n if (d.control != null) {\n if (typeof d.control !== \"object\")\n throw TypeError(\".RPC.control: object expected\");\n m.control = $root.RPC.ControlMessage.fromObject(d.control);\n }\n return m;\n };\n\n /**\n * Creates a plain object from a RPC message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC\n * @static\n * @param {RPC} m RPC\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n RPC.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.arrays || o.defaults) {\n d.subscriptions = [];\n d.messages = [];\n }\n if (m.subscriptions && m.subscriptions.length) {\n d.subscriptions = [];\n for (var j = 0; j < m.subscriptions.length; ++j) {\n d.subscriptions[j] = $root.RPC.SubOpts.toObject(m.subscriptions[j], o);\n }\n }\n if (m.messages && m.messages.length) {\n d.messages = [];\n for (var j = 0; j < m.messages.length; ++j) {\n d.messages[j] = $root.RPC.Message.toObject(m.messages[j], o);\n }\n }\n if (m.control != null && m.hasOwnProperty(\"control\")) {\n d.control = $root.RPC.ControlMessage.toObject(m.control, o);\n if (o.oneofs)\n d._control = \"control\";\n }\n return d;\n };\n\n /**\n * Converts this RPC to JSON.\n * @function toJSON\n * @memberof RPC\n * @instance\n * @returns {Object.} JSON object\n */\n RPC.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n RPC.SubOpts = (function() {\n\n /**\n * Properties of a SubOpts.\n * @memberof RPC\n * @interface ISubOpts\n * @property {boolean|null} [subscribe] SubOpts subscribe\n * @property {string|null} [topic] SubOpts topic\n */\n\n /**\n * Constructs a new SubOpts.\n * @memberof RPC\n * @classdesc Represents a SubOpts.\n * @implements ISubOpts\n * @constructor\n * @param {RPC.ISubOpts=} [p] Properties to set\n */\n function SubOpts(p) {\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * SubOpts subscribe.\n * @member {boolean|null|undefined} subscribe\n * @memberof RPC.SubOpts\n * @instance\n */\n SubOpts.prototype.subscribe = null;\n\n /**\n * SubOpts topic.\n * @member {string|null|undefined} topic\n * @memberof RPC.SubOpts\n * @instance\n */\n SubOpts.prototype.topic = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * SubOpts _subscribe.\n * @member {\"subscribe\"|undefined} _subscribe\n * @memberof RPC.SubOpts\n * @instance\n */\n Object.defineProperty(SubOpts.prototype, \"_subscribe\", {\n get: $util.oneOfGetter($oneOfFields = [\"subscribe\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * SubOpts _topic.\n * @member {\"topic\"|undefined} _topic\n * @memberof RPC.SubOpts\n * @instance\n */\n Object.defineProperty(SubOpts.prototype, \"_topic\", {\n get: $util.oneOfGetter($oneOfFields = [\"topic\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified SubOpts message. Does not implicitly {@link RPC.SubOpts.verify|verify} messages.\n * @function encode\n * @memberof RPC.SubOpts\n * @static\n * @param {RPC.ISubOpts} m SubOpts message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n SubOpts.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.subscribe != null && Object.hasOwnProperty.call(m, \"subscribe\"))\n w.uint32(8).bool(m.subscribe);\n if (m.topic != null && Object.hasOwnProperty.call(m, \"topic\"))\n w.uint32(18).string(m.topic);\n return w;\n };\n\n /**\n * Decodes a SubOpts message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.SubOpts\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.SubOpts} SubOpts\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n SubOpts.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.SubOpts();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.subscribe = r.bool();\n break;\n case 2:\n m.topic = r.string();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a SubOpts message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.SubOpts\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.SubOpts} SubOpts\n */\n SubOpts.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.SubOpts)\n return d;\n var m = new $root.RPC.SubOpts();\n if (d.subscribe != null) {\n m.subscribe = Boolean(d.subscribe);\n }\n if (d.topic != null) {\n m.topic = String(d.topic);\n }\n return m;\n };\n\n /**\n * Creates a plain object from a SubOpts message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.SubOpts\n * @static\n * @param {RPC.SubOpts} m SubOpts\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n SubOpts.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (m.subscribe != null && m.hasOwnProperty(\"subscribe\")) {\n d.subscribe = m.subscribe;\n if (o.oneofs)\n d._subscribe = \"subscribe\";\n }\n if (m.topic != null && m.hasOwnProperty(\"topic\")) {\n d.topic = m.topic;\n if (o.oneofs)\n d._topic = \"topic\";\n }\n return d;\n };\n\n /**\n * Converts this SubOpts to JSON.\n * @function toJSON\n * @memberof RPC.SubOpts\n * @instance\n * @returns {Object.} JSON object\n */\n SubOpts.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return SubOpts;\n })();\n\n RPC.Message = (function() {\n\n /**\n * Properties of a Message.\n * @memberof RPC\n * @interface IMessage\n * @property {Uint8Array|null} [from] Message from\n * @property {Uint8Array|null} [data] Message data\n * @property {Uint8Array|null} [seqno] Message seqno\n * @property {string} topic Message topic\n * @property {Uint8Array|null} [signature] Message signature\n * @property {Uint8Array|null} [key] Message key\n */\n\n /**\n * Constructs a new Message.\n * @memberof RPC\n * @classdesc Represents a Message.\n * @implements IMessage\n * @constructor\n * @param {RPC.IMessage=} [p] Properties to set\n */\n function Message(p) {\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * Message from.\n * @member {Uint8Array|null|undefined} from\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.from = null;\n\n /**\n * Message data.\n * @member {Uint8Array|null|undefined} data\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.data = null;\n\n /**\n * Message seqno.\n * @member {Uint8Array|null|undefined} seqno\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.seqno = null;\n\n /**\n * Message topic.\n * @member {string} topic\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.topic = \"\";\n\n /**\n * Message signature.\n * @member {Uint8Array|null|undefined} signature\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.signature = null;\n\n /**\n * Message key.\n * @member {Uint8Array|null|undefined} key\n * @memberof RPC.Message\n * @instance\n */\n Message.prototype.key = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * Message _from.\n * @member {\"from\"|undefined} _from\n * @memberof RPC.Message\n * @instance\n */\n Object.defineProperty(Message.prototype, \"_from\", {\n get: $util.oneOfGetter($oneOfFields = [\"from\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Message _data.\n * @member {\"data\"|undefined} _data\n * @memberof RPC.Message\n * @instance\n */\n Object.defineProperty(Message.prototype, \"_data\", {\n get: $util.oneOfGetter($oneOfFields = [\"data\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Message _seqno.\n * @member {\"seqno\"|undefined} _seqno\n * @memberof RPC.Message\n * @instance\n */\n Object.defineProperty(Message.prototype, \"_seqno\", {\n get: $util.oneOfGetter($oneOfFields = [\"seqno\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Message _signature.\n * @member {\"signature\"|undefined} _signature\n * @memberof RPC.Message\n * @instance\n */\n Object.defineProperty(Message.prototype, \"_signature\", {\n get: $util.oneOfGetter($oneOfFields = [\"signature\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Message _key.\n * @member {\"key\"|undefined} _key\n * @memberof RPC.Message\n * @instance\n */\n Object.defineProperty(Message.prototype, \"_key\", {\n get: $util.oneOfGetter($oneOfFields = [\"key\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified Message message. Does not implicitly {@link RPC.Message.verify|verify} messages.\n * @function encode\n * @memberof RPC.Message\n * @static\n * @param {RPC.IMessage} m Message message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n Message.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.from != null && Object.hasOwnProperty.call(m, \"from\"))\n w.uint32(10).bytes(m.from);\n if (m.data != null && Object.hasOwnProperty.call(m, \"data\"))\n w.uint32(18).bytes(m.data);\n if (m.seqno != null && Object.hasOwnProperty.call(m, \"seqno\"))\n w.uint32(26).bytes(m.seqno);\n w.uint32(34).string(m.topic);\n if (m.signature != null && Object.hasOwnProperty.call(m, \"signature\"))\n w.uint32(42).bytes(m.signature);\n if (m.key != null && Object.hasOwnProperty.call(m, \"key\"))\n w.uint32(50).bytes(m.key);\n return w;\n };\n\n /**\n * Decodes a Message message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.Message\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.Message} Message\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n Message.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.Message();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.from = r.bytes();\n break;\n case 2:\n m.data = r.bytes();\n break;\n case 3:\n m.seqno = r.bytes();\n break;\n case 4:\n m.topic = r.string();\n break;\n case 5:\n m.signature = r.bytes();\n break;\n case 6:\n m.key = r.bytes();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n if (!m.hasOwnProperty(\"topic\"))\n throw $util.ProtocolError(\"missing required 'topic'\", { instance: m });\n return m;\n };\n\n /**\n * Creates a Message message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.Message\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.Message} Message\n */\n Message.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.Message)\n return d;\n var m = new $root.RPC.Message();\n if (d.from != null) {\n if (typeof d.from === \"string\")\n $util.base64.decode(d.from, m.from = $util.newBuffer($util.base64.length(d.from)), 0);\n else if (d.from.length)\n m.from = d.from;\n }\n if (d.data != null) {\n if (typeof d.data === \"string\")\n $util.base64.decode(d.data, m.data = $util.newBuffer($util.base64.length(d.data)), 0);\n else if (d.data.length)\n m.data = d.data;\n }\n if (d.seqno != null) {\n if (typeof d.seqno === \"string\")\n $util.base64.decode(d.seqno, m.seqno = $util.newBuffer($util.base64.length(d.seqno)), 0);\n else if (d.seqno.length)\n m.seqno = d.seqno;\n }\n if (d.topic != null) {\n m.topic = String(d.topic);\n }\n if (d.signature != null) {\n if (typeof d.signature === \"string\")\n $util.base64.decode(d.signature, m.signature = $util.newBuffer($util.base64.length(d.signature)), 0);\n else if (d.signature.length)\n m.signature = d.signature;\n }\n if (d.key != null) {\n if (typeof d.key === \"string\")\n $util.base64.decode(d.key, m.key = $util.newBuffer($util.base64.length(d.key)), 0);\n else if (d.key.length)\n m.key = d.key;\n }\n return m;\n };\n\n /**\n * Creates a plain object from a Message message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.Message\n * @static\n * @param {RPC.Message} m Message\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n Message.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.defaults) {\n d.topic = \"\";\n }\n if (m.from != null && m.hasOwnProperty(\"from\")) {\n d.from = o.bytes === String ? $util.base64.encode(m.from, 0, m.from.length) : o.bytes === Array ? Array.prototype.slice.call(m.from) : m.from;\n if (o.oneofs)\n d._from = \"from\";\n }\n if (m.data != null && m.hasOwnProperty(\"data\")) {\n d.data = o.bytes === String ? $util.base64.encode(m.data, 0, m.data.length) : o.bytes === Array ? Array.prototype.slice.call(m.data) : m.data;\n if (o.oneofs)\n d._data = \"data\";\n }\n if (m.seqno != null && m.hasOwnProperty(\"seqno\")) {\n d.seqno = o.bytes === String ? $util.base64.encode(m.seqno, 0, m.seqno.length) : o.bytes === Array ? Array.prototype.slice.call(m.seqno) : m.seqno;\n if (o.oneofs)\n d._seqno = \"seqno\";\n }\n if (m.topic != null && m.hasOwnProperty(\"topic\")) {\n d.topic = m.topic;\n }\n if (m.signature != null && m.hasOwnProperty(\"signature\")) {\n d.signature = o.bytes === String ? $util.base64.encode(m.signature, 0, m.signature.length) : o.bytes === Array ? Array.prototype.slice.call(m.signature) : m.signature;\n if (o.oneofs)\n d._signature = \"signature\";\n }\n if (m.key != null && m.hasOwnProperty(\"key\")) {\n d.key = o.bytes === String ? $util.base64.encode(m.key, 0, m.key.length) : o.bytes === Array ? Array.prototype.slice.call(m.key) : m.key;\n if (o.oneofs)\n d._key = \"key\";\n }\n return d;\n };\n\n /**\n * Converts this Message to JSON.\n * @function toJSON\n * @memberof RPC.Message\n * @instance\n * @returns {Object.} JSON object\n */\n Message.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return Message;\n })();\n\n RPC.ControlMessage = (function() {\n\n /**\n * Properties of a ControlMessage.\n * @memberof RPC\n * @interface IControlMessage\n * @property {Array.|null} [ihave] ControlMessage ihave\n * @property {Array.|null} [iwant] ControlMessage iwant\n * @property {Array.|null} [graft] ControlMessage graft\n * @property {Array.|null} [prune] ControlMessage prune\n */\n\n /**\n * Constructs a new ControlMessage.\n * @memberof RPC\n * @classdesc Represents a ControlMessage.\n * @implements IControlMessage\n * @constructor\n * @param {RPC.IControlMessage=} [p] Properties to set\n */\n function ControlMessage(p) {\n this.ihave = [];\n this.iwant = [];\n this.graft = [];\n this.prune = [];\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * ControlMessage ihave.\n * @member {Array.} ihave\n * @memberof RPC.ControlMessage\n * @instance\n */\n ControlMessage.prototype.ihave = $util.emptyArray;\n\n /**\n * ControlMessage iwant.\n * @member {Array.} iwant\n * @memberof RPC.ControlMessage\n * @instance\n */\n ControlMessage.prototype.iwant = $util.emptyArray;\n\n /**\n * ControlMessage graft.\n * @member {Array.} graft\n * @memberof RPC.ControlMessage\n * @instance\n */\n ControlMessage.prototype.graft = $util.emptyArray;\n\n /**\n * ControlMessage prune.\n * @member {Array.} prune\n * @memberof RPC.ControlMessage\n * @instance\n */\n ControlMessage.prototype.prune = $util.emptyArray;\n\n /**\n * Encodes the specified ControlMessage message. Does not implicitly {@link RPC.ControlMessage.verify|verify} messages.\n * @function encode\n * @memberof RPC.ControlMessage\n * @static\n * @param {RPC.IControlMessage} m ControlMessage message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n ControlMessage.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.ihave != null && m.ihave.length) {\n for (var i = 0; i < m.ihave.length; ++i)\n $root.RPC.ControlIHave.encode(m.ihave[i], w.uint32(10).fork()).ldelim();\n }\n if (m.iwant != null && m.iwant.length) {\n for (var i = 0; i < m.iwant.length; ++i)\n $root.RPC.ControlIWant.encode(m.iwant[i], w.uint32(18).fork()).ldelim();\n }\n if (m.graft != null && m.graft.length) {\n for (var i = 0; i < m.graft.length; ++i)\n $root.RPC.ControlGraft.encode(m.graft[i], w.uint32(26).fork()).ldelim();\n }\n if (m.prune != null && m.prune.length) {\n for (var i = 0; i < m.prune.length; ++i)\n $root.RPC.ControlPrune.encode(m.prune[i], w.uint32(34).fork()).ldelim();\n }\n return w;\n };\n\n /**\n * Decodes a ControlMessage message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.ControlMessage\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.ControlMessage} ControlMessage\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n ControlMessage.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.ControlMessage();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.ihave && m.ihave.length))\n m.ihave = [];\n m.ihave.push($root.RPC.ControlIHave.decode(r, r.uint32()));\n break;\n case 2:\n if (!(m.iwant && m.iwant.length))\n m.iwant = [];\n m.iwant.push($root.RPC.ControlIWant.decode(r, r.uint32()));\n break;\n case 3:\n if (!(m.graft && m.graft.length))\n m.graft = [];\n m.graft.push($root.RPC.ControlGraft.decode(r, r.uint32()));\n break;\n case 4:\n if (!(m.prune && m.prune.length))\n m.prune = [];\n m.prune.push($root.RPC.ControlPrune.decode(r, r.uint32()));\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a ControlMessage message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.ControlMessage\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.ControlMessage} ControlMessage\n */\n ControlMessage.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.ControlMessage)\n return d;\n var m = new $root.RPC.ControlMessage();\n if (d.ihave) {\n if (!Array.isArray(d.ihave))\n throw TypeError(\".RPC.ControlMessage.ihave: array expected\");\n m.ihave = [];\n for (var i = 0; i < d.ihave.length; ++i) {\n if (typeof d.ihave[i] !== \"object\")\n throw TypeError(\".RPC.ControlMessage.ihave: object expected\");\n m.ihave[i] = $root.RPC.ControlIHave.fromObject(d.ihave[i]);\n }\n }\n if (d.iwant) {\n if (!Array.isArray(d.iwant))\n throw TypeError(\".RPC.ControlMessage.iwant: array expected\");\n m.iwant = [];\n for (var i = 0; i < d.iwant.length; ++i) {\n if (typeof d.iwant[i] !== \"object\")\n throw TypeError(\".RPC.ControlMessage.iwant: object expected\");\n m.iwant[i] = $root.RPC.ControlIWant.fromObject(d.iwant[i]);\n }\n }\n if (d.graft) {\n if (!Array.isArray(d.graft))\n throw TypeError(\".RPC.ControlMessage.graft: array expected\");\n m.graft = [];\n for (var i = 0; i < d.graft.length; ++i) {\n if (typeof d.graft[i] !== \"object\")\n throw TypeError(\".RPC.ControlMessage.graft: object expected\");\n m.graft[i] = $root.RPC.ControlGraft.fromObject(d.graft[i]);\n }\n }\n if (d.prune) {\n if (!Array.isArray(d.prune))\n throw TypeError(\".RPC.ControlMessage.prune: array expected\");\n m.prune = [];\n for (var i = 0; i < d.prune.length; ++i) {\n if (typeof d.prune[i] !== \"object\")\n throw TypeError(\".RPC.ControlMessage.prune: object expected\");\n m.prune[i] = $root.RPC.ControlPrune.fromObject(d.prune[i]);\n }\n }\n return m;\n };\n\n /**\n * Creates a plain object from a ControlMessage message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.ControlMessage\n * @static\n * @param {RPC.ControlMessage} m ControlMessage\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n ControlMessage.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.arrays || o.defaults) {\n d.ihave = [];\n d.iwant = [];\n d.graft = [];\n d.prune = [];\n }\n if (m.ihave && m.ihave.length) {\n d.ihave = [];\n for (var j = 0; j < m.ihave.length; ++j) {\n d.ihave[j] = $root.RPC.ControlIHave.toObject(m.ihave[j], o);\n }\n }\n if (m.iwant && m.iwant.length) {\n d.iwant = [];\n for (var j = 0; j < m.iwant.length; ++j) {\n d.iwant[j] = $root.RPC.ControlIWant.toObject(m.iwant[j], o);\n }\n }\n if (m.graft && m.graft.length) {\n d.graft = [];\n for (var j = 0; j < m.graft.length; ++j) {\n d.graft[j] = $root.RPC.ControlGraft.toObject(m.graft[j], o);\n }\n }\n if (m.prune && m.prune.length) {\n d.prune = [];\n for (var j = 0; j < m.prune.length; ++j) {\n d.prune[j] = $root.RPC.ControlPrune.toObject(m.prune[j], o);\n }\n }\n return d;\n };\n\n /**\n * Converts this ControlMessage to JSON.\n * @function toJSON\n * @memberof RPC.ControlMessage\n * @instance\n * @returns {Object.} JSON object\n */\n ControlMessage.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return ControlMessage;\n })();\n\n RPC.ControlIHave = (function() {\n\n /**\n * Properties of a ControlIHave.\n * @memberof RPC\n * @interface IControlIHave\n * @property {string|null} [topicID] ControlIHave topicID\n * @property {Array.|null} [messageIDs] ControlIHave messageIDs\n */\n\n /**\n * Constructs a new ControlIHave.\n * @memberof RPC\n * @classdesc Represents a ControlIHave.\n * @implements IControlIHave\n * @constructor\n * @param {RPC.IControlIHave=} [p] Properties to set\n */\n function ControlIHave(p) {\n this.messageIDs = [];\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * ControlIHave topicID.\n * @member {string|null|undefined} topicID\n * @memberof RPC.ControlIHave\n * @instance\n */\n ControlIHave.prototype.topicID = null;\n\n /**\n * ControlIHave messageIDs.\n * @member {Array.} messageIDs\n * @memberof RPC.ControlIHave\n * @instance\n */\n ControlIHave.prototype.messageIDs = $util.emptyArray;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * ControlIHave _topicID.\n * @member {\"topicID\"|undefined} _topicID\n * @memberof RPC.ControlIHave\n * @instance\n */\n Object.defineProperty(ControlIHave.prototype, \"_topicID\", {\n get: $util.oneOfGetter($oneOfFields = [\"topicID\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified ControlIHave message. Does not implicitly {@link RPC.ControlIHave.verify|verify} messages.\n * @function encode\n * @memberof RPC.ControlIHave\n * @static\n * @param {RPC.IControlIHave} m ControlIHave message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n ControlIHave.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.topicID != null && Object.hasOwnProperty.call(m, \"topicID\"))\n w.uint32(10).string(m.topicID);\n if (m.messageIDs != null && m.messageIDs.length) {\n for (var i = 0; i < m.messageIDs.length; ++i)\n w.uint32(18).bytes(m.messageIDs[i]);\n }\n return w;\n };\n\n /**\n * Decodes a ControlIHave message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.ControlIHave\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.ControlIHave} ControlIHave\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n ControlIHave.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.ControlIHave();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n case 2:\n if (!(m.messageIDs && m.messageIDs.length))\n m.messageIDs = [];\n m.messageIDs.push(r.bytes());\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a ControlIHave message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.ControlIHave\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.ControlIHave} ControlIHave\n */\n ControlIHave.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.ControlIHave)\n return d;\n var m = new $root.RPC.ControlIHave();\n if (d.topicID != null) {\n m.topicID = String(d.topicID);\n }\n if (d.messageIDs) {\n if (!Array.isArray(d.messageIDs))\n throw TypeError(\".RPC.ControlIHave.messageIDs: array expected\");\n m.messageIDs = [];\n for (var i = 0; i < d.messageIDs.length; ++i) {\n if (typeof d.messageIDs[i] === \"string\")\n $util.base64.decode(d.messageIDs[i], m.messageIDs[i] = $util.newBuffer($util.base64.length(d.messageIDs[i])), 0);\n else if (d.messageIDs[i].length)\n m.messageIDs[i] = d.messageIDs[i];\n }\n }\n return m;\n };\n\n /**\n * Creates a plain object from a ControlIHave message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.ControlIHave\n * @static\n * @param {RPC.ControlIHave} m ControlIHave\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n ControlIHave.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.arrays || o.defaults) {\n d.messageIDs = [];\n }\n if (m.topicID != null && m.hasOwnProperty(\"topicID\")) {\n d.topicID = m.topicID;\n if (o.oneofs)\n d._topicID = \"topicID\";\n }\n if (m.messageIDs && m.messageIDs.length) {\n d.messageIDs = [];\n for (var j = 0; j < m.messageIDs.length; ++j) {\n d.messageIDs[j] = o.bytes === String ? $util.base64.encode(m.messageIDs[j], 0, m.messageIDs[j].length) : o.bytes === Array ? Array.prototype.slice.call(m.messageIDs[j]) : m.messageIDs[j];\n }\n }\n return d;\n };\n\n /**\n * Converts this ControlIHave to JSON.\n * @function toJSON\n * @memberof RPC.ControlIHave\n * @instance\n * @returns {Object.} JSON object\n */\n ControlIHave.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return ControlIHave;\n })();\n\n RPC.ControlIWant = (function() {\n\n /**\n * Properties of a ControlIWant.\n * @memberof RPC\n * @interface IControlIWant\n * @property {Array.|null} [messageIDs] ControlIWant messageIDs\n */\n\n /**\n * Constructs a new ControlIWant.\n * @memberof RPC\n * @classdesc Represents a ControlIWant.\n * @implements IControlIWant\n * @constructor\n * @param {RPC.IControlIWant=} [p] Properties to set\n */\n function ControlIWant(p) {\n this.messageIDs = [];\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * ControlIWant messageIDs.\n * @member {Array.} messageIDs\n * @memberof RPC.ControlIWant\n * @instance\n */\n ControlIWant.prototype.messageIDs = $util.emptyArray;\n\n /**\n * Encodes the specified ControlIWant message. Does not implicitly {@link RPC.ControlIWant.verify|verify} messages.\n * @function encode\n * @memberof RPC.ControlIWant\n * @static\n * @param {RPC.IControlIWant} m ControlIWant message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n ControlIWant.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.messageIDs != null && m.messageIDs.length) {\n for (var i = 0; i < m.messageIDs.length; ++i)\n w.uint32(10).bytes(m.messageIDs[i]);\n }\n return w;\n };\n\n /**\n * Decodes a ControlIWant message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.ControlIWant\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.ControlIWant} ControlIWant\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n ControlIWant.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.ControlIWant();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.messageIDs && m.messageIDs.length))\n m.messageIDs = [];\n m.messageIDs.push(r.bytes());\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a ControlIWant message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.ControlIWant\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.ControlIWant} ControlIWant\n */\n ControlIWant.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.ControlIWant)\n return d;\n var m = new $root.RPC.ControlIWant();\n if (d.messageIDs) {\n if (!Array.isArray(d.messageIDs))\n throw TypeError(\".RPC.ControlIWant.messageIDs: array expected\");\n m.messageIDs = [];\n for (var i = 0; i < d.messageIDs.length; ++i) {\n if (typeof d.messageIDs[i] === \"string\")\n $util.base64.decode(d.messageIDs[i], m.messageIDs[i] = $util.newBuffer($util.base64.length(d.messageIDs[i])), 0);\n else if (d.messageIDs[i].length)\n m.messageIDs[i] = d.messageIDs[i];\n }\n }\n return m;\n };\n\n /**\n * Creates a plain object from a ControlIWant message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.ControlIWant\n * @static\n * @param {RPC.ControlIWant} m ControlIWant\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n ControlIWant.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.arrays || o.defaults) {\n d.messageIDs = [];\n }\n if (m.messageIDs && m.messageIDs.length) {\n d.messageIDs = [];\n for (var j = 0; j < m.messageIDs.length; ++j) {\n d.messageIDs[j] = o.bytes === String ? $util.base64.encode(m.messageIDs[j], 0, m.messageIDs[j].length) : o.bytes === Array ? Array.prototype.slice.call(m.messageIDs[j]) : m.messageIDs[j];\n }\n }\n return d;\n };\n\n /**\n * Converts this ControlIWant to JSON.\n * @function toJSON\n * @memberof RPC.ControlIWant\n * @instance\n * @returns {Object.} JSON object\n */\n ControlIWant.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return ControlIWant;\n })();\n\n RPC.ControlGraft = (function() {\n\n /**\n * Properties of a ControlGraft.\n * @memberof RPC\n * @interface IControlGraft\n * @property {string|null} [topicID] ControlGraft topicID\n */\n\n /**\n * Constructs a new ControlGraft.\n * @memberof RPC\n * @classdesc Represents a ControlGraft.\n * @implements IControlGraft\n * @constructor\n * @param {RPC.IControlGraft=} [p] Properties to set\n */\n function ControlGraft(p) {\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * ControlGraft topicID.\n * @member {string|null|undefined} topicID\n * @memberof RPC.ControlGraft\n * @instance\n */\n ControlGraft.prototype.topicID = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * ControlGraft _topicID.\n * @member {\"topicID\"|undefined} _topicID\n * @memberof RPC.ControlGraft\n * @instance\n */\n Object.defineProperty(ControlGraft.prototype, \"_topicID\", {\n get: $util.oneOfGetter($oneOfFields = [\"topicID\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified ControlGraft message. Does not implicitly {@link RPC.ControlGraft.verify|verify} messages.\n * @function encode\n * @memberof RPC.ControlGraft\n * @static\n * @param {RPC.IControlGraft} m ControlGraft message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n ControlGraft.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.topicID != null && Object.hasOwnProperty.call(m, \"topicID\"))\n w.uint32(10).string(m.topicID);\n return w;\n };\n\n /**\n * Decodes a ControlGraft message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.ControlGraft\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.ControlGraft} ControlGraft\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n ControlGraft.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.ControlGraft();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a ControlGraft message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.ControlGraft\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.ControlGraft} ControlGraft\n */\n ControlGraft.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.ControlGraft)\n return d;\n var m = new $root.RPC.ControlGraft();\n if (d.topicID != null) {\n m.topicID = String(d.topicID);\n }\n return m;\n };\n\n /**\n * Creates a plain object from a ControlGraft message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.ControlGraft\n * @static\n * @param {RPC.ControlGraft} m ControlGraft\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n ControlGraft.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (m.topicID != null && m.hasOwnProperty(\"topicID\")) {\n d.topicID = m.topicID;\n if (o.oneofs)\n d._topicID = \"topicID\";\n }\n return d;\n };\n\n /**\n * Converts this ControlGraft to JSON.\n * @function toJSON\n * @memberof RPC.ControlGraft\n * @instance\n * @returns {Object.} JSON object\n */\n ControlGraft.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return ControlGraft;\n })();\n\n RPC.ControlPrune = (function() {\n\n /**\n * Properties of a ControlPrune.\n * @memberof RPC\n * @interface IControlPrune\n * @property {string|null} [topicID] ControlPrune topicID\n * @property {Array.|null} [peers] ControlPrune peers\n * @property {number|null} [backoff] ControlPrune backoff\n */\n\n /**\n * Constructs a new ControlPrune.\n * @memberof RPC\n * @classdesc Represents a ControlPrune.\n * @implements IControlPrune\n * @constructor\n * @param {RPC.IControlPrune=} [p] Properties to set\n */\n function ControlPrune(p) {\n this.peers = [];\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * ControlPrune topicID.\n * @member {string|null|undefined} topicID\n * @memberof RPC.ControlPrune\n * @instance\n */\n ControlPrune.prototype.topicID = null;\n\n /**\n * ControlPrune peers.\n * @member {Array.} peers\n * @memberof RPC.ControlPrune\n * @instance\n */\n ControlPrune.prototype.peers = $util.emptyArray;\n\n /**\n * ControlPrune backoff.\n * @member {number|null|undefined} backoff\n * @memberof RPC.ControlPrune\n * @instance\n */\n ControlPrune.prototype.backoff = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * ControlPrune _topicID.\n * @member {\"topicID\"|undefined} _topicID\n * @memberof RPC.ControlPrune\n * @instance\n */\n Object.defineProperty(ControlPrune.prototype, \"_topicID\", {\n get: $util.oneOfGetter($oneOfFields = [\"topicID\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * ControlPrune _backoff.\n * @member {\"backoff\"|undefined} _backoff\n * @memberof RPC.ControlPrune\n * @instance\n */\n Object.defineProperty(ControlPrune.prototype, \"_backoff\", {\n get: $util.oneOfGetter($oneOfFields = [\"backoff\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified ControlPrune message. Does not implicitly {@link RPC.ControlPrune.verify|verify} messages.\n * @function encode\n * @memberof RPC.ControlPrune\n * @static\n * @param {RPC.IControlPrune} m ControlPrune message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n ControlPrune.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.topicID != null && Object.hasOwnProperty.call(m, \"topicID\"))\n w.uint32(10).string(m.topicID);\n if (m.peers != null && m.peers.length) {\n for (var i = 0; i < m.peers.length; ++i)\n $root.RPC.PeerInfo.encode(m.peers[i], w.uint32(18).fork()).ldelim();\n }\n if (m.backoff != null && Object.hasOwnProperty.call(m, \"backoff\"))\n w.uint32(24).uint64(m.backoff);\n return w;\n };\n\n /**\n * Decodes a ControlPrune message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.ControlPrune\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.ControlPrune} ControlPrune\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n ControlPrune.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.ControlPrune();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n case 2:\n if (!(m.peers && m.peers.length))\n m.peers = [];\n m.peers.push($root.RPC.PeerInfo.decode(r, r.uint32()));\n break;\n case 3:\n m.backoff = r.uint64();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a ControlPrune message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.ControlPrune\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.ControlPrune} ControlPrune\n */\n ControlPrune.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.ControlPrune)\n return d;\n var m = new $root.RPC.ControlPrune();\n if (d.topicID != null) {\n m.topicID = String(d.topicID);\n }\n if (d.peers) {\n if (!Array.isArray(d.peers))\n throw TypeError(\".RPC.ControlPrune.peers: array expected\");\n m.peers = [];\n for (var i = 0; i < d.peers.length; ++i) {\n if (typeof d.peers[i] !== \"object\")\n throw TypeError(\".RPC.ControlPrune.peers: object expected\");\n m.peers[i] = $root.RPC.PeerInfo.fromObject(d.peers[i]);\n }\n }\n if (d.backoff != null) {\n if ($util.Long)\n (m.backoff = $util.Long.fromValue(d.backoff)).unsigned = true;\n else if (typeof d.backoff === \"string\")\n m.backoff = parseInt(d.backoff, 10);\n else if (typeof d.backoff === \"number\")\n m.backoff = d.backoff;\n else if (typeof d.backoff === \"object\")\n m.backoff = new $util.LongBits(d.backoff.low >>> 0, d.backoff.high >>> 0).toNumber(true);\n }\n return m;\n };\n\n /**\n * Creates a plain object from a ControlPrune message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.ControlPrune\n * @static\n * @param {RPC.ControlPrune} m ControlPrune\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n ControlPrune.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (o.arrays || o.defaults) {\n d.peers = [];\n }\n if (m.topicID != null && m.hasOwnProperty(\"topicID\")) {\n d.topicID = m.topicID;\n if (o.oneofs)\n d._topicID = \"topicID\";\n }\n if (m.peers && m.peers.length) {\n d.peers = [];\n for (var j = 0; j < m.peers.length; ++j) {\n d.peers[j] = $root.RPC.PeerInfo.toObject(m.peers[j], o);\n }\n }\n if (m.backoff != null && m.hasOwnProperty(\"backoff\")) {\n if (typeof m.backoff === \"number\")\n d.backoff = o.longs === String ? String(m.backoff) : m.backoff;\n else\n d.backoff = o.longs === String ? $util.Long.prototype.toString.call(m.backoff) : o.longs === Number ? new $util.LongBits(m.backoff.low >>> 0, m.backoff.high >>> 0).toNumber(true) : m.backoff;\n if (o.oneofs)\n d._backoff = \"backoff\";\n }\n return d;\n };\n\n /**\n * Converts this ControlPrune to JSON.\n * @function toJSON\n * @memberof RPC.ControlPrune\n * @instance\n * @returns {Object.} JSON object\n */\n ControlPrune.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return ControlPrune;\n })();\n\n RPC.PeerInfo = (function() {\n\n /**\n * Properties of a PeerInfo.\n * @memberof RPC\n * @interface IPeerInfo\n * @property {Uint8Array|null} [peerID] PeerInfo peerID\n * @property {Uint8Array|null} [signedPeerRecord] PeerInfo signedPeerRecord\n */\n\n /**\n * Constructs a new PeerInfo.\n * @memberof RPC\n * @classdesc Represents a PeerInfo.\n * @implements IPeerInfo\n * @constructor\n * @param {RPC.IPeerInfo=} [p] Properties to set\n */\n function PeerInfo(p) {\n if (p)\n for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)\n if (p[ks[i]] != null)\n this[ks[i]] = p[ks[i]];\n }\n\n /**\n * PeerInfo peerID.\n * @member {Uint8Array|null|undefined} peerID\n * @memberof RPC.PeerInfo\n * @instance\n */\n PeerInfo.prototype.peerID = null;\n\n /**\n * PeerInfo signedPeerRecord.\n * @member {Uint8Array|null|undefined} signedPeerRecord\n * @memberof RPC.PeerInfo\n * @instance\n */\n PeerInfo.prototype.signedPeerRecord = null;\n\n // OneOf field names bound to virtual getters and setters\n var $oneOfFields;\n\n /**\n * PeerInfo _peerID.\n * @member {\"peerID\"|undefined} _peerID\n * @memberof RPC.PeerInfo\n * @instance\n */\n Object.defineProperty(PeerInfo.prototype, \"_peerID\", {\n get: $util.oneOfGetter($oneOfFields = [\"peerID\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * PeerInfo _signedPeerRecord.\n * @member {\"signedPeerRecord\"|undefined} _signedPeerRecord\n * @memberof RPC.PeerInfo\n * @instance\n */\n Object.defineProperty(PeerInfo.prototype, \"_signedPeerRecord\", {\n get: $util.oneOfGetter($oneOfFields = [\"signedPeerRecord\"]),\n set: $util.oneOfSetter($oneOfFields)\n });\n\n /**\n * Encodes the specified PeerInfo message. Does not implicitly {@link RPC.PeerInfo.verify|verify} messages.\n * @function encode\n * @memberof RPC.PeerInfo\n * @static\n * @param {RPC.IPeerInfo} m PeerInfo message or plain object to encode\n * @param {$protobuf.Writer} [w] Writer to encode to\n * @returns {$protobuf.Writer} Writer\n */\n PeerInfo.encode = function encode(m, w) {\n if (!w)\n w = $Writer.create();\n if (m.peerID != null && Object.hasOwnProperty.call(m, \"peerID\"))\n w.uint32(10).bytes(m.peerID);\n if (m.signedPeerRecord != null && Object.hasOwnProperty.call(m, \"signedPeerRecord\"))\n w.uint32(18).bytes(m.signedPeerRecord);\n return w;\n };\n\n /**\n * Decodes a PeerInfo message from the specified reader or buffer.\n * @function decode\n * @memberof RPC.PeerInfo\n * @static\n * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from\n * @param {number} [l] Message length if known beforehand\n * @returns {RPC.PeerInfo} PeerInfo\n * @throws {Error} If the payload is not a reader or valid buffer\n * @throws {$protobuf.util.ProtocolError} If required fields are missing\n */\n PeerInfo.decode = function decode(r, l) {\n if (!(r instanceof $Reader))\n r = $Reader.create(r);\n var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.PeerInfo();\n while (r.pos < c) {\n var t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.peerID = r.bytes();\n break;\n case 2:\n m.signedPeerRecord = r.bytes();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n };\n\n /**\n * Creates a PeerInfo message from a plain object. Also converts values to their respective internal types.\n * @function fromObject\n * @memberof RPC.PeerInfo\n * @static\n * @param {Object.} d Plain object\n * @returns {RPC.PeerInfo} PeerInfo\n */\n PeerInfo.fromObject = function fromObject(d) {\n if (d instanceof $root.RPC.PeerInfo)\n return d;\n var m = new $root.RPC.PeerInfo();\n if (d.peerID != null) {\n if (typeof d.peerID === \"string\")\n $util.base64.decode(d.peerID, m.peerID = $util.newBuffer($util.base64.length(d.peerID)), 0);\n else if (d.peerID.length)\n m.peerID = d.peerID;\n }\n if (d.signedPeerRecord != null) {\n if (typeof d.signedPeerRecord === \"string\")\n $util.base64.decode(d.signedPeerRecord, m.signedPeerRecord = $util.newBuffer($util.base64.length(d.signedPeerRecord)), 0);\n else if (d.signedPeerRecord.length)\n m.signedPeerRecord = d.signedPeerRecord;\n }\n return m;\n };\n\n /**\n * Creates a plain object from a PeerInfo message. Also converts values to other types if specified.\n * @function toObject\n * @memberof RPC.PeerInfo\n * @static\n * @param {RPC.PeerInfo} m PeerInfo\n * @param {$protobuf.IConversionOptions} [o] Conversion options\n * @returns {Object.} Plain object\n */\n PeerInfo.toObject = function toObject(m, o) {\n if (!o)\n o = {};\n var d = {};\n if (m.peerID != null && m.hasOwnProperty(\"peerID\")) {\n d.peerID = o.bytes === String ? $util.base64.encode(m.peerID, 0, m.peerID.length) : o.bytes === Array ? Array.prototype.slice.call(m.peerID) : m.peerID;\n if (o.oneofs)\n d._peerID = \"peerID\";\n }\n if (m.signedPeerRecord != null && m.hasOwnProperty(\"signedPeerRecord\")) {\n d.signedPeerRecord = o.bytes === String ? $util.base64.encode(m.signedPeerRecord, 0, m.signedPeerRecord.length) : o.bytes === Array ? Array.prototype.slice.call(m.signedPeerRecord) : m.signedPeerRecord;\n if (o.oneofs)\n d._signedPeerRecord = \"signedPeerRecord\";\n }\n return d;\n };\n\n /**\n * Converts this PeerInfo to JSON.\n * @function toJSON\n * @memberof RPC.PeerInfo\n * @instance\n * @returns {Object.} JSON object\n */\n PeerInfo.prototype.toJSON = function toJSON() {\n return this.constructor.toObject(this, $protobuf.util.toJSONOptions);\n };\n\n return PeerInfo;\n })();\n\n return RPC;\n })();\n\n return $root;\n});\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs?"); - -/***/ }), - /***/ "./node_modules/@chainsafe/is-ip/lib/is-ip.js": /*!****************************************************!*\ !*** ./node_modules/@chainsafe/is-ip/lib/is-ip.js ***! @@ -2071,6 +1638,358 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js": +/*!************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ACCEPT_FROM_WHITELIST_DURATION_MS: () => (/* binding */ ACCEPT_FROM_WHITELIST_DURATION_MS),\n/* harmony export */ ACCEPT_FROM_WHITELIST_MAX_MESSAGES: () => (/* binding */ ACCEPT_FROM_WHITELIST_MAX_MESSAGES),\n/* harmony export */ ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE: () => (/* binding */ ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE),\n/* harmony export */ BACKOFF_SLACK: () => (/* binding */ BACKOFF_SLACK),\n/* harmony export */ DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS: () => (/* binding */ DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS),\n/* harmony export */ ERR_TOPIC_VALIDATOR_IGNORE: () => (/* binding */ ERR_TOPIC_VALIDATOR_IGNORE),\n/* harmony export */ ERR_TOPIC_VALIDATOR_REJECT: () => (/* binding */ ERR_TOPIC_VALIDATOR_REJECT),\n/* harmony export */ FloodsubID: () => (/* binding */ FloodsubID),\n/* harmony export */ GossipsubConnectionTimeout: () => (/* binding */ GossipsubConnectionTimeout),\n/* harmony export */ GossipsubConnectors: () => (/* binding */ GossipsubConnectors),\n/* harmony export */ GossipsubD: () => (/* binding */ GossipsubD),\n/* harmony export */ GossipsubDhi: () => (/* binding */ GossipsubDhi),\n/* harmony export */ GossipsubDirectConnectInitialDelay: () => (/* binding */ GossipsubDirectConnectInitialDelay),\n/* harmony export */ GossipsubDirectConnectTicks: () => (/* binding */ GossipsubDirectConnectTicks),\n/* harmony export */ GossipsubDlazy: () => (/* binding */ GossipsubDlazy),\n/* harmony export */ GossipsubDlo: () => (/* binding */ GossipsubDlo),\n/* harmony export */ GossipsubDout: () => (/* binding */ GossipsubDout),\n/* harmony export */ GossipsubDscore: () => (/* binding */ GossipsubDscore),\n/* harmony export */ GossipsubFanoutTTL: () => (/* binding */ GossipsubFanoutTTL),\n/* harmony export */ GossipsubGossipFactor: () => (/* binding */ GossipsubGossipFactor),\n/* harmony export */ GossipsubGossipRetransmission: () => (/* binding */ GossipsubGossipRetransmission),\n/* harmony export */ GossipsubGraftFloodThreshold: () => (/* binding */ GossipsubGraftFloodThreshold),\n/* harmony export */ GossipsubHeartbeatInitialDelay: () => (/* binding */ GossipsubHeartbeatInitialDelay),\n/* harmony export */ GossipsubHeartbeatInterval: () => (/* binding */ GossipsubHeartbeatInterval),\n/* harmony export */ GossipsubHistoryGossip: () => (/* binding */ GossipsubHistoryGossip),\n/* harmony export */ GossipsubHistoryLength: () => (/* binding */ GossipsubHistoryLength),\n/* harmony export */ GossipsubIDv10: () => (/* binding */ GossipsubIDv10),\n/* harmony export */ GossipsubIDv11: () => (/* binding */ GossipsubIDv11),\n/* harmony export */ GossipsubIWantFollowupTime: () => (/* binding */ GossipsubIWantFollowupTime),\n/* harmony export */ GossipsubMaxIHaveLength: () => (/* binding */ GossipsubMaxIHaveLength),\n/* harmony export */ GossipsubMaxIHaveMessages: () => (/* binding */ GossipsubMaxIHaveMessages),\n/* harmony export */ GossipsubMaxPendingConnections: () => (/* binding */ GossipsubMaxPendingConnections),\n/* harmony export */ GossipsubOpportunisticGraftPeers: () => (/* binding */ GossipsubOpportunisticGraftPeers),\n/* harmony export */ GossipsubOpportunisticGraftTicks: () => (/* binding */ GossipsubOpportunisticGraftTicks),\n/* harmony export */ GossipsubPruneBackoff: () => (/* binding */ GossipsubPruneBackoff),\n/* harmony export */ GossipsubPruneBackoffTicks: () => (/* binding */ GossipsubPruneBackoffTicks),\n/* harmony export */ GossipsubPrunePeers: () => (/* binding */ GossipsubPrunePeers),\n/* harmony export */ GossipsubSeenTTL: () => (/* binding */ GossipsubSeenTTL),\n/* harmony export */ GossipsubUnsubscribeBackoff: () => (/* binding */ GossipsubUnsubscribeBackoff),\n/* harmony export */ TimeCacheDuration: () => (/* binding */ TimeCacheDuration),\n/* harmony export */ minute: () => (/* binding */ minute),\n/* harmony export */ second: () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n// Protocol identifiers\nconst FloodsubID = '/floodsub/1.0.0';\n/**\n * The protocol ID for version 1.0.0 of the Gossipsub protocol\n * It is advertised along with GossipsubIDv11 for backwards compatability\n */\nconst GossipsubIDv10 = '/meshsub/1.0.0';\n/**\n * The protocol ID for version 1.1.0 of the Gossipsub protocol\n * See the spec for details about how v1.1.0 compares to v1.0.0:\n * https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md\n */\nconst GossipsubIDv11 = '/meshsub/1.1.0';\n// Overlay parameters\n/**\n * GossipsubD sets the optimal degree for a Gossipsub topic mesh. For example, if GossipsubD == 6,\n * each peer will want to have about six peers in their mesh for each topic they're subscribed to.\n * GossipsubD should be set somewhere between GossipsubDlo and GossipsubDhi.\n */\nconst GossipsubD = 6;\n/**\n * GossipsubDlo sets the lower bound on the number of peers we keep in a Gossipsub topic mesh.\n * If we have fewer than GossipsubDlo peers, we will attempt to graft some more into the mesh at\n * the next heartbeat.\n */\nconst GossipsubDlo = 4;\n/**\n * GossipsubDhi sets the upper bound on the number of peers we keep in a Gossipsub topic mesh.\n * If we have more than GossipsubDhi peers, we will select some to prune from the mesh at the next heartbeat.\n */\nconst GossipsubDhi = 12;\n/**\n * GossipsubDscore affects how peers are selected when pruning a mesh due to over subscription.\n * At least GossipsubDscore of the retained peers will be high-scoring, while the remainder are\n * chosen randomly.\n */\nconst GossipsubDscore = 4;\n/**\n * GossipsubDout sets the quota for the number of outbound connections to maintain in a topic mesh.\n * When the mesh is pruned due to over subscription, we make sure that we have outbound connections\n * to at least GossipsubDout of the survivor peers. This prevents sybil attackers from overwhelming\n * our mesh with incoming connections.\n *\n * GossipsubDout must be set below GossipsubDlo, and must not exceed GossipsubD / 2.\n */\nconst GossipsubDout = 2;\n// Gossip parameters\n/**\n * GossipsubHistoryLength controls the size of the message cache used for gossip.\n * The message cache will remember messages for GossipsubHistoryLength heartbeats.\n */\nconst GossipsubHistoryLength = 5;\n/**\n * GossipsubHistoryGossip controls how many cached message ids we will advertise in\n * IHAVE gossip messages. When asked for our seen message IDs, we will return\n * only those from the most recent GossipsubHistoryGossip heartbeats. The slack between\n * GossipsubHistoryGossip and GossipsubHistoryLength allows us to avoid advertising messages\n * that will be expired by the time they're requested.\n *\n * GossipsubHistoryGossip must be less than or equal to GossipsubHistoryLength to\n * avoid a runtime panic.\n */\nconst GossipsubHistoryGossip = 3;\n/**\n * GossipsubDlazy affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to at least GossipsubDlazy peers outside our mesh. The actual\n * number may be more, depending on GossipsubGossipFactor and how many peers we're\n * connected to.\n */\nconst GossipsubDlazy = 6;\n/**\n * GossipsubGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to GossipsubGossipFactor * (total number of non-mesh peers), or\n * GossipsubDlazy, whichever is greater.\n */\nconst GossipsubGossipFactor = 0.25;\n/**\n * GossipsubGossipRetransmission controls how many times we will allow a peer to request\n * the same message id through IWANT gossip before we start ignoring them. This is designed\n * to prevent peers from spamming us with requests and wasting our resources.\n */\nconst GossipsubGossipRetransmission = 3;\n// Heartbeat interval\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst GossipsubHeartbeatInitialDelay = 100;\n/**\n * GossipsubHeartbeatInterval controls the time between heartbeats.\n */\nconst GossipsubHeartbeatInterval = second;\n/**\n * GossipsubFanoutTTL controls how long we keep track of the fanout state. If it's been\n * GossipsubFanoutTTL since we've published to a topic that we're not subscribed to,\n * we'll delete the fanout map for that topic.\n */\nconst GossipsubFanoutTTL = minute;\n/**\n * GossipsubPrunePeers controls the number of peers to include in prune Peer eXchange.\n * When we prune a peer that's eligible for PX (has a good score, etc), we will try to\n * send them signed peer records for up to GossipsubPrunePeers other peers that we\n * know of.\n */\nconst GossipsubPrunePeers = 16;\n/**\n * GossipsubPruneBackoff controls the backoff time for pruned peers. This is how long\n * a peer must wait before attempting to graft into our mesh again after being pruned.\n * When pruning a peer, we send them our value of GossipsubPruneBackoff so they know\n * the minimum time to wait. Peers running older versions may not send a backoff time,\n * so if we receive a prune message without one, we will wait at least GossipsubPruneBackoff\n * before attempting to re-graft.\n */\nconst GossipsubPruneBackoff = minute;\n/**\n * Backoff to use when unsuscribing from a topic. Should not resubscribe to this topic before it expired.\n */\nconst GossipsubUnsubscribeBackoff = 10 * second;\n/**\n * GossipsubPruneBackoffTicks is the number of heartbeat ticks for attempting to prune expired\n * backoff timers.\n */\nconst GossipsubPruneBackoffTicks = 15;\n/**\n * GossipsubConnectors controls the number of active connection attempts for peers obtained through PX.\n */\nconst GossipsubConnectors = 8;\n/**\n * GossipsubMaxPendingConnections sets the maximum number of pending connections for peers attempted through px.\n */\nconst GossipsubMaxPendingConnections = 128;\n/**\n * GossipsubConnectionTimeout controls the timeout for connection attempts.\n */\nconst GossipsubConnectionTimeout = 30 * second;\n/**\n * GossipsubDirectConnectTicks is the number of heartbeat ticks for attempting to reconnect direct peers\n * that are not currently connected.\n */\nconst GossipsubDirectConnectTicks = 300;\n/**\n * GossipsubDirectConnectInitialDelay is the initial delay before opening connections to direct peers\n */\nconst GossipsubDirectConnectInitialDelay = second;\n/**\n * GossipsubOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every GossipsubOpportunisticGraftTicks we will attempt to select some\n * high-scoring mesh peers to replace lower-scoring ones, if the median score of our mesh peers falls\n * below a threshold\n */\nconst GossipsubOpportunisticGraftTicks = 60;\n/**\n * GossipsubOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst GossipsubOpportunisticGraftPeers = 2;\n/**\n * If a GRAFT comes before GossipsubGraftFloodThreshold has elapsed since the last PRUNE,\n * then there is an extra score penalty applied to the peer through P7.\n */\nconst GossipsubGraftFloodThreshold = 10 * second;\n/**\n * GossipsubMaxIHaveLength is the maximum number of messages to include in an IHAVE message.\n * Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a\n * peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the\n * default if your system is pushing more than 5000 messages in GossipsubHistoryGossip heartbeats;\n * with the defaults this is 1666 messages/s.\n */\nconst GossipsubMaxIHaveLength = 5000;\n/**\n * GossipsubMaxIHaveMessages is the maximum number of IHAVE messages to accept from a peer within a heartbeat.\n */\nconst GossipsubMaxIHaveMessages = 10;\n/**\n * Time to wait for a message requested through IWANT following an IHAVE advertisement.\n * If the message is not received within this window, a broken promise is declared and\n * the router may apply bahavioural penalties.\n */\nconst GossipsubIWantFollowupTime = 3 * second;\n/**\n * Time in milliseconds to keep message ids in the seen cache\n */\nconst GossipsubSeenTTL = 2 * minute;\nconst TimeCacheDuration = 120 * 1000;\nconst ERR_TOPIC_VALIDATOR_REJECT = 'ERR_TOPIC_VALIDATOR_REJECT';\nconst ERR_TOPIC_VALIDATOR_IGNORE = 'ERR_TOPIC_VALIDATOR_IGNORE';\n/**\n * If peer score is better than this, we accept messages from this peer\n * within ACCEPT_FROM_WHITELIST_DURATION_MS from the last time computing score.\n **/\nconst ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE = 0;\n/**\n * If peer score >= ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE, accept up to this\n * number of messages from that peer.\n */\nconst ACCEPT_FROM_WHITELIST_MAX_MESSAGES = 128;\n/**\n * If peer score >= ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE, accept messages from\n * this peer up to this time duration.\n */\nconst ACCEPT_FROM_WHITELIST_DURATION_MS = 1000;\n/**\n * The default MeshMessageDeliveriesWindow to be used in metrics.\n */\nconst DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS = 1000;\n/** Wait for 1 more heartbeats before clearing a backoff */\nconst BACKOFF_SLACK = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js": +/*!********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ GossipSub: () => (/* binding */ GossipSub),\n/* harmony export */ gossipsub: () => (/* binding */ gossipsub),\n/* harmony export */ multicodec: () => (/* binding */ multicodec)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./utils/create-gossip-rpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/create-gossip-rpc.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIDv11;\nvar GossipStatusCode;\n(function (GossipStatusCode) {\n GossipStatusCode[GossipStatusCode[\"started\"] = 0] = \"started\";\n GossipStatusCode[GossipStatusCode[\"stopped\"] = 1] = \"stopped\";\n})(GossipStatusCode || (GossipStatusCode = {}));\nclass GossipSub extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.TypedEventEmitter {\n /**\n * The signature policy to follow by default\n */\n globalSignaturePolicy;\n multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIDv10];\n publishConfig;\n dataTransform;\n // State\n peers = new Set();\n streamsInbound = new Map();\n streamsOutbound = new Map();\n /** Ensures outbound streams are created sequentially */\n outboundInflightQueue = (0,it_pushable__WEBPACK_IMPORTED_MODULE_2__.pushable)({ objectMode: true });\n /** Direct peers */\n direct = new Set();\n /** Floodsub peers */\n floodsubPeers = new Set();\n /** Cache of seen messages */\n seenCache;\n /**\n * Map of peer id and AcceptRequestWhileListEntry\n */\n acceptFromWhitelist = new Map();\n /**\n * Map of topics to which peers are subscribed to\n */\n topics = new Map();\n /**\n * List of our subscriptions\n */\n subscriptions = new Set();\n /**\n * Map of topic meshes\n * topic => peer id set\n */\n mesh = new Map();\n /**\n * Map of topics to set of peers. These mesh peers are the ones to which we are publishing without a topic membership\n * topic => peer id set\n */\n fanout = new Map();\n /**\n * Map of last publish time for fanout topics\n * topic => last publish time\n */\n fanoutLastpub = new Map();\n /**\n * Map of pending messages to gossip\n * peer id => control messages\n */\n gossip = new Map();\n /**\n * Map of control messages\n * peer id => control message\n */\n control = new Map();\n /**\n * Number of IHAVEs received from peer in the last heartbeat\n */\n peerhave = new Map();\n /** Number of messages we have asked from peer in the last heartbeat */\n iasked = new Map();\n /** Prune backoff map */\n backoff = new Map();\n /**\n * Connection direction cache, marks peers with outbound connections\n * peer id => direction\n */\n outbound = new Map();\n msgIdFn;\n /**\n * A fast message id function used for internal message de-duplication\n */\n fastMsgIdFn;\n msgIdToStrFn;\n /** Maps fast message-id to canonical message-id */\n fastMsgIdCache;\n /**\n * Short term cache for published message ids. This is used for penalizing peers sending\n * our own messages back if the messages are anonymous or use a random author.\n */\n publishedMessageIds;\n /**\n * A message cache that contains the messages for last few heartbeat ticks\n */\n mcache;\n /** Peer score tracking */\n score;\n /**\n * Custom validator function per topic.\n * Must return or resolve quickly (< 100ms) to prevent causing penalties for late messages.\n * If you need to apply validation that may require longer times use `asyncValidation` option and callback the\n * validation result through `Gossipsub.reportValidationResult`\n */\n topicValidators = new Map();\n /**\n * Make this protected so child class may want to redirect to its own log.\n */\n log;\n /**\n * Number of heartbeats since the beginning of time\n * This allows us to amortize some resource cleanup -- eg: backoff cleanup\n */\n heartbeatTicks = 0;\n /**\n * Tracks IHAVE/IWANT promises broken by peers\n */\n gossipTracer;\n components;\n directPeerInitial = null;\n static multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIDv11;\n // Options\n opts;\n decodeRpcLimits;\n metrics;\n status = { code: GossipStatusCode.stopped };\n maxInboundStreams;\n maxOutboundStreams;\n runOnTransientConnection;\n allowedTopics;\n heartbeatTimer = null;\n constructor(components, options = {}) {\n super();\n const opts = {\n fallbackToFloodsub: true,\n floodPublish: true,\n batchPublish: false,\n doPX: false,\n directPeers: [],\n D: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubPruneBackoff,\n unsubcribeBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubUnsubscribeBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_5__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_6__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_7__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.StrictSign;\n // Also wants to get notified of peers connected using floodsub\n if (opts.fallbackToFloodsub) {\n this.multicodecs.push(_constants_js__WEBPACK_IMPORTED_MODULE_3__.FloodsubID);\n }\n // From pubsub\n this.log = components.logger.forComponent(opts.debugName ?? 'libp2p:gossipsub');\n // Gossipsub\n this.opts = opts;\n this.direct = new Set(opts.directPeers.map((p) => p.id.toString()));\n this.seenCache = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_9__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_9__.SimpleTimeCache({ validityMs: opts.seenTTL });\n if (options.msgIdFn != null) {\n // Use custom function\n this.msgIdFn = options.msgIdFn;\n }\n else {\n switch (this.globalSignaturePolicy) {\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_10__.msgIdFnStrictSign;\n break;\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_10__.msgIdFnStrictNoSign;\n break;\n default:\n throw new Error(`Invalid globalSignaturePolicy: ${this.globalSignaturePolicy}`);\n }\n }\n if (options.fastMsgIdFn != null) {\n this.fastMsgIdFn = options.fastMsgIdFn;\n this.fastMsgIdCache = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_9__.SimpleTimeCache({ validityMs: opts.seenTTL });\n }\n // By default, gossipsub only provide a browser friendly function to convert Uint8Array message id to string.\n this.msgIdToStrFn = options.msgIdToStrFn ?? _utils_index_js__WEBPACK_IMPORTED_MODULE_11__.messageIdToString;\n this.mcache = options.messageCache ?? new _message_cache_js__WEBPACK_IMPORTED_MODULE_12__.MessageCache(opts.mcacheGossip, opts.mcacheLength, this.msgIdToStrFn);\n if (options.dataTransform != null) {\n this.dataTransform = options.dataTransform;\n }\n if (options.metricsRegister != null) {\n if (options.metricsTopicStrToLabel == null) {\n throw Error('Must set metricsTopicStrToLabel with metrics');\n }\n // in theory, each topic has its own meshMessageDeliveriesWindow param\n // however in lodestar, we configure it mostly the same so just pick the max of positive ones\n // (some topics have meshMessageDeliveriesWindow as 0)\n const maxMeshMessageDeliveriesWindowMs = Math.max(...Object.values(opts.scoreParams.topics).map((topicParam) => topicParam.meshMessageDeliveriesWindow), _constants_js__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS);\n const metrics = (0,_metrics_js__WEBPACK_IMPORTED_MODULE_13__.getMetrics)(options.metricsRegister, options.metricsTopicStrToLabel, {\n gossipPromiseExpireSec: this.opts.gossipsubIWantFollowupMs / 1000,\n behaviourPenaltyThreshold: opts.scoreParams.behaviourPenaltyThreshold,\n maxMeshMessageDeliveriesWindowSec: maxMeshMessageDeliveriesWindowMs / 1000\n });\n metrics.mcacheSize.addCollect(() => { this.onScrapeMetrics(metrics); });\n for (const protocol of this.multicodecs) {\n metrics.protocolsEnabled.set({ protocol }, 1);\n }\n this.metrics = metrics;\n }\n else {\n this.metrics = null;\n }\n this.gossipTracer = new _tracer_js__WEBPACK_IMPORTED_MODULE_14__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_15__.PeerScore(this.opts.scoreParams, this.metrics, this.components.logger, {\n scoreCacheValidityMs: opts.heartbeatInterval\n });\n this.maxInboundStreams = options.maxInboundStreams;\n this.maxOutboundStreams = options.maxOutboundStreams;\n this.runOnTransientConnection = options.runOnTransientConnection;\n this.allowedTopics = (opts.allowedTopics != null) ? new Set(opts.allowedTopics) : null;\n }\n getPeers() {\n return [...this.peers.keys()].map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromString)(str));\n }\n isStarted() {\n return this.status.code === GossipStatusCode.started;\n }\n // LIFECYCLE METHODS\n /**\n * Mounts the gossipsub protocol onto the libp2p node and sends our\n * our subscriptions to every peer connected\n */\n async start() {\n // From pubsub\n if (this.isStarted()) {\n return;\n }\n this.log('starting');\n this.publishConfig = await (0,_utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_17__.getPublishConfigFromPeerId)(this.globalSignaturePolicy, this.components.peerId);\n // Create the outbound inflight queue\n // This ensures that outbound stream creation happens sequentially\n this.outboundInflightQueue = (0,it_pushable__WEBPACK_IMPORTED_MODULE_2__.pushable)({ objectMode: true });\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(this.outboundInflightQueue, async (source) => {\n for await (const { peerId, connection } of source) {\n await this.createOutboundStream(peerId, connection);\n }\n }).catch((e) => { this.log.error('outbound inflight queue error', e); });\n // set direct peer addresses in the address book\n await Promise.all(this.opts.directPeers.map(async (p) => {\n await this.components.peerStore.merge(p.id, {\n multiaddrs: p.addrs\n });\n }));\n const registrar = this.components.registrar;\n // Incoming streams\n // Called after a peer dials us\n await Promise.all(this.multicodecs.map(async (multicodec) => registrar.handle(multicodec, this.onIncomingStream.bind(this), {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams,\n runOnTransientConnection: this.runOnTransientConnection\n })));\n // # How does Gossipsub interact with libp2p? Rough guide from Mar 2022\n //\n // ## Setup:\n // Gossipsub requests libp2p to callback, TBD\n //\n // `this.libp2p.handle()` registers a handler for `/meshsub/1.1.0` and other Gossipsub protocols\n // The handler callback is registered in libp2p Upgrader.protocols map.\n //\n // Upgrader receives an inbound connection from some transport and (`Upgrader.upgradeInbound`):\n // - Adds encryption (NOISE in our case)\n // - Multiplex stream\n // - Create a muxer and register that for each new stream call Upgrader.protocols handler\n //\n // ## Topology\n // - new instance of Topology (unlinked to libp2p) with handlers\n // - registar.register(topology)\n // register protocol with topology\n // Topology callbacks called on connection manager changes\n const topology = {\n onConnect: this.onPeerConnected.bind(this),\n onDisconnect: this.onPeerDisconnected.bind(this),\n notifyOnTransient: this.runOnTransientConnection\n };\n const registrarTopologyIds = await Promise.all(this.multicodecs.map(async (multicodec) => registrar.register(multicodec, topology)));\n // Schedule to start heartbeat after `GossipsubHeartbeatInitialDelay`\n const heartbeatTimeout = setTimeout(this.runHeartbeat, _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubHeartbeatInitialDelay);\n // Then, run heartbeat every `heartbeatInterval` offset by `GossipsubHeartbeatInitialDelay`\n this.status = {\n code: GossipStatusCode.started,\n registrarTopologyIds,\n heartbeatTimeout,\n hearbeatStartMs: Date.now() + _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubHeartbeatInitialDelay\n };\n this.score.start();\n // connect to direct peers\n this.directPeerInitial = setTimeout(() => {\n Promise.resolve()\n .then(async () => {\n await Promise.all(Array.from(this.direct).map(async (id) => this.connect(id)));\n })\n .catch((err) => {\n this.log(err);\n });\n }, _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubDirectConnectInitialDelay);\n this.log('started');\n }\n /**\n * Unmounts the gossipsub protocol and shuts down every connection\n */\n async stop() {\n this.log('stopping');\n // From pubsub\n if (this.status.code !== GossipStatusCode.started) {\n return;\n }\n const { registrarTopologyIds } = this.status;\n this.status = { code: GossipStatusCode.stopped };\n // unregister protocol and handlers\n const registrar = this.components.registrar;\n await Promise.all(this.multicodecs.map(async (multicodec) => registrar.unhandle(multicodec)));\n registrarTopologyIds.forEach((id) => { registrar.unregister(id); });\n this.outboundInflightQueue.end();\n const closePromises = [];\n for (const outboundStream of this.streamsOutbound.values()) {\n closePromises.push(outboundStream.close());\n }\n this.streamsOutbound.clear();\n for (const inboundStream of this.streamsInbound.values()) {\n closePromises.push(inboundStream.close());\n }\n this.streamsInbound.clear();\n await Promise.all(closePromises);\n this.peers.clear();\n this.subscriptions.clear();\n // Gossipsub\n if (this.heartbeatTimer != null) {\n this.heartbeatTimer.cancel();\n this.heartbeatTimer = null;\n }\n this.score.stop();\n this.mesh.clear();\n this.fanout.clear();\n this.fanoutLastpub.clear();\n this.gossip.clear();\n this.control.clear();\n this.peerhave.clear();\n this.iasked.clear();\n this.backoff.clear();\n this.outbound.clear();\n this.gossipTracer.clear();\n this.seenCache.clear();\n if (this.fastMsgIdCache != null)\n this.fastMsgIdCache.clear();\n if (this.directPeerInitial != null)\n clearTimeout(this.directPeerInitial);\n this.log('stopped');\n }\n /** FOR DEBUG ONLY - Dump peer stats for all peers. Data is cloned, safe to mutate */\n dumpPeerScoreStats() {\n return this.score.dumpPeerScoreStats();\n }\n /**\n * On an inbound stream opened\n */\n onIncomingStream({ stream, connection }) {\n if (!this.isStarted()) {\n return;\n }\n const peerId = connection.remotePeer;\n // add peer to router\n this.addPeer(peerId, connection.direction, connection.remoteAddr);\n // create inbound stream\n this.createInboundStream(peerId, stream);\n // attempt to create outbound stream\n this.outboundInflightQueue.push({ peerId, connection });\n }\n /**\n * Registrar notifies an established connection with pubsub protocol\n */\n onPeerConnected(peerId, connection) {\n this.metrics?.newConnectionCount.inc({ status: connection.status });\n // libp2p may emit a closed connection and never issue peer:disconnect event\n // see https://github.com/ChainSafe/js-libp2p-gossipsub/issues/398\n if (!this.isStarted() || connection.status !== 'open') {\n return;\n }\n this.addPeer(peerId, connection.direction, connection.remoteAddr);\n this.outboundInflightQueue.push({ peerId, connection });\n }\n /**\n * Registrar notifies a closing connection with pubsub protocol\n */\n onPeerDisconnected(peerId) {\n this.log('connection ended %p', peerId);\n this.removePeer(peerId);\n }\n async createOutboundStream(peerId, connection) {\n if (!this.isStarted()) {\n return;\n }\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // TODO make this behavior more robust\n // This behavior is different than for inbound streams\n // If an outbound stream already exists, don't create a new stream\n if (this.streamsOutbound.has(id)) {\n return;\n }\n try {\n const stream = new _stream_js__WEBPACK_IMPORTED_MODULE_18__.OutboundStream(await connection.newStream(this.multicodecs, {\n runOnTransientConnection: this.runOnTransientConnection\n }), (e) => { this.log.error('outbound pipe error', e); }, { maxBufferSize: this.opts.maxOutboundBufferSize });\n this.log('create outbound stream %p', peerId);\n this.streamsOutbound.set(id, stream);\n const protocol = stream.protocol;\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_3__.FloodsubID) {\n this.floodsubPeers.add(id);\n }\n this.metrics?.peersPerProtocol.inc({ protocol }, 1);\n // Immediately send own subscriptions via the newly attached stream\n if (this.subscriptions.size > 0) {\n this.log('send subscriptions to', id);\n this.sendSubscriptions(id, Array.from(this.subscriptions), true);\n }\n }\n catch (e) {\n this.log.error('createOutboundStream error', e);\n }\n }\n createInboundStream(peerId, stream) {\n if (!this.isStarted()) {\n return;\n }\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // TODO make this behavior more robust\n // This behavior is different than for outbound streams\n // If a peer initiates a new inbound connection\n // we assume that one is the new canonical inbound stream\n const priorInboundStream = this.streamsInbound.get(id);\n if (priorInboundStream !== undefined) {\n this.log('replacing existing inbound steam %s', id);\n priorInboundStream.close().catch((err) => { this.log.error(err); });\n }\n this.log('create inbound stream %s', id);\n const inboundStream = new _stream_js__WEBPACK_IMPORTED_MODULE_18__.InboundStream(stream, { maxDataLength: this.opts.maxInboundDataLength });\n this.streamsInbound.set(id, inboundStream);\n this.pipePeerReadStream(peerId, inboundStream.source).catch((err) => { this.log(err); });\n }\n /**\n * Add a peer to the router\n */\n addPeer(peerId, direction, addr) {\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n this.log('new peer %p', peerId);\n this.peers.add(id);\n // Add to peer scoring\n this.score.addPeer(id);\n const currentIP = (0,_utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_19__.multiaddrToIPStr)(addr);\n if (currentIP !== null) {\n this.score.addIP(id, currentIP);\n }\n else {\n this.log('Added peer has no IP in current address %s %s', id, addr.toString());\n }\n // track the connection direction. Don't allow to unset outbound\n if (!this.outbound.has(id)) {\n this.outbound.set(id, direction === 'outbound');\n }\n }\n }\n /**\n * Removes a peer from the router\n */\n removePeer(peerId) {\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // delete peer\n this.log('delete peer %p', peerId);\n this.peers.delete(id);\n const outboundStream = this.streamsOutbound.get(id);\n const inboundStream = this.streamsInbound.get(id);\n if (outboundStream != null) {\n this.metrics?.peersPerProtocol.inc({ protocol: outboundStream.protocol }, -1);\n }\n // close streams\n outboundStream?.close().catch((err) => { this.log.error(err); });\n inboundStream?.close().catch((err) => { this.log.error(err); });\n // remove streams\n this.streamsOutbound.delete(id);\n this.streamsInbound.delete(id);\n // remove peer from topics map\n for (const peers of this.topics.values()) {\n peers.delete(id);\n }\n // Remove this peer from the mesh\n for (const [topicStr, peers] of this.mesh) {\n if (peers.delete(id)) {\n this.metrics?.onRemoveFromMesh(topicStr, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ChurnReason.Dc, 1);\n }\n }\n // Remove this peer from the fanout\n for (const peers of this.fanout.values()) {\n peers.delete(id);\n }\n // Remove from floodsubPeers\n this.floodsubPeers.delete(id);\n // Remove from gossip mapping\n this.gossip.delete(id);\n // Remove from control mapping\n this.control.delete(id);\n // Remove from backoff mapping\n this.outbound.delete(id);\n // Remove from peer scoring\n this.score.removePeer(id);\n this.acceptFromWhitelist.delete(id);\n }\n // API METHODS\n get started() {\n return this.status.code === GossipStatusCode.started;\n }\n /**\n * Get a the peer-ids in a topic mesh\n */\n getMeshPeers(topic) {\n const peersInTopic = this.mesh.get(topic);\n return (peersInTopic != null) ? Array.from(peersInTopic) : [];\n }\n /**\n * Get a list of the peer-ids that are subscribed to one topic.\n */\n getSubscribers(topic) {\n const peersInTopic = this.topics.get(topic);\n return ((peersInTopic != null) ? Array.from(peersInTopic) : []).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromString)(str));\n }\n /**\n * Get the list of topics which the peer is subscribed to.\n */\n getTopics() {\n return Array.from(this.subscriptions);\n }\n // TODO: Reviewing Pubsub API\n // MESSAGE METHODS\n /**\n * Responsible for processing each RPC message received by other peers.\n */\n async pipePeerReadStream(peerId, stream) {\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(stream, async (source) => {\n for await (const data of source) {\n try {\n // TODO: Check max gossip message size, before decodeRpc()\n const rpcBytes = data.subarray();\n // Note: This function may throw, it must be wrapped in a try {} catch {} to prevent closing the stream.\n // TODO: What should we do if the entire RPC is invalid?\n const rpc = _message_rpc_js__WEBPACK_IMPORTED_MODULE_20__.RPC.decode(rpcBytes, {\n limits: {\n subscriptions: this.decodeRpcLimits.maxSubscriptions,\n messages: this.decodeRpcLimits.maxMessages,\n control$: {\n ihave: this.decodeRpcLimits.maxIhaveMessageIDs,\n iwant: this.decodeRpcLimits.maxIwantMessageIDs,\n graft: this.decodeRpcLimits.maxControlMessages,\n prune: this.decodeRpcLimits.maxControlMessages,\n prune$: {\n peers: this.decodeRpcLimits.maxPeerInfos\n }\n }\n }\n });\n this.metrics?.onRpcRecv(rpc, rpcBytes.length);\n // Since processRpc may be overridden entirely in unsafe ways,\n // the simplest/safest option here is to wrap in a function and capture all errors\n // to prevent a top-level unhandled exception\n // This processing of rpc messages should happen without awaiting full validation/execution of prior messages\n if (this.opts.awaitRpcHandler) {\n try {\n await this.handleReceivedRpc(peerId, rpc);\n }\n catch (err) {\n this.metrics?.onRpcRecvError();\n this.log(err);\n }\n }\n else {\n this.handleReceivedRpc(peerId, rpc).catch((err) => {\n this.metrics?.onRpcRecvError();\n this.log(err);\n });\n }\n }\n catch (e) {\n this.metrics?.onRpcDataError();\n this.log(e);\n }\n }\n });\n }\n catch (err) {\n this.metrics?.onPeerReadStreamError();\n this.handlePeerReadStreamError(err, peerId);\n }\n }\n /**\n * Handle error when read stream pipe throws, less of the functional use but more\n * to for testing purposes to spy on the error handling\n * */\n handlePeerReadStreamError(err, peerId) {\n this.log.error(err);\n this.onPeerDisconnected(peerId);\n }\n /**\n * Handles an rpc request from a peer\n */\n async handleReceivedRpc(from, rpc) {\n // Check if peer is graylisted in which case we ignore the event\n if (!this.acceptFrom(from.toString())) {\n this.log('received message from unacceptable peer %p', from);\n this.metrics?.rpcRecvNotAccepted.inc();\n return;\n }\n const subscriptions = (rpc.subscriptions != null) ? rpc.subscriptions.length : 0;\n const messages = (rpc.messages != null) ? rpc.messages.length : 0;\n let ihave = 0;\n let iwant = 0;\n let graft = 0;\n let prune = 0;\n if (rpc.control != null) {\n if (rpc.control.ihave != null)\n ihave = rpc.control.ihave.length;\n if (rpc.control.iwant != null)\n iwant = rpc.control.iwant.length;\n if (rpc.control.graft != null)\n graft = rpc.control.graft.length;\n if (rpc.control.prune != null)\n prune = rpc.control.prune.length;\n }\n this.log(`rpc.from ${from.toString()} subscriptions ${subscriptions} messages ${messages} ihave ${ihave} iwant ${iwant} graft ${graft} prune ${prune}`);\n // Handle received subscriptions\n if ((rpc.subscriptions != null) && rpc.subscriptions.length > 0) {\n // update peer subscriptions\n const subscriptions = [];\n rpc.subscriptions.forEach((subOpt) => {\n const topic = subOpt.topic;\n const subscribe = subOpt.subscribe === true;\n if (topic != null) {\n if ((this.allowedTopics != null) && !this.allowedTopics.has(topic)) {\n // Not allowed: subscription data-structures are not bounded by topic count\n // TODO: Should apply behaviour penalties?\n return;\n }\n this.handleReceivedSubscription(from, topic, subscribe);\n subscriptions.push({ topic, subscribe });\n }\n });\n this.safeDispatchEvent('subscription-change', {\n detail: { peerId: from, subscriptions }\n });\n }\n // Handle messages\n // TODO: (up to limit)\n for (const message of rpc.messages) {\n if ((this.allowedTopics != null) && !this.allowedTopics.has(message.topic)) {\n // Not allowed: message cache data-structures are not bounded by topic count\n // TODO: Should apply behaviour penalties?\n continue;\n }\n const handleReceivedMessagePromise = this.handleReceivedMessage(from, message)\n // Should never throw, but handle just in case\n .catch((err) => {\n this.metrics?.onMsgRecvError(message.topic);\n this.log(err);\n });\n if (this.opts.awaitRpcMessageHandler) {\n await handleReceivedMessagePromise;\n }\n }\n // Handle control messages\n if (rpc.control != null) {\n await this.handleControlMessage(from.toString(), rpc.control);\n }\n }\n /**\n * Handles a subscription change from a peer\n */\n handleReceivedSubscription(from, topic, subscribe) {\n this.log('subscription update from %p topic %s', from, topic);\n let topicSet = this.topics.get(topic);\n if (topicSet == null) {\n topicSet = new Set();\n this.topics.set(topic, topicSet);\n }\n if (subscribe) {\n // subscribe peer to new topic\n topicSet.add(from.toString());\n }\n else {\n // unsubscribe from existing topic\n topicSet.delete(from.toString());\n }\n // TODO: rust-libp2p has A LOT more logic here\n }\n /**\n * Handles a newly received message from an RPC.\n * May forward to all peers in the mesh.\n */\n async handleReceivedMessage(from, rpcMsg) {\n this.metrics?.onMsgRecvPreValidation(rpcMsg.topic);\n const validationResult = await this.validateReceivedMessage(from, rpcMsg);\n this.metrics?.onPrevalidationResult(rpcMsg.topic, validationResult.code);\n const validationCode = validationResult.code;\n switch (validationCode) {\n case _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.duplicate:\n // Report the duplicate\n this.score.duplicateMessage(from.toString(), validationResult.msgIdStr, rpcMsg.topic);\n // due to the collision of fastMsgIdFn, 2 different messages may end up the same fastMsgId\n // so we need to also mark the duplicate message as delivered or the promise is not resolved\n // and peer gets penalized. See https://github.com/ChainSafe/js-libp2p-gossipsub/pull/385\n this.gossipTracer.deliverMessage(validationResult.msgIdStr, true);\n this.mcache.observeDuplicate(validationResult.msgIdStr, from.toString());\n return;\n case _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.invalid:\n // invalid messages received\n // metrics.register_invalid_message(&raw_message.topic)\n // Tell peer_score about reject\n // Reject the original source, and any duplicates we've seen from other peers.\n if (validationResult.msgIdStr != null) {\n const msgIdStr = validationResult.msgIdStr;\n this.score.rejectMessage(from.toString(), msgIdStr, rpcMsg.topic, validationResult.reason);\n this.gossipTracer.rejectMessage(msgIdStr, validationResult.reason);\n }\n else {\n this.score.rejectInvalidMessage(from.toString(), rpcMsg.topic);\n }\n this.metrics?.onMsgRecvInvalid(rpcMsg.topic, validationResult);\n return;\n case _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.valid:\n // Tells score that message arrived (but is maybe not fully validated yet).\n // Consider the message as delivered for gossip promises.\n this.score.validateMessage(validationResult.messageId.msgIdStr);\n this.gossipTracer.deliverMessage(validationResult.messageId.msgIdStr);\n // Add the message to our memcache\n // if no validation is required, mark the message as validated\n this.mcache.put(validationResult.messageId, rpcMsg, !this.opts.asyncValidation);\n // Dispatch the message to the user if we are subscribed to the topic\n if (this.subscriptions.has(rpcMsg.topic)) {\n const isFromSelf = this.components.peerId.equals(from);\n if (!isFromSelf || this.opts.emitSelf) {\n super.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:message', {\n detail: {\n propagationSource: from,\n msgId: validationResult.messageId.msgIdStr,\n msg: validationResult.msg\n }\n }));\n // TODO: Add option to switch between emit per topic or all messages in one\n super.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('message', { detail: validationResult.msg }));\n }\n }\n // Forward the message to mesh peers, if no validation is required\n // If asyncValidation is ON, expect the app layer to call reportMessageValidationResult(), then forward\n if (!this.opts.asyncValidation) {\n // TODO: in rust-libp2p\n // .forward_msg(&msg_id, raw_message, Some(propagation_source))\n this.forwardMessage(validationResult.messageId.msgIdStr, rpcMsg, from.toString());\n }\n break;\n default:\n throw new Error(`Invalid validation result: ${validationCode}`);\n }\n }\n /**\n * Handles a newly received message from an RPC.\n * May forward to all peers in the mesh.\n */\n async validateReceivedMessage(propagationSource, rpcMsg) {\n // Fast message ID stuff\n const fastMsgIdStr = this.fastMsgIdFn?.(rpcMsg);\n const msgIdCached = fastMsgIdStr !== undefined ? this.fastMsgIdCache?.get(fastMsgIdStr) : undefined;\n if (msgIdCached != null) {\n // This message has been seen previously. Ignore it\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.duplicate, msgIdStr: msgIdCached };\n }\n // Perform basic validation on message and convert to RawGossipsubMessage for fastMsgIdFn()\n const validationResult = await (0,_utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_22__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_21__.RejectReason.Error, error: validationResult.error };\n }\n const msg = validationResult.message;\n // Try and perform the data transform to the message. If it fails, consider it invalid.\n try {\n if (this.dataTransform != null) {\n msg.data = this.dataTransform.inboundTransform(rpcMsg.topic, msg.data);\n }\n }\n catch (e) {\n this.log('Invalid message, transform failed', e);\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_21__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_21__.ValidateError.TransformFailed };\n }\n // TODO: Check if message is from a blacklisted source or propagation origin\n // - Reject any message from a blacklisted peer\n // - Also reject any message that originated from a blacklisted peer\n // - reject messages claiming to be from ourselves but not locally published\n // Calculate the message id on the transformed data.\n const msgId = await this.msgIdFn(msg);\n const msgIdStr = this.msgIdToStrFn(msgId);\n const messageId = { msgId, msgIdStr };\n // Add the message to the duplicate caches\n if (fastMsgIdStr !== undefined && (this.fastMsgIdCache != null)) {\n const collision = this.fastMsgIdCache.put(fastMsgIdStr, msgIdStr);\n if (collision) {\n this.metrics?.fastMsgIdCacheCollision.inc();\n }\n }\n if (this.seenCache.has(msgIdStr)) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.duplicate, msgIdStr };\n }\n else {\n this.seenCache.put(msgIdStr);\n }\n // (Optional) Provide custom validation here with dynamic validators per topic\n // NOTE: This custom topicValidator() must resolve fast (< 100ms) to allow scores\n // to not penalize peers for long validation times.\n const topicValidator = this.topicValidators.get(rpcMsg.topic);\n if (topicValidator != null) {\n let acceptance;\n // Use try {} catch {} in case topicValidator() is synchronous\n try {\n acceptance = await topicValidator(propagationSource, msg);\n }\n catch (e) {\n const errCode = e.code;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_3__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_3__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_21__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_21__.MessageStatus.valid, messageId, msg };\n }\n /**\n * Return score of a peer.\n */\n getScore(peerId) {\n return this.score.score(peerId);\n }\n /**\n * Send an rpc object to a peer with subscriptions\n */\n sendSubscriptions(toPeer, topics, subscribe) {\n this.sendRpc(toPeer, {\n subscriptions: topics.map((topic) => ({ topic, subscribe })),\n messages: []\n });\n }\n /**\n * Handles an rpc control message from a peer\n */\n async handleControlMessage(id, controlMsg) {\n if (controlMsg === undefined) {\n return;\n }\n const iwant = (controlMsg.ihave != null) ? this.handleIHave(id, controlMsg.ihave) : [];\n const ihave = (controlMsg.iwant != null) ? this.handleIWant(id, controlMsg.iwant) : [];\n const prune = (controlMsg.graft != null) ? await this.handleGraft(id, controlMsg.graft) : [];\n (controlMsg.prune != null) && (await this.handlePrune(id, controlMsg.prune));\n if ((iwant.length === 0) && (ihave.length === 0) && (prune.length === 0)) {\n return;\n }\n const sent = this.sendRpc(id, (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)(ihave, { iwant, prune }));\n const iwantMessageIds = iwant[0]?.messageIDs;\n if (iwantMessageIds != null) {\n if (sent) {\n this.gossipTracer.addPromise(id, iwantMessageIds);\n }\n else {\n this.metrics?.iwantPromiseUntracked.inc(1);\n }\n }\n }\n /**\n * Whether to accept a message from a peer\n */\n acceptFrom(id) {\n if (this.direct.has(id)) {\n return true;\n }\n const now = Date.now();\n const entry = this.acceptFromWhitelist.get(id);\n if ((entry != null) && entry.messagesAccepted < _constants_js__WEBPACK_IMPORTED_MODULE_3__.ACCEPT_FROM_WHITELIST_MAX_MESSAGES && entry.acceptUntil >= now) {\n entry.messagesAccepted += 1;\n return true;\n }\n const score = this.score.score(id);\n if (score >= _constants_js__WEBPACK_IMPORTED_MODULE_3__.ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE) {\n // peer is unlikely to be able to drop its score to `graylistThreshold`\n // after 128 messages or 1s\n this.acceptFromWhitelist.set(id, {\n messagesAccepted: 0,\n acceptUntil: now + _constants_js__WEBPACK_IMPORTED_MODULE_3__.ACCEPT_FROM_WHITELIST_DURATION_MS\n });\n }\n else {\n this.acceptFromWhitelist.delete(id);\n }\n return score >= this.opts.scoreThresholds.graylistThreshold;\n }\n /**\n * Handles IHAVE messages\n */\n handleIHave(id, ihave) {\n if (ihave.length === 0) {\n return [];\n }\n // we ignore IHAVE gossip from any peer whose score is below the gossips threshold\n const score = this.score.score(id);\n if (score < this.opts.scoreThresholds.gossipThreshold) {\n this.log('IHAVE: ignoring peer %s with score below threshold [ score = %d ]', id, score);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_13__.IHaveIgnoreReason.LowScore });\n return [];\n }\n // IHAVE flood protection\n const peerhave = (this.peerhave.get(id) ?? 0) + 1;\n this.peerhave.set(id, peerhave);\n if (peerhave > _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveMessages) {\n this.log('IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring', id, peerhave);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_13__.IHaveIgnoreReason.MaxIhave });\n return [];\n }\n const iasked = this.iasked.get(id) ?? 0;\n if (iasked >= _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength) {\n this.log('IHAVE: peer %s has already advertised too many messages (%d); ignoring', id, iasked);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_13__.IHaveIgnoreReason.MaxIasked });\n return [];\n }\n // string msgId => msgId\n const iwant = new Map();\n ihave.forEach(({ topicID, messageIDs }) => {\n if (topicID == null || (messageIDs == null) || !this.mesh.has(topicID)) {\n return;\n }\n let idonthave = 0;\n messageIDs.forEach((msgId) => {\n const msgIdStr = this.msgIdToStrFn(msgId);\n if (!this.seenCache.has(msgIdStr)) {\n iwant.set(msgIdStr, msgId);\n idonthave++;\n }\n });\n this.metrics?.onIhaveRcv(topicID, messageIDs.length, idonthave);\n });\n if (iwant.size === 0) {\n return [];\n }\n let iask = iwant.size;\n if (iask + iasked > _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength - iasked;\n }\n this.log('IHAVE: Asking for %d out of %d messages from %s', iask, iwant.size, id);\n let iwantList = Array.from(iwant.values());\n // ask in random order\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(iwantList);\n // truncate to the messages we are actually asking for and update the iasked counter\n iwantList = iwantList.slice(0, iask);\n this.iasked.set(id, iasked + iask);\n // do not add gossipTracer promise here until a successful sendRpc()\n return [\n {\n messageIDs: iwantList\n }\n ];\n }\n /**\n * Handles IWANT messages\n * Returns messages to send back to peer\n */\n handleIWant(id, iwant) {\n if (iwant.length === 0) {\n return [];\n }\n // we don't respond to IWANT requests from any per whose score is below the gossip threshold\n const score = this.score.score(id);\n if (score < this.opts.scoreThresholds.gossipThreshold) {\n this.log('IWANT: ignoring peer %s with score below threshold [score = %d]', id, score);\n return [];\n }\n const ihave = new Map();\n const iwantByTopic = new Map();\n let iwantDonthave = 0;\n iwant.forEach(({ messageIDs }) => {\n messageIDs?.forEach((msgId) => {\n const msgIdStr = this.msgIdToStrFn(msgId);\n const entry = this.mcache.getWithIWantCount(msgIdStr, id);\n if (entry == null) {\n iwantDonthave++;\n return;\n }\n iwantByTopic.set(entry.msg.topic, 1 + (iwantByTopic.get(entry.msg.topic) ?? 0));\n if (entry.count > _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubGossipRetransmission) {\n this.log('IWANT: Peer %s has asked for message %s too many times: ignoring request', id, msgId);\n return;\n }\n ihave.set(msgIdStr, entry.msg);\n });\n });\n this.metrics?.onIwantRcv(iwantByTopic, iwantDonthave);\n if (ihave.size === 0) {\n this.log('IWANT: Could not provide any wanted messages to %s', id);\n return [];\n }\n this.log('IWANT: Sending %d messages to %s', ihave.size, id);\n return Array.from(ihave.values());\n }\n /**\n * Handles Graft messages\n */\n async handleGraft(id, graft) {\n const prune = [];\n const score = this.score.score(id);\n const now = Date.now();\n let doPX = this.opts.doPX;\n graft.forEach(({ topicID }) => {\n if (topicID == null) {\n return;\n }\n const peersInMesh = this.mesh.get(topicID);\n if (peersInMesh == null) {\n // don't do PX when there is an unknown topic to avoid leaking our peers\n doPX = false;\n // spam hardening: ignore GRAFTs for unknown topics\n return;\n }\n // check if peer is already in the mesh; if so do nothing\n if (peersInMesh.has(id)) {\n return;\n }\n // we don't GRAFT to/from direct peers; complain loudly if this happens\n if (this.direct.has(id)) {\n this.log('GRAFT: ignoring request from direct peer %s', id);\n // this is possibly a bug from a non-reciprical configuration; send a PRUNE\n prune.push(topicID);\n // but don't px\n doPX = false;\n return;\n }\n // make sure we are not backing off that peer\n const expire = this.backoff.get(topicID)?.get(id);\n if (typeof expire === 'number' && now < expire) {\n this.log('GRAFT: ignoring backed off peer %s', id);\n // add behavioral penalty\n this.score.addPenalty(id, 1, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ScorePenalty.GraftBackoff);\n // no PX\n doPX = false;\n // check the flood cutoff -- is the GRAFT coming too fast?\n const floodCutoff = expire + this.opts.graftFloodThreshold - this.opts.pruneBackoff;\n if (now < floodCutoff) {\n // extra penalty\n this.score.addPenalty(id, 1, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ScorePenalty.GraftBackoff);\n }\n // refresh the backoff\n this.addBackoff(id, topicID);\n prune.push(topicID);\n return;\n }\n // check the score\n if (score < 0) {\n // we don't GRAFT peers with negative score\n this.log('GRAFT: ignoring peer %s with negative score: score=%d, topic=%s', id, score, topicID);\n // we do send them PRUNE however, because it's a matter of protocol correctness\n prune.push(topicID);\n // but we won't PX to them\n doPX = false;\n // add/refresh backoff so that we don't reGRAFT too early even if the score decays\n this.addBackoff(id, topicID);\n return;\n }\n // check the number of mesh peers; if it is at (or over) Dhi, we only accept grafts\n // from peers with outbound connections; this is a defensive check to restrict potential\n // mesh takeover attacks combined with love bombing\n if (peersInMesh.size >= this.opts.Dhi && !(this.outbound.get(id) ?? false)) {\n prune.push(topicID);\n this.addBackoff(id, topicID);\n return;\n }\n this.log('GRAFT: Add mesh link from %s in %s', id, topicID);\n this.score.graft(id, topicID);\n peersInMesh.add(id);\n this.metrics?.onAddToMesh(topicID, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.Subscribed, 1);\n });\n if (prune.length === 0) {\n return [];\n }\n const onUnsubscribe = false;\n return Promise.all(prune.map(async (topic) => this.makePrune(id, topic, doPX, onUnsubscribe)));\n }\n /**\n * Handles Prune messages\n */\n async handlePrune(id, prune) {\n const score = this.score.score(id);\n for (const { topicID, backoff, peers } of prune) {\n if (topicID == null) {\n continue;\n }\n const peersInMesh = this.mesh.get(topicID);\n if (peersInMesh == null) {\n return;\n }\n this.log('PRUNE: Remove mesh link to %s in %s', id, topicID);\n this.score.prune(id, topicID);\n if (peersInMesh.has(id)) {\n peersInMesh.delete(id);\n this.metrics?.onRemoveFromMesh(topicID, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ChurnReason.Prune, 1);\n }\n // is there a backoff specified by the peer? if so obey it\n if (typeof backoff === 'number' && backoff > 0) {\n this.doAddBackoff(id, topicID, backoff * 1000);\n }\n else {\n this.addBackoff(id, topicID);\n }\n // PX\n if ((peers != null) && (peers.length > 0)) {\n // we ignore PX from peers with insufficient scores\n if (score < this.opts.scoreThresholds.acceptPXThreshold) {\n this.log('PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]', id, score, topicID);\n continue;\n }\n await this.pxConnect(peers);\n }\n }\n }\n /**\n * Add standard backoff log for a peer in a topic\n */\n addBackoff(id, topic) {\n this.doAddBackoff(id, topic, this.opts.pruneBackoff);\n }\n /**\n * Add backoff expiry interval for a peer in a topic\n *\n * @param id\n * @param topic\n * @param intervalMs - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, intervalMs) {\n let backoff = this.backoff.get(topic);\n if (backoff == null) {\n backoff = new Map();\n this.backoff.set(topic, backoff);\n }\n const expire = Date.now() + intervalMs;\n const existingExpire = backoff.get(id) ?? 0;\n if (existingExpire < expire) {\n backoff.set(id, expire);\n }\n }\n /**\n * Apply penalties from broken IHAVE/IWANT promises\n */\n applyIwantPenalties() {\n this.gossipTracer.getBrokenPromises().forEach((count, p) => {\n this.log(\"peer %s didn't follow up in %d IWANT requests; adding penalty\", p, count);\n this.score.addPenalty(p, count, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ScorePenalty.BrokenPromise);\n });\n }\n /**\n * Clear expired backoff expiries\n */\n clearBackoff() {\n // we only clear once every GossipsubPruneBackoffTicks ticks to avoid iterating over the maps too much\n if (this.heartbeatTicks % _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n // add some slack time to the expiration, see https://github.com/libp2p/specs/pull/289\n if (expire + _constants_js__WEBPACK_IMPORTED_MODULE_3__.BACKOFF_SLACK * this.opts.heartbeatInterval < now) {\n backoff.delete(id);\n }\n });\n if (backoff.size === 0) {\n this.backoff.delete(topic);\n }\n });\n }\n /**\n * Maybe reconnect to direct peers\n */\n async directConnect() {\n const toconnect = [];\n this.direct.forEach((id) => {\n if (!this.streamsOutbound.has(id)) {\n toconnect.push(id);\n }\n });\n await Promise.all(toconnect.map(async (id) => this.connect(id)));\n }\n /**\n * Maybe attempt connection given signed peer records\n */\n async pxConnect(peers) {\n if (peers.length > this.opts.prunePeers) {\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(peers);\n peers = peers.slice(0, this.opts.prunePeers);\n }\n const toconnect = [];\n await Promise.all(peers.map(async (pi) => {\n if (pi.peerID == null) {\n return;\n }\n const peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromBytes)(pi.peerID);\n const p = peer.toString();\n if (this.peers.has(p)) {\n return;\n }\n if (pi.signedPeerRecord == null) {\n toconnect.push(p);\n return;\n }\n // The peer sent us a signed record\n // This is not a record from the peer who sent the record, but another peer who is connected with it\n // Ensure that it is valid\n try {\n if (!(await this.components.peerStore.consumePeerRecord(pi.signedPeerRecord, peer))) {\n this.log('bogus peer record obtained through px: could not add peer record to address book');\n return;\n }\n toconnect.push(p);\n }\n catch (e) {\n this.log('bogus peer record obtained through px: invalid signature or not a peer record');\n }\n }));\n if (toconnect.length === 0) {\n return;\n }\n await Promise.all(toconnect.map(async (id) => this.connect(id)));\n }\n /**\n * Connect to a peer using the gossipsub protocol\n */\n async connect(id) {\n this.log('Initiating connection with %s', id);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromString)(id);\n const connection = await this.components.connectionManager.openConnection(peerId);\n for (const multicodec of this.multicodecs) {\n for (const topology of this.components.registrar.getTopologies(multicodec)) {\n topology.onConnect?.(peerId, connection);\n }\n }\n }\n /**\n * Subscribes to a topic\n */\n subscribe(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Pubsub has not started');\n }\n if (!this.subscriptions.has(topic)) {\n this.subscriptions.add(topic);\n for (const peerId of this.peers.keys()) {\n this.sendSubscriptions(peerId, [topic], true);\n }\n }\n this.join(topic);\n }\n /**\n * Unsubscribe to a topic\n */\n unsubscribe(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Pubsub is not started');\n }\n const wasSubscribed = this.subscriptions.delete(topic);\n this.log('unsubscribe from %s - am subscribed %s', topic, wasSubscribed);\n if (wasSubscribed) {\n for (const peerId of this.peers.keys()) {\n this.sendSubscriptions(peerId, [topic], false);\n }\n }\n this.leave(topic);\n }\n /**\n * Join topic\n */\n join(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Gossipsub has not started');\n }\n // if we are already in the mesh, return\n if (this.mesh.has(topic)) {\n return;\n }\n this.log('JOIN %s', topic);\n this.metrics?.onJoin(topic);\n const toAdd = new Set();\n const backoff = this.backoff.get(topic);\n // check if we have mesh_n peers in fanout[topic] and add them to the mesh if we do,\n // removing the fanout entry.\n const fanoutPeers = this.fanout.get(topic);\n if (fanoutPeers != null) {\n // Remove fanout entry and the last published time\n this.fanout.delete(topic);\n this.fanoutLastpub.delete(topic);\n // remove explicit peers, peers with negative scores, and backoffed peers\n fanoutPeers.forEach((id) => {\n if (!this.direct.has(id) && this.score.score(id) >= 0 && ((backoff == null) || !backoff.has(id))) {\n toAdd.add(id);\n }\n });\n this.metrics?.onAddToMesh(topic, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.Fanout, toAdd.size);\n }\n // check if we need to get more peers, which we randomly select\n if (toAdd.size < this.opts.D) {\n const fanoutCount = toAdd.size;\n const newPeers = this.getRandomGossipPeers(topic, this.opts.D, (id) => \n // filter direct peers and peers with negative score\n !toAdd.has(id) && !this.direct.has(id) && this.score.score(id) >= 0 && ((backoff == null) || !backoff.has(id)));\n newPeers.forEach((peer) => {\n toAdd.add(peer);\n });\n this.metrics?.onAddToMesh(topic, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.Random, toAdd.size - fanoutCount);\n }\n this.mesh.set(topic, toAdd);\n toAdd.forEach((id) => {\n this.log('JOIN: Add mesh link to %s in %s', id, topic);\n this.sendGraft(id, topic);\n // rust-libp2p\n // - peer_score.graft()\n // - Self::control_pool_add()\n // - peer_added_to_mesh()\n });\n }\n /**\n * Leave topic\n */\n leave(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Gossipsub has not started');\n }\n this.log('LEAVE %s', topic);\n this.metrics?.onLeave(topic);\n // Send PRUNE to mesh peers\n const meshPeers = this.mesh.get(topic);\n if (meshPeers != null) {\n Promise.all(Array.from(meshPeers).map(async (id) => {\n this.log('LEAVE: Remove mesh link to %s in %s', id, topic);\n await this.sendPrune(id, topic);\n })).catch((err) => {\n this.log('Error sending prunes to mesh peers', err);\n });\n this.mesh.delete(topic);\n }\n }\n selectPeersToForward(topic, propagationSource, excludePeers) {\n const tosend = new Set();\n // Add explicit peers\n const peersInTopic = this.topics.get(topic);\n if (peersInTopic != null) {\n this.direct.forEach((peer) => {\n if (peersInTopic.has(peer) && propagationSource !== peer && !(excludePeers?.has(peer) ?? false)) {\n tosend.add(peer);\n }\n });\n // As of Mar 2022, spec + golang-libp2p include this while rust-libp2p does not\n // rust-libp2p: https://github.com/libp2p/rust-libp2p/blob/6cc3b4ec52c922bfcf562a29b5805c3150e37c75/protocols/gossipsub/src/behaviour.rs#L2693\n // spec: https://github.com/libp2p/specs/blob/10712c55ab309086a52eec7d25f294df4fa96528/pubsub/gossipsub/gossipsub-v1.0.md?plain=1#L361\n this.floodsubPeers.forEach((peer) => {\n if (peersInTopic.has(peer) &&\n propagationSource !== peer &&\n !(excludePeers?.has(peer) ?? false) &&\n this.score.score(peer) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(peer);\n }\n });\n }\n // add mesh peers\n const meshPeers = this.mesh.get(topic);\n if ((meshPeers != null) && meshPeers.size > 0) {\n meshPeers.forEach((peer) => {\n if (propagationSource !== peer && !(excludePeers?.has(peer) ?? false)) {\n tosend.add(peer);\n }\n });\n }\n return tosend;\n }\n selectPeersToPublish(topic) {\n const tosend = new Set();\n const tosendCount = {\n direct: 0,\n floodsub: 0,\n mesh: 0,\n fanout: 0\n };\n const peersInTopic = this.topics.get(topic);\n if (peersInTopic != null) {\n // flood-publish behavior\n // send to direct peers and _all_ peers meeting the publishThreshold\n if (this.opts.floodPublish) {\n peersInTopic.forEach((id) => {\n if (this.direct.has(id)) {\n tosend.add(id);\n tosendCount.direct++;\n }\n else if (this.score.score(id) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(id);\n tosendCount.floodsub++;\n }\n });\n }\n else {\n // non-flood-publish behavior\n // send to direct peers, subscribed floodsub peers\n // and some mesh peers above publishThreshold\n // direct peers (if subscribed)\n this.direct.forEach((id) => {\n if (peersInTopic.has(id)) {\n tosend.add(id);\n tosendCount.direct++;\n }\n });\n // floodsub peers\n // Note: if there are no floodsub peers, we save a loop through peersInTopic Map\n this.floodsubPeers.forEach((id) => {\n if (peersInTopic.has(id) && this.score.score(id) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(id);\n tosendCount.floodsub++;\n }\n });\n // Gossipsub peers handling\n const meshPeers = this.mesh.get(topic);\n if ((meshPeers != null) && meshPeers.size > 0) {\n meshPeers.forEach((peer) => {\n tosend.add(peer);\n tosendCount.mesh++;\n });\n // eslint-disable-next-line @typescript-eslint/brace-style\n }\n // We are not in the mesh for topic, use fanout peers\n else {\n const fanoutPeers = this.fanout.get(topic);\n if ((fanoutPeers != null) && fanoutPeers.size > 0) {\n fanoutPeers.forEach((peer) => {\n tosend.add(peer);\n tosendCount.fanout++;\n });\n // eslint-disable-next-line @typescript-eslint/brace-style\n }\n // We have no fanout peers, select mesh_n of them and add them to the fanout\n else {\n // If we are not in the fanout, then pick peers in topic above the publishThreshold\n const newFanoutPeers = this.getRandomGossipPeers(topic, this.opts.D, (id) => {\n return this.score.score(id) >= this.opts.scoreThresholds.publishThreshold;\n });\n // eslint-disable-next-line max-depth\n if (newFanoutPeers.size > 0) {\n this.fanout.set(topic, newFanoutPeers);\n newFanoutPeers.forEach((peer) => {\n tosend.add(peer);\n tosendCount.fanout++;\n });\n }\n }\n // We are publishing to fanout peers - update the time we published\n this.fanoutLastpub.set(topic, Date.now());\n }\n }\n }\n return { tosend, tosendCount };\n }\n /**\n * Forwards a message from our peers.\n *\n * For messages published by us (the app layer), this class uses `publish`\n */\n forwardMessage(msgIdStr, rawMsg, propagationSource, excludePeers) {\n // message is fully validated inform peer_score\n if (propagationSource != null) {\n this.score.deliverMessage(propagationSource, msgIdStr, rawMsg.topic);\n }\n const tosend = this.selectPeersToForward(rawMsg.topic, propagationSource, excludePeers);\n // Note: Don't throw if tosend is empty, we can have a mesh with a single peer\n // forward the message to peers\n tosend.forEach((id) => {\n // sendRpc may mutate RPC message on piggyback, create a new message for each peer\n this.sendRpc(id, (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([rawMsg]));\n });\n this.metrics?.onForwardMsg(rawMsg.topic, tosend.size);\n }\n /**\n * App layer publishes a message to peers, return number of peers this message is published to\n * Note: `async` due to crypto only if `StrictSign`, otherwise it's a sync fn.\n *\n * For messages not from us, this class uses `forwardMessage`.\n */\n async publish(topic, data, opts) {\n const startMs = Date.now();\n const transformedData = (this.dataTransform != null) ? this.dataTransform.outboundTransform(topic, data) : data;\n if (this.publishConfig == null) {\n throw Error('PublishError.Uninitialized');\n }\n // Prepare raw message with user's publishConfig\n const { raw: rawMsg, msg } = await (0,_utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_22__.buildRawMessage)(this.publishConfig, topic, data, transformedData);\n // calculate the message id from the un-transformed data\n const msgId = await this.msgIdFn(msg);\n const msgIdStr = this.msgIdToStrFn(msgId);\n // Current publish opt takes precedence global opts, while preserving false value\n const ignoreDuplicatePublishError = opts?.ignoreDuplicatePublishError ?? this.opts.ignoreDuplicatePublishError;\n if (this.seenCache.has(msgIdStr)) {\n // This message has already been seen. We don't re-publish messages that have already\n // been published on the network.\n if (ignoreDuplicatePublishError) {\n this.metrics?.onPublishDuplicateMsg(topic);\n return { recipients: [] };\n }\n throw Error('PublishError.Duplicate');\n }\n const { tosend, tosendCount } = this.selectPeersToPublish(topic);\n const willSendToSelf = this.opts.emitSelf && this.subscriptions.has(topic);\n // Current publish opt takes precedence global opts, while preserving false value\n const allowPublishToZeroPeers = opts?.allowPublishToZeroPeers ?? this.opts.allowPublishToZeroPeers;\n if (tosend.size === 0 && !allowPublishToZeroPeers && !willSendToSelf) {\n throw Error('PublishError.InsufficientPeers');\n }\n // If the message isn't a duplicate and we have sent it to some peers add it to the\n // duplicate cache and memcache.\n this.seenCache.put(msgIdStr);\n // all published messages are valid\n this.mcache.put({ msgId, msgIdStr }, rawMsg, true);\n // If the message is anonymous or has a random author add it to the published message ids cache.\n this.publishedMessageIds.put(msgIdStr);\n const batchPublish = opts?.batchPublish ?? this.opts.batchPublish;\n const rpc = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([rawMsg]);\n if (batchPublish) {\n this.sendRpcInBatch(tosend, rpc);\n }\n else {\n // Send to set of peers aggregated from direct, mesh, fanout\n for (const id of tosend) {\n // sendRpc may mutate RPC message on piggyback, create a new message for each peer\n const sent = this.sendRpc(id, rpc);\n // did not actually send the message\n if (!sent) {\n tosend.delete(id);\n }\n }\n }\n const durationMs = Date.now() - startMs;\n this.metrics?.onPublishMsg(topic, tosendCount, tosend.size, rawMsg.data != null ? rawMsg.data.length : 0, durationMs);\n // Dispatch the message to the user if we are subscribed to the topic\n if (willSendToSelf) {\n tosend.add(this.components.peerId.toString());\n super.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:message', {\n detail: {\n propagationSource: this.components.peerId,\n msgId: msgIdStr,\n msg\n }\n }));\n // TODO: Add option to switch between emit per topic or all messages in one\n super.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromString)(str))\n };\n }\n /**\n * Send the same data in batch to tosend list without considering cached control messages\n * This is not only faster but also avoid allocating memory for each peer\n * see https://github.com/ChainSafe/js-libp2p-gossipsub/issues/344\n */\n sendRpcInBatch(tosend, rpc) {\n const rpcBytes = _message_rpc_js__WEBPACK_IMPORTED_MODULE_20__.RPC.encode(rpc);\n const prefixedData = it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.encode.single(rpcBytes);\n for (const id of tosend) {\n const outboundStream = this.streamsOutbound.get(id);\n if (outboundStream == null) {\n this.log(`Cannot send RPC to ${id} as there is no open stream to it available`);\n tosend.delete(id);\n continue;\n }\n try {\n outboundStream.pushPrefixed(prefixedData);\n }\n catch (e) {\n tosend.delete(id);\n this.log.error(`Cannot send rpc to ${id}`, e);\n }\n this.metrics?.onRpcSent(rpc, rpcBytes.length);\n }\n }\n /**\n * This function should be called when `asyncValidation` is `true` after\n * the message got validated by the caller. Messages are stored in the `mcache` and\n * validation is expected to be fast enough that the messages should still exist in the cache.\n * There are three possible validation outcomes and the outcome is given in acceptance.\n *\n * If acceptance = `MessageAcceptance.Accept` the message will get propagated to the\n * network. The `propagation_source` parameter indicates who the message was received by and\n * will not be forwarded back to that peer.\n *\n * If acceptance = `MessageAcceptance.Reject` the message will be deleted from the memcache\n * and the P₄ penalty will be applied to the `propagationSource`.\n *\n * If acceptance = `MessageAcceptance.Ignore` the message will be deleted from the memcache\n * but no P₄ penalty will be applied.\n *\n * This function will return true if the message was found in the cache and false if was not\n * in the cache anymore.\n *\n * This should only be called once per message.\n */\n reportMessageValidationResult(msgId, propagationSource, acceptance) {\n let cacheEntry;\n if (acceptance === _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.TopicValidatorResult.Accept) {\n cacheEntry = this.mcache.validate(msgId);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource, msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource, originatingPeers);\n }\n // else, Message not in cache. Ignoring forwarding\n // eslint-disable-next-line @typescript-eslint/brace-style\n }\n // Not valid\n else {\n cacheEntry = this.mcache.remove(msgId);\n if (cacheEntry != null) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_21__.rejectReasonFromAcceptance)(acceptance);\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // Tell peer_score about reject\n // Reject the original source, and any duplicates we've seen from other peers.\n this.score.rejectMessage(propagationSource, msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n }\n // else, Message not in cache. Ignoring forwarding\n }\n const firstSeenTimestampMs = this.score.messageFirstSeenTimestampMs(msgId);\n this.metrics?.onReportValidation(cacheEntry, acceptance, firstSeenTimestampMs);\n }\n /**\n * Sends a GRAFT message to a peer\n */\n sendGraft(id, topic) {\n const graft = [\n {\n topicID: topic\n }\n ];\n const out = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { graft });\n this.sendRpc(id, out);\n }\n /**\n * Sends a PRUNE message to a peer\n */\n async sendPrune(id, topic) {\n // this is only called from leave() function\n const onUnsubscribe = true;\n const prune = [await this.makePrune(id, topic, this.opts.doPX, onUnsubscribe)];\n const out = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { prune });\n this.sendRpc(id, out);\n }\n /**\n * Send an rpc object to a peer\n */\n sendRpc(id, rpc) {\n const outboundStream = this.streamsOutbound.get(id);\n if (outboundStream == null) {\n this.log(`Cannot send RPC to ${id} as there is no open stream to it available`);\n return false;\n }\n // piggyback control message retries\n const ctrl = this.control.get(id);\n if (ctrl != null) {\n this.piggybackControl(id, rpc, ctrl);\n this.control.delete(id);\n }\n // piggyback gossip\n const ihave = this.gossip.get(id);\n if (ihave != null) {\n this.piggybackGossip(id, rpc, ihave);\n this.gossip.delete(id);\n }\n const rpcBytes = _message_rpc_js__WEBPACK_IMPORTED_MODULE_20__.RPC.encode(rpc);\n try {\n outboundStream.push(rpcBytes);\n }\n catch (e) {\n this.log.error(`Cannot send rpc to ${id}`, e);\n // if the peer had control messages or gossip, re-attach\n if (ctrl != null) {\n this.control.set(id, ctrl);\n }\n if (ihave != null) {\n this.gossip.set(id, ihave);\n }\n return false;\n }\n this.metrics?.onRpcSent(rpc, rpcBytes.length);\n return true;\n }\n /** Mutates `outRpc` adding graft and prune control messages */\n piggybackControl(id, outRpc, ctrl) {\n const rpc = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.ensureControl)(outRpc);\n for (const graft of ctrl.graft) {\n if (graft.topicID != null && (this.mesh.get(graft.topicID)?.has(id) ?? false)) {\n rpc.control.graft.push(graft);\n }\n }\n for (const prune of ctrl.prune) {\n if (prune.topicID != null && !(this.mesh.get(prune.topicID)?.has(id) ?? false)) {\n rpc.control.prune.push(prune);\n }\n }\n }\n /** Mutates `outRpc` adding ihave control messages */\n piggybackGossip(id, outRpc, ihave) {\n const rpc = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.ensureControl)(outRpc);\n rpc.control.ihave = ihave;\n }\n /**\n * Send graft and prune messages\n *\n * @param tograft - peer id => topic[]\n * @param toprune - peer id => topic[]\n */\n async sendGraftPrune(tograft, toprune, noPX) {\n const doPX = this.opts.doPX;\n const onUnsubscribe = false;\n for (const [id, topics] of tograft) {\n const graft = topics.map((topicID) => ({ topicID }));\n let prune = [];\n // If a peer also has prunes, process them now\n const pruning = toprune.get(id);\n if (pruning != null) {\n prune = await Promise.all(pruning.map(async (topicID) => this.makePrune(id, topicID, doPX && !(noPX.get(id) ?? false), onUnsubscribe)));\n toprune.delete(id);\n }\n this.sendRpc(id, (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { graft, prune }));\n }\n for (const [id, topics] of toprune) {\n const prune = await Promise.all(topics.map(async (topicID) => this.makePrune(id, topicID, doPX && !(noPX.get(id) ?? false), onUnsubscribe)));\n this.sendRpc(id, (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { prune }));\n }\n }\n /**\n * Emits gossip - Send IHAVE messages to a random set of gossip peers\n */\n emitGossip(peersToGossipByTopic) {\n const gossipIDsByTopic = this.mcache.getGossipIDs(new Set(peersToGossipByTopic.keys()));\n for (const [topic, peersToGossip] of peersToGossipByTopic) {\n this.doEmitGossip(topic, peersToGossip, gossipIDsByTopic.get(topic) ?? []);\n }\n }\n /**\n * Send gossip messages to GossipFactor peers above threshold with a minimum of D_lazy\n * Peers are randomly selected from the heartbeat which exclude mesh + fanout peers\n * We also exclude direct peers, as there is no reason to emit gossip to them\n *\n * @param topic\n * @param candidateToGossip - peers to gossip\n * @param messageIDs - message ids to gossip\n */\n doEmitGossip(topic, candidateToGossip, messageIDs) {\n if (messageIDs.length === 0) {\n return;\n }\n // shuffle to emit in random order\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength) {\n // we do the truncation (with shuffling) per peer below\n this.log('too many messages for gossip; will truncate IHAVE list (%d messages)', messageIDs.length);\n }\n if (candidateToGossip.size === 0)\n return;\n let target = this.opts.Dlazy;\n const factor = _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubGossipFactor * candidateToGossip.size;\n let peersToGossip = candidateToGossip;\n if (factor > target) {\n target = factor;\n }\n if (target > peersToGossip.size) {\n target = peersToGossip.size;\n }\n else {\n // only shuffle if needed\n peersToGossip = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(Array.from(peersToGossip)).slice(0, target);\n }\n // Emit the IHAVE gossip to the selected peers up to the target\n peersToGossip.forEach((id) => {\n let peerMessageIDs = messageIDs;\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength) {\n // shuffle and slice message IDs per peer so that we emit a different set for each peer\n // we have enough reduncancy in the system that this will significantly increase the message\n // coverage when we do truncate\n peerMessageIDs = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubMaxIHaveLength);\n }\n this.pushGossip(id, {\n topicID: topic,\n messageIDs: peerMessageIDs\n });\n });\n }\n /**\n * Flush gossip and control messages\n */\n flush() {\n // send gossip first, which will also piggyback control\n for (const [peer, ihave] of this.gossip.entries()) {\n this.gossip.delete(peer);\n this.sendRpc(peer, (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { ihave }));\n }\n // send the remaining control messages\n for (const [peer, control] of this.control.entries()) {\n this.control.delete(peer);\n const out = (0,_utils_create_gossip_rpc_js__WEBPACK_IMPORTED_MODULE_23__.createGossipRpc)([], { graft: control.graft, prune: control.prune });\n this.sendRpc(peer, out);\n }\n }\n /**\n * Adds new IHAVE messages to pending gossip\n */\n pushGossip(id, controlIHaveMsgs) {\n this.log('Add gossip to %s', id);\n const gossip = this.gossip.get(id) ?? [];\n this.gossip.set(id, gossip.concat(controlIHaveMsgs));\n }\n /**\n * Make a PRUNE control message for a peer in a topic\n */\n async makePrune(id, topic, doPX, onUnsubscribe) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id)?.protocol === _constants_js__WEBPACK_IMPORTED_MODULE_3__.GossipsubIDv10) {\n // Gossipsub v1.0 -- no backoff, the peer won't be able to parse it anyway\n return {\n topicID: topic,\n peers: []\n };\n }\n // backoff is measured in seconds\n // GossipsubPruneBackoff and GossipsubUnsubscribeBackoff are measured in milliseconds\n // The protobuf has it as a uint64\n const backoffMs = onUnsubscribe ? this.opts.unsubcribeBackoff : this.opts.pruneBackoff;\n const backoff = backoffMs / 1000;\n this.doAddBackoff(id, topic, backoffMs);\n if (!doPX) {\n return {\n topicID: topic,\n peers: [],\n backoff\n };\n }\n // select peers for Peer eXchange\n const peers = this.getRandomGossipPeers(topic, this.opts.prunePeers, (xid) => {\n return xid !== id && this.score.score(xid) >= 0;\n });\n const px = await Promise.all(Array.from(peers).map(async (peerId) => {\n // see if we have a signed record to send back; if we don't, just send\n // the peer ID and let the pruned peer find them in the DHT -- we can't trust\n // unsigned address records through PX anyways\n // Finding signed records in the DHT is not supported at the time of writing in js-libp2p\n const id = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_16__.peerIdFromString)(peerId);\n let peerInfo;\n try {\n peerInfo = await this.components.peerStore.get(id);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n return {\n peerID: id.toBytes(),\n signedPeerRecord: peerInfo?.peerRecordEnvelope\n };\n }));\n return {\n topicID: topic,\n peers: px,\n backoff\n };\n }\n runHeartbeat = () => {\n const timer = this.metrics?.heartbeatDuration.startTimer();\n this.heartbeat()\n .catch((err) => {\n this.log('Error running heartbeat', err);\n })\n .finally(() => {\n if (timer != null) {\n timer();\n }\n // Schedule the next run if still in started status\n if (this.status.code === GossipStatusCode.started) {\n // Clear previous timeout before overwriting `status.heartbeatTimeout`, it should be completed tho.\n clearTimeout(this.status.heartbeatTimeout);\n // NodeJS setInterval function is innexact, calls drift by a few miliseconds on each call.\n // To run the heartbeat precisely setTimeout() must be used recomputing the delay on every loop.\n let msToNextHeartbeat = this.opts.heartbeatInterval - ((Date.now() - this.status.hearbeatStartMs) % this.opts.heartbeatInterval);\n // If too close to next heartbeat, skip one\n if (msToNextHeartbeat < this.opts.heartbeatInterval * 0.25) {\n msToNextHeartbeat += this.opts.heartbeatInterval;\n this.metrics?.heartbeatSkipped.inc();\n }\n this.status.heartbeatTimeout = setTimeout(this.runHeartbeat, msToNextHeartbeat);\n }\n });\n };\n /**\n * Maintains the mesh and fanout maps in gossipsub.\n */\n async heartbeat() {\n const { D, Dlo, Dhi, Dscore, Dout, fanoutTTL } = this.opts;\n this.heartbeatTicks++;\n // cache scores throught the heartbeat\n const scores = new Map();\n const getScore = (id) => {\n let s = scores.get(id);\n if (s === undefined) {\n s = this.score.score(id);\n scores.set(id, s);\n }\n return s;\n };\n // peer id => topic[]\n const tograft = new Map();\n // peer id => topic[]\n const toprune = new Map();\n // peer id => don't px\n const noPX = new Map();\n // clean up expired backoffs\n this.clearBackoff();\n // clean up peerhave/iasked counters\n this.peerhave.clear();\n this.metrics?.cacheSize.set({ cache: 'iasked' }, this.iasked.size);\n this.iasked.clear();\n // apply IWANT request penalties\n this.applyIwantPenalties();\n // ensure direct peers are connected\n if (this.heartbeatTicks % this.opts.directConnectTicks === 0) {\n // we only do this every few ticks to allow pending connections to complete and account for restarts/downtime\n await this.directConnect();\n }\n // EXTRA: Prune caches\n this.fastMsgIdCache?.prune();\n this.seenCache.prune();\n this.gossipTracer.prune();\n this.publishedMessageIds.prune();\n /**\n * Instead of calling getRandomGossipPeers multiple times to:\n * + get more mesh peers\n * + more outbound peers\n * + oppportunistic grafting\n * + emitGossip\n *\n * We want to loop through the topic peers only a single time and prepare gossip peers for all topics to improve the performance\n */\n const peersToGossipByTopic = new Map();\n // maintain the mesh for topics we have joined\n // eslint-disable-next-line complexity\n this.mesh.forEach((peers, topic) => {\n const peersInTopic = this.topics.get(topic);\n const candidateMeshPeers = new Set();\n const peersToGossip = new Set();\n peersToGossipByTopic.set(topic, peersToGossip);\n if (peersInTopic != null) {\n const shuffledPeers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(Array.from(peersInTopic));\n const backoff = this.backoff.get(topic);\n for (const id of shuffledPeers) {\n const peerStreams = this.streamsOutbound.get(id);\n if ((peerStreams != null) &&\n this.multicodecs.includes(peerStreams.protocol) &&\n !peers.has(id) &&\n !this.direct.has(id)) {\n const score = getScore(id);\n if (((backoff == null) || !backoff.has(id)) && score >= 0)\n candidateMeshPeers.add(id);\n // instead of having to find gossip peers after heartbeat which require another loop\n // we prepare peers to gossip in a topic within heartbeat to improve performance\n if (score >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n }\n }\n }\n // prune/graft helper functions (defined per topic)\n const prunePeer = (id, reason) => {\n this.log('HEARTBEAT: Remove mesh link to %s in %s', id, topic);\n // no need to update peer score here as we do it in makePrune\n // add prune backoff record\n this.addBackoff(id, topic);\n // remove peer from mesh\n peers.delete(id);\n // after pruning a peer from mesh, we want to gossip topic to it if its score meet the gossip threshold\n if (getScore(id) >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n this.metrics?.onRemoveFromMesh(topic, reason, 1);\n // add to toprune\n const topics = toprune.get(id);\n if (topics == null) {\n toprune.set(id, [topic]);\n }\n else {\n topics.push(topic);\n }\n };\n const graftPeer = (id, reason) => {\n this.log('HEARTBEAT: Add mesh link to %s in %s', id, topic);\n // update peer score\n this.score.graft(id, topic);\n // add peer to mesh\n peers.add(id);\n // when we add a new mesh peer, we don't want to gossip messages to it\n peersToGossip.delete(id);\n this.metrics?.onAddToMesh(topic, reason, 1);\n // add to tograft\n const topics = tograft.get(id);\n if (topics == null) {\n tograft.set(id, [topic]);\n }\n else {\n topics.push(topic);\n }\n };\n // drop all peers with negative score, without PX\n peers.forEach((id) => {\n const score = getScore(id);\n // Record the score\n if (score < 0) {\n this.log('HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s', id, score, topic);\n prunePeer(id, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ChurnReason.BadScore);\n noPX.set(id, true);\n }\n });\n // do we have enough peers?\n if (peers.size < Dlo) {\n const ineed = D - peers.size;\n // slice up to first `ineed` items and remove them from candidateMeshPeers\n // same to `const newMeshPeers = candidateMeshPeers.slice(0, ineed)`\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_25__.removeFirstNItemsFromSet)(candidateMeshPeers, ineed);\n newMeshPeers.forEach((p) => {\n graftPeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.NotEnough);\n });\n }\n // do we have to many peers?\n if (peers.size > Dhi) {\n let peersArray = Array.from(peers);\n // sort by score\n peersArray.sort((a, b) => getScore(b) - getScore(a));\n // We keep the first D_score peers by score and the remaining up to D randomly\n // under the constraint that we keep D_out peers in the mesh (if we have that many)\n peersArray = peersArray.slice(0, Dscore).concat((0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(peersArray.slice(Dscore)));\n // count the outbound peers we are keeping\n let outbound = 0;\n peersArray.slice(0, D).forEach((p) => {\n if (this.outbound.get(p) ?? false) {\n outbound++;\n }\n });\n // if it's less than D_out, bubble up some outbound peers from the random selection\n if (outbound < Dout) {\n const rotate = (i) => {\n // rotate the peersArray to the right and put the ith peer in the front\n const p = peersArray[i];\n for (let j = i; j > 0; j--) {\n peersArray[j] = peersArray[j - 1];\n }\n peersArray[0] = p;\n };\n // first bubble up all outbound peers already in the selection to the front\n if (outbound > 0) {\n let ihave = outbound;\n for (let i = 1; i < D && ihave > 0; i++) {\n // eslint-disable-next-line max-depth\n if (this.outbound.get(peersArray[i]) ?? false) {\n rotate(i);\n ihave--;\n }\n }\n }\n // now bubble up enough outbound peers outside the selection to the front\n let ineed = D - outbound;\n for (let i = D; i < peersArray.length && ineed > 0; i++) {\n if (this.outbound.get(peersArray[i]) ?? false) {\n rotate(i);\n ineed--;\n }\n }\n }\n // prune the excess peers\n peersArray.slice(D).forEach((p) => {\n prunePeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.ChurnReason.Excess);\n });\n }\n // do we have enough outbound peers?\n if (peers.size >= Dlo) {\n // count the outbound peers we have\n let outbound = 0;\n peers.forEach((p) => {\n if (this.outbound.get(p) ?? false) {\n outbound++;\n }\n });\n // if it's less than D_out, select some peers with outbound connections and graft them\n if (outbound < Dout) {\n const ineed = Dout - outbound;\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_25__.removeItemsFromSet)(candidateMeshPeers, ineed, (id) => this.outbound.get(id) === true);\n newMeshPeers.forEach((p) => {\n graftPeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.Outbound);\n });\n }\n }\n // should we try to improve the mesh with opportunistic grafting?\n if (this.heartbeatTicks % this.opts.opportunisticGraftTicks === 0 && peers.size > 1) {\n // Opportunistic grafting works as follows: we check the median score of peers in the\n // mesh; if this score is below the opportunisticGraftThreshold, we select a few peers at\n // random with score over the median.\n // The intention is to (slowly) improve an underperforming mesh by introducing good\n // scoring peers that may have been gossiping at us. This allows us to get out of sticky\n // situations where we are stuck with poor peers and also recover from churn of good peers.\n // now compute the median peer score in the mesh\n const peersList = Array.from(peers).sort((a, b) => getScore(a) - getScore(b));\n const medianIndex = Math.floor(peers.size / 2);\n const medianScore = getScore(peersList[medianIndex]);\n // if the median score is below the threshold, select a better peer (if any) and GRAFT\n if (medianScore < this.opts.scoreThresholds.opportunisticGraftThreshold) {\n const ineed = this.opts.opportunisticGraftPeers;\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_25__.removeItemsFromSet)(candidateMeshPeers, ineed, (id) => getScore(id) > medianScore);\n for (const id of newMeshPeers) {\n this.log('HEARTBEAT: Opportunistically graft peer %s on topic %s', id, topic);\n graftPeer(id, _metrics_js__WEBPACK_IMPORTED_MODULE_13__.InclusionReason.Opportunistic);\n }\n }\n }\n });\n // expire fanout for topics we haven't published to in a while\n const now = Date.now();\n this.fanoutLastpub.forEach((lastpb, topic) => {\n if (lastpb + fanoutTTL < now) {\n this.fanout.delete(topic);\n this.fanoutLastpub.delete(topic);\n }\n });\n // maintain our fanout for topics we are publishing but we have not joined\n this.fanout.forEach((fanoutPeers, topic) => {\n // checks whether our peers are still in the topic and have a score above the publish threshold\n const topicPeers = this.topics.get(topic);\n fanoutPeers.forEach((id) => {\n if (!(topicPeers?.has(id) ?? false) || getScore(id) < this.opts.scoreThresholds.publishThreshold) {\n fanoutPeers.delete(id);\n }\n });\n const peersInTopic = this.topics.get(topic);\n const candidateFanoutPeers = [];\n // the fanout map contains topics to which we are not subscribed.\n const peersToGossip = new Set();\n peersToGossipByTopic.set(topic, peersToGossip);\n if (peersInTopic != null) {\n const shuffledPeers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(Array.from(peersInTopic));\n for (const id of shuffledPeers) {\n const peerStreams = this.streamsOutbound.get(id);\n if ((peerStreams != null) &&\n this.multicodecs.includes(peerStreams.protocol) &&\n !fanoutPeers.has(id) &&\n !this.direct.has(id)) {\n const score = getScore(id);\n if (score >= this.opts.scoreThresholds.publishThreshold)\n candidateFanoutPeers.push(id);\n // instead of having to find gossip peers after heartbeat which require another loop\n // we prepare peers to gossip in a topic within heartbeat to improve performance\n if (score >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n }\n }\n }\n // do we need more peers?\n if (fanoutPeers.size < D) {\n const ineed = D - fanoutPeers.size;\n candidateFanoutPeers.slice(0, ineed).forEach((id) => {\n fanoutPeers.add(id);\n peersToGossip?.delete(id);\n });\n }\n });\n this.emitGossip(peersToGossipByTopic);\n // send coalesced GRAFT/PRUNE messages (will piggyback gossip)\n await this.sendGraftPrune(tograft, toprune, noPX);\n // flush pending gossip that wasn't piggybacked above\n this.flush();\n // advance the message history window\n this.mcache.shift();\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:heartbeat'));\n }\n /**\n * Given a topic, returns up to count peers subscribed to that topic\n * that pass an optional filter function\n *\n * @param topic\n * @param count\n * @param filter - a function to filter acceptable peers\n */\n getRandomGossipPeers(topic, count, filter = () => true) {\n const peersInTopic = this.topics.get(topic);\n if (peersInTopic == null) {\n return new Set();\n }\n // Adds all peers using our protocol\n // that also pass the filter function\n let peers = [];\n peersInTopic.forEach((id) => {\n const peerStreams = this.streamsOutbound.get(id);\n if (peerStreams == null) {\n return;\n }\n if (this.multicodecs.includes(peerStreams.protocol) && filter(id)) {\n peers.push(id);\n }\n });\n // Pseudo-randomly shuffles peers\n peers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_24__.shuffle)(peers);\n if (count > 0 && peers.length > count) {\n peers = peers.slice(0, count);\n }\n return new Set(peers);\n }\n onScrapeMetrics(metrics) {\n /* Data structure sizes */\n metrics.mcacheSize.set(this.mcache.size);\n metrics.mcacheNotValidatedCount.set(this.mcache.notValidatedCount);\n // Arbitrary size\n metrics.cacheSize.set({ cache: 'direct' }, this.direct.size);\n metrics.cacheSize.set({ cache: 'seenCache' }, this.seenCache.size);\n metrics.cacheSize.set({ cache: 'fastMsgIdCache' }, this.fastMsgIdCache?.size ?? 0);\n metrics.cacheSize.set({ cache: 'publishedMessageIds' }, this.publishedMessageIds.size);\n metrics.cacheSize.set({ cache: 'mcache' }, this.mcache.size);\n metrics.cacheSize.set({ cache: 'score' }, this.score.size);\n metrics.cacheSize.set({ cache: 'gossipTracer.promises' }, this.gossipTracer.size);\n metrics.cacheSize.set({ cache: 'gossipTracer.requests' }, this.gossipTracer.requestMsByMsgSize);\n // Bounded by topic\n metrics.cacheSize.set({ cache: 'topics' }, this.topics.size);\n metrics.cacheSize.set({ cache: 'subscriptions' }, this.subscriptions.size);\n metrics.cacheSize.set({ cache: 'mesh' }, this.mesh.size);\n metrics.cacheSize.set({ cache: 'fanout' }, this.fanout.size);\n // Bounded by peer\n metrics.cacheSize.set({ cache: 'peers' }, this.peers.size);\n metrics.cacheSize.set({ cache: 'streamsOutbound' }, this.streamsOutbound.size);\n metrics.cacheSize.set({ cache: 'streamsInbound' }, this.streamsInbound.size);\n metrics.cacheSize.set({ cache: 'acceptFromWhitelist' }, this.acceptFromWhitelist.size);\n metrics.cacheSize.set({ cache: 'gossip' }, this.gossip.size);\n metrics.cacheSize.set({ cache: 'control' }, this.control.size);\n metrics.cacheSize.set({ cache: 'peerhave' }, this.peerhave.size);\n metrics.cacheSize.set({ cache: 'outbound' }, this.outbound.size);\n // 2D nested data structure\n let backoffSize = 0;\n const now = Date.now();\n metrics.connectedPeersBackoffSec.reset();\n for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\n for (const [peer, expiredMs] of backoff.entries()) {\n if (this.peers.has(peer)) {\n metrics.connectedPeersBackoffSec.observe(Math.max(0, expiredMs - now) / 1000);\n }\n }\n }\n metrics.cacheSize.set({ cache: 'backoff' }, backoffSize);\n // Peer counts\n for (const [topicStr, peers] of this.topics) {\n metrics.topicPeersCount.set({ topicStr }, peers.size);\n }\n for (const [topicStr, peers] of this.mesh) {\n metrics.meshPeerCounts.set({ topicStr }, peers.size);\n }\n // Peer scores\n const scores = [];\n const scoreByPeer = new Map();\n metrics.behaviourPenalty.reset();\n for (const peerIdStr of this.peers.keys()) {\n const score = this.score.score(peerIdStr);\n scores.push(score);\n scoreByPeer.set(peerIdStr, score);\n metrics.behaviourPenalty.observe(this.score.peerStats.get(peerIdStr)?.behaviourPenalty ?? 0);\n }\n metrics.registerScores(scores, this.opts.scoreThresholds);\n // Breakdown score per mesh topicLabel\n metrics.registerScorePerMesh(this.mesh, scoreByPeer);\n // Breakdown on each score weight\n const sw = (0,_score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_26__.computeAllPeersScoreWeights)(this.peers.keys(), this.score.peerStats, this.score.params, this.score.peerIPs, metrics.topicStrToLabel);\n metrics.registerScoreWeights(sw);\n }\n}\nfunction gossipsub(init = {}) {\n return (components) => new GossipSub(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageCache: () => (/* binding */ MessageCache)\n/* harmony export */ });\nclass MessageCache {\n gossip;\n msgs = new Map();\n msgIdToStrFn;\n history = [];\n /** Track with accounting of messages in the mcache that are not yet validated */\n notValidatedCount = 0;\n /**\n * Holds history of messages in timebounded history arrays\n */\n constructor(\n /**\n * The number of indices in the cache history used for gossiping. That means that a message\n * won't get gossiped anymore when shift got called `gossip` many times after inserting the\n * message in the cache.\n */\n gossip, historyCapacity, msgIdToStrFn) {\n this.gossip = gossip;\n this.msgIdToStrFn = msgIdToStrFn;\n for (let i = 0; i < historyCapacity; i++) {\n this.history[i] = [];\n }\n }\n get size() {\n return this.msgs.size;\n }\n /**\n * Adds a message to the current window and the cache\n * Returns true if the message is not known and is inserted in the cache\n */\n put(messageId, msg, validated = false) {\n const { msgIdStr } = messageId;\n // Don't add duplicate entries to the cache.\n if (this.msgs.has(msgIdStr)) {\n return false;\n }\n this.msgs.set(msgIdStr, {\n message: msg,\n validated,\n originatingPeers: new Set(),\n iwantCounts: new Map()\n });\n this.history[0].push({ ...messageId, topic: msg.topic });\n if (!validated) {\n this.notValidatedCount++;\n }\n return true;\n }\n observeDuplicate(msgId, fromPeerIdStr) {\n const entry = this.msgs.get(msgId);\n if ((entry != null) &&\n // if the message is already validated, we don't need to store extra peers sending us\n // duplicates as the message has already been forwarded\n !entry.validated) {\n entry.originatingPeers.add(fromPeerIdStr);\n }\n }\n /**\n * Retrieves a message from the cache by its ID, if it is still present\n */\n get(msgId) {\n return this.msgs.get(this.msgIdToStrFn(msgId))?.message;\n }\n /**\n * Increases the iwant count for the given message by one and returns the message together\n * with the iwant if the message exists.\n */\n getWithIWantCount(msgIdStr, p) {\n const msg = this.msgs.get(msgIdStr);\n if (msg == null) {\n return null;\n }\n const count = (msg.iwantCounts.get(p) ?? 0) + 1;\n msg.iwantCounts.set(p, count);\n return { msg: msg.message, count };\n }\n /**\n * Retrieves a list of message IDs for a set of topics\n */\n getGossipIDs(topics) {\n const msgIdsByTopic = new Map();\n for (let i = 0; i < this.gossip; i++) {\n this.history[i].forEach((entry) => {\n const msg = this.msgs.get(entry.msgIdStr);\n if ((msg?.validated ?? false) && topics.has(entry.topic)) {\n let msgIds = msgIdsByTopic.get(entry.topic);\n if (msgIds == null) {\n msgIds = [];\n msgIdsByTopic.set(entry.topic, msgIds);\n }\n msgIds.push(entry.msgId);\n }\n });\n }\n return msgIdsByTopic;\n }\n /**\n * Gets a message with msgId and tags it as validated.\n * This function also returns the known peers that have sent us this message. This is used to\n * prevent us sending redundant messages to peers who have already propagated it.\n */\n validate(msgId) {\n const entry = this.msgs.get(msgId);\n if (entry == null) {\n return null;\n }\n if (!entry.validated) {\n this.notValidatedCount--;\n }\n const { message, originatingPeers } = entry;\n entry.validated = true;\n // Clear the known peers list (after a message is validated, it is forwarded and we no\n // longer need to store the originating peers).\n entry.originatingPeers = new Set();\n return { message, originatingPeers };\n }\n /**\n * Shifts the current window, discarding messages older than this.history.length of the cache\n */\n shift() {\n const lastCacheEntries = this.history[this.history.length - 1];\n lastCacheEntries.forEach((cacheEntry) => {\n const entry = this.msgs.get(cacheEntry.msgIdStr);\n if (entry != null) {\n this.msgs.delete(cacheEntry.msgIdStr);\n if (!entry.validated) {\n this.notValidatedCount--;\n }\n }\n });\n this.history.pop();\n this.history.unshift([]);\n }\n remove(msgId) {\n const entry = this.msgs.get(msgId);\n if (entry == null) {\n return null;\n }\n // Keep the message on the history vector, it will be dropped on a shift()\n this.msgs.delete(msgId);\n return entry;\n }\n}\n//# sourceMappingURL=message-cache.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultDecodeRpcLimits: () => (/* binding */ defaultDecodeRpcLimits)\n/* harmony export */ });\nconst defaultDecodeRpcLimits = {\n maxSubscriptions: Infinity,\n maxMessages: Infinity,\n maxIhaveMessageIDs: Infinity,\n maxIwantMessageIDs: Infinity,\n maxControlMessages: Infinity,\n maxPeerInfos: Infinity\n};\n//# sourceMappingURL=decodeRpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js": +/*!**************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js ***! + \**************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RPC: () => (/* binding */ RPC)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar RPC;\n(function (RPC) {\n let SubOpts;\n (function (SubOpts) {\n let _codec;\n SubOpts.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.subscribe != null) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if (obj.topic != null) {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.subscribe = reader.bool();\n break;\n }\n case 2: {\n obj.topic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n SubOpts.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, SubOpts.codec());\n };\n SubOpts.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, SubOpts.codec(), opts);\n };\n })(SubOpts = RPC.SubOpts || (RPC.SubOpts = {}));\n let Message;\n (function (Message) {\n let _codec;\n Message.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.from != null) {\n w.uint32(10);\n w.bytes(obj.from);\n }\n if (obj.data != null) {\n w.uint32(18);\n w.bytes(obj.data);\n }\n if (obj.seqno != null) {\n w.uint32(26);\n w.bytes(obj.seqno);\n }\n if ((obj.topic != null && obj.topic !== '')) {\n w.uint32(34);\n w.string(obj.topic);\n }\n if (obj.signature != null) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (obj.key != null) {\n w.uint32(50);\n w.bytes(obj.key);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n topic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.from = reader.bytes();\n break;\n }\n case 2: {\n obj.data = reader.bytes();\n break;\n }\n case 3: {\n obj.seqno = reader.bytes();\n break;\n }\n case 4: {\n obj.topic = reader.string();\n break;\n }\n case 5: {\n obj.signature = reader.bytes();\n break;\n }\n case 6: {\n obj.key = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Message.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Message.codec());\n };\n Message.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Message.codec(), opts);\n };\n })(Message = RPC.Message || (RPC.Message = {}));\n let ControlMessage;\n (function (ControlMessage) {\n let _codec;\n ControlMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.ihave != null) {\n for (const value of obj.ihave) {\n w.uint32(10);\n RPC.ControlIHave.codec().encode(value, w);\n }\n }\n if (obj.iwant != null) {\n for (const value of obj.iwant) {\n w.uint32(18);\n RPC.ControlIWant.codec().encode(value, w);\n }\n }\n if (obj.graft != null) {\n for (const value of obj.graft) {\n w.uint32(26);\n RPC.ControlGraft.codec().encode(value, w);\n }\n }\n if (obj.prune != null) {\n for (const value of obj.prune) {\n w.uint32(34);\n RPC.ControlPrune.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n ihave: [],\n iwant: [],\n graft: [],\n prune: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.ihave != null && obj.ihave.length === opts.limits.ihave) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"ihave\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.ihave.push(RPC.ControlIHave.codec().decode(reader, reader.uint32()));\n break;\n }\n case 2: {\n if (opts.limits?.iwant != null && obj.iwant.length === opts.limits.iwant) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"iwant\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.iwant.push(RPC.ControlIWant.codec().decode(reader, reader.uint32()));\n break;\n }\n case 3: {\n if (opts.limits?.graft != null && obj.graft.length === opts.limits.graft) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"graft\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.graft.push(RPC.ControlGraft.codec().decode(reader, reader.uint32()));\n break;\n }\n case 4: {\n if (opts.limits?.prune != null && obj.prune.length === opts.limits.prune) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"prune\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.prune.push(RPC.ControlPrune.codec().decode(reader, reader.uint32()));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ControlMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ControlMessage.codec());\n };\n ControlMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ControlMessage.codec(), opts);\n };\n })(ControlMessage = RPC.ControlMessage || (RPC.ControlMessage = {}));\n let ControlIHave;\n (function (ControlIHave) {\n let _codec;\n ControlIHave.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.topicID != null) {\n w.uint32(10);\n w.string(obj.topicID);\n }\n if (obj.messageIDs != null) {\n for (const value of obj.messageIDs) {\n w.uint32(18);\n w.bytes(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messageIDs: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.topicID = reader.string();\n break;\n }\n case 2: {\n if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messageIDs\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messageIDs.push(reader.bytes());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ControlIHave.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ControlIHave.codec());\n };\n ControlIHave.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ControlIHave.codec(), opts);\n };\n })(ControlIHave = RPC.ControlIHave || (RPC.ControlIHave = {}));\n let ControlIWant;\n (function (ControlIWant) {\n let _codec;\n ControlIWant.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messageIDs != null) {\n for (const value of obj.messageIDs) {\n w.uint32(10);\n w.bytes(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messageIDs: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messageIDs\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messageIDs.push(reader.bytes());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ControlIWant.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ControlIWant.codec());\n };\n ControlIWant.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ControlIWant.codec(), opts);\n };\n })(ControlIWant = RPC.ControlIWant || (RPC.ControlIWant = {}));\n let ControlGraft;\n (function (ControlGraft) {\n let _codec;\n ControlGraft.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.topicID != null) {\n w.uint32(10);\n w.string(obj.topicID);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.topicID = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ControlGraft.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ControlGraft.codec());\n };\n ControlGraft.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ControlGraft.codec(), opts);\n };\n })(ControlGraft = RPC.ControlGraft || (RPC.ControlGraft = {}));\n let ControlPrune;\n (function (ControlPrune) {\n let _codec;\n ControlPrune.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.topicID != null) {\n w.uint32(10);\n w.string(obj.topicID);\n }\n if (obj.peers != null) {\n for (const value of obj.peers) {\n w.uint32(18);\n RPC.PeerInfo.codec().encode(value, w);\n }\n }\n if (obj.backoff != null) {\n w.uint32(24);\n w.uint64Number(obj.backoff);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n peers: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.topicID = reader.string();\n break;\n }\n case 2: {\n if (opts.limits?.peers != null && obj.peers.length === opts.limits.peers) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"peers\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.peers.push(RPC.PeerInfo.codec().decode(reader, reader.uint32()));\n break;\n }\n case 3: {\n obj.backoff = reader.uint64Number();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ControlPrune.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ControlPrune.codec());\n };\n ControlPrune.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ControlPrune.codec(), opts);\n };\n })(ControlPrune = RPC.ControlPrune || (RPC.ControlPrune = {}));\n let PeerInfo;\n (function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerID != null) {\n w.uint32(10);\n w.bytes(obj.peerID);\n }\n if (obj.signedPeerRecord != null) {\n w.uint32(18);\n w.bytes(obj.signedPeerRecord);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.peerID = reader.bytes();\n break;\n }\n case 2: {\n obj.signedPeerRecord = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec(), opts);\n };\n })(PeerInfo = RPC.PeerInfo || (RPC.PeerInfo = {}));\n let _codec;\n RPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.subscriptions != null) {\n for (const value of obj.subscriptions) {\n w.uint32(10);\n RPC.SubOpts.codec().encode(value, w);\n }\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n RPC.Message.codec().encode(value, w);\n }\n }\n if (obj.control != null) {\n w.uint32(26);\n RPC.ControlMessage.codec().encode(obj.control, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n subscriptions: [],\n messages: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.subscriptions != null && obj.subscriptions.length === opts.limits.subscriptions) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"subscriptions\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32()));\n break;\n }\n case 2: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32()));\n break;\n }\n case 3: {\n obj.control = RPC.ControlMessage.codec().decode(reader, reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RPC.codec());\n };\n RPC.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RPC.codec(), opts);\n };\n})(RPC || (RPC = {}));\n//# sourceMappingURL=rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChurnReason: () => (/* binding */ ChurnReason),\n/* harmony export */ IHaveIgnoreReason: () => (/* binding */ IHaveIgnoreReason),\n/* harmony export */ InclusionReason: () => (/* binding */ InclusionReason),\n/* harmony export */ MessageSource: () => (/* binding */ MessageSource),\n/* harmony export */ ScorePenalty: () => (/* binding */ ScorePenalty),\n/* harmony export */ ScoreThreshold: () => (/* binding */ ScoreThreshold),\n/* harmony export */ getMetrics: () => (/* binding */ getMetrics)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n\nvar MessageSource;\n(function (MessageSource) {\n MessageSource[\"forward\"] = \"forward\";\n MessageSource[\"publish\"] = \"publish\";\n})(MessageSource || (MessageSource = {}));\nvar InclusionReason;\n(function (InclusionReason) {\n /** Peer was a fanaout peer. */\n InclusionReason[\"Fanout\"] = \"fanout\";\n /** Included from random selection. */\n InclusionReason[\"Random\"] = \"random\";\n /** Peer subscribed. */\n InclusionReason[\"Subscribed\"] = \"subscribed\";\n /** On heartbeat, peer was included to fill the outbound quota. */\n InclusionReason[\"Outbound\"] = \"outbound\";\n /** On heartbeat, not enough peers in mesh */\n InclusionReason[\"NotEnough\"] = \"not_enough\";\n /** On heartbeat opportunistic grafting due to low mesh score */\n InclusionReason[\"Opportunistic\"] = \"opportunistic\";\n})(InclusionReason || (InclusionReason = {}));\n/// Reasons why a peer was removed from the mesh.\nvar ChurnReason;\n(function (ChurnReason) {\n /// Peer disconnected.\n ChurnReason[\"Dc\"] = \"disconnected\";\n /// Peer had a bad score.\n ChurnReason[\"BadScore\"] = \"bad_score\";\n /// Peer sent a PRUNE.\n ChurnReason[\"Prune\"] = \"prune\";\n /// Too many peers.\n ChurnReason[\"Excess\"] = \"excess\";\n})(ChurnReason || (ChurnReason = {}));\n/// Kinds of reasons a peer's score has been penalized\nvar ScorePenalty;\n(function (ScorePenalty) {\n /// A peer grafted before waiting the back-off time.\n ScorePenalty[\"GraftBackoff\"] = \"graft_backoff\";\n /// A Peer did not respond to an IWANT request in time.\n ScorePenalty[\"BrokenPromise\"] = \"broken_promise\";\n /// A Peer did not send enough messages as expected.\n ScorePenalty[\"MessageDeficit\"] = \"message_deficit\";\n /// Too many peers under one IP address.\n ScorePenalty[\"IPColocation\"] = \"IP_colocation\";\n})(ScorePenalty || (ScorePenalty = {}));\nvar IHaveIgnoreReason;\n(function (IHaveIgnoreReason) {\n IHaveIgnoreReason[\"LowScore\"] = \"low_score\";\n IHaveIgnoreReason[\"MaxIhave\"] = \"max_ihave\";\n IHaveIgnoreReason[\"MaxIasked\"] = \"max_iasked\";\n})(IHaveIgnoreReason || (IHaveIgnoreReason = {}));\nvar ScoreThreshold;\n(function (ScoreThreshold) {\n ScoreThreshold[\"graylist\"] = \"graylist\";\n ScoreThreshold[\"publish\"] = \"publish\";\n ScoreThreshold[\"gossip\"] = \"gossip\";\n ScoreThreshold[\"mesh\"] = \"mesh\";\n})(ScoreThreshold || (ScoreThreshold = {}));\n/**\n * A collection of metrics used throughout the Gossipsub behaviour.\n * NOTE: except for special reasons, do not add more than 1 label for frequent metrics,\n * there's a performance penalty as of June 2023.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nfunction getMetrics(register, topicStrToLabel, opts) {\n // Using function style instead of class to prevent having to re-declare all MetricsPrometheus types.\n return {\n /* Metrics for static config */\n protocolsEnabled: register.gauge({\n name: 'gossipsub_protocol',\n help: 'Status of enabled protocols',\n labelNames: ['protocol']\n }),\n /* Metrics per known topic */\n /**\n * Status of our subscription to this topic. This metric allows analyzing other topic metrics\n * filtered by our current subscription status.\n * = rust-libp2p `topic_subscription_status` */\n topicSubscriptionStatus: register.gauge({\n name: 'gossipsub_topic_subscription_status',\n help: 'Status of our subscription to this topic',\n labelNames: ['topicStr']\n }),\n /** Number of peers subscribed to each topic. This allows us to analyze a topic's behaviour\n * regardless of our subscription status. */\n topicPeersCount: register.gauge({\n name: 'gossipsub_topic_peer_count',\n help: 'Number of peers subscribed to each topic',\n labelNames: ['topicStr']\n }),\n /* Metrics regarding mesh state */\n /**\n * Number of peers in our mesh. This metric should be updated with the count of peers for a\n * topic in the mesh regardless of inclusion and churn events.\n * = rust-libp2p `mesh_peer_counts` */\n meshPeerCounts: register.gauge({\n name: 'gossipsub_mesh_peer_count',\n help: 'Number of peers in our mesh',\n labelNames: ['topicStr']\n }),\n /**\n * Number of times we include peers in a topic mesh for different reasons.\n * = rust-libp2p `mesh_peer_inclusion_events` */\n meshPeerInclusionEventsFanout: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_fanout_total',\n help: 'Number of times we include peers in a topic mesh for fanout reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsRandom: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_random_total',\n help: 'Number of times we include peers in a topic mesh for random reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsSubscribed: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_subscribed_total',\n help: 'Number of times we include peers in a topic mesh for subscribed reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsOutbound: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_outbound_total',\n help: 'Number of times we include peers in a topic mesh for outbound reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsNotEnough: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_not_enough_total',\n help: 'Number of times we include peers in a topic mesh for not_enough reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsOpportunistic: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_opportunistic_total',\n help: 'Number of times we include peers in a topic mesh for opportunistic reasons',\n labelNames: ['topic']\n }),\n meshPeerInclusionEventsUnknown: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_unknown_total',\n help: 'Number of times we include peers in a topic mesh for unknown reasons',\n labelNames: ['topic']\n }),\n /**\n * Number of times we remove peers in a topic mesh for different reasons.\n * = rust-libp2p `mesh_peer_churn_events` */\n meshPeerChurnEventsDisconnected: register.gauge({\n name: 'gossipsub_peer_churn_events_disconnected_total',\n help: 'Number of times we remove peers in a topic mesh for disconnected reasons',\n labelNames: ['topic']\n }),\n meshPeerChurnEventsBadScore: register.gauge({\n name: 'gossipsub_peer_churn_events_bad_score_total',\n help: 'Number of times we remove peers in a topic mesh for bad_score reasons',\n labelNames: ['topic']\n }),\n meshPeerChurnEventsPrune: register.gauge({\n name: 'gossipsub_peer_churn_events_prune_total',\n help: 'Number of times we remove peers in a topic mesh for prune reasons',\n labelNames: ['topic']\n }),\n meshPeerChurnEventsExcess: register.gauge({\n name: 'gossipsub_peer_churn_events_excess_total',\n help: 'Number of times we remove peers in a topic mesh for excess reasons',\n labelNames: ['topic']\n }),\n meshPeerChurnEventsUnknown: register.gauge({\n name: 'gossipsub_peer_churn_events_unknown_total',\n help: 'Number of times we remove peers in a topic mesh for unknown reasons',\n labelNames: ['topic']\n }),\n /* General Metrics */\n /**\n * Gossipsub supports floodsub, gossipsub v1.0 and gossipsub v1.1. Peers are classified based\n * on which protocol they support. This metric keeps track of the number of peers that are\n * connected of each type. */\n peersPerProtocol: register.gauge({\n name: 'gossipsub_peers_per_protocol_count',\n help: 'Peers connected for each topic',\n labelNames: ['protocol']\n }),\n /** The time it takes to complete one iteration of the heartbeat. */\n heartbeatDuration: register.histogram({\n name: 'gossipsub_heartbeat_duration_seconds',\n help: 'The time it takes to complete one iteration of the heartbeat',\n // Should take <10ms, over 1s it's a huge issue that needs debugging, since a heartbeat will be cancelled\n buckets: [0.01, 0.1, 1]\n }),\n /** Heartbeat run took longer than heartbeat interval so next is skipped */\n heartbeatSkipped: register.gauge({\n name: 'gossipsub_heartbeat_skipped',\n help: 'Heartbeat run took longer than heartbeat interval so next is skipped'\n }),\n /**\n * Message validation results for each topic.\n * Invalid == Reject?\n * = rust-libp2p `invalid_messages`, `accepted_messages`, `ignored_messages`, `rejected_messages` */\n acceptedMessagesTotal: register.gauge({\n name: 'gossipsub_accepted_messages_total',\n help: 'Total accepted messages for each topic',\n labelNames: ['topic']\n }),\n ignoredMessagesTotal: register.gauge({\n name: 'gossipsub_ignored_messages_total',\n help: 'Total ignored messages for each topic',\n labelNames: ['topic']\n }),\n rejectedMessagesTotal: register.gauge({\n name: 'gossipsub_rejected_messages_total',\n help: 'Total rejected messages for each topic',\n labelNames: ['topic']\n }),\n unknownValidationResultsTotal: register.gauge({\n name: 'gossipsub_unknown_validation_results_total',\n help: 'Total unknown validation results for each topic',\n labelNames: ['topic']\n }),\n /**\n * When the user validates a message, it tries to re propagate it to its mesh peers. If the\n * message expires from the memcache before it can be validated, we count this a cache miss\n * and it is an indicator that the memcache size should be increased.\n * = rust-libp2p `mcache_misses` */\n asyncValidationMcacheHit: register.gauge({\n name: 'gossipsub_async_validation_mcache_hit_total',\n help: 'Async validation result reported by the user layer',\n labelNames: ['hit']\n }),\n asyncValidationDelayFromFirstSeenSec: register.histogram({\n name: 'gossipsub_async_validation_delay_from_first_seen',\n help: 'Async validation report delay from first seen in second',\n buckets: [0.01, 0.03, 0.1, 0.3, 1, 3, 10]\n }),\n asyncValidationUnknownFirstSeen: register.gauge({\n name: 'gossipsub_async_validation_unknown_first_seen_count_total',\n help: 'Async validation report unknown first seen value for message'\n }),\n // peer stream\n peerReadStreamError: register.gauge({\n name: 'gossipsub_peer_read_stream_err_count_total',\n help: 'Peer read stream error'\n }),\n // RPC outgoing. Track byte length + data structure sizes\n rpcRecvBytes: register.gauge({ name: 'gossipsub_rpc_recv_bytes_total', help: 'RPC recv' }),\n rpcRecvCount: register.gauge({ name: 'gossipsub_rpc_recv_count_total', help: 'RPC recv' }),\n rpcRecvSubscription: register.gauge({ name: 'gossipsub_rpc_recv_subscription_total', help: 'RPC recv' }),\n rpcRecvMessage: register.gauge({ name: 'gossipsub_rpc_recv_message_total', help: 'RPC recv' }),\n rpcRecvControl: register.gauge({ name: 'gossipsub_rpc_recv_control_total', help: 'RPC recv' }),\n rpcRecvIHave: register.gauge({ name: 'gossipsub_rpc_recv_ihave_total', help: 'RPC recv' }),\n rpcRecvIWant: register.gauge({ name: 'gossipsub_rpc_recv_iwant_total', help: 'RPC recv' }),\n rpcRecvGraft: register.gauge({ name: 'gossipsub_rpc_recv_graft_total', help: 'RPC recv' }),\n rpcRecvPrune: register.gauge({ name: 'gossipsub_rpc_recv_prune_total', help: 'RPC recv' }),\n rpcDataError: register.gauge({ name: 'gossipsub_rpc_data_err_count_total', help: 'RPC data error' }),\n rpcRecvError: register.gauge({ name: 'gossipsub_rpc_recv_err_count_total', help: 'RPC recv error' }),\n /** Total count of RPC dropped because acceptFrom() == false */\n rpcRecvNotAccepted: register.gauge({\n name: 'gossipsub_rpc_rcv_not_accepted_total',\n help: 'Total count of RPC dropped because acceptFrom() == false'\n }),\n // RPC incoming. Track byte length + data structure sizes\n rpcSentBytes: register.gauge({ name: 'gossipsub_rpc_sent_bytes_total', help: 'RPC sent' }),\n rpcSentCount: register.gauge({ name: 'gossipsub_rpc_sent_count_total', help: 'RPC sent' }),\n rpcSentSubscription: register.gauge({ name: 'gossipsub_rpc_sent_subscription_total', help: 'RPC sent' }),\n rpcSentMessage: register.gauge({ name: 'gossipsub_rpc_sent_message_total', help: 'RPC sent' }),\n rpcSentControl: register.gauge({ name: 'gossipsub_rpc_sent_control_total', help: 'RPC sent' }),\n rpcSentIHave: register.gauge({ name: 'gossipsub_rpc_sent_ihave_total', help: 'RPC sent' }),\n rpcSentIWant: register.gauge({ name: 'gossipsub_rpc_sent_iwant_total', help: 'RPC sent' }),\n rpcSentGraft: register.gauge({ name: 'gossipsub_rpc_sent_graft_total', help: 'RPC sent' }),\n rpcSentPrune: register.gauge({ name: 'gossipsub_rpc_sent_prune_total', help: 'RPC sent' }),\n // publish message. Track peers sent to and bytes\n /** Total count of msg published by topic */\n msgPublishCount: register.gauge({\n name: 'gossipsub_msg_publish_count_total',\n help: 'Total count of msg published by topic',\n labelNames: ['topic']\n }),\n /** Total count of peers that we publish a msg to */\n msgPublishPeersByTopic: register.gauge({\n name: 'gossipsub_msg_publish_peers_total',\n help: 'Total count of peers that we publish a msg to',\n labelNames: ['topic']\n }),\n /** Total count of peers (by group) that we publish a msg to */\n directPeersPublishedTotal: register.gauge({\n name: 'gossipsub_direct_peers_published_total',\n help: 'Total direct peers that we publish a msg to',\n labelNames: ['topic']\n }),\n floodsubPeersPublishedTotal: register.gauge({\n name: 'gossipsub_floodsub_peers_published_total',\n help: 'Total floodsub peers that we publish a msg to',\n labelNames: ['topic']\n }),\n meshPeersPublishedTotal: register.gauge({\n name: 'gossipsub_mesh_peers_published_total',\n help: 'Total mesh peers that we publish a msg to',\n labelNames: ['topic']\n }),\n fanoutPeersPublishedTotal: register.gauge({\n name: 'gossipsub_fanout_peers_published_total',\n help: 'Total fanout peers that we publish a msg to',\n labelNames: ['topic']\n }),\n /** Total count of msg publish data.length bytes */\n msgPublishBytes: register.gauge({\n name: 'gossipsub_msg_publish_bytes_total',\n help: 'Total count of msg publish data.length bytes',\n labelNames: ['topic']\n }),\n /** Total time in seconds to publish a message */\n msgPublishTime: register.histogram({\n name: 'gossipsub_msg_publish_seconds',\n help: 'Total time in seconds to publish a message',\n buckets: [0.001, 0.002, 0.005, 0.01, 0.1, 0.5, 1],\n labelNames: ['topic']\n }),\n /** Total count of msg forwarded by topic */\n msgForwardCount: register.gauge({\n name: 'gossipsub_msg_forward_count_total',\n help: 'Total count of msg forwarded by topic',\n labelNames: ['topic']\n }),\n /** Total count of peers that we forward a msg to */\n msgForwardPeers: register.gauge({\n name: 'gossipsub_msg_forward_peers_total',\n help: 'Total count of peers that we forward a msg to',\n labelNames: ['topic']\n }),\n /** Total count of recv msgs before any validation */\n msgReceivedPreValidation: register.gauge({\n name: 'gossipsub_msg_received_prevalidation_total',\n help: 'Total count of recv msgs before any validation',\n labelNames: ['topic']\n }),\n /** Total count of recv msgs error */\n msgReceivedError: register.gauge({\n name: 'gossipsub_msg_received_error_total',\n help: 'Total count of recv msgs error',\n labelNames: ['topic']\n }),\n /** Tracks distribution of recv msgs by duplicate, invalid, valid */\n prevalidationInvalidTotal: register.gauge({\n name: 'gossipsub_pre_validation_invalid_total',\n help: 'Total count of invalid messages received',\n labelNames: ['topic']\n }),\n prevalidationValidTotal: register.gauge({\n name: 'gossipsub_pre_validation_valid_total',\n help: 'Total count of valid messages received',\n labelNames: ['topic']\n }),\n prevalidationDuplicateTotal: register.gauge({\n name: 'gossipsub_pre_validation_duplicate_total',\n help: 'Total count of duplicate messages received',\n labelNames: ['topic']\n }),\n prevalidationUnknownTotal: register.gauge({\n name: 'gossipsub_pre_validation_unknown_status_total',\n help: 'Total count of unknown_status messages received',\n labelNames: ['topic']\n }),\n /** Tracks specific reason of invalid */\n msgReceivedInvalid: register.gauge({\n name: 'gossipsub_msg_received_invalid_total',\n help: 'Tracks specific reason of invalid',\n labelNames: ['error']\n }),\n msgReceivedInvalidByTopic: register.gauge({\n name: 'gossipsub_msg_received_invalid_by_topic_total',\n help: 'Tracks specific invalid message by topic',\n labelNames: ['topic']\n }),\n /** Track duplicate message delivery time */\n duplicateMsgDeliveryDelay: register.histogram({\n name: 'gossisub_duplicate_msg_delivery_delay_seconds',\n help: 'Time since the 1st duplicated message validated',\n labelNames: ['topic'],\n buckets: [\n 0.25 * opts.maxMeshMessageDeliveriesWindowSec,\n 0.5 * opts.maxMeshMessageDeliveriesWindowSec,\n Number(opts.maxMeshMessageDeliveriesWindowSec),\n 2 * opts.maxMeshMessageDeliveriesWindowSec,\n 4 * opts.maxMeshMessageDeliveriesWindowSec\n ]\n }),\n /** Total count of late msg delivery total by topic */\n duplicateMsgLateDelivery: register.gauge({\n name: 'gossisub_duplicate_msg_late_delivery_total',\n help: 'Total count of late duplicate message delivery by topic, which triggers P3 penalty',\n labelNames: ['topic']\n }),\n duplicateMsgIgnored: register.gauge({\n name: 'gossisub_ignored_published_duplicate_msgs_total',\n help: 'Total count of published duplicate message ignored by topic',\n labelNames: ['topic']\n }),\n /* Metrics related to scoring */\n /** Total times score() is called */\n scoreFnCalls: register.gauge({\n name: 'gossipsub_score_fn_calls_total',\n help: 'Total times score() is called'\n }),\n /** Total times score() call actually computed computeScore(), no cache */\n scoreFnRuns: register.gauge({\n name: 'gossipsub_score_fn_runs_total',\n help: 'Total times score() call actually computed computeScore(), no cache'\n }),\n scoreCachedDelta: register.histogram({\n name: 'gossipsub_score_cache_delta',\n help: 'Delta of score between cached values that expired',\n buckets: [10, 100, 1000]\n }),\n /** Current count of peers by score threshold */\n peersByScoreThreshold: register.gauge({\n name: 'gossipsub_peers_by_score_threshold_count',\n help: 'Current count of peers by score threshold',\n labelNames: ['threshold']\n }),\n score: register.avgMinMax({\n name: 'gossipsub_score',\n help: 'Avg min max of gossip scores'\n }),\n /**\n * Separate score weights\n * Need to use 2-label metrics in this case to debug the score weights\n **/\n scoreWeights: register.avgMinMax({\n name: 'gossipsub_score_weights',\n help: 'Separate score weights',\n labelNames: ['topic', 'p']\n }),\n /** Histogram of the scores for each mesh topic. */\n // TODO: Not implemented\n scorePerMesh: register.avgMinMax({\n name: 'gossipsub_score_per_mesh',\n help: 'Histogram of the scores for each mesh topic',\n labelNames: ['topic']\n }),\n /** A counter of the kind of penalties being applied to peers. */\n // TODO: Not fully implemented\n scoringPenalties: register.gauge({\n name: 'gossipsub_scoring_penalties_total',\n help: 'A counter of the kind of penalties being applied to peers',\n labelNames: ['penalty']\n }),\n behaviourPenalty: register.histogram({\n name: 'gossipsub_peer_stat_behaviour_penalty',\n help: 'Current peer stat behaviour_penalty at each scrape',\n buckets: [\n 0.25 * opts.behaviourPenaltyThreshold,\n 0.5 * opts.behaviourPenaltyThreshold,\n Number(opts.behaviourPenaltyThreshold),\n 2 * opts.behaviourPenaltyThreshold,\n 4 * opts.behaviourPenaltyThreshold\n ]\n }),\n // TODO:\n // - iasked per peer (on heartbeat)\n // - when promise is resolved, track messages from promises\n /** Total received IHAVE messages that we ignore for some reason */\n ihaveRcvIgnored: register.gauge({\n name: 'gossipsub_ihave_rcv_ignored_total',\n help: 'Total received IHAVE messages that we ignore for some reason',\n labelNames: ['reason']\n }),\n /** Total received IHAVE messages by topic */\n ihaveRcvMsgids: register.gauge({\n name: 'gossipsub_ihave_rcv_msgids_total',\n help: 'Total received IHAVE messages by topic',\n labelNames: ['topic']\n }),\n /**\n * Total messages per topic we don't have. Not actual requests.\n * The number of times we have decided that an IWANT control message is required for this\n * topic. A very high metric might indicate an underperforming network.\n * = rust-libp2p `topic_iwant_msgs` */\n ihaveRcvNotSeenMsgids: register.gauge({\n name: 'gossipsub_ihave_rcv_not_seen_msgids_total',\n help: 'Total messages per topic we do not have, not actual requests',\n labelNames: ['topic']\n }),\n /** Total received IWANT messages by topic */\n iwantRcvMsgids: register.gauge({\n name: 'gossipsub_iwant_rcv_msgids_total',\n help: 'Total received IWANT messages by topic',\n labelNames: ['topic']\n }),\n /** Total requested messageIDs that we don't have */\n iwantRcvDonthaveMsgids: register.gauge({\n name: 'gossipsub_iwant_rcv_dont_have_msgids_total',\n help: 'Total requested messageIDs that we do not have'\n }),\n iwantPromiseStarted: register.gauge({\n name: 'gossipsub_iwant_promise_sent_total',\n help: 'Total count of started IWANT promises'\n }),\n /** Total count of resolved IWANT promises */\n iwantPromiseResolved: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_total',\n help: 'Total count of resolved IWANT promises'\n }),\n /** Total count of resolved IWANT promises from duplicate messages */\n iwantPromiseResolvedFromDuplicate: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_from_duplicate_total',\n help: 'Total count of resolved IWANT promises from duplicate messages'\n }),\n /** Total count of peers we have asked IWANT promises that are resolved */\n iwantPromiseResolvedPeers: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_peers',\n help: 'Total count of peers we have asked IWANT promises that are resolved'\n }),\n iwantPromiseBroken: register.gauge({\n name: 'gossipsub_iwant_promise_broken',\n help: 'Total count of broken IWANT promises'\n }),\n iwantMessagePruned: register.gauge({\n name: 'gossipsub_iwant_message_pruned',\n help: 'Total count of pruned IWANT messages'\n }),\n /** Histogram of delivery time of resolved IWANT promises */\n iwantPromiseDeliveryTime: register.histogram({\n name: 'gossipsub_iwant_promise_delivery_seconds',\n help: 'Histogram of delivery time of resolved IWANT promises',\n buckets: [\n 0.5 * opts.gossipPromiseExpireSec,\n Number(opts.gossipPromiseExpireSec),\n 2 * opts.gossipPromiseExpireSec,\n 4 * opts.gossipPromiseExpireSec\n ]\n }),\n iwantPromiseUntracked: register.gauge({\n name: 'gossip_iwant_promise_untracked',\n help: 'Total count of untracked IWANT promise'\n }),\n /** Backoff time */\n connectedPeersBackoffSec: register.histogram({\n name: 'gossipsub_connected_peers_backoff_seconds',\n help: 'Backoff time in seconds',\n // Using 1 seconds as minimum as that's close to the heartbeat duration, no need for more resolution.\n // As per spec, backoff times are 10 seconds for UnsubscribeBackoff and 60 seconds for PruneBackoff.\n // Higher values of 60 seconds should not occur, but we add 120 seconds just in case\n // https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#overview-of-new-parameters\n buckets: [1, 2, 4, 10, 20, 60, 120]\n }),\n /* Data structure sizes */\n /** Unbounded cache sizes */\n cacheSize: register.gauge({\n name: 'gossipsub_cache_size',\n help: 'Unbounded cache sizes',\n labelNames: ['cache']\n }),\n /** Current mcache msg count */\n mcacheSize: register.gauge({\n name: 'gossipsub_mcache_size',\n help: 'Current mcache msg count'\n }),\n mcacheNotValidatedCount: register.gauge({\n name: 'gossipsub_mcache_not_validated_count',\n help: 'Current mcache msg count not validated'\n }),\n fastMsgIdCacheCollision: register.gauge({\n name: 'gossipsub_fastmsgid_cache_collision_total',\n help: 'Total count of key collisions on fastmsgid cache put'\n }),\n newConnectionCount: register.gauge({\n name: 'gossipsub_new_connection_total',\n help: 'Total new connection by status',\n labelNames: ['status']\n }),\n topicStrToLabel,\n toTopic(topicStr) {\n return this.topicStrToLabel.get(topicStr) ?? topicStr;\n },\n /** We joined a topic */\n onJoin(topicStr) {\n this.topicSubscriptionStatus.set({ topicStr }, 1);\n this.meshPeerCounts.set({ topicStr }, 0); // Reset count\n },\n /** We left a topic */\n onLeave(topicStr) {\n this.topicSubscriptionStatus.set({ topicStr }, 0);\n this.meshPeerCounts.set({ topicStr }, 0); // Reset count\n },\n /** Register the inclusion of peers in our mesh due to some reason. */\n onAddToMesh(topicStr, reason, count) {\n const topic = this.toTopic(topicStr);\n switch (reason) {\n case InclusionReason.Fanout:\n this.meshPeerInclusionEventsFanout.inc({ topic }, count);\n break;\n case InclusionReason.Random:\n this.meshPeerInclusionEventsRandom.inc({ topic }, count);\n break;\n case InclusionReason.Subscribed:\n this.meshPeerInclusionEventsSubscribed.inc({ topic }, count);\n break;\n case InclusionReason.Outbound:\n this.meshPeerInclusionEventsOutbound.inc({ topic }, count);\n break;\n case InclusionReason.NotEnough:\n this.meshPeerInclusionEventsNotEnough.inc({ topic }, count);\n break;\n case InclusionReason.Opportunistic:\n this.meshPeerInclusionEventsOpportunistic.inc({ topic }, count);\n break;\n default:\n this.meshPeerInclusionEventsUnknown.inc({ topic }, count);\n break;\n }\n },\n /** Register the removal of peers in our mesh due to some reason */\n // - remove_peer_from_mesh()\n // - heartbeat() Churn::BadScore\n // - heartbeat() Churn::Excess\n // - on_disconnect() Churn::Ds\n onRemoveFromMesh(topicStr, reason, count) {\n const topic = this.toTopic(topicStr);\n switch (reason) {\n case ChurnReason.Dc:\n this.meshPeerChurnEventsDisconnected.inc({ topic }, count);\n break;\n case ChurnReason.BadScore:\n this.meshPeerChurnEventsBadScore.inc({ topic }, count);\n break;\n case ChurnReason.Prune:\n this.meshPeerChurnEventsPrune.inc({ topic }, count);\n break;\n case ChurnReason.Excess:\n this.meshPeerChurnEventsExcess.inc({ topic }, count);\n break;\n default:\n this.meshPeerChurnEventsUnknown.inc({ topic }, count);\n break;\n }\n },\n /**\n * Update validation result to metrics\n *\n * @param messageRecord - null means the message's mcache record was not known at the time of acceptance report\n */\n onReportValidation(messageRecord, acceptance, firstSeenTimestampMs) {\n this.asyncValidationMcacheHit.inc({ hit: messageRecord != null ? 'hit' : 'miss' });\n if (messageRecord != null) {\n const topic = this.toTopic(messageRecord.message.topic);\n switch (acceptance) {\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Accept:\n this.acceptedMessagesTotal.inc({ topic });\n break;\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Ignore:\n this.ignoredMessagesTotal.inc({ topic });\n break;\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Reject:\n this.rejectedMessagesTotal.inc({ topic });\n break;\n default:\n this.unknownValidationResultsTotal.inc({ topic });\n break;\n }\n }\n if (firstSeenTimestampMs != null) {\n this.asyncValidationDelayFromFirstSeenSec.observe((Date.now() - firstSeenTimestampMs) / 1000);\n }\n else {\n this.asyncValidationUnknownFirstSeen.inc();\n }\n },\n /**\n * - in handle_graft() Penalty::GraftBackoff\n * - in apply_iwant_penalties() Penalty::BrokenPromise\n * - in metric_score() P3 Penalty::MessageDeficit\n * - in metric_score() P6 Penalty::IPColocation\n */\n onScorePenalty(penalty) {\n // Can this be labeled by topic too?\n this.scoringPenalties.inc({ penalty }, 1);\n },\n onIhaveRcv(topicStr, ihave, idonthave) {\n const topic = this.toTopic(topicStr);\n this.ihaveRcvMsgids.inc({ topic }, ihave);\n this.ihaveRcvNotSeenMsgids.inc({ topic }, idonthave);\n },\n onIwantRcv(iwantByTopic, iwantDonthave) {\n for (const [topicStr, iwant] of iwantByTopic) {\n const topic = this.toTopic(topicStr);\n this.iwantRcvMsgids.inc({ topic }, iwant);\n }\n this.iwantRcvDonthaveMsgids.inc(iwantDonthave);\n },\n onForwardMsg(topicStr, tosendCount) {\n const topic = this.toTopic(topicStr);\n this.msgForwardCount.inc({ topic }, 1);\n this.msgForwardPeers.inc({ topic }, tosendCount);\n },\n onPublishMsg(topicStr, tosendGroupCount, tosendCount, dataLen, ms) {\n const topic = this.toTopic(topicStr);\n this.msgPublishCount.inc({ topic }, 1);\n this.msgPublishBytes.inc({ topic }, tosendCount * dataLen);\n this.msgPublishPeersByTopic.inc({ topic }, tosendCount);\n this.directPeersPublishedTotal.inc({ topic }, tosendGroupCount.direct);\n this.floodsubPeersPublishedTotal.inc({ topic }, tosendGroupCount.floodsub);\n this.meshPeersPublishedTotal.inc({ topic }, tosendGroupCount.mesh);\n this.fanoutPeersPublishedTotal.inc({ topic }, tosendGroupCount.fanout);\n this.msgPublishTime.observe({ topic }, ms / 1000);\n },\n onMsgRecvPreValidation(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedPreValidation.inc({ topic }, 1);\n },\n onMsgRecvError(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedError.inc({ topic }, 1);\n },\n onPrevalidationResult(topicStr, status) {\n const topic = this.toTopic(topicStr);\n switch (status) {\n case _types_js__WEBPACK_IMPORTED_MODULE_1__.MessageStatus.duplicate:\n this.prevalidationDuplicateTotal.inc({ topic });\n break;\n case _types_js__WEBPACK_IMPORTED_MODULE_1__.MessageStatus.invalid:\n this.prevalidationInvalidTotal.inc({ topic });\n break;\n case _types_js__WEBPACK_IMPORTED_MODULE_1__.MessageStatus.valid:\n this.prevalidationValidTotal.inc({ topic });\n break;\n default:\n this.prevalidationUnknownTotal.inc({ topic });\n break;\n }\n },\n onMsgRecvInvalid(topicStr, reason) {\n const topic = this.toTopic(topicStr);\n const error = reason.reason === _types_js__WEBPACK_IMPORTED_MODULE_1__.RejectReason.Error ? reason.error : reason.reason;\n this.msgReceivedInvalid.inc({ error }, 1);\n this.msgReceivedInvalidByTopic.inc({ topic }, 1);\n },\n onDuplicateMsgDelivery(topicStr, deliveryDelayMs, isLateDelivery) {\n const topic = this.toTopic(topicStr);\n this.duplicateMsgDeliveryDelay.observe({ topic }, deliveryDelayMs / 1000);\n if (isLateDelivery) {\n this.duplicateMsgLateDelivery.inc({ topic }, 1);\n }\n },\n onPublishDuplicateMsg(topicStr) {\n const topic = this.toTopic(topicStr);\n this.duplicateMsgIgnored.inc({ topic }, 1);\n },\n onPeerReadStreamError() {\n this.peerReadStreamError.inc(1);\n },\n onRpcRecvError() {\n this.rpcRecvError.inc(1);\n },\n onRpcDataError() {\n this.rpcDataError.inc(1);\n },\n onRpcRecv(rpc, rpcBytes) {\n this.rpcRecvBytes.inc(rpcBytes);\n this.rpcRecvCount.inc(1);\n if (rpc.subscriptions != null)\n this.rpcRecvSubscription.inc(rpc.subscriptions.length);\n if (rpc.messages != null)\n this.rpcRecvMessage.inc(rpc.messages.length);\n if (rpc.control != null) {\n this.rpcRecvControl.inc(1);\n if (rpc.control.ihave != null)\n this.rpcRecvIHave.inc(rpc.control.ihave.length);\n if (rpc.control.iwant != null)\n this.rpcRecvIWant.inc(rpc.control.iwant.length);\n if (rpc.control.graft != null)\n this.rpcRecvGraft.inc(rpc.control.graft.length);\n if (rpc.control.prune != null)\n this.rpcRecvPrune.inc(rpc.control.prune.length);\n }\n },\n onRpcSent(rpc, rpcBytes) {\n this.rpcSentBytes.inc(rpcBytes);\n this.rpcSentCount.inc(1);\n if (rpc.subscriptions != null)\n this.rpcSentSubscription.inc(rpc.subscriptions.length);\n if (rpc.messages != null)\n this.rpcSentMessage.inc(rpc.messages.length);\n if (rpc.control != null) {\n const ihave = rpc.control.ihave?.length ?? 0;\n const iwant = rpc.control.iwant?.length ?? 0;\n const graft = rpc.control.graft?.length ?? 0;\n const prune = rpc.control.prune?.length ?? 0;\n if (ihave > 0)\n this.rpcSentIHave.inc(ihave);\n if (iwant > 0)\n this.rpcSentIWant.inc(iwant);\n if (graft > 0)\n this.rpcSentGraft.inc(graft);\n if (prune > 0)\n this.rpcSentPrune.inc(prune);\n if (ihave > 0 || iwant > 0 || graft > 0 || prune > 0)\n this.rpcSentControl.inc(1);\n }\n },\n registerScores(scores, scoreThresholds) {\n let graylist = 0;\n let publish = 0;\n let gossip = 0;\n let mesh = 0;\n for (const score of scores) {\n if (score >= scoreThresholds.graylistThreshold)\n graylist++;\n if (score >= scoreThresholds.publishThreshold)\n publish++;\n if (score >= scoreThresholds.gossipThreshold)\n gossip++;\n if (score >= 0)\n mesh++;\n }\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.graylist }, graylist);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.publish }, publish);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.gossip }, gossip);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.mesh }, mesh);\n // Register full score too\n this.score.set(scores);\n },\n registerScoreWeights(sw) {\n for (const [topic, wsTopic] of sw.byTopic) {\n this.scoreWeights.set({ topic, p: 'p1' }, wsTopic.p1w);\n this.scoreWeights.set({ topic, p: 'p2' }, wsTopic.p2w);\n this.scoreWeights.set({ topic, p: 'p3' }, wsTopic.p3w);\n this.scoreWeights.set({ topic, p: 'p3b' }, wsTopic.p3bw);\n this.scoreWeights.set({ topic, p: 'p4' }, wsTopic.p4w);\n }\n this.scoreWeights.set({ p: 'p5' }, sw.p5w);\n this.scoreWeights.set({ p: 'p6' }, sw.p6w);\n this.scoreWeights.set({ p: 'p7' }, sw.p7w);\n },\n registerScorePerMesh(mesh, scoreByPeer) {\n const peersPerTopicLabel = new Map();\n mesh.forEach((peers, topicStr) => {\n // Aggregate by known topicLabel or throw to 'unknown'. This prevent too high cardinality\n const topicLabel = this.topicStrToLabel.get(topicStr) ?? 'unknown';\n let peersInMesh = peersPerTopicLabel.get(topicLabel);\n if (peersInMesh == null) {\n peersInMesh = new Set();\n peersPerTopicLabel.set(topicLabel, peersInMesh);\n }\n peers.forEach((p) => peersInMesh?.add(p));\n });\n for (const [topic, peers] of peersPerTopicLabel) {\n const meshScores = [];\n peers.forEach((peer) => {\n meshScores.push(scoreByPeer.get(peer) ?? 0);\n });\n this.scorePerMesh.set({ topic }, meshScores);\n }\n }\n };\n}\n//# sourceMappingURL=metrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ computeScore: () => (/* binding */ computeScore)\n/* harmony export */ });\nfunction computeScore(peer, pstats, params, peerIPs) {\n let score = 0;\n // topic stores\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n // the topic parameters\n const topicParams = params.topics[topic];\n if (topicParams === undefined) {\n // we are not scoring this topic\n return;\n }\n let topicScore = 0;\n // P1: time in Mesh\n if (tstats.inMesh) {\n let p1 = tstats.meshTime / topicParams.timeInMeshQuantum;\n if (p1 > topicParams.timeInMeshCap) {\n p1 = topicParams.timeInMeshCap;\n }\n topicScore += p1 * topicParams.timeInMeshWeight;\n }\n // P2: first message deliveries\n let p2 = tstats.firstMessageDeliveries;\n if (p2 > topicParams.firstMessageDeliveriesCap) {\n p2 = topicParams.firstMessageDeliveriesCap;\n }\n topicScore += p2 * topicParams.firstMessageDeliveriesWeight;\n // P3: mesh message deliveries\n if (tstats.meshMessageDeliveriesActive &&\n tstats.meshMessageDeliveries < topicParams.meshMessageDeliveriesThreshold) {\n const deficit = topicParams.meshMessageDeliveriesThreshold - tstats.meshMessageDeliveries;\n const p3 = deficit * deficit;\n topicScore += p3 * topicParams.meshMessageDeliveriesWeight;\n }\n // P3b:\n // NOTE: the weight of P3b is negative (validated in validateTopicScoreParams) so this detracts\n const p3b = tstats.meshFailurePenalty;\n topicScore += p3b * topicParams.meshFailurePenaltyWeight;\n // P4: invalid messages\n // NOTE: the weight of P4 is negative (validated in validateTopicScoreParams) so this detracts\n const p4 = tstats.invalidMessageDeliveries * tstats.invalidMessageDeliveries;\n topicScore += p4 * topicParams.invalidMessageDeliveriesWeight;\n // update score, mixing with topic weight\n score += topicScore * topicParams.topicWeight;\n });\n // apply the topic score cap, if any\n if (params.topicScoreCap > 0 && score > params.topicScoreCap) {\n score = params.topicScoreCap;\n }\n // P5: application-specific score\n const p5 = params.appSpecificScore(peer);\n score += p5 * params.appSpecificWeight;\n // P6: IP colocation factor\n pstats.knownIPs.forEach((ip) => {\n if (params.IPColocationFactorWhitelist.has(ip)) {\n return;\n }\n // P6 has a cliff (IPColocationFactorThreshold)\n // It's only applied if at least that many peers are connected to us from that source IP addr.\n // It is quadratic, and the weight is negative (validated in validatePeerScoreParams)\n const peersInIP = peerIPs.get(ip);\n const numPeersInIP = (peersInIP != null) ? peersInIP.size : 0;\n if (numPeersInIP > params.IPColocationFactorThreshold) {\n const surplus = numPeersInIP - params.IPColocationFactorThreshold;\n const p6 = surplus * surplus;\n score += p6 * params.IPColocationFactorWeight;\n }\n });\n // P7: behavioural pattern penalty\n if (pstats.behaviourPenalty > params.behaviourPenaltyThreshold) {\n const excess = pstats.behaviourPenalty - params.behaviourPenaltyThreshold;\n const p7 = excess * excess;\n score += p7 * params.behaviourPenaltyWeight;\n }\n return score;\n}\n//# sourceMappingURL=compute-score.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ERR_INVALID_PEER_SCORE_PARAMS: () => (/* binding */ ERR_INVALID_PEER_SCORE_PARAMS),\n/* harmony export */ ERR_INVALID_PEER_SCORE_THRESHOLDS: () => (/* binding */ ERR_INVALID_PEER_SCORE_THRESHOLDS)\n/* harmony export */ });\nconst ERR_INVALID_PEER_SCORE_PARAMS = 'ERR_INVALID_PEER_SCORE_PARAMS';\nconst ERR_INVALID_PEER_SCORE_THRESHOLDS = 'ERR_INVALID_PEER_SCORE_THRESHOLDS';\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DeliveryRecordStatus: () => (/* binding */ DeliveryRecordStatus),\n/* harmony export */ MessageDeliveries: () => (/* binding */ MessageDeliveries)\n/* harmony export */ });\n/* harmony import */ var denque__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! denque */ \"./node_modules/denque/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n\n\nvar DeliveryRecordStatus;\n(function (DeliveryRecordStatus) {\n /**\n * we don't know (yet) if the message is valid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"unknown\"] = 0] = \"unknown\";\n /**\n * we know the message is valid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"valid\"] = 1] = \"valid\";\n /**\n * we know the message is invalid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"invalid\"] = 2] = \"invalid\";\n /**\n * we were instructed by the validator to ignore the message\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"ignored\"] = 3] = \"ignored\";\n})(DeliveryRecordStatus || (DeliveryRecordStatus = {}));\n/**\n * Map of canonical message ID to DeliveryRecord\n *\n * Maintains an internal queue for efficient gc of old messages\n */\nclass MessageDeliveries {\n records;\n queue;\n constructor() {\n this.records = new Map();\n this.queue = new denque__WEBPACK_IMPORTED_MODULE_0__();\n }\n getRecord(msgIdStr) {\n return this.records.get(msgIdStr);\n }\n ensureRecord(msgIdStr) {\n let drec = this.records.get(msgIdStr);\n if (drec != null) {\n return drec;\n }\n // record doesn't exist yet\n // create record\n drec = {\n status: DeliveryRecordStatus.unknown,\n firstSeenTsMs: Date.now(),\n validated: 0,\n peers: new Set()\n };\n this.records.set(msgIdStr, drec);\n // and add msgId to the queue\n const entry = {\n msgId: msgIdStr,\n expire: Date.now() + _constants_js__WEBPACK_IMPORTED_MODULE_1__.TimeCacheDuration\n };\n this.queue.push(entry);\n return drec;\n }\n gc() {\n const now = Date.now();\n // queue is sorted by expiry time\n // remove expired messages, remove from queue until first un-expired message found\n let head = this.queue.peekFront();\n while ((head != null) && head.expire < now) {\n this.records.delete(head.msgId);\n this.queue.shift();\n head = this.queue.peekFront();\n }\n }\n clear() {\n this.records.clear();\n this.queue.clear();\n }\n}\n//# sourceMappingURL=message-deliveries.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerScoreParams: () => (/* binding */ createPeerScoreParams),\n/* harmony export */ createTopicScoreParams: () => (/* binding */ createTopicScoreParams),\n/* harmony export */ defaultPeerScoreParams: () => (/* binding */ defaultPeerScoreParams),\n/* harmony export */ defaultTopicScoreParams: () => (/* binding */ defaultTopicScoreParams),\n/* harmony export */ validatePeerScoreParams: () => (/* binding */ validatePeerScoreParams),\n/* harmony export */ validateTopicScoreParams: () => (/* binding */ validateTopicScoreParams)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js\");\n\n\nconst defaultPeerScoreParams = {\n topics: {},\n topicScoreCap: 10.0,\n appSpecificScore: () => 0.0,\n appSpecificWeight: 10.0,\n IPColocationFactorWeight: -5.0,\n IPColocationFactorThreshold: 10.0,\n IPColocationFactorWhitelist: new Set(),\n behaviourPenaltyWeight: -10.0,\n behaviourPenaltyThreshold: 0.0,\n behaviourPenaltyDecay: 0.2,\n decayInterval: 1000.0,\n decayToZero: 0.1,\n retainScore: 3600 * 1000\n};\nconst defaultTopicScoreParams = {\n topicWeight: 0.5,\n timeInMeshWeight: 1,\n timeInMeshQuantum: 1,\n timeInMeshCap: 3600,\n firstMessageDeliveriesWeight: 1,\n firstMessageDeliveriesDecay: 0.5,\n firstMessageDeliveriesCap: 2000,\n meshMessageDeliveriesWeight: -1,\n meshMessageDeliveriesDecay: 0.5,\n meshMessageDeliveriesCap: 100,\n meshMessageDeliveriesThreshold: 20,\n meshMessageDeliveriesWindow: 10,\n meshMessageDeliveriesActivation: 5000,\n meshFailurePenaltyWeight: -1,\n meshFailurePenaltyDecay: 0.5,\n invalidMessageDeliveriesWeight: -1,\n invalidMessageDeliveriesDecay: 0.3\n};\nfunction createPeerScoreParams(p = {}) {\n return {\n ...defaultPeerScoreParams,\n ...p,\n topics: (p.topics != null)\n ? Object.entries(p.topics).reduce((topics, [topic, topicScoreParams]) => {\n topics[topic] = createTopicScoreParams(topicScoreParams);\n return topics;\n }, {})\n : {}\n };\n}\nfunction createTopicScoreParams(p = {}) {\n return {\n ...defaultTopicScoreParams,\n ...p\n };\n}\n// peer score parameter validation\nfunction validatePeerScoreParams(p) {\n for (const [topic, params] of Object.entries(p.topics)) {\n try {\n validateTopicScoreParams(params);\n }\n catch (e) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError(`invalid score parameters for topic ${topic}: ${e.message}`, _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n }\n // check that the topic score is 0 or something positive\n if (p.topicScoreCap < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid topic score cap; must be positive (or 0 for no cap)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check that we have an app specific score; the weight can be anything (but expected positive)\n if (p.appSpecificScore === null || p.appSpecificScore === undefined) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('missing application specific score function', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the IP colocation factor\n if (p.IPColocationFactorWeight > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid IPColocationFactorWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.IPColocationFactorWeight !== 0 && p.IPColocationFactorThreshold < 1) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid IPColocationFactorThreshold; must be at least 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the behaviour penalty\n if (p.behaviourPenaltyWeight > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.behaviourPenaltyWeight !== 0 && (p.behaviourPenaltyDecay <= 0 || p.behaviourPenaltyDecay >= 1)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid BehaviourPenaltyDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the decay parameters\n if (p.decayInterval < 1000) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid DecayInterval; must be at least 1s', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.decayToZero <= 0 || p.decayToZero >= 1) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid DecayToZero; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // no need to check the score retention; a value of 0 means that we don't retain scores\n}\n// eslint-disable-next-line complexity\nfunction validateTopicScoreParams(p) {\n // make sure we have a sane topic weight\n if (p.topicWeight < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid topic weight; must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P1\n if (p.timeInMeshQuantum === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid TimeInMeshQuantum; must be non zero', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid TimeInMeshWeight; must be positive (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight !== 0 && p.timeInMeshQuantum <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid TimeInMeshQuantum; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight !== 0 && p.timeInMeshCap <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid TimeInMeshCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P2\n if (p.firstMessageDeliveriesWeight < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.firstMessageDeliveriesWeight !== 0 &&\n (p.firstMessageDeliveriesDecay <= 0 || p.firstMessageDeliveriesDecay >= 1)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid FirstMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.firstMessageDeliveriesWeight !== 0 && p.firstMessageDeliveriesCap <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid FirstMessageDeliveriesCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P3\n if (p.meshMessageDeliveriesWeight > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && (p.meshMessageDeliveriesDecay <= 0 || p.meshMessageDeliveriesDecay >= 1)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesCap <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesThreshold <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesThreshold; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWindow < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesWindow; must be non-negative', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesActivation < 1000) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshMessageDeliveriesActivation; must be at least 1s', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P3b\n if (p.meshFailurePenaltyWeight > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshFailurePenaltyWeight !== 0 && (p.meshFailurePenaltyDecay <= 0 || p.meshFailurePenaltyDecay >= 1)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid MeshFailurePenaltyDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P4\n if (p.invalidMessageDeliveriesWeight > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.invalidMessageDeliveriesDecay <= 0 || p.invalidMessageDeliveriesDecay >= 1) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid InvalidMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n}\n//# sourceMappingURL=peer-score-params.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerScoreThresholds: () => (/* binding */ createPeerScoreThresholds),\n/* harmony export */ defaultPeerScoreThresholds: () => (/* binding */ defaultPeerScoreThresholds),\n/* harmony export */ validatePeerScoreThresholds: () => (/* binding */ validatePeerScoreThresholds)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js\");\n\n\nconst defaultPeerScoreThresholds = {\n gossipThreshold: -10,\n publishThreshold: -50,\n graylistThreshold: -80,\n acceptPXThreshold: 10,\n opportunisticGraftThreshold: 20\n};\nfunction createPeerScoreThresholds(p = {}) {\n return {\n ...defaultPeerScoreThresholds,\n ...p\n };\n}\nfunction validatePeerScoreThresholds(p) {\n if (p.gossipThreshold > 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid gossip threshold; it must be <= 0', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.publishThreshold > 0 || p.publishThreshold > p.gossipThreshold) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid publish threshold; it must be <= 0 and <= gossip threshold', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.graylistThreshold > 0 || p.graylistThreshold > p.publishThreshold) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid graylist threshold; it must be <= 0 and <= publish threshold', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.acceptPXThreshold < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid accept PX threshold; it must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.opportunisticGraftThreshold < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('invalid opportunistic grafting threshold; it must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n}\n//# sourceMappingURL=peer-score-thresholds.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerScore: () => (/* binding */ PeerScore)\n/* harmony export */ });\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/set.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var _compute_score_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./compute-score.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js\");\n/* harmony import */ var _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./message-deliveries.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js\");\n/* harmony import */ var _peer_score_params_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./peer-score-params.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js\");\n\n\n\n\n\nclass PeerScore {\n params;\n metrics;\n /**\n * Per-peer stats for score calculation\n */\n peerStats = new Map();\n /**\n * IP colocation tracking; maps IP => set of peers.\n */\n peerIPs = new _utils_set_js__WEBPACK_IMPORTED_MODULE_0__.MapDef(() => new Set());\n /**\n * Cache score up to decayInterval if topic stats are unchanged.\n */\n scoreCache = new Map();\n /**\n * Recent message delivery timing/participants\n */\n deliveryRecords = new _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.MessageDeliveries();\n _backgroundInterval;\n scoreCacheValidityMs;\n computeScore;\n log;\n constructor(params, metrics, componentLogger, opts) {\n this.params = params;\n this.metrics = metrics;\n (0,_peer_score_params_js__WEBPACK_IMPORTED_MODULE_2__.validatePeerScoreParams)(params);\n this.scoreCacheValidityMs = opts.scoreCacheValidityMs;\n this.computeScore = opts.computeScore ?? _compute_score_js__WEBPACK_IMPORTED_MODULE_3__.computeScore;\n this.log = componentLogger.forComponent('libp2p:gossipsub:score');\n }\n get size() {\n return this.peerStats.size;\n }\n /**\n * Start PeerScore instance\n */\n start() {\n if (this._backgroundInterval != null) {\n this.log('Peer score already running');\n return;\n }\n this._backgroundInterval = setInterval(() => { this.background(); }, this.params.decayInterval);\n this.log('started');\n }\n /**\n * Stop PeerScore instance\n */\n stop() {\n if (this._backgroundInterval == null) {\n this.log('Peer score already stopped');\n return;\n }\n clearInterval(this._backgroundInterval);\n delete this._backgroundInterval;\n this.peerIPs.clear();\n this.peerStats.clear();\n this.deliveryRecords.clear();\n this.log('stopped');\n }\n /**\n * Periodic maintenance\n */\n background() {\n this.refreshScores();\n this.deliveryRecords.gc();\n }\n dumpPeerScoreStats() {\n return Object.fromEntries(Array.from(this.peerStats.entries()).map(([peer, stats]) => [peer, stats]));\n }\n messageFirstSeenTimestampMs(msgIdStr) {\n const drec = this.deliveryRecords.getRecord(msgIdStr);\n return (drec != null) ? drec.firstSeenTsMs : null;\n }\n /**\n * Decays scores, and purges score records for disconnected peers once their expiry has elapsed.\n */\n refreshScores() {\n const now = Date.now();\n const decayToZero = this.params.decayToZero;\n this.peerStats.forEach((pstats, id) => {\n if (!pstats.connected) {\n // has the retention period expired?\n if (now > pstats.expire) {\n // yes, throw it away (but clean up the IP tracking first)\n this.removeIPsForPeer(id, pstats.knownIPs);\n this.peerStats.delete(id);\n this.scoreCache.delete(id);\n }\n // we don't decay retained scores, as the peer is not active.\n // this way the peer cannot reset a negative score by simply disconnecting and reconnecting,\n // unless the retention period has elapsed.\n // similarly, a well behaved peer does not lose its score by getting disconnected.\n return;\n }\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n const tparams = this.params.topics[topic];\n if (tparams === undefined) {\n // we are not scoring this topic\n // should be unreachable, we only add scored topics to pstats\n return;\n }\n // decay counters\n tstats.firstMessageDeliveries *= tparams.firstMessageDeliveriesDecay;\n if (tstats.firstMessageDeliveries < decayToZero) {\n tstats.firstMessageDeliveries = 0;\n }\n tstats.meshMessageDeliveries *= tparams.meshMessageDeliveriesDecay;\n if (tstats.meshMessageDeliveries < decayToZero) {\n tstats.meshMessageDeliveries = 0;\n }\n tstats.meshFailurePenalty *= tparams.meshFailurePenaltyDecay;\n if (tstats.meshFailurePenalty < decayToZero) {\n tstats.meshFailurePenalty = 0;\n }\n tstats.invalidMessageDeliveries *= tparams.invalidMessageDeliveriesDecay;\n if (tstats.invalidMessageDeliveries < decayToZero) {\n tstats.invalidMessageDeliveries = 0;\n }\n // update mesh time and activate mesh message delivery parameter if need be\n if (tstats.inMesh) {\n tstats.meshTime = now - tstats.graftTime;\n if (tstats.meshTime > tparams.meshMessageDeliveriesActivation) {\n tstats.meshMessageDeliveriesActive = true;\n }\n }\n });\n // decay P7 counter\n pstats.behaviourPenalty *= this.params.behaviourPenaltyDecay;\n if (pstats.behaviourPenalty < decayToZero) {\n pstats.behaviourPenalty = 0;\n }\n });\n }\n /**\n * Return the score for a peer\n */\n score(id) {\n this.metrics?.scoreFnCalls.inc();\n const pstats = this.peerStats.get(id);\n if (pstats == null) {\n return 0;\n }\n const now = Date.now();\n const cacheEntry = this.scoreCache.get(id);\n // Found cached score within validity period\n if ((cacheEntry != null) && cacheEntry.cacheUntil > now) {\n return cacheEntry.score;\n }\n this.metrics?.scoreFnRuns.inc();\n const score = this.computeScore(id, pstats, this.params, this.peerIPs);\n const cacheUntil = now + this.scoreCacheValidityMs;\n if (cacheEntry != null) {\n this.metrics?.scoreCachedDelta.observe(Math.abs(score - cacheEntry.score));\n cacheEntry.score = score;\n cacheEntry.cacheUntil = cacheUntil;\n }\n else {\n this.scoreCache.set(id, { score, cacheUntil });\n }\n return score;\n }\n /**\n * Apply a behavioural penalty to a peer\n */\n addPenalty(id, penalty, penaltyLabel) {\n const pstats = this.peerStats.get(id);\n if (pstats != null) {\n pstats.behaviourPenalty += penalty;\n this.metrics?.onScorePenalty(penaltyLabel);\n }\n }\n addPeer(id) {\n // create peer stats (not including topic stats for each topic to be scored)\n // topic stats will be added as needed\n const pstats = {\n connected: true,\n expire: 0,\n topics: {},\n knownIPs: new Set(),\n behaviourPenalty: 0\n };\n this.peerStats.set(id, pstats);\n }\n /** Adds a new IP to a peer, if the peer is not known the update is ignored */\n addIP(id, ip) {\n const pstats = this.peerStats.get(id);\n if (pstats != null) {\n pstats.knownIPs.add(ip);\n }\n this.peerIPs.getOrDefault(ip).add(id);\n }\n /** Remove peer association with IP */\n removeIP(id, ip) {\n const pstats = this.peerStats.get(id);\n if (pstats != null) {\n pstats.knownIPs.delete(ip);\n }\n const peersWithIP = this.peerIPs.get(ip);\n if (peersWithIP != null) {\n peersWithIP.delete(id);\n if (peersWithIP.size === 0) {\n this.peerIPs.delete(ip);\n }\n }\n }\n removePeer(id) {\n const pstats = this.peerStats.get(id);\n if (pstats == null) {\n return;\n }\n // decide whether to retain the score; this currently only retains non-positive scores\n // to dissuade attacks on the score function.\n if (this.score(id) > 0) {\n this.removeIPsForPeer(id, pstats.knownIPs);\n this.peerStats.delete(id);\n return;\n }\n // furthermore, when we decide to retain the score, the firstMessageDelivery counters are\n // reset to 0 and mesh delivery penalties applied.\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n tstats.firstMessageDeliveries = 0;\n const threshold = this.params.topics[topic].meshMessageDeliveriesThreshold;\n if (tstats.inMesh && tstats.meshMessageDeliveriesActive && tstats.meshMessageDeliveries < threshold) {\n const deficit = threshold - tstats.meshMessageDeliveries;\n tstats.meshFailurePenalty += deficit * deficit;\n }\n tstats.inMesh = false;\n tstats.meshMessageDeliveriesActive = false;\n });\n pstats.connected = false;\n pstats.expire = Date.now() + this.params.retainScore;\n }\n /** Handles scoring functionality as a peer GRAFTs to a topic. */\n graft(id, topic) {\n const pstats = this.peerStats.get(id);\n if (pstats != null) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats != null) {\n // if we are scoring the topic, update the mesh status.\n tstats.inMesh = true;\n tstats.graftTime = Date.now();\n tstats.meshTime = 0;\n tstats.meshMessageDeliveriesActive = false;\n }\n }\n }\n /** Handles scoring functionality as a peer PRUNEs from a topic. */\n prune(id, topic) {\n const pstats = this.peerStats.get(id);\n if (pstats != null) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats != null) {\n // sticky mesh delivery rate failure penalty\n const threshold = this.params.topics[topic].meshMessageDeliveriesThreshold;\n if (tstats.meshMessageDeliveriesActive && tstats.meshMessageDeliveries < threshold) {\n const deficit = threshold - tstats.meshMessageDeliveries;\n tstats.meshFailurePenalty += deficit * deficit;\n }\n tstats.meshMessageDeliveriesActive = false;\n tstats.inMesh = false;\n // TODO: Consider clearing score cache on important penalties\n // this.scoreCache.delete(id)\n }\n }\n }\n validateMessage(msgIdStr) {\n this.deliveryRecords.ensureRecord(msgIdStr);\n }\n deliverMessage(from, msgIdStr, topic) {\n this.markFirstMessageDelivery(from, topic);\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n const now = Date.now();\n // defensive check that this is the first delivery trace -- delivery status should be unknown\n if (drec.status !== _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.unknown) {\n this.log('unexpected delivery: message from %s was first seen %s ago and has delivery status %s', from, now - drec.firstSeenTsMs, _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus[drec.status]);\n return;\n }\n // mark the message as valid and reward mesh peers that have already forwarded it to us\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.valid;\n drec.validated = now;\n drec.peers.forEach((p) => {\n // this check is to make sure a peer can't send us a message twice and get a double count\n // if it is a first delivery.\n if (p !== from.toString()) {\n this.markDuplicateMessageDelivery(p, topic);\n }\n });\n }\n /**\n * Similar to `rejectMessage` except does not require the message id or reason for an invalid message.\n */\n rejectInvalidMessage(from, topic) {\n this.markInvalidMessageDelivery(from, topic);\n }\n rejectMessage(from, msgIdStr, topic, reason) {\n // eslint-disable-next-line default-case\n switch (reason) {\n // these messages are not tracked, but the peer is penalized as they are invalid\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Error:\n this.markInvalidMessageDelivery(from, topic);\n return;\n // we ignore those messages, so do nothing.\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Blacklisted:\n return;\n // the rest are handled after record creation\n }\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n // defensive check that this is the first rejection -- delivery status should be unknown\n if (drec.status !== _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.unknown) {\n this.log('unexpected rejection: message from %s was first seen %s ago and has delivery status %d', from, Date.now() - drec.firstSeenTsMs, _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus[drec.status]);\n return;\n }\n if (reason === _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Ignore) {\n // we were explicitly instructed by the validator to ignore the message but not penalize the peer\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.ignored;\n drec.peers.clear();\n return;\n }\n // mark the message as invalid and penalize peers that have already forwarded it.\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.invalid;\n this.markInvalidMessageDelivery(from, topic);\n drec.peers.forEach((p) => {\n this.markInvalidMessageDelivery(p, topic);\n });\n // release the delivery time tracking map to free some memory early\n drec.peers.clear();\n }\n duplicateMessage(from, msgIdStr, topic) {\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n if (drec.peers.has(from)) {\n // we have already seen this duplicate\n return;\n }\n // eslint-disable-next-line default-case\n switch (drec.status) {\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.unknown:\n // the message is being validated; track the peer delivery and wait for\n // the Deliver/Reject/Ignore notification.\n drec.peers.add(from);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.valid:\n // mark the peer delivery time to only count a duplicate delivery once.\n drec.peers.add(from);\n this.markDuplicateMessageDelivery(from, topic, drec.validated);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.invalid:\n // we no longer track delivery time\n this.markInvalidMessageDelivery(from, topic);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_1__.DeliveryRecordStatus.ignored:\n // the message was ignored; do nothing (we don't know if it was valid)\n break;\n }\n }\n /**\n * Increments the \"invalid message deliveries\" counter for all scored topics the message is published in.\n */\n markInvalidMessageDelivery(from, topic) {\n const pstats = this.peerStats.get(from);\n if (pstats != null) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats != null) {\n tstats.invalidMessageDeliveries += 1;\n }\n }\n }\n /**\n * Increments the \"first message deliveries\" counter for all scored topics the message is published in,\n * as well as the \"mesh message deliveries\" counter, if the peer is in the mesh for the topic.\n * Messages already known (with the seenCache) are counted with markDuplicateMessageDelivery()\n */\n markFirstMessageDelivery(from, topic) {\n const pstats = this.peerStats.get(from);\n if (pstats != null) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats != null) {\n let cap = this.params.topics[topic].firstMessageDeliveriesCap;\n tstats.firstMessageDeliveries = Math.min(cap, tstats.firstMessageDeliveries + 1);\n if (tstats.inMesh) {\n cap = this.params.topics[topic].meshMessageDeliveriesCap;\n tstats.meshMessageDeliveries = Math.min(cap, tstats.meshMessageDeliveries + 1);\n }\n }\n }\n }\n /**\n * Increments the \"mesh message deliveries\" counter for messages we've seen before,\n * as long the message was received within the P3 window.\n */\n markDuplicateMessageDelivery(from, topic, validatedTime) {\n const pstats = this.peerStats.get(from);\n if (pstats != null) {\n const now = validatedTime !== undefined ? Date.now() : 0;\n const tstats = this.getPtopicStats(pstats, topic);\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (tstats != null && tstats.inMesh) {\n const tparams = this.params.topics[topic];\n // check against the mesh delivery window -- if the validated time is passed as 0, then\n // the message was received before we finished validation and thus falls within the mesh\n // delivery window.\n if (validatedTime !== undefined) {\n const deliveryDelayMs = now - validatedTime;\n const isLateDelivery = deliveryDelayMs > tparams.meshMessageDeliveriesWindow;\n this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs, isLateDelivery);\n if (isLateDelivery) {\n return;\n }\n }\n const cap = tparams.meshMessageDeliveriesCap;\n tstats.meshMessageDeliveries = Math.min(cap, tstats.meshMessageDeliveries + 1);\n }\n }\n }\n /**\n * Removes an IP list from the tracking list for a peer.\n */\n removeIPsForPeer(id, ipsToRemove) {\n for (const ipToRemove of ipsToRemove) {\n const peerSet = this.peerIPs.get(ipToRemove);\n if (peerSet != null) {\n peerSet.delete(id);\n if (peerSet.size === 0) {\n this.peerIPs.delete(ipToRemove);\n }\n }\n }\n }\n /**\n * Returns topic stats if they exist, otherwise if the supplied parameters score the\n * topic, inserts the default stats and returns a reference to those. If neither apply, returns None.\n */\n getPtopicStats(pstats, topic) {\n let topicStats = pstats.topics[topic];\n if (topicStats !== undefined) {\n return topicStats;\n }\n if (this.params.topics[topic] !== undefined) {\n topicStats = {\n inMesh: false,\n graftTime: 0,\n meshTime: 0,\n firstMessageDeliveries: 0,\n meshMessageDeliveries: 0,\n meshMessageDeliveriesActive: false,\n meshFailurePenalty: 0,\n invalidMessageDeliveries: 0\n };\n pstats.topics[topic] = topicStats;\n return topicStats;\n }\n return null;\n }\n}\n//# sourceMappingURL=peer-score.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ computeAllPeersScoreWeights: () => (/* binding */ computeAllPeersScoreWeights),\n/* harmony export */ computeScoreWeights: () => (/* binding */ computeScoreWeights)\n/* harmony export */ });\nfunction computeScoreWeights(peer, pstats, params, peerIPs, topicStrToLabel) {\n let score = 0;\n const byTopic = new Map();\n // topic stores\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n // the topic parameters\n // Aggregate by known topicLabel or throw to 'unknown'. This prevent too high cardinality\n const topicLabel = topicStrToLabel.get(topic) ?? 'unknown';\n const topicParams = params.topics[topic];\n if (topicParams === undefined) {\n // we are not scoring this topic\n return;\n }\n let topicScores = byTopic.get(topicLabel);\n if (topicScores == null) {\n topicScores = {\n p1w: 0,\n p2w: 0,\n p3w: 0,\n p3bw: 0,\n p4w: 0\n };\n byTopic.set(topicLabel, topicScores);\n }\n let p1w = 0;\n let p2w = 0;\n let p3w = 0;\n let p3bw = 0;\n let p4w = 0;\n // P1: time in Mesh\n if (tstats.inMesh) {\n const p1 = Math.max(tstats.meshTime / topicParams.timeInMeshQuantum, topicParams.timeInMeshCap);\n p1w += p1 * topicParams.timeInMeshWeight;\n }\n // P2: first message deliveries\n let p2 = tstats.firstMessageDeliveries;\n if (p2 > topicParams.firstMessageDeliveriesCap) {\n p2 = topicParams.firstMessageDeliveriesCap;\n }\n p2w += p2 * topicParams.firstMessageDeliveriesWeight;\n // P3: mesh message deliveries\n if (tstats.meshMessageDeliveriesActive &&\n tstats.meshMessageDeliveries < topicParams.meshMessageDeliveriesThreshold) {\n const deficit = topicParams.meshMessageDeliveriesThreshold - tstats.meshMessageDeliveries;\n const p3 = deficit * deficit;\n p3w += p3 * topicParams.meshMessageDeliveriesWeight;\n }\n // P3b:\n // NOTE: the weight of P3b is negative (validated in validateTopicScoreParams) so this detracts\n const p3b = tstats.meshFailurePenalty;\n p3bw += p3b * topicParams.meshFailurePenaltyWeight;\n // P4: invalid messages\n // NOTE: the weight of P4 is negative (validated in validateTopicScoreParams) so this detracts\n const p4 = tstats.invalidMessageDeliveries * tstats.invalidMessageDeliveries;\n p4w += p4 * topicParams.invalidMessageDeliveriesWeight;\n // update score, mixing with topic weight\n score += (p1w + p2w + p3w + p3bw + p4w) * topicParams.topicWeight;\n topicScores.p1w += p1w;\n topicScores.p2w += p2w;\n topicScores.p3w += p3w;\n topicScores.p3bw += p3bw;\n topicScores.p4w += p4w;\n });\n // apply the topic score cap, if any\n if (params.topicScoreCap > 0 && score > params.topicScoreCap) {\n score = params.topicScoreCap;\n // Proportionally apply cap to all individual contributions\n const capF = params.topicScoreCap / score;\n for (const ws of byTopic.values()) {\n ws.p1w *= capF;\n ws.p2w *= capF;\n ws.p3w *= capF;\n ws.p3bw *= capF;\n ws.p4w *= capF;\n }\n }\n let p5w = 0;\n let p6w = 0;\n let p7w = 0;\n // P5: application-specific score\n const p5 = params.appSpecificScore(peer);\n p5w += p5 * params.appSpecificWeight;\n // P6: IP colocation factor\n pstats.knownIPs.forEach((ip) => {\n if (params.IPColocationFactorWhitelist.has(ip)) {\n return;\n }\n // P6 has a cliff (IPColocationFactorThreshold)\n // It's only applied if at least that many peers are connected to us from that source IP addr.\n // It is quadratic, and the weight is negative (validated in validatePeerScoreParams)\n const peersInIP = peerIPs.get(ip);\n const numPeersInIP = (peersInIP != null) ? peersInIP.size : 0;\n if (numPeersInIP > params.IPColocationFactorThreshold) {\n const surplus = numPeersInIP - params.IPColocationFactorThreshold;\n const p6 = surplus * surplus;\n p6w += p6 * params.IPColocationFactorWeight;\n }\n });\n // P7: behavioural pattern penalty\n const p7 = pstats.behaviourPenalty * pstats.behaviourPenalty;\n p7w += p7 * params.behaviourPenaltyWeight;\n score += p5w + p6w + p7w;\n return {\n byTopic,\n p5w,\n p6w,\n p7w,\n score\n };\n}\nfunction computeAllPeersScoreWeights(peerIdStrs, peerStats, params, peerIPs, topicStrToLabel) {\n const sw = {\n byTopic: new Map(),\n p5w: [],\n p6w: [],\n p7w: [],\n score: []\n };\n for (const peerIdStr of peerIdStrs) {\n const pstats = peerStats.get(peerIdStr);\n if (pstats != null) {\n const swPeer = computeScoreWeights(peerIdStr, pstats, params, peerIPs, topicStrToLabel);\n for (const [topic, swPeerTopic] of swPeer.byTopic) {\n let swTopic = sw.byTopic.get(topic);\n if (swTopic == null) {\n swTopic = {\n p1w: [],\n p2w: [],\n p3w: [],\n p3bw: [],\n p4w: []\n };\n sw.byTopic.set(topic, swTopic);\n }\n swTopic.p1w.push(swPeerTopic.p1w);\n swTopic.p2w.push(swPeerTopic.p2w);\n swTopic.p3w.push(swPeerTopic.p3w);\n swTopic.p3bw.push(swPeerTopic.p3bw);\n swTopic.p4w.push(swPeerTopic.p4w);\n }\n sw.p5w.push(swPeer.p5w);\n sw.p6w.push(swPeer.p6w);\n sw.p7w.push(swPeer.p7w);\n sw.score.push(swPeer.score);\n }\n else {\n sw.p5w.push(0);\n sw.p6w.push(0);\n sw.p7w.push(0);\n sw.score.push(0);\n }\n }\n return sw;\n}\n//# sourceMappingURL=scoreMetrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InboundStream: () => (/* binding */ InboundStream),\n/* harmony export */ OutboundStream: () => (/* binding */ OutboundStream)\n/* harmony export */ });\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n\n\n\nclass OutboundStream {\n rawStream;\n pushable;\n closeController;\n maxBufferSize;\n constructor(rawStream, errCallback, opts) {\n this.rawStream = rawStream;\n this.pushable = (0,it_pushable__WEBPACK_IMPORTED_MODULE_2__.pushable)();\n this.closeController = new AbortController();\n this.maxBufferSize = opts.maxBufferSize ?? Infinity;\n this.closeController.signal.addEventListener('abort', () => {\n rawStream.close()\n .catch(err => {\n rawStream.abort(err);\n });\n });\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(this.pushable, this.rawStream).catch(errCallback);\n }\n get protocol() {\n // TODO remove this non-nullish assertion after https://github.com/libp2p/js-libp2p-interfaces/pull/265 is incorporated\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.rawStream.protocol;\n }\n push(data) {\n if (this.pushable.readableLength > this.maxBufferSize) {\n throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);\n }\n this.pushable.push(it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.encode.single(data));\n }\n /**\n * Same to push() but this is prefixed data so no need to encode length prefixed again\n */\n pushPrefixed(data) {\n if (this.pushable.readableLength > this.maxBufferSize) {\n throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);\n }\n this.pushable.push(data);\n }\n async close() {\n this.closeController.abort();\n // similar to pushable.end() but clear the internal buffer\n await this.pushable.return();\n }\n}\nclass InboundStream {\n source;\n rawStream;\n closeController;\n constructor(rawStream, opts = {}) {\n this.rawStream = rawStream;\n this.closeController = new AbortController();\n this.closeController.signal.addEventListener('abort', () => {\n rawStream.close()\n .catch(err => {\n rawStream.abort(err);\n });\n });\n this.source = (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(this.rawStream, (source) => (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.decode)(source, opts));\n }\n async close() {\n this.closeController.abort();\n }\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ IWantTracer: () => (/* binding */ IWantTracer)\n/* harmony export */ });\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n/**\n * IWantTracer is an internal tracer that tracks IWANT requests in order to penalize\n * peers who don't follow up on IWANT requests after an IHAVE advertisement.\n * The tracking of promises is probabilistic to avoid using too much memory.\n *\n * Note: Do not confuse these 'promises' with JS Promise objects.\n * These 'promises' are merely expectations of a peer's behavior.\n */\nclass IWantTracer {\n gossipsubIWantFollowupMs;\n msgIdToStrFn;\n metrics;\n /**\n * Promises to deliver a message\n * Map per message id, per peer, promise expiration time\n */\n promises = new Map();\n /**\n * First request time by msgId. Used for metrics to track expire times.\n * Necessary to know if peers are actually breaking promises or simply sending them a bit later\n */\n requestMsByMsg = new Map();\n requestMsByMsgExpire;\n constructor(gossipsubIWantFollowupMs, msgIdToStrFn, metrics) {\n this.gossipsubIWantFollowupMs = gossipsubIWantFollowupMs;\n this.msgIdToStrFn = msgIdToStrFn;\n this.metrics = metrics;\n this.requestMsByMsgExpire = 10 * gossipsubIWantFollowupMs;\n }\n get size() {\n return this.promises.size;\n }\n get requestMsByMsgSize() {\n return this.requestMsByMsg.size;\n }\n /**\n * Track a promise to deliver a message from a list of msgIds we are requesting\n */\n addPromise(from, msgIds) {\n // pick msgId randomly from the list\n const ix = Math.floor(Math.random() * msgIds.length);\n const msgId = msgIds[ix];\n const msgIdStr = this.msgIdToStrFn(msgId);\n let expireByPeer = this.promises.get(msgIdStr);\n if (expireByPeer == null) {\n expireByPeer = new Map();\n this.promises.set(msgIdStr, expireByPeer);\n }\n const now = Date.now();\n // If a promise for this message id and peer already exists we don't update the expiry\n if (!expireByPeer.has(from)) {\n expireByPeer.set(from, now + this.gossipsubIWantFollowupMs);\n if (this.metrics != null) {\n this.metrics.iwantPromiseStarted.inc(1);\n if (!this.requestMsByMsg.has(msgIdStr)) {\n this.requestMsByMsg.set(msgIdStr, now);\n }\n }\n }\n }\n /**\n * Returns the number of broken promises for each peer who didn't follow up on an IWANT request.\n *\n * This should be called not too often relative to the expire times, since it iterates over the whole data.\n */\n getBrokenPromises() {\n const now = Date.now();\n const result = new Map();\n let brokenPromises = 0;\n this.promises.forEach((expireByPeer, msgId) => {\n expireByPeer.forEach((expire, p) => {\n // the promise has been broken\n if (expire < now) {\n // add 1 to result\n result.set(p, (result.get(p) ?? 0) + 1);\n // delete from tracked promises\n expireByPeer.delete(p);\n // for metrics\n brokenPromises++;\n }\n });\n // clean up empty promises for a msgId\n if (expireByPeer.size === 0) {\n this.promises.delete(msgId);\n }\n });\n this.metrics?.iwantPromiseBroken.inc(brokenPromises);\n return result;\n }\n /**\n * Someone delivered a message, stop tracking promises for it\n */\n deliverMessage(msgIdStr, isDuplicate = false) {\n this.trackMessage(msgIdStr);\n const expireByPeer = this.promises.get(msgIdStr);\n // Expired promise, check requestMsByMsg\n if (expireByPeer != null) {\n this.promises.delete(msgIdStr);\n if (this.metrics != null) {\n this.metrics.iwantPromiseResolved.inc(1);\n if (isDuplicate)\n this.metrics.iwantPromiseResolvedFromDuplicate.inc(1);\n this.metrics.iwantPromiseResolvedPeers.inc(expireByPeer.size);\n }\n }\n }\n /**\n * A message got rejected, so we can stop tracking promises and let the score penalty apply from invalid message delivery,\n * unless its an obviously invalid message.\n */\n rejectMessage(msgIdStr, reason) {\n this.trackMessage(msgIdStr);\n // A message got rejected, so we can stop tracking promises and let the score penalty apply.\n // With the expection of obvious invalid messages\n switch (reason) {\n case _types_js__WEBPACK_IMPORTED_MODULE_0__.RejectReason.Error:\n return;\n default:\n break;\n }\n this.promises.delete(msgIdStr);\n }\n clear() {\n this.promises.clear();\n }\n prune() {\n const maxMs = Date.now() - this.requestMsByMsgExpire;\n let count = 0;\n for (const [k, v] of this.requestMsByMsg.entries()) {\n if (v < maxMs) {\n // messages that stay too long in the requestMsByMsg map, delete\n this.requestMsByMsg.delete(k);\n count++;\n }\n else {\n // recent messages, keep them\n // sort by insertion order\n break;\n }\n }\n this.metrics?.iwantMessagePruned.inc(count);\n }\n trackMessage(msgIdStr) {\n if (this.metrics != null) {\n const requestMs = this.requestMsByMsg.get(msgIdStr);\n if (requestMs !== undefined) {\n this.metrics.iwantPromiseDeliveryTime.observe((Date.now() - requestMs) / 1000);\n this.requestMsByMsg.delete(msgIdStr);\n }\n }\n }\n}\n//# sourceMappingURL=tracer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js": +/*!********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageStatus: () => (/* binding */ MessageStatus),\n/* harmony export */ PublishConfigType: () => (/* binding */ PublishConfigType),\n/* harmony export */ RejectReason: () => (/* binding */ RejectReason),\n/* harmony export */ SignaturePolicy: () => (/* binding */ SignaturePolicy),\n/* harmony export */ ValidateError: () => (/* binding */ ValidateError),\n/* harmony export */ rejectReasonFromAcceptance: () => (/* binding */ rejectReasonFromAcceptance)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n\nvar SignaturePolicy;\n(function (SignaturePolicy) {\n /**\n * On the producing side:\n * - Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.\n *\n * On the consuming side:\n * - Enforce the fields to be present, reject otherwise.\n * - Propagate only if the fields are valid and signature can be verified, reject otherwise.\n */\n SignaturePolicy[\"StrictSign\"] = \"StrictSign\";\n /**\n * On the producing side:\n * - Build messages without the signature, key, from and seqno fields.\n * - The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty.\n *\n * On the consuming side:\n * - Enforce the fields to be absent, reject otherwise.\n * - Propagate only if the fields are absent, reject otherwise.\n * - A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.\n */\n SignaturePolicy[\"StrictNoSign\"] = \"StrictNoSign\";\n})(SignaturePolicy || (SignaturePolicy = {}));\nvar PublishConfigType;\n(function (PublishConfigType) {\n PublishConfigType[PublishConfigType[\"Signing\"] = 0] = \"Signing\";\n PublishConfigType[PublishConfigType[\"Anonymous\"] = 1] = \"Anonymous\";\n})(PublishConfigType || (PublishConfigType = {}));\nvar RejectReason;\n(function (RejectReason) {\n /**\n * The message failed the configured validation during decoding.\n * SelfOrigin is considered a ValidationError\n */\n RejectReason[\"Error\"] = \"error\";\n /**\n * Custom validator fn reported status IGNORE.\n */\n RejectReason[\"Ignore\"] = \"ignore\";\n /**\n * Custom validator fn reported status REJECT.\n */\n RejectReason[\"Reject\"] = \"reject\";\n /**\n * The peer that sent the message OR the source from field is blacklisted.\n * Causes messages to be ignored, not penalized, neither do score record creation.\n */\n RejectReason[\"Blacklisted\"] = \"blacklisted\";\n})(RejectReason || (RejectReason = {}));\nvar ValidateError;\n(function (ValidateError) {\n /// The message has an invalid signature,\n ValidateError[\"InvalidSignature\"] = \"invalid_signature\";\n /// The sequence number was the incorrect size\n ValidateError[\"InvalidSeqno\"] = \"invalid_seqno\";\n /// The PeerId was invalid\n ValidateError[\"InvalidPeerId\"] = \"invalid_peerid\";\n /// Signature existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"SignaturePresent\"] = \"signature_present\";\n /// Sequence number existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"SeqnoPresent\"] = \"seqno_present\";\n /// Message source existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"FromPresent\"] = \"from_present\";\n /// The data transformation failed.\n ValidateError[\"TransformFailed\"] = \"transform_failed\";\n})(ValidateError || (ValidateError = {}));\nvar MessageStatus;\n(function (MessageStatus) {\n MessageStatus[\"duplicate\"] = \"duplicate\";\n MessageStatus[\"invalid\"] = \"invalid\";\n MessageStatus[\"valid\"] = \"valid\";\n})(MessageStatus || (MessageStatus = {}));\n/**\n * Typesafe conversion of MessageAcceptance -> RejectReason. TS ensures all values covered\n */\nfunction rejectReasonFromAcceptance(acceptance) {\n switch (acceptance) {\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Ignore:\n return RejectReason.Ignore;\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Reject:\n return RejectReason.Reject;\n default:\n throw new Error('Unreachable');\n }\n}\n//# sourceMappingURL=types.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SignPrefix: () => (/* binding */ SignPrefix),\n/* harmony export */ buildRawMessage: () => (/* binding */ buildRawMessage),\n/* harmony export */ validateToRawMessage: () => (/* binding */ validateToRawMessage)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../message/rpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n\n\n\n\n\n\n\n\n\nconst SignPrefix = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)('libp2p-pubsub:');\nasync function buildRawMessage(publishConfig, topic, originalData, transformedData) {\n switch (publishConfig.type) {\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.PublishConfigType.Signing: {\n const rpcMsg = {\n from: publishConfig.author.toBytes(),\n data: transformedData,\n seqno: (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(8),\n topic,\n signature: undefined, // Exclude signature field for signing\n key: undefined // Exclude key field for signing\n };\n // Get the message in bytes, and prepend with the pubsub prefix\n // the signature is over the bytes \"libp2p-pubsub:\"\n const bytes = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([SignPrefix, _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__.RPC.Message.encode(rpcMsg)]);\n rpcMsg.signature = await publishConfig.privateKey.sign(bytes);\n rpcMsg.key = publishConfig.key;\n const msg = {\n type: 'signed',\n from: publishConfig.author,\n data: originalData,\n sequenceNumber: BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(rpcMsg.seqno, 'base16')}`),\n topic,\n signature: rpcMsg.signature,\n key: rpcMsg.key\n };\n return {\n raw: rpcMsg,\n msg\n };\n }\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.PublishConfigType.Anonymous: {\n return {\n raw: {\n from: undefined,\n data: transformedData,\n seqno: undefined,\n topic,\n signature: undefined,\n key: undefined\n },\n msg: {\n type: 'unsigned',\n data: originalData,\n topic\n }\n };\n }\n default:\n throw new Error('Unreachable');\n }\n}\nasync function validateToRawMessage(signaturePolicy, msg) {\n // If strict-sign, verify all\n // If anonymous (no-sign), ensure no preven\n switch (signaturePolicy) {\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.StrictNoSign:\n if (msg.signature != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.SignaturePresent };\n if (msg.seqno != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.SeqnoPresent };\n if (msg.key != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.FromPresent };\n return { valid: true, message: { type: 'unsigned', topic: msg.topic, data: msg.data ?? new Uint8Array(0) } };\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.StrictSign: {\n // Verify seqno\n if (msg.seqno == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidSeqno };\n if (msg.seqno.length !== 8) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidSeqno };\n }\n if (msg.signature == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidSignature };\n if (msg.from == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidPeerId };\n let fromPeerId;\n try {\n // TODO: Fix PeerId types\n fromPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_8__.peerIdFromBytes)(msg.from);\n }\n catch (e) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidPeerId };\n }\n // - check from defined\n // - transform source to PeerId\n // - parse signature\n // - get .key, else from source\n // - check key == source if present\n // - verify sig\n let publicKey;\n if (msg.key != null) {\n publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.unmarshalPublicKey)(msg.key);\n // TODO: Should `fromPeerId.pubKey` be optional?\n if (fromPeerId.publicKey !== undefined && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(publicKey.bytes, fromPeerId.publicKey)) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidPeerId };\n }\n }\n else {\n if (fromPeerId.publicKey == null) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidPeerId };\n }\n publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.unmarshalPublicKey)(fromPeerId.publicKey);\n }\n const rpcMsgPreSign = {\n from: msg.from,\n data: msg.data,\n seqno: msg.seqno,\n topic: msg.topic,\n signature: undefined, // Exclude signature field for signing\n key: undefined // Exclude key field for signing\n };\n // Get the message in bytes, and prepend with the pubsub prefix\n // the signature is over the bytes \"libp2p-pubsub:\"\n const bytes = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([SignPrefix, _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__.RPC.Message.encode(rpcMsgPreSign)]);\n if (!(await publicKey.verify(bytes, msg.signature))) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_4__.ValidateError.InvalidSignature };\n }\n return {\n valid: true,\n message: {\n type: 'signed',\n from: fromPeerId,\n data: msg.data ?? new Uint8Array(0),\n sequenceNumber: BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(msg.seqno, 'base16')}`),\n topic: msg.topic,\n signature: msg.signature,\n key: msg.key ?? (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.marshalPublicKey)(publicKey)\n }\n };\n }\n default:\n throw new Error('Unreachable');\n }\n}\n//# sourceMappingURL=buildRawMessage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/create-gossip-rpc.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/create-gossip-rpc.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createGossipRpc: () => (/* binding */ createGossipRpc),\n/* harmony export */ ensureControl: () => (/* binding */ ensureControl)\n/* harmony export */ });\n/**\n * Create a gossipsub RPC object\n */\nfunction createGossipRpc(messages = [], control) {\n return {\n subscriptions: [],\n messages,\n control: control !== undefined\n ? {\n graft: control.graft ?? [],\n prune: control.prune ?? [],\n ihave: control.ihave ?? [],\n iwant: control.iwant ?? []\n }\n : undefined\n };\n}\nfunction ensureControl(rpc) {\n if (rpc.control === undefined) {\n rpc.control = {\n graft: [],\n prune: [],\n ihave: [],\n iwant: []\n };\n }\n return rpc;\n}\n//# sourceMappingURL=create-gossip-rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/create-gossip-rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ messageIdToString: () => (/* binding */ messageIdToString)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/to-string.js\");\n\n/**\n * Browser friendly function to convert Uint8Array message id to base64 string.\n */\nfunction messageIdToString(msgId) {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(msgId, 'base64');\n}\n//# sourceMappingURL=messageIdToString.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ msgIdFnStrictNoSign: () => (/* binding */ msgIdFnStrictNoSign),\n/* harmony export */ msgIdFnStrictSign: () => (/* binding */ msgIdFnStrictSign)\n/* harmony export */ });\n/* harmony import */ var _libp2p_pubsub_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/pubsub/utils */ \"./node_modules/@libp2p/pubsub/dist/src/utils.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n\n\n/**\n * Generate a message id, based on the `key` and `seqno`\n */\nfunction msgIdFnStrictSign(msg) {\n if (msg.type !== 'signed') {\n throw new Error('expected signed message type');\n }\n // Should never happen\n if (msg.sequenceNumber == null)\n throw Error('missing seqno field');\n // TODO: Should use .from here or key?\n return (0,_libp2p_pubsub_utils__WEBPACK_IMPORTED_MODULE_1__.msgId)(msg.from.toBytes(), msg.sequenceNumber);\n}\n/**\n * Generate a message id, based on message `data`\n */\nasync function msgIdFnStrictNoSign(msg) {\n return multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.encode(msg.data);\n}\n//# sourceMappingURL=msgIdFn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrToIPStr: () => (/* binding */ multiaddrToIPStr)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n\n// Protocols https://github.com/multiformats/multiaddr/blob/master/protocols.csv\n// code size name\n// 4 32 ip4\n// 41 128 ip6\nvar Protocol;\n(function (Protocol) {\n Protocol[Protocol[\"ip4\"] = 4] = \"ip4\";\n Protocol[Protocol[\"ip6\"] = 41] = \"ip6\";\n})(Protocol || (Protocol = {}));\nfunction multiaddrToIPStr(multiaddr) {\n for (const tuple of multiaddr.tuples()) {\n switch (tuple[0]) {\n case Protocol.ip4:\n case Protocol.ip6:\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(tuple[0], tuple[1]);\n default:\n break;\n }\n }\n return null;\n}\n//# sourceMappingURL=multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPublishConfigFromPeerId: () => (/* binding */ getPublishConfigFromPeerId)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n\n\n/**\n * Prepare a PublishConfig object from a PeerId.\n */\nasync function getPublishConfigFromPeerId(signaturePolicy, peerId) {\n switch (signaturePolicy) {\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.StrictSign: {\n if (peerId == null) {\n throw Error('Must provide PeerId');\n }\n if (peerId.privateKey == null) {\n throw Error('Cannot sign message, no private key present');\n }\n if (peerId.publicKey == null) {\n throw Error('Cannot sign message, no public key present');\n }\n // Transform privateKey once at initialization time instead of once per message\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.unmarshalPrivateKey)(peerId.privateKey);\n return {\n type: _types_js__WEBPACK_IMPORTED_MODULE_2__.PublishConfigType.Signing,\n author: peerId,\n key: peerId.publicKey,\n privateKey\n };\n }\n case _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.StrictNoSign:\n return {\n type: _types_js__WEBPACK_IMPORTED_MODULE_2__.PublishConfigType.Anonymous\n };\n default:\n throw new Error(`Unknown signature policy \"${signaturePolicy}\"`);\n }\n}\n//# sourceMappingURL=publishConfig.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js": +/*!************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MapDef: () => (/* binding */ MapDef),\n/* harmony export */ removeFirstNItemsFromSet: () => (/* binding */ removeFirstNItemsFromSet),\n/* harmony export */ removeItemsFromSet: () => (/* binding */ removeItemsFromSet)\n/* harmony export */ });\n/**\n * Exclude up to `ineed` items from a set if item meets condition `cond`\n */\nfunction removeItemsFromSet(superSet, ineed, cond = () => true) {\n const subset = new Set();\n if (ineed <= 0)\n return subset;\n for (const id of superSet) {\n if (subset.size >= ineed)\n break;\n if (cond(id)) {\n subset.add(id);\n superSet.delete(id);\n }\n }\n return subset;\n}\n/**\n * Exclude up to `ineed` items from a set\n */\nfunction removeFirstNItemsFromSet(superSet, ineed) {\n return removeItemsFromSet(superSet, ineed, () => true);\n}\nclass MapDef extends Map {\n getDefault;\n constructor(getDefault) {\n super();\n this.getDefault = getDefault;\n }\n getOrDefault(key) {\n let value = super.get(key);\n if (value === undefined) {\n value = this.getDefault();\n this.set(key, value);\n }\n return value;\n }\n}\n//# sourceMappingURL=set.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ shuffle: () => (/* binding */ shuffle)\n/* harmony export */ });\n/**\n * Pseudo-randomly shuffles an array\n *\n * Mutates the input array\n */\nfunction shuffle(arr) {\n if (arr.length <= 1) {\n return arr;\n }\n const randInt = () => {\n return Math.floor(Math.random() * Math.floor(arr.length));\n };\n for (let i = 0; i < arr.length; i++) {\n const j = randInt();\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n return arr;\n}\n//# sourceMappingURL=shuffle.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SimpleTimeCache: () => (/* binding */ SimpleTimeCache)\n/* harmony export */ });\n/**\n * This is similar to https://github.com/daviddias/time-cache/blob/master/src/index.js\n * for our own need, we don't use lodash throttle to improve performance.\n * This gives 4x - 5x performance gain compared to npm TimeCache\n */\nclass SimpleTimeCache {\n entries = new Map();\n validityMs;\n constructor(opts) {\n this.validityMs = opts.validityMs;\n // allow negative validityMs so that this does not cache anything, spec test compliance.spec.js\n // sends duplicate messages and expect peer to receive all. Application likely uses positive validityMs\n }\n get size() {\n return this.entries.size;\n }\n /** Returns true if there was a key collision and the entry is dropped */\n put(key, value) {\n if (this.entries.has(key)) {\n // Key collisions break insertion order in the entries cache, which break prune logic.\n // prune relies on each iterated entry to have strictly ascending validUntilMs, else it\n // won't prune expired entries and SimpleTimeCache will grow unexpectedly.\n // As of Oct 2022 NodeJS v16, inserting the same key twice with different value does not\n // change the key position in the iterator stream. A unit test asserts this behaviour.\n return true;\n }\n this.entries.set(key, { value, validUntilMs: Date.now() + this.validityMs });\n return false;\n }\n prune() {\n const now = Date.now();\n for (const [k, v] of this.entries.entries()) {\n if (v.validUntilMs < now) {\n this.entries.delete(k);\n }\n else {\n // Entries are inserted with strictly ascending validUntilMs.\n // Stop early to save iterations\n break;\n }\n }\n }\n has(key) {\n return this.entries.has(key);\n }\n get(key) {\n const value = this.entries.get(key);\n return (value != null) && value.validUntilMs >= Date.now() ? value.value : undefined;\n }\n clear() {\n this.entries.clear();\n }\n}\n//# sourceMappingURL=time-cache.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/alloc.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/alloc.js ***! + \*********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/concat.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/concat.js ***! + \**********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ concat: () => (/* binding */ concat)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns a new Uint8Array created by concatenating the passed Uint8Arrays\n */\nfunction concat(arrays, length) {\n if (length == null) {\n length = arrays.reduce((acc, curr) => acc + curr.length, 0);\n }\n const output = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(length);\n let offset = 0;\n for (const arr of arrays) {\n output.set(arr, offset);\n offset += arr.length;\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(output);\n}\n//# sourceMappingURL=concat.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/concat.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/equals.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/equals.js ***! + \**********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/from-string.js": +/*!***************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/from-string.js ***! + \***************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/to-string.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/to-string.js ***! + \*************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/as-uint8array.js": +/*!**********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/as-uint8array.js ***! + \**********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ asUint8Array: () => (/* binding */ asUint8Array)\n/* harmony export */ });\n/**\n * To guarantee Uint8Array semantics, convert nodejs Buffers\n * into vanilla Uint8Arrays\n */\nfunction asUint8Array(buf) {\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/bases.js": +/*!**************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/bases.js ***! + \**************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + /***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js": /*!********************************************************************!*\ !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js ***! @@ -2082,6 +2001,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.browser.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.browser.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultCrypto: () => (/* binding */ defaultCrypto)\n/* harmony export */ });\n/* harmony import */ var _js_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./js.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js\");\n\nconst defaultCrypto = _js_js__WEBPACK_IMPORTED_MODULE_0__.pureJsCrypto;\n//# sourceMappingURL=index.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.browser.js?"); + +/***/ }), + /***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js": /*!********************************************************************!*\ !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js ***! @@ -2089,7 +2019,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pureJsCrypto: () => (/* binding */ pureJsCrypto)\n/* harmony export */ });\n/* harmony import */ var _noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/ciphers/chacha */ \"./node_modules/@noble/ciphers/esm/chacha.js\");\n/* harmony import */ var _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @noble/curves/ed25519 */ \"./node_modules/@noble/curves/esm/ed25519.js\");\n/* harmony import */ var _noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/hashes/hkdf */ \"./node_modules/@noble/hashes/esm/hkdf.js\");\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n\n\n\n\nconst pureJsCrypto = {\n hashSHA256(data) {\n return (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256)(data);\n },\n getHKDF(ck, ikm) {\n const prk = (0,_noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__.extract)(_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256, ikm, ck);\n const okmU8Array = (0,_noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__.expand)(_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256, prk, undefined, 96);\n const okm = okmU8Array;\n const k1 = okm.subarray(0, 32);\n const k2 = okm.subarray(32, 64);\n const k3 = okm.subarray(64, 96);\n return [k1, k2, k3];\n },\n generateX25519KeyPair() {\n const secretKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.utils.randomPrivateKey();\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getPublicKey(secretKey);\n return {\n publicKey,\n privateKey: secretKey\n };\n },\n generateX25519KeyPairFromSeed(seed) {\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getPublicKey(seed);\n return {\n publicKey,\n privateKey: seed\n };\n },\n generateX25519SharedKey(privateKey, publicKey) {\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getSharedSecret(privateKey, publicKey);\n },\n chaCha20Poly1305Encrypt(plaintext, nonce, ad, k) {\n return (0,_noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__.chacha20_poly1305)(k, nonce, ad).encrypt(plaintext);\n },\n chaCha20Poly1305Decrypt(ciphertext, nonce, ad, k, dst) {\n const result = (0,_noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__.chacha20_poly1305)(k, nonce, ad).decrypt(ciphertext);\n if (dst) {\n dst.set(result);\n return result;\n }\n return result;\n }\n};\n//# sourceMappingURL=js.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pureJsCrypto: () => (/* binding */ pureJsCrypto)\n/* harmony export */ });\n/* harmony import */ var _noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/ciphers/chacha */ \"./node_modules/@noble/ciphers/esm/chacha.js\");\n/* harmony import */ var _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @noble/curves/ed25519 */ \"./node_modules/@noble/curves/esm/ed25519.js\");\n/* harmony import */ var _noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/hashes/hkdf */ \"./node_modules/@noble/hashes/esm/hkdf.js\");\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n\n\n\n\nconst pureJsCrypto = {\n hashSHA256(data) {\n return (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256)(data.subarray());\n },\n getHKDF(ck, ikm) {\n const prk = (0,_noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__.extract)(_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256, ikm, ck);\n const okmU8Array = (0,_noble_hashes_hkdf__WEBPACK_IMPORTED_MODULE_2__.expand)(_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256, prk, undefined, 96);\n const okm = okmU8Array;\n const k1 = okm.subarray(0, 32);\n const k2 = okm.subarray(32, 64);\n const k3 = okm.subarray(64, 96);\n return [k1, k2, k3];\n },\n generateX25519KeyPair() {\n const secretKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.utils.randomPrivateKey();\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getPublicKey(secretKey);\n return {\n publicKey,\n privateKey: secretKey\n };\n },\n generateX25519KeyPairFromSeed(seed) {\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getPublicKey(seed);\n return {\n publicKey,\n privateKey: seed\n };\n },\n generateX25519SharedKey(privateKey, publicKey) {\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_3__.x25519.getSharedSecret(privateKey.subarray(), publicKey.subarray());\n },\n chaCha20Poly1305Encrypt(plaintext, nonce, ad, k) {\n return (0,_noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__.chacha20poly1305)(k, nonce, ad).encrypt(plaintext.subarray());\n },\n chaCha20Poly1305Decrypt(ciphertext, nonce, ad, k, dst) {\n return (0,_noble_ciphers_chacha__WEBPACK_IMPORTED_MODULE_0__.chacha20poly1305)(k, nonce, ad).decrypt(ciphertext.subarray(), dst);\n }\n};\n//# sourceMappingURL=js.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js?"); /***/ }), @@ -2100,7 +2030,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decryptStream: () => (/* binding */ decryptStream),\n/* harmony export */ encryptStream: () => (/* binding */ encryptStream)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n\n\nconst CHACHA_TAG_LENGTH = 16;\n// Returns generator that encrypts payload from the user\nfunction encryptStream(handshake, metrics) {\n return async function* (source) {\n for await (const chunk of source) {\n for (let i = 0; i < chunk.length; i += _constants_js__WEBPACK_IMPORTED_MODULE_0__.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG) {\n let end = i + _constants_js__WEBPACK_IMPORTED_MODULE_0__.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG;\n if (end > chunk.length) {\n end = chunk.length;\n }\n const data = handshake.encrypt(chunk.subarray(i, end), handshake.session);\n metrics?.encryptedPackets.increment();\n yield (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.uint16BEEncode)(data.byteLength);\n yield data;\n }\n }\n };\n}\n// Decrypt received payload to the user\nfunction decryptStream(handshake, metrics) {\n return async function* (source) {\n for await (const chunk of source) {\n for (let i = 0; i < chunk.length; i += _constants_js__WEBPACK_IMPORTED_MODULE_0__.NOISE_MSG_MAX_LENGTH_BYTES) {\n let end = i + _constants_js__WEBPACK_IMPORTED_MODULE_0__.NOISE_MSG_MAX_LENGTH_BYTES;\n if (end > chunk.length) {\n end = chunk.length;\n }\n if (end - CHACHA_TAG_LENGTH < i) {\n throw new Error('Invalid chunk');\n }\n const encrypted = chunk.subarray(i, end);\n // memory allocation is not cheap so reuse the encrypted Uint8Array\n // see https://github.com/ChainSafe/js-libp2p-noise/pull/242#issue-1422126164\n // this is ok because chacha20 reads bytes one by one and don't reread after that\n // it's also tested in https://github.com/ChainSafe/as-chacha20poly1305/pull/1/files#diff-25252846b58979dcaf4e41d47b3eadd7e4f335e7fb98da6c049b1f9cd011f381R48\n const dst = chunk.subarray(i, end - CHACHA_TAG_LENGTH);\n const { plaintext: decrypted, valid } = handshake.decrypt(encrypted, handshake.session, dst);\n if (!valid) {\n metrics?.decryptErrors.increment();\n throw new Error('Failed to validate decrypted chunk');\n }\n metrics?.decryptedPackets.increment();\n yield decrypted;\n }\n }\n };\n}\n//# sourceMappingURL=streaming.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decryptStream: () => (/* binding */ decryptStream),\n/* harmony export */ encryptStream: () => (/* binding */ encryptStream)\n/* harmony export */ });\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n\n\n\nconst CHACHA_TAG_LENGTH = 16;\n// Returns generator that encrypts payload from the user\nfunction encryptStream(handshake, metrics) {\n return async function* (source) {\n for await (const chunk of source) {\n for (let i = 0; i < chunk.length; i += _constants_js__WEBPACK_IMPORTED_MODULE_1__.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG) {\n let end = i + _constants_js__WEBPACK_IMPORTED_MODULE_1__.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG;\n if (end > chunk.length) {\n end = chunk.length;\n }\n let data;\n if (chunk instanceof Uint8Array) {\n data = handshake.encrypt(chunk.subarray(i, end), handshake.session);\n }\n else {\n data = handshake.encrypt(chunk.sublist(i, end), handshake.session);\n }\n metrics?.encryptedPackets.increment();\n yield new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList((0,_encoder_js__WEBPACK_IMPORTED_MODULE_2__.uint16BEEncode)(data.byteLength), data);\n }\n }\n };\n}\n// Decrypt received payload to the user\nfunction decryptStream(handshake, metrics) {\n return async function* (source) {\n for await (const chunk of source) {\n for (let i = 0; i < chunk.length; i += _constants_js__WEBPACK_IMPORTED_MODULE_1__.NOISE_MSG_MAX_LENGTH_BYTES) {\n let end = i + _constants_js__WEBPACK_IMPORTED_MODULE_1__.NOISE_MSG_MAX_LENGTH_BYTES;\n if (end > chunk.length) {\n end = chunk.length;\n }\n if (end - CHACHA_TAG_LENGTH < i) {\n throw new Error('Invalid chunk');\n }\n const encrypted = chunk.sublist(i, end);\n // memory allocation is not cheap so reuse the encrypted Uint8Array\n // see https://github.com/ChainSafe/js-libp2p-noise/pull/242#issue-1422126164\n // this is ok because chacha20 reads bytes one by one and don't reread after that\n // it's also tested in https://github.com/ChainSafe/as-chacha20poly1305/pull/1/files#diff-25252846b58979dcaf4e41d47b3eadd7e4f335e7fb98da6c049b1f9cd011f381R48\n const dst = chunk.subarray(i, end - CHACHA_TAG_LENGTH);\n const { plaintext: decrypted, valid } = handshake.decrypt(encrypted, handshake.session, dst);\n if (!valid) {\n metrics?.decryptErrors.increment();\n throw new Error('Failed to validate decrypted chunk');\n }\n metrics?.decryptedPackets.increment();\n yield decrypted;\n }\n }\n };\n}\n//# sourceMappingURL=streaming.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js?"); /***/ }), @@ -2111,7 +2041,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode0: () => (/* binding */ decode0),\n/* harmony export */ decode1: () => (/* binding */ decode1),\n/* harmony export */ decode2: () => (/* binding */ decode2),\n/* harmony export */ encode0: () => (/* binding */ encode0),\n/* harmony export */ encode1: () => (/* binding */ encode1),\n/* harmony export */ encode2: () => (/* binding */ encode2),\n/* harmony export */ uint16BEDecode: () => (/* binding */ uint16BEDecode),\n/* harmony export */ uint16BEEncode: () => (/* binding */ uint16BEEncode)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n\nconst allocUnsafe = (len) => {\n if (globalThis.Buffer) {\n return globalThis.Buffer.allocUnsafe(len);\n }\n return new Uint8Array(len);\n};\nconst uint16BEEncode = (value) => {\n const target = allocUnsafe(2);\n new DataView(target.buffer, target.byteOffset, target.byteLength).setUint16(0, value, false);\n return target;\n};\nuint16BEEncode.bytes = 2;\nconst uint16BEDecode = (data) => {\n if (data.length < 2)\n throw RangeError('Could not decode int16BE');\n if (data instanceof Uint8Array) {\n return new DataView(data.buffer, data.byteOffset, data.byteLength).getUint16(0, false);\n }\n return data.getUint16(0);\n};\nuint16BEDecode.bytes = 2;\n// Note: IK and XX encoder usage is opposite (XX uses in stages encode0 where IK uses encode1)\nfunction encode0(message) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([message.ne, message.ciphertext], message.ne.length + message.ciphertext.length);\n}\nfunction encode1(message) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([message.ne, message.ns, message.ciphertext], message.ne.length + message.ns.length + message.ciphertext.length);\n}\nfunction encode2(message) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([message.ns, message.ciphertext], message.ns.length + message.ciphertext.length);\n}\nfunction decode0(input) {\n if (input.length < 32) {\n throw new Error('Cannot decode stage 0 MessageBuffer: length less than 32 bytes.');\n }\n return {\n ne: input.subarray(0, 32),\n ciphertext: input.subarray(32, input.length),\n ns: new Uint8Array(0)\n };\n}\nfunction decode1(input) {\n if (input.length < 80) {\n throw new Error('Cannot decode stage 1 MessageBuffer: length less than 80 bytes.');\n }\n return {\n ne: input.subarray(0, 32),\n ns: input.subarray(32, 80),\n ciphertext: input.subarray(80, input.length)\n };\n}\nfunction decode2(input) {\n if (input.length < 48) {\n throw new Error('Cannot decode stage 2 MessageBuffer: length less than 48 bytes.');\n }\n return {\n ne: new Uint8Array(0),\n ns: input.subarray(0, 48),\n ciphertext: input.subarray(48, input.length)\n };\n}\n//# sourceMappingURL=encoder.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode0: () => (/* binding */ decode0),\n/* harmony export */ decode1: () => (/* binding */ decode1),\n/* harmony export */ decode2: () => (/* binding */ decode2),\n/* harmony export */ encode0: () => (/* binding */ encode0),\n/* harmony export */ encode1: () => (/* binding */ encode1),\n/* harmony export */ encode2: () => (/* binding */ encode2),\n/* harmony export */ uint16BEDecode: () => (/* binding */ uint16BEDecode),\n/* harmony export */ uint16BEEncode: () => (/* binding */ uint16BEEncode)\n/* harmony export */ });\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nconst uint16BEEncode = (value) => {\n const target = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(2);\n new DataView(target.buffer, target.byteOffset, target.byteLength).setUint16(0, value, false);\n return target;\n};\nuint16BEEncode.bytes = 2;\nconst uint16BEDecode = (data) => {\n if (data.length < 2)\n throw RangeError('Could not decode int16BE');\n if (data instanceof Uint8Array) {\n return new DataView(data.buffer, data.byteOffset, data.byteLength).getUint16(0, false);\n }\n return data.getUint16(0);\n};\nuint16BEDecode.bytes = 2;\n// Note: IK and XX encoder usage is opposite (XX uses in stages encode0 where IK uses encode1)\nfunction encode0(message) {\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(message.ne, message.ciphertext);\n}\nfunction encode1(message) {\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(message.ne, message.ns, message.ciphertext);\n}\nfunction encode2(message) {\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(message.ns, message.ciphertext);\n}\nfunction decode0(input) {\n if (input.length < 32) {\n throw new Error('Cannot decode stage 0 MessageBuffer: length less than 32 bytes.');\n }\n return {\n ne: input.subarray(0, 32),\n ciphertext: input.subarray(32, input.length),\n ns: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n}\nfunction decode1(input) {\n if (input.length < 80) {\n throw new Error('Cannot decode stage 1 MessageBuffer: length less than 80 bytes.');\n }\n return {\n ne: input.subarray(0, 32),\n ns: input.subarray(32, 80),\n ciphertext: input.subarray(80, input.length)\n };\n}\nfunction decode2(input) {\n if (input.length < 48) {\n throw new Error('Cannot decode stage 2 MessageBuffer: length less than 48 bytes.');\n }\n return {\n ne: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n ns: input.subarray(0, 48),\n ciphertext: input.subarray(48, input.length)\n };\n}\n//# sourceMappingURL=encoder.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/errors.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/errors.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InvalidCryptoExchangeError: () => (/* binding */ InvalidCryptoExchangeError),\n/* harmony export */ UnexpectedPeerError: () => (/* binding */ UnexpectedPeerError)\n/* harmony export */ });\nclass UnexpectedPeerError extends Error {\n code;\n constructor(message = 'Unexpected Peer') {\n super(message);\n this.code = UnexpectedPeerError.code;\n }\n static code = 'ERR_UNEXPECTED_PEER';\n}\nclass InvalidCryptoExchangeError extends Error {\n code;\n constructor(message = 'Invalid crypto exchange') {\n super(message);\n this.code = InvalidCryptoExchangeError.code;\n }\n static code = 'ERR_INVALID_CRYPTO_EXCHANGE';\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/errors.js?"); /***/ }), @@ -2122,7 +2063,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ XXHandshake: () => (/* binding */ XXHandshake)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-connection-encrypter/errors */ \"./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n/* harmony import */ var _handshakes_xx_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./handshakes/xx.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js\");\n/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n\n\n\n\n\nclass XXHandshake {\n isInitiator;\n session;\n remotePeer;\n remoteExtensions = { webtransportCerthashes: [] };\n payload;\n connection;\n xx;\n staticKeypair;\n prologue;\n constructor(isInitiator, payload, prologue, crypto, staticKeypair, connection, remotePeer, handshake) {\n this.isInitiator = isInitiator;\n this.payload = payload;\n this.prologue = prologue;\n this.staticKeypair = staticKeypair;\n this.connection = connection;\n if (remotePeer) {\n this.remotePeer = remotePeer;\n }\n this.xx = handshake ?? new _handshakes_xx_js__WEBPACK_IMPORTED_MODULE_2__.XX(crypto);\n this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair);\n }\n // stage 0\n async propose() {\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logLocalStaticKeys)(this.session.hs.s);\n if (this.isInitiator) {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 0 - Initiator starting to send first message.');\n const messageBuffer = this.xx.sendMessage(this.session, new Uint8Array(0));\n this.connection.writeLP((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode0)(messageBuffer));\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 0 - Initiator finished sending first message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logLocalEphemeralKeys)(this.session.hs.e);\n }\n else {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 0 - Responder waiting to receive first message...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode0)((await this.connection.readLP()).subarray());\n const { valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.InvalidCryptoExchangeError('xx handshake stage 0 validation fail');\n }\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 0 - Responder received first message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logRemoteEphemeralKey)(this.session.hs.re);\n }\n }\n // stage 1\n async exchange() {\n if (this.isInitiator) {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 1 - Initiator waiting to receive first message from responder...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode1)((await this.connection.readLP()).subarray());\n const { plaintext, valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.InvalidCryptoExchangeError('xx handshake stage 1 validation fail');\n }\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 1 - Initiator received the message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logRemoteEphemeralKey)(this.session.hs.re);\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logRemoteStaticKey)(this.session.hs.rs);\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace(\"Initiator going to check remote's signature...\");\n try {\n const decodedPayload = (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.decodePayload)(plaintext);\n this.remotePeer = this.remotePeer || await (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.getPeerIdFromPayload)(decodedPayload);\n await (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.verifySignedPayload)(this.session.hs.rs, decodedPayload, this.remotePeer);\n this.setRemoteNoiseExtension(decodedPayload.extensions);\n }\n catch (e) {\n const err = e;\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedPeerError(`Error occurred while verifying signed payload: ${err.message}`);\n }\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('All good with the signature!');\n }\n else {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 1 - Responder sending out first message with signed payload and static key.');\n const messageBuffer = this.xx.sendMessage(this.session, this.payload);\n this.connection.writeLP((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode1)(messageBuffer));\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 1 - Responder sent the second handshake message with signed payload.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logLocalEphemeralKeys)(this.session.hs.e);\n }\n }\n // stage 2\n async finish() {\n if (this.isInitiator) {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 2 - Initiator sending third handshake message.');\n const messageBuffer = this.xx.sendMessage(this.session, this.payload);\n this.connection.writeLP((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode2)(messageBuffer));\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 2 - Initiator sent message with signed payload.');\n }\n else {\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 2 - Responder waiting for third handshake message...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode2)((await this.connection.readLP()).subarray());\n const { plaintext, valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.InvalidCryptoExchangeError('xx handshake stage 2 validation fail');\n }\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.trace('Stage 2 - Responder received the message, finished handshake.');\n try {\n const decodedPayload = (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.decodePayload)(plaintext);\n this.remotePeer = this.remotePeer || await (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.getPeerIdFromPayload)(decodedPayload);\n await (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.verifySignedPayload)(this.session.hs.rs, decodedPayload, this.remotePeer);\n this.setRemoteNoiseExtension(decodedPayload.extensions);\n }\n catch (e) {\n const err = e;\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedPeerError(`Error occurred while verifying signed payload: ${err.message}`);\n }\n }\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logCipherState)(this.session);\n }\n encrypt(plaintext, session) {\n const cs = this.getCS(session);\n return this.xx.encryptWithAd(cs, new Uint8Array(0), plaintext);\n }\n decrypt(ciphertext, session, dst) {\n const cs = this.getCS(session, false);\n return this.xx.decryptWithAd(cs, new Uint8Array(0), ciphertext, dst);\n }\n getRemoteStaticKey() {\n return this.session.hs.rs;\n }\n getCS(session, encryption = true) {\n if (!session.cs1 || !session.cs2) {\n throw new _libp2p_interface_connection_encrypter_errors__WEBPACK_IMPORTED_MODULE_0__.InvalidCryptoExchangeError('Handshake not completed properly, cipher state does not exist.');\n }\n if (this.isInitiator) {\n return encryption ? session.cs1 : session.cs2;\n }\n else {\n return encryption ? session.cs2 : session.cs1;\n }\n }\n setRemoteNoiseExtension(e) {\n if (e) {\n this.remoteExtensions = e;\n }\n }\n}\n//# sourceMappingURL=handshake-xx.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ XXHandshake: () => (/* binding */ XXHandshake)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/errors.js\");\n/* harmony import */ var _handshakes_xx_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./handshakes/xx.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js\");\n/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n\n\n\n\n\n\nclass XXHandshake {\n isInitiator;\n session;\n remotePeer;\n remoteExtensions = { webtransportCerthashes: [] };\n payload;\n connection;\n xx;\n staticKeypair;\n prologue;\n log;\n constructor(components, isInitiator, payload, prologue, crypto, staticKeypair, connection, remotePeer, handshake) {\n this.log = components.logger.forComponent('libp2p:noise:xxhandshake');\n this.isInitiator = isInitiator;\n this.payload = payload;\n this.prologue = prologue;\n this.staticKeypair = staticKeypair;\n this.connection = connection;\n if (remotePeer) {\n this.remotePeer = remotePeer;\n }\n this.xx = handshake ?? new _handshakes_xx_js__WEBPACK_IMPORTED_MODULE_3__.XX(components, crypto);\n this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair);\n }\n // stage 0\n async propose() {\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logLocalStaticKeys)(this.session.hs.s, this.log);\n if (this.isInitiator) {\n this.log.trace('Stage 0 - Initiator starting to send first message.');\n const messageBuffer = this.xx.sendMessage(this.session, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(0));\n await this.connection.write((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode0)(messageBuffer));\n this.log.trace('Stage 0 - Initiator finished sending first message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logLocalEphemeralKeys)(this.session.hs.e, this.log);\n }\n else {\n this.log.trace('Stage 0 - Responder waiting to receive first message...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode0)((await this.connection.read()).subarray());\n const { valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidCryptoExchangeError('xx handshake stage 0 validation fail');\n }\n this.log.trace('Stage 0 - Responder received first message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logRemoteEphemeralKey)(this.session.hs.re, this.log);\n }\n }\n // stage 1\n async exchange() {\n if (this.isInitiator) {\n this.log.trace('Stage 1 - Initiator waiting to receive first message from responder...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode1)((await this.connection.read()).subarray());\n const { plaintext, valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidCryptoExchangeError('xx handshake stage 1 validation fail');\n }\n this.log.trace('Stage 1 - Initiator received the message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logRemoteEphemeralKey)(this.session.hs.re, this.log);\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logRemoteStaticKey)(this.session.hs.rs, this.log);\n this.log.trace(\"Initiator going to check remote's signature...\");\n try {\n const decodedPayload = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.decodePayload)(plaintext);\n this.remotePeer = this.remotePeer || await (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.getPeerIdFromPayload)(decodedPayload);\n await (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.verifySignedPayload)(this.session.hs.rs, decodedPayload, this.remotePeer);\n this.setRemoteNoiseExtension(decodedPayload.extensions);\n }\n catch (e) {\n const err = e;\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.UnexpectedPeerError(`Error occurred while verifying signed payload: ${err.message}`);\n }\n this.log.trace('All good with the signature!');\n }\n else {\n this.log.trace('Stage 1 - Responder sending out first message with signed payload and static key.');\n const messageBuffer = this.xx.sendMessage(this.session, this.payload);\n await this.connection.write((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode1)(messageBuffer));\n this.log.trace('Stage 1 - Responder sent the second handshake message with signed payload.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logLocalEphemeralKeys)(this.session.hs.e, this.log);\n }\n }\n // stage 2\n async finish() {\n if (this.isInitiator) {\n this.log.trace('Stage 2 - Initiator sending third handshake message.');\n const messageBuffer = this.xx.sendMessage(this.session, this.payload);\n await this.connection.write((0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.encode2)(messageBuffer));\n this.log.trace('Stage 2 - Initiator sent message with signed payload.');\n }\n else {\n this.log.trace('Stage 2 - Responder waiting for third handshake message...');\n const receivedMessageBuffer = (0,_encoder_js__WEBPACK_IMPORTED_MODULE_1__.decode2)((await this.connection.read()).subarray());\n const { plaintext, valid } = this.xx.recvMessage(this.session, receivedMessageBuffer);\n if (!valid) {\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidCryptoExchangeError('xx handshake stage 2 validation fail');\n }\n this.log.trace('Stage 2 - Responder received the message, finished handshake.');\n try {\n const decodedPayload = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.decodePayload)(plaintext);\n this.remotePeer = this.remotePeer || await (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.getPeerIdFromPayload)(decodedPayload);\n await (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.verifySignedPayload)(this.session.hs.rs, decodedPayload, this.remotePeer);\n this.setRemoteNoiseExtension(decodedPayload.extensions);\n }\n catch (e) {\n const err = e;\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.UnexpectedPeerError(`Error occurred while verifying signed payload: ${err.message}`);\n }\n }\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.logCipherState)(this.session, this.log);\n }\n encrypt(plaintext, session) {\n const cs = this.getCS(session);\n return this.xx.encryptWithAd(cs, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(0), plaintext);\n }\n decrypt(ciphertext, session, dst) {\n const cs = this.getCS(session, false);\n return this.xx.decryptWithAd(cs, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(0), ciphertext, dst);\n }\n getRemoteStaticKey() {\n return this.session.hs.rs;\n }\n getCS(session, encryption = true) {\n if (!session.cs1 || !session.cs2) {\n throw new _errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidCryptoExchangeError('Handshake not completed properly, cipher state does not exist.');\n }\n if (this.isInitiator) {\n return encryption ? session.cs1 : session.cs2;\n }\n else {\n return encryption ? session.cs2 : session.cs1;\n }\n }\n setRemoteNoiseExtension(e) {\n if (e) {\n this.remoteExtensions = e;\n }\n }\n}\n//# sourceMappingURL=handshake-xx.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js?"); /***/ }), @@ -2133,7 +2074,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbstractHandshake: () => (/* binding */ AbstractHandshake)\n/* harmony export */ });\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../logger.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js\");\n/* harmony import */ var _nonce_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../nonce.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js\");\n\n\n\n\n\nclass AbstractHandshake {\n crypto;\n constructor(crypto) {\n this.crypto = crypto;\n }\n encryptWithAd(cs, ad, plaintext) {\n const e = this.encrypt(cs.k, cs.n, ad, plaintext);\n cs.n.increment();\n return e;\n }\n decryptWithAd(cs, ad, ciphertext, dst) {\n const { plaintext, valid } = this.decrypt(cs.k, cs.n, ad, ciphertext, dst);\n if (valid)\n cs.n.increment();\n return { plaintext, valid };\n }\n // Cipher state related\n hasKey(cs) {\n return !this.isEmptyKey(cs.k);\n }\n createEmptyKey() {\n return new Uint8Array(32);\n }\n isEmptyKey(k) {\n const emptyKey = this.createEmptyKey();\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(emptyKey, k);\n }\n encrypt(k, n, ad, plaintext) {\n n.assertValue();\n return this.crypto.chaCha20Poly1305Encrypt(plaintext, n.getBytes(), ad, k);\n }\n encryptAndHash(ss, plaintext) {\n let ciphertext;\n if (this.hasKey(ss.cs)) {\n ciphertext = this.encryptWithAd(ss.cs, ss.h, plaintext);\n }\n else {\n ciphertext = plaintext;\n }\n this.mixHash(ss, ciphertext);\n return ciphertext;\n }\n decrypt(k, n, ad, ciphertext, dst) {\n n.assertValue();\n const encryptedMessage = this.crypto.chaCha20Poly1305Decrypt(ciphertext, n.getBytes(), ad, k, dst);\n if (encryptedMessage) {\n return {\n plaintext: encryptedMessage,\n valid: true\n };\n }\n else {\n return {\n plaintext: new Uint8Array(0),\n valid: false\n };\n }\n }\n decryptAndHash(ss, ciphertext) {\n let plaintext;\n let valid = true;\n if (this.hasKey(ss.cs)) {\n ({ plaintext, valid } = this.decryptWithAd(ss.cs, ss.h, ciphertext));\n }\n else {\n plaintext = ciphertext;\n }\n this.mixHash(ss, ciphertext);\n return { plaintext, valid };\n }\n dh(privateKey, publicKey) {\n try {\n const derivedU8 = this.crypto.generateX25519SharedKey(privateKey, publicKey);\n if (derivedU8.length === 32) {\n return derivedU8;\n }\n return derivedU8.subarray(0, 32);\n }\n catch (e) {\n const err = e;\n _logger_js__WEBPACK_IMPORTED_MODULE_3__.logger.error(err);\n return new Uint8Array(32);\n }\n }\n mixHash(ss, data) {\n ss.h = this.getHash(ss.h, data);\n }\n getHash(a, b) {\n const u = this.crypto.hashSHA256((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([a, b], a.length + b.length));\n return u;\n }\n mixKey(ss, ikm) {\n const [ck, tempK] = this.crypto.getHKDF(ss.ck, ikm);\n ss.cs = this.initializeKey(tempK);\n ss.ck = ck;\n }\n initializeKey(k) {\n return { k, n: new _nonce_js__WEBPACK_IMPORTED_MODULE_4__.Nonce() };\n }\n // Symmetric state related\n initializeSymmetric(protocolName) {\n const protocolNameBytes = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_0__.fromString)(protocolName, 'utf-8');\n const h = this.hashProtocolName(protocolNameBytes);\n const ck = h;\n const key = this.createEmptyKey();\n const cs = this.initializeKey(key);\n return { cs, ck, h };\n }\n hashProtocolName(protocolName) {\n if (protocolName.length <= 32) {\n const h = new Uint8Array(32);\n h.set(protocolName);\n return h;\n }\n else {\n return this.getHash(protocolName, new Uint8Array(0));\n }\n }\n split(ss) {\n const [tempk1, tempk2] = this.crypto.getHKDF(ss.ck, new Uint8Array(0));\n const cs1 = this.initializeKey(tempk1);\n const cs2 = this.initializeKey(tempk2);\n return { cs1, cs2 };\n }\n writeMessageRegular(cs, payload) {\n const ciphertext = this.encryptWithAd(cs, new Uint8Array(0), payload);\n const ne = this.createEmptyKey();\n const ns = new Uint8Array(0);\n return { ne, ns, ciphertext };\n }\n readMessageRegular(cs, message) {\n return this.decryptWithAd(cs, new Uint8Array(0), message.ciphertext);\n }\n}\n//# sourceMappingURL=abstract-handshake.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbstractHandshake: () => (/* binding */ AbstractHandshake)\n/* harmony export */ });\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _nonce_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../nonce.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js\");\n\n\n\n\n\nclass AbstractHandshake {\n crypto;\n log;\n constructor(components, crypto) {\n this.log = components.logger.forComponent('libp2p:noise:abstract-handshake');\n this.crypto = crypto;\n }\n encryptWithAd(cs, ad, plaintext) {\n const e = this.encrypt(cs.k, cs.n, ad, plaintext);\n cs.n.increment();\n return e;\n }\n decryptWithAd(cs, ad, ciphertext, dst) {\n const { plaintext, valid } = this.decrypt(cs.k, cs.n, ad, ciphertext, dst);\n if (valid)\n cs.n.increment();\n return { plaintext, valid };\n }\n // Cipher state related\n hasKey(cs) {\n return !this.isEmptyKey(cs.k);\n }\n createEmptyKey() {\n return (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(32);\n }\n isEmptyKey(k) {\n const emptyKey = this.createEmptyKey();\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(emptyKey, k);\n }\n encrypt(k, n, ad, plaintext) {\n n.assertValue();\n return this.crypto.chaCha20Poly1305Encrypt(plaintext, n.getBytes(), ad, k);\n }\n encryptAndHash(ss, plaintext) {\n let ciphertext;\n if (this.hasKey(ss.cs)) {\n ciphertext = this.encryptWithAd(ss.cs, ss.h, plaintext);\n }\n else {\n ciphertext = plaintext;\n }\n this.mixHash(ss, ciphertext);\n return ciphertext;\n }\n decrypt(k, n, ad, ciphertext, dst) {\n n.assertValue();\n const encryptedMessage = this.crypto.chaCha20Poly1305Decrypt(ciphertext, n.getBytes(), ad, k, dst);\n if (encryptedMessage) {\n return {\n plaintext: encryptedMessage,\n valid: true\n };\n }\n else {\n return {\n plaintext: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0),\n valid: false\n };\n }\n }\n decryptAndHash(ss, ciphertext) {\n let plaintext;\n let valid = true;\n if (this.hasKey(ss.cs)) {\n ({ plaintext, valid } = this.decryptWithAd(ss.cs, ss.h, ciphertext));\n }\n else {\n plaintext = ciphertext;\n }\n this.mixHash(ss, ciphertext);\n return { plaintext, valid };\n }\n dh(privateKey, publicKey) {\n try {\n const derivedU8 = this.crypto.generateX25519SharedKey(privateKey, publicKey);\n if (derivedU8.length === 32) {\n return derivedU8;\n }\n return derivedU8.subarray(0, 32);\n }\n catch (e) {\n const err = e;\n this.log.error('error deriving shared key', err);\n return (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(32);\n }\n }\n mixHash(ss, data) {\n ss.h = this.getHash(ss.h, data);\n }\n getHash(a, b) {\n const u = this.crypto.hashSHA256(new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(a, b));\n return u;\n }\n mixKey(ss, ikm) {\n const [ck, tempK] = this.crypto.getHKDF(ss.ck, ikm);\n ss.cs = this.initializeKey(tempK);\n ss.ck = ck;\n }\n initializeKey(k) {\n return { k, n: new _nonce_js__WEBPACK_IMPORTED_MODULE_4__.Nonce() };\n }\n // Symmetric state related\n initializeSymmetric(protocolName) {\n const protocolNameBytes = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_1__.fromString)(protocolName, 'utf-8');\n const h = this.hashProtocolName(protocolNameBytes);\n const ck = h;\n const key = this.createEmptyKey();\n const cs = this.initializeKey(key);\n return { cs, ck, h };\n }\n hashProtocolName(protocolName) {\n if (protocolName.length <= 32) {\n const h = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(32);\n h.set(protocolName);\n return h;\n }\n else {\n return this.getHash(protocolName, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0));\n }\n }\n split(ss) {\n const [tempk1, tempk2] = this.crypto.getHKDF(ss.ck, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0));\n const cs1 = this.initializeKey(tempk1);\n const cs2 = this.initializeKey(tempk2);\n return { cs1, cs2 };\n }\n writeMessageRegular(cs, payload) {\n const ciphertext = this.encryptWithAd(cs, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0), payload);\n const ne = this.createEmptyKey();\n const ns = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0);\n return { ne, ns, ciphertext };\n }\n readMessageRegular(cs, message) {\n return this.decryptWithAd(cs, (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.alloc)(0), message.ciphertext);\n }\n}\n//# sourceMappingURL=abstract-handshake.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js?"); /***/ }), @@ -2144,7 +2085,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ XX: () => (/* binding */ XX)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n/* harmony import */ var _abstract_handshake_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstract-handshake.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js\");\n\n\nclass XX extends _abstract_handshake_js__WEBPACK_IMPORTED_MODULE_1__.AbstractHandshake {\n initializeInitiator(prologue, s, rs, psk) {\n const name = 'Noise_XX_25519_ChaChaPoly_SHA256';\n const ss = this.initializeSymmetric(name);\n this.mixHash(ss, prologue);\n const re = new Uint8Array(32);\n return { ss, s, rs, psk, re };\n }\n initializeResponder(prologue, s, rs, psk) {\n const name = 'Noise_XX_25519_ChaChaPoly_SHA256';\n const ss = this.initializeSymmetric(name);\n this.mixHash(ss, prologue);\n const re = new Uint8Array(32);\n return { ss, s, rs, psk, re };\n }\n writeMessageA(hs, payload, e) {\n const ns = new Uint8Array(0);\n if (e !== undefined) {\n hs.e = e;\n }\n else {\n hs.e = this.crypto.generateX25519KeyPair();\n }\n const ne = hs.e.publicKey;\n this.mixHash(hs.ss, ne);\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n return { ne, ns, ciphertext };\n }\n writeMessageB(hs, payload) {\n hs.e = this.crypto.generateX25519KeyPair();\n const ne = hs.e.publicKey;\n this.mixHash(hs.ss, ne);\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.re));\n const spk = hs.s.publicKey;\n const ns = this.encryptAndHash(hs.ss, spk);\n this.mixKey(hs.ss, this.dh(hs.s.privateKey, hs.re));\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n return { ne, ns, ciphertext };\n }\n writeMessageC(hs, payload) {\n const spk = hs.s.publicKey;\n const ns = this.encryptAndHash(hs.ss, spk);\n this.mixKey(hs.ss, this.dh(hs.s.privateKey, hs.re));\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n const ne = this.createEmptyKey();\n const messageBuffer = { ne, ns, ciphertext };\n const { cs1, cs2 } = this.split(hs.ss);\n return { h: hs.ss.h, messageBuffer, cs1, cs2 };\n }\n readMessageA(hs, message) {\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidPublicKey)(message.ne)) {\n hs.re = message.ne;\n }\n this.mixHash(hs.ss, hs.re);\n return this.decryptAndHash(hs.ss, message.ciphertext);\n }\n readMessageB(hs, message) {\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidPublicKey)(message.ne)) {\n hs.re = message.ne;\n }\n this.mixHash(hs.ss, hs.re);\n if (!hs.e) {\n throw new Error('Handshake state `e` param is missing.');\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.re));\n const { plaintext: ns, valid: valid1 } = this.decryptAndHash(hs.ss, message.ns);\n if (valid1 && (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidPublicKey)(ns)) {\n hs.rs = ns;\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.rs));\n const { plaintext, valid: valid2 } = this.decryptAndHash(hs.ss, message.ciphertext);\n return { plaintext, valid: (valid1 && valid2) };\n }\n readMessageC(hs, message) {\n const { plaintext: ns, valid: valid1 } = this.decryptAndHash(hs.ss, message.ns);\n if (valid1 && (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidPublicKey)(ns)) {\n hs.rs = ns;\n }\n if (!hs.e) {\n throw new Error('Handshake state `e` param is missing.');\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.rs));\n const { plaintext, valid: valid2 } = this.decryptAndHash(hs.ss, message.ciphertext);\n const { cs1, cs2 } = this.split(hs.ss);\n return { h: hs.ss.h, plaintext, valid: (valid1 && valid2), cs1, cs2 };\n }\n initSession(initiator, prologue, s) {\n const psk = this.createEmptyKey();\n const rs = new Uint8Array(32); // no static key yet\n let hs;\n if (initiator) {\n hs = this.initializeInitiator(prologue, s, rs, psk);\n }\n else {\n hs = this.initializeResponder(prologue, s, rs, psk);\n }\n return {\n hs,\n i: initiator,\n mc: 0\n };\n }\n sendMessage(session, message, ephemeral) {\n let messageBuffer;\n if (session.mc === 0) {\n messageBuffer = this.writeMessageA(session.hs, message, ephemeral);\n }\n else if (session.mc === 1) {\n messageBuffer = this.writeMessageB(session.hs, message);\n }\n else if (session.mc === 2) {\n const { h, messageBuffer: resultingBuffer, cs1, cs2 } = this.writeMessageC(session.hs, message);\n messageBuffer = resultingBuffer;\n session.h = h;\n session.cs1 = cs1;\n session.cs2 = cs2;\n }\n else if (session.mc > 2) {\n if (session.i) {\n if (!session.cs1) {\n throw new Error('CS1 (cipher state) is not defined');\n }\n messageBuffer = this.writeMessageRegular(session.cs1, message);\n }\n else {\n if (!session.cs2) {\n throw new Error('CS2 (cipher state) is not defined');\n }\n messageBuffer = this.writeMessageRegular(session.cs2, message);\n }\n }\n else {\n throw new Error('Session invalid.');\n }\n session.mc++;\n return messageBuffer;\n }\n recvMessage(session, message) {\n let plaintext = new Uint8Array(0);\n let valid = false;\n if (session.mc === 0) {\n ({ plaintext, valid } = this.readMessageA(session.hs, message));\n }\n else if (session.mc === 1) {\n ({ plaintext, valid } = this.readMessageB(session.hs, message));\n }\n else if (session.mc === 2) {\n const { h, plaintext: resultingPlaintext, valid: resultingValid, cs1, cs2 } = this.readMessageC(session.hs, message);\n plaintext = resultingPlaintext;\n valid = resultingValid;\n session.h = h;\n session.cs1 = cs1;\n session.cs2 = cs2;\n }\n session.mc++;\n return { plaintext, valid };\n }\n}\n//# sourceMappingURL=xx.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ XX: () => (/* binding */ XX)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n/* harmony import */ var _abstract_handshake_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstract-handshake.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js\");\n\n\n\nclass XX extends _abstract_handshake_js__WEBPACK_IMPORTED_MODULE_2__.AbstractHandshake {\n initializeInitiator(prologue, s, rs, psk) {\n const name = 'Noise_XX_25519_ChaChaPoly_SHA256';\n const ss = this.initializeSymmetric(name);\n this.mixHash(ss, prologue);\n const re = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(32);\n return { ss, s, rs, psk, re };\n }\n initializeResponder(prologue, s, rs, psk) {\n const name = 'Noise_XX_25519_ChaChaPoly_SHA256';\n const ss = this.initializeSymmetric(name);\n this.mixHash(ss, prologue);\n const re = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(32);\n return { ss, s, rs, psk, re };\n }\n writeMessageA(hs, payload, e) {\n const ns = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(0);\n if (e !== undefined) {\n hs.e = e;\n }\n else {\n hs.e = this.crypto.generateX25519KeyPair();\n }\n const ne = hs.e.publicKey;\n this.mixHash(hs.ss, ne);\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n return { ne, ns, ciphertext };\n }\n writeMessageB(hs, payload) {\n hs.e = this.crypto.generateX25519KeyPair();\n const ne = hs.e.publicKey;\n this.mixHash(hs.ss, ne);\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.re));\n const spk = hs.s.publicKey;\n const ns = this.encryptAndHash(hs.ss, spk);\n this.mixKey(hs.ss, this.dh(hs.s.privateKey, hs.re));\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n return { ne, ns, ciphertext };\n }\n writeMessageC(hs, payload) {\n const spk = hs.s.publicKey;\n const ns = this.encryptAndHash(hs.ss, spk);\n this.mixKey(hs.ss, this.dh(hs.s.privateKey, hs.re));\n const ciphertext = this.encryptAndHash(hs.ss, payload);\n const ne = this.createEmptyKey();\n const messageBuffer = { ne, ns, ciphertext };\n const { cs1, cs2 } = this.split(hs.ss);\n return { h: hs.ss.h, messageBuffer, cs1, cs2 };\n }\n readMessageA(hs, message) {\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidPublicKey)(message.ne)) {\n hs.re = message.ne;\n }\n this.mixHash(hs.ss, hs.re);\n return this.decryptAndHash(hs.ss, message.ciphertext);\n }\n readMessageB(hs, message) {\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidPublicKey)(message.ne)) {\n hs.re = message.ne;\n }\n this.mixHash(hs.ss, hs.re);\n if (!hs.e) {\n throw new Error('Handshake state `e` param is missing.');\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.re));\n const { plaintext: ns, valid: valid1 } = this.decryptAndHash(hs.ss, message.ns);\n if (valid1 && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidPublicKey)(ns)) {\n hs.rs = ns;\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.rs));\n const { plaintext, valid: valid2 } = this.decryptAndHash(hs.ss, message.ciphertext);\n return { plaintext, valid: (valid1 && valid2) };\n }\n readMessageC(hs, message) {\n const { plaintext: ns, valid: valid1 } = this.decryptAndHash(hs.ss, message.ns);\n if (valid1 && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidPublicKey)(ns)) {\n hs.rs = ns;\n }\n if (!hs.e) {\n throw new Error('Handshake state `e` param is missing.');\n }\n this.mixKey(hs.ss, this.dh(hs.e.privateKey, hs.rs));\n const { plaintext, valid: valid2 } = this.decryptAndHash(hs.ss, message.ciphertext);\n const { cs1, cs2 } = this.split(hs.ss);\n return { h: hs.ss.h, plaintext, valid: (valid1 && valid2), cs1, cs2 };\n }\n initSession(initiator, prologue, s) {\n const psk = this.createEmptyKey();\n const rs = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(32); // no static key yet\n let hs;\n if (initiator) {\n hs = this.initializeInitiator(prologue, s, rs, psk);\n }\n else {\n hs = this.initializeResponder(prologue, s, rs, psk);\n }\n return {\n hs,\n i: initiator,\n mc: 0\n };\n }\n sendMessage(session, message, ephemeral) {\n let messageBuffer;\n if (session.mc === 0) {\n messageBuffer = this.writeMessageA(session.hs, message, ephemeral);\n }\n else if (session.mc === 1) {\n messageBuffer = this.writeMessageB(session.hs, message);\n }\n else if (session.mc === 2) {\n const { h, messageBuffer: resultingBuffer, cs1, cs2 } = this.writeMessageC(session.hs, message);\n messageBuffer = resultingBuffer;\n session.h = h;\n session.cs1 = cs1;\n session.cs2 = cs2;\n }\n else if (session.mc > 2) {\n if (session.i) {\n if (!session.cs1) {\n throw new Error('CS1 (cipher state) is not defined');\n }\n messageBuffer = this.writeMessageRegular(session.cs1, message);\n }\n else {\n if (!session.cs2) {\n throw new Error('CS2 (cipher state) is not defined');\n }\n messageBuffer = this.writeMessageRegular(session.cs2, message);\n }\n }\n else {\n throw new Error('Session invalid.');\n }\n session.mc++;\n return messageBuffer;\n }\n recvMessage(session, message) {\n let plaintext = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(0);\n let valid = false;\n if (session.mc === 0) {\n ({ plaintext, valid } = this.readMessageA(session.hs, message));\n }\n else if (session.mc === 1) {\n ({ plaintext, valid } = this.readMessageB(session.hs, message));\n }\n else if (session.mc === 2) {\n const { h, plaintext: resultingPlaintext, valid: resultingValid, cs1, cs2 } = this.readMessageC(session.hs, message);\n plaintext = resultingPlaintext;\n valid = resultingValid;\n session.h = h;\n session.cs1 = cs1;\n session.cs2 = cs2;\n }\n session.mc++;\n return { plaintext, valid };\n }\n}\n//# sourceMappingURL=xx.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js?"); /***/ }), @@ -2155,7 +2096,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ noise: () => (/* binding */ noise),\n/* harmony export */ pureJsCrypto: () => (/* reexport safe */ _crypto_js_js__WEBPACK_IMPORTED_MODULE_1__.pureJsCrypto)\n/* harmony export */ });\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js\");\n/* harmony import */ var _crypto_js_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto/js.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js\");\n\n\nfunction noise(init = {}) {\n return () => new _noise_js__WEBPACK_IMPORTED_MODULE_0__.Noise(init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ noise: () => (/* binding */ noise),\n/* harmony export */ pureJsCrypto: () => (/* reexport safe */ _crypto_js_js__WEBPACK_IMPORTED_MODULE_1__.pureJsCrypto)\n/* harmony export */ });\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js\");\n/* harmony import */ var _crypto_js_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto/js.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js\");\n\n\nfunction noise(init = {}) {\n return (components) => new _noise_js__WEBPACK_IMPORTED_MODULE_0__.Noise(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/index.js?"); /***/ }), @@ -2166,7 +2107,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ logCipherState: () => (/* binding */ logCipherState),\n/* harmony export */ logLocalEphemeralKeys: () => (/* binding */ logLocalEphemeralKeys),\n/* harmony export */ logLocalStaticKeys: () => (/* binding */ logLocalStaticKeys),\n/* harmony export */ logRemoteEphemeralKey: () => (/* binding */ logRemoteEphemeralKey),\n/* harmony export */ logRemoteStaticKey: () => (/* binding */ logRemoteStaticKey),\n/* harmony export */ logger: () => (/* binding */ log)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:noise');\n\nlet keyLogger;\nif (_constants_js__WEBPACK_IMPORTED_MODULE_2__.DUMP_SESSION_KEYS) {\n keyLogger = log;\n}\nelse {\n keyLogger = Object.assign(() => { }, {\n enabled: false,\n trace: () => { },\n error: () => { }\n });\n}\nfunction logLocalStaticKeys(s) {\n keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(s.publicKey, 'hex')}`);\n keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(s.privateKey, 'hex')}`);\n}\nfunction logLocalEphemeralKeys(e) {\n if (e) {\n keyLogger(`LOCAL_PUBLIC_EPHEMERAL_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(e.publicKey, 'hex')}`);\n keyLogger(`LOCAL_PRIVATE_EPHEMERAL_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(e.privateKey, 'hex')}`);\n }\n else {\n keyLogger('Missing local ephemeral keys.');\n }\n}\nfunction logRemoteStaticKey(rs) {\n keyLogger(`REMOTE_STATIC_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(rs, 'hex')}`);\n}\nfunction logRemoteEphemeralKey(re) {\n keyLogger(`REMOTE_EPHEMERAL_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(re, 'hex')}`);\n}\nfunction logCipherState(session) {\n if (session.cs1 && session.cs2) {\n keyLogger(`CIPHER_STATE_1 ${session.cs1.n.getUint64()} ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(session.cs1.k, 'hex')}`);\n keyLogger(`CIPHER_STATE_2 ${session.cs2.n.getUint64()} ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(session.cs2.k, 'hex')}`);\n }\n else {\n keyLogger('Missing cipher state.');\n }\n}\n//# sourceMappingURL=logger.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ logCipherState: () => (/* binding */ logCipherState),\n/* harmony export */ logLocalEphemeralKeys: () => (/* binding */ logLocalEphemeralKeys),\n/* harmony export */ logLocalStaticKeys: () => (/* binding */ logLocalStaticKeys),\n/* harmony export */ logRemoteEphemeralKey: () => (/* binding */ logRemoteEphemeralKey),\n/* harmony export */ logRemoteStaticKey: () => (/* binding */ logRemoteStaticKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n\n\nfunction logLocalStaticKeys(s, keyLogger) {\n if (!keyLogger.enabled || !_constants_js__WEBPACK_IMPORTED_MODULE_1__.DUMP_SESSION_KEYS) {\n return;\n }\n keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(s.publicKey, 'hex')}`);\n keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(s.privateKey, 'hex')}`);\n}\nfunction logLocalEphemeralKeys(e, keyLogger) {\n if (!keyLogger.enabled || !_constants_js__WEBPACK_IMPORTED_MODULE_1__.DUMP_SESSION_KEYS) {\n return;\n }\n if (e) {\n keyLogger(`LOCAL_PUBLIC_EPHEMERAL_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(e.publicKey, 'hex')}`);\n keyLogger(`LOCAL_PRIVATE_EPHEMERAL_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(e.privateKey, 'hex')}`);\n }\n else {\n keyLogger('Missing local ephemeral keys.');\n }\n}\nfunction logRemoteStaticKey(rs, keyLogger) {\n if (!keyLogger.enabled || !_constants_js__WEBPACK_IMPORTED_MODULE_1__.DUMP_SESSION_KEYS) {\n return;\n }\n keyLogger(`REMOTE_STATIC_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(rs.subarray(), 'hex')}`);\n}\nfunction logRemoteEphemeralKey(re, keyLogger) {\n if (!keyLogger.enabled || !_constants_js__WEBPACK_IMPORTED_MODULE_1__.DUMP_SESSION_KEYS) {\n return;\n }\n keyLogger(`REMOTE_EPHEMERAL_PUBLIC_KEY ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(re.subarray(), 'hex')}`);\n}\nfunction logCipherState(session, keyLogger) {\n if (!keyLogger.enabled || !_constants_js__WEBPACK_IMPORTED_MODULE_1__.DUMP_SESSION_KEYS) {\n return;\n }\n if (session.cs1 && session.cs2) {\n keyLogger(`CIPHER_STATE_1 ${session.cs1.n.getUint64()} ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(session.cs1.k, 'hex')}`);\n keyLogger(`CIPHER_STATE_2 ${session.cs2.n.getUint64()} ${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(session.cs2.k, 'hex')}`);\n }\n else {\n keyLogger('Missing cipher state.');\n }\n}\n//# sourceMappingURL=logger.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js?"); /***/ }), @@ -2188,7 +2129,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Noise: () => (/* binding */ Noise)\n/* harmony export */ });\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pair_duplex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pair/duplex */ \"./node_modules/it-pair/dist/src/duplex.js\");\n/* harmony import */ var it_pb_stream__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pb-stream */ \"./node_modules/it-pb-stream/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n/* harmony import */ var _crypto_js_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./crypto/js.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/js.js\");\n/* harmony import */ var _crypto_streaming_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./crypto/streaming.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n/* harmony import */ var _handshake_xx_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./handshake-xx.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n\n\n\n\n\n\n\n\n\n\n\nclass Noise {\n protocol = '/noise';\n crypto;\n prologue;\n staticKeys;\n extensions;\n metrics;\n constructor(init = {}) {\n const { staticNoiseKey, extensions, crypto, prologueBytes, metrics } = init;\n this.crypto = crypto ?? _crypto_js_js__WEBPACK_IMPORTED_MODULE_5__.pureJsCrypto;\n this.extensions = extensions;\n this.metrics = metrics ? (0,_metrics_js__WEBPACK_IMPORTED_MODULE_9__.registerMetrics)(metrics) : undefined;\n if (staticNoiseKey) {\n // accepts x25519 private key of length 32\n this.staticKeys = this.crypto.generateX25519KeyPairFromSeed(staticNoiseKey);\n }\n else {\n this.staticKeys = this.crypto.generateX25519KeyPair();\n }\n this.prologue = prologueBytes ?? new Uint8Array(0);\n }\n /**\n * Encrypt outgoing data to the remote party (handshake as initiator)\n *\n * @param {PeerId} localPeer - PeerId of the receiving peer\n * @param {Duplex, AsyncIterable, Promise>} connection - streaming iterable duplex that will be encrypted\n * @param {PeerId} remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer.\n * @returns {Promise}\n */\n async secureOutbound(localPeer, connection, remotePeer) {\n const wrappedConnection = (0,it_pb_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(connection, {\n lengthEncoder: _encoder_js__WEBPACK_IMPORTED_MODULE_7__.uint16BEEncode,\n lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_7__.uint16BEDecode,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_4__.NOISE_MSG_MAX_LENGTH_BYTES\n });\n const handshake = await this.performHandshake({\n connection: wrappedConnection,\n isInitiator: true,\n localPeer,\n remotePeer\n });\n const conn = await this.createSecureConnection(wrappedConnection, handshake);\n return {\n conn,\n remoteExtensions: handshake.remoteExtensions,\n remotePeer: handshake.remotePeer\n };\n }\n /**\n * Decrypt incoming data (handshake as responder).\n *\n * @param {PeerId} localPeer - PeerId of the receiving peer.\n * @param {Duplex, AsyncIterable, Promise>} connection - streaming iterable duplex that will be encryption.\n * @param {PeerId} remotePeer - optional PeerId of the initiating peer, if known. This may only exist during transport upgrades.\n * @returns {Promise}\n */\n async secureInbound(localPeer, connection, remotePeer) {\n const wrappedConnection = (0,it_pb_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(connection, {\n lengthEncoder: _encoder_js__WEBPACK_IMPORTED_MODULE_7__.uint16BEEncode,\n lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_7__.uint16BEDecode,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_4__.NOISE_MSG_MAX_LENGTH_BYTES\n });\n const handshake = await this.performHandshake({\n connection: wrappedConnection,\n isInitiator: false,\n localPeer,\n remotePeer\n });\n const conn = await this.createSecureConnection(wrappedConnection, handshake);\n return {\n conn,\n remotePeer: handshake.remotePeer,\n remoteExtensions: handshake.remoteExtensions\n };\n }\n /**\n * If Noise pipes supported, tries IK handshake first with XX as fallback if it fails.\n * If noise pipes disabled or remote peer static key is unknown, use XX.\n *\n * @param {HandshakeParams} params\n */\n async performHandshake(params) {\n const payload = await (0,_utils_js__WEBPACK_IMPORTED_MODULE_10__.getPayload)(params.localPeer, this.staticKeys.publicKey, this.extensions);\n // run XX handshake\n return this.performXXHandshake(params, payload);\n }\n async performXXHandshake(params, payload) {\n const { isInitiator, remotePeer, connection } = params;\n const handshake = new _handshake_xx_js__WEBPACK_IMPORTED_MODULE_8__.XXHandshake(isInitiator, payload, this.prologue, this.crypto, this.staticKeys, connection, remotePeer);\n try {\n await handshake.propose();\n await handshake.exchange();\n await handshake.finish();\n this.metrics?.xxHandshakeSuccesses.increment();\n }\n catch (e) {\n this.metrics?.xxHandshakeErrors.increment();\n if (e instanceof Error) {\n e.message = `Error occurred during XX handshake: ${e.message}`;\n throw e;\n }\n }\n return handshake;\n }\n async createSecureConnection(connection, handshake) {\n // Create encryption box/unbox wrapper\n const [secure, user] = (0,it_pair_duplex__WEBPACK_IMPORTED_MODULE_1__.duplexPair)();\n const network = connection.unwrap();\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)(secure, // write to wrapper\n (0,_crypto_streaming_js__WEBPACK_IMPORTED_MODULE_6__.encryptStream)(handshake, this.metrics), // encrypt data + prefix with message length\n network, // send to the remote peer\n (source) => (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.decode)(source, { lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_7__.uint16BEDecode }), // read message length prefix\n (0,_crypto_streaming_js__WEBPACK_IMPORTED_MODULE_6__.decryptStream)(handshake, this.metrics), // decrypt the incoming data\n secure // pipe to the wrapper\n );\n return user;\n }\n}\n//# sourceMappingURL=noise.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Noise: () => (/* binding */ Noise)\n/* harmony export */ });\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-length-prefixed-stream */ \"./node_modules/it-length-prefixed-stream/dist/src/index.js\");\n/* harmony import */ var it_pair_duplex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pair/duplex */ \"./node_modules/it-pair/dist/src/duplex.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n/* harmony import */ var _crypto_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./crypto/index.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.browser.js\");\n/* harmony import */ var _crypto_streaming_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./crypto/streaming.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js\");\n/* harmony import */ var _encoder_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./encoder.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n/* harmony import */ var _handshake_xx_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./handshake-xx.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nclass Noise {\n protocol = '/noise';\n crypto;\n prologue;\n staticKeys;\n extensions;\n metrics;\n components;\n constructor(components, init = {}) {\n const { staticNoiseKey, extensions, crypto, prologueBytes } = init;\n const { metrics } = components;\n this.components = components;\n this.crypto = crypto ?? _crypto_index_js__WEBPACK_IMPORTED_MODULE_6__.defaultCrypto;\n this.extensions = extensions;\n this.metrics = metrics ? (0,_metrics_js__WEBPACK_IMPORTED_MODULE_10__.registerMetrics)(metrics) : undefined;\n if (staticNoiseKey) {\n // accepts x25519 private key of length 32\n this.staticKeys = this.crypto.generateX25519KeyPairFromSeed(staticNoiseKey);\n }\n else {\n this.staticKeys = this.crypto.generateX25519KeyPair();\n }\n this.prologue = prologueBytes ?? (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_4__.alloc)(0);\n }\n /**\n * Encrypt outgoing data to the remote party (handshake as initiator)\n *\n * @param {PeerId} localPeer - PeerId of the receiving peer\n * @param {Stream} connection - streaming iterable duplex that will be encrypted\n * @param {PeerId} remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer.\n * @returns {Promise>}\n */\n async secureOutbound(localPeer, connection, remotePeer) {\n const wrappedConnection = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_1__.lpStream)(connection, {\n lengthEncoder: _encoder_js__WEBPACK_IMPORTED_MODULE_8__.uint16BEEncode,\n lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_8__.uint16BEDecode,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_5__.NOISE_MSG_MAX_LENGTH_BYTES\n });\n const handshake = await this.performHandshake({\n connection: wrappedConnection,\n isInitiator: true,\n localPeer,\n remotePeer\n });\n const conn = await this.createSecureConnection(wrappedConnection, handshake);\n connection.source = conn.source;\n connection.sink = conn.sink;\n return {\n conn: connection,\n remoteExtensions: handshake.remoteExtensions,\n remotePeer: handshake.remotePeer\n };\n }\n /**\n * Decrypt incoming data (handshake as responder).\n *\n * @param {PeerId} localPeer - PeerId of the receiving peer.\n * @param {Stream} connection - streaming iterable duplex that will be encrypted.\n * @param {PeerId} remotePeer - optional PeerId of the initiating peer, if known. This may only exist during transport upgrades.\n * @returns {Promise>}\n */\n async secureInbound(localPeer, connection, remotePeer) {\n const wrappedConnection = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_1__.lpStream)(connection, {\n lengthEncoder: _encoder_js__WEBPACK_IMPORTED_MODULE_8__.uint16BEEncode,\n lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_8__.uint16BEDecode,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_5__.NOISE_MSG_MAX_LENGTH_BYTES\n });\n const handshake = await this.performHandshake({\n connection: wrappedConnection,\n isInitiator: false,\n localPeer,\n remotePeer\n });\n const conn = await this.createSecureConnection(wrappedConnection, handshake);\n connection.source = conn.source;\n connection.sink = conn.sink;\n return {\n conn: connection,\n remotePeer: handshake.remotePeer,\n remoteExtensions: handshake.remoteExtensions\n };\n }\n /**\n * If Noise pipes supported, tries IK handshake first with XX as fallback if it fails.\n * If noise pipes disabled or remote peer static key is unknown, use XX.\n *\n * @param {HandshakeParams} params\n */\n async performHandshake(params) {\n const payload = await (0,_utils_js__WEBPACK_IMPORTED_MODULE_11__.getPayload)(params.localPeer, this.staticKeys.publicKey, this.extensions);\n // run XX handshake\n return this.performXXHandshake(params, payload);\n }\n async performXXHandshake(params, payload) {\n const { isInitiator, remotePeer, connection } = params;\n const handshake = new _handshake_xx_js__WEBPACK_IMPORTED_MODULE_9__.XXHandshake(this.components, isInitiator, payload, this.prologue, this.crypto, this.staticKeys, connection, remotePeer);\n try {\n await handshake.propose();\n await handshake.exchange();\n await handshake.finish();\n this.metrics?.xxHandshakeSuccesses.increment();\n }\n catch (e) {\n this.metrics?.xxHandshakeErrors.increment();\n if (e instanceof Error) {\n e.message = `Error occurred during XX handshake: ${e.message}`;\n throw e;\n }\n }\n return handshake;\n }\n async createSecureConnection(connection, handshake) {\n // Create encryption box/unbox wrapper\n const [secure, user] = (0,it_pair_duplex__WEBPACK_IMPORTED_MODULE_2__.duplexPair)();\n const network = connection.unwrap();\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)(secure, // write to wrapper\n (0,_crypto_streaming_js__WEBPACK_IMPORTED_MODULE_7__.encryptStream)(handshake, this.metrics), // encrypt data + prefix with message length\n network, // send to the remote peer\n (source) => (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.decode)(source, { lengthDecoder: _encoder_js__WEBPACK_IMPORTED_MODULE_8__.uint16BEDecode }), // read message length prefix\n (0,_crypto_streaming_js__WEBPACK_IMPORTED_MODULE_7__.decryptStream)(handshake, this.metrics), // decrypt the incoming data\n secure // pipe to the wrapper\n );\n return user;\n }\n}\n//# sourceMappingURL=noise.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js?"); /***/ }), @@ -2199,7 +2140,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_NONCE: () => (/* binding */ MAX_NONCE),\n/* harmony export */ MIN_NONCE: () => (/* binding */ MIN_NONCE),\n/* harmony export */ Nonce: () => (/* binding */ Nonce)\n/* harmony export */ });\nconst MIN_NONCE = 0;\n// For performance reasons, the nonce is represented as a JS `number`\n// Although JS `number` can safely represent integers up to 2 ** 53 - 1, we choose to only use\n// 4 bytes to store the data for performance reason.\n// This is a slight deviation from the noise spec, which describes the max nonce as 2 ** 64 - 2\n// The effect is that this implementation will need a new handshake to be performed after fewer messages are exchanged than other implementations with full uint64 nonces.\n// this MAX_NONCE is still a large number of messages, so the practical effect of this is negligible.\nconst MAX_NONCE = 0xffffffff;\nconst ERR_MAX_NONCE = 'Cipherstate has reached maximum n, a new handshake must be performed';\n/**\n * The nonce is an uint that's increased over time.\n * Maintaining different representations help improve performance.\n */\nclass Nonce {\n n;\n bytes;\n view;\n constructor(n = MIN_NONCE) {\n this.n = n;\n this.bytes = new Uint8Array(12);\n this.view = new DataView(this.bytes.buffer, this.bytes.byteOffset, this.bytes.byteLength);\n this.view.setUint32(4, n, true);\n }\n increment() {\n this.n++;\n // Even though we're treating the nonce as 8 bytes, RFC7539 specifies 12 bytes for a nonce.\n this.view.setUint32(4, this.n, true);\n }\n getBytes() {\n return this.bytes;\n }\n getUint64() {\n return this.n;\n }\n assertValue() {\n if (this.n > MAX_NONCE) {\n throw new Error(ERR_MAX_NONCE);\n }\n }\n}\n//# sourceMappingURL=nonce.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_NONCE: () => (/* binding */ MAX_NONCE),\n/* harmony export */ MIN_NONCE: () => (/* binding */ MIN_NONCE),\n/* harmony export */ Nonce: () => (/* binding */ Nonce)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n\nconst MIN_NONCE = 0;\n// For performance reasons, the nonce is represented as a JS `number`\n// Although JS `number` can safely represent integers up to 2 ** 53 - 1, we choose to only use\n// 4 bytes to store the data for performance reason.\n// This is a slight deviation from the noise spec, which describes the max nonce as 2 ** 64 - 2\n// The effect is that this implementation will need a new handshake to be performed after fewer messages are exchanged than other implementations with full uint64 nonces.\n// this MAX_NONCE is still a large number of messages, so the practical effect of this is negligible.\nconst MAX_NONCE = 0xffffffff;\nconst ERR_MAX_NONCE = 'Cipherstate has reached maximum n, a new handshake must be performed';\n/**\n * The nonce is an uint that's increased over time.\n * Maintaining different representations help improve performance.\n */\nclass Nonce {\n n;\n bytes;\n view;\n constructor(n = MIN_NONCE) {\n this.n = n;\n this.bytes = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.alloc)(12);\n this.view = new DataView(this.bytes.buffer, this.bytes.byteOffset, this.bytes.byteLength);\n this.view.setUint32(4, n, true);\n }\n increment() {\n this.n++;\n // Even though we're treating the nonce as 8 bytes, RFC7539 specifies 12 bytes for a nonce.\n this.view.setUint32(4, this.n, true);\n }\n getBytes() {\n return this.bytes;\n }\n getUint64() {\n return this.n;\n }\n assertValue() {\n if (this.n > MAX_NONCE) {\n throw new Error(ERR_MAX_NONCE);\n }\n }\n}\n//# sourceMappingURL=nonce.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js?"); /***/ }), @@ -2210,7 +2151,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseExtensions: () => (/* binding */ NoiseExtensions),\n/* harmony export */ NoiseHandshakePayload: () => (/* binding */ NoiseHandshakePayload)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar NoiseExtensions;\n(function (NoiseExtensions) {\n let _codec;\n NoiseExtensions.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.webtransportCerthashes != null) {\n for (const value of obj.webtransportCerthashes) {\n w.uint32(10);\n w.bytes(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n webtransportCerthashes: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.webtransportCerthashes.push(reader.bytes());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n NoiseExtensions.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, NoiseExtensions.codec());\n };\n NoiseExtensions.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, NoiseExtensions.codec());\n };\n})(NoiseExtensions || (NoiseExtensions = {}));\nvar NoiseHandshakePayload;\n(function (NoiseHandshakePayload) {\n let _codec;\n NoiseHandshakePayload.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (opts.writeDefaults === true || (obj.identityKey != null && obj.identityKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.identityKey ?? new Uint8Array(0));\n }\n if (opts.writeDefaults === true || (obj.identitySig != null && obj.identitySig.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.identitySig ?? new Uint8Array(0));\n }\n if (obj.extensions != null) {\n w.uint32(34);\n NoiseExtensions.codec().encode(obj.extensions, w, {\n writeDefaults: false\n });\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n identityKey: new Uint8Array(0),\n identitySig: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.identityKey = reader.bytes();\n break;\n case 2:\n obj.identitySig = reader.bytes();\n break;\n case 4:\n obj.extensions = NoiseExtensions.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n NoiseHandshakePayload.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, NoiseHandshakePayload.codec());\n };\n NoiseHandshakePayload.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, NoiseHandshakePayload.codec());\n };\n})(NoiseHandshakePayload || (NoiseHandshakePayload = {}));\n//# sourceMappingURL=payload.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseExtensions: () => (/* binding */ NoiseExtensions),\n/* harmony export */ NoiseHandshakePayload: () => (/* binding */ NoiseHandshakePayload)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar NoiseExtensions;\n(function (NoiseExtensions) {\n let _codec;\n NoiseExtensions.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.webtransportCerthashes != null) {\n for (const value of obj.webtransportCerthashes) {\n w.uint32(10);\n w.bytes(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n webtransportCerthashes: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.webtransportCerthashes.push(reader.bytes());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n NoiseExtensions.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, NoiseExtensions.codec());\n };\n NoiseExtensions.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, NoiseExtensions.codec());\n };\n})(NoiseExtensions || (NoiseExtensions = {}));\nvar NoiseHandshakePayload;\n(function (NoiseHandshakePayload) {\n let _codec;\n NoiseHandshakePayload.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.identityKey != null && obj.identityKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.identityKey);\n }\n if ((obj.identitySig != null && obj.identitySig.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.identitySig);\n }\n if (obj.extensions != null) {\n w.uint32(34);\n NoiseExtensions.codec().encode(obj.extensions, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n identityKey: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n identitySig: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.identityKey = reader.bytes();\n break;\n }\n case 2: {\n obj.identitySig = reader.bytes();\n break;\n }\n case 4: {\n obj.extensions = NoiseExtensions.codec().decode(reader, reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n NoiseHandshakePayload.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, NoiseHandshakePayload.codec());\n };\n NoiseHandshakePayload.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, NoiseHandshakePayload.codec());\n };\n})(NoiseHandshakePayload || (NoiseHandshakePayload = {}));\n//# sourceMappingURL=payload.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js?"); /***/ }), @@ -2221,29 +2162,348 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createHandshakePayload: () => (/* binding */ createHandshakePayload),\n/* harmony export */ decodePayload: () => (/* binding */ decodePayload),\n/* harmony export */ getHandshakePayload: () => (/* binding */ getHandshakePayload),\n/* harmony export */ getPayload: () => (/* binding */ getPayload),\n/* harmony export */ getPeerIdFromPayload: () => (/* binding */ getPeerIdFromPayload),\n/* harmony export */ isValidPublicKey: () => (/* binding */ isValidPublicKey),\n/* harmony export */ signPayload: () => (/* binding */ signPayload),\n/* harmony export */ verifySignedPayload: () => (/* binding */ verifySignedPayload)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proto/payload.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js\");\n\n\n\n\n\nasync function getPayload(localPeer, staticPublicKey, extensions) {\n const signedPayload = await signPayload(localPeer, getHandshakePayload(staticPublicKey));\n if (localPeer.publicKey == null) {\n throw new Error('PublicKey was missing from local PeerId');\n }\n return createHandshakePayload(localPeer.publicKey, signedPayload, extensions);\n}\nfunction createHandshakePayload(libp2pPublicKey, signedPayload, extensions) {\n return _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__.NoiseHandshakePayload.encode({\n identityKey: libp2pPublicKey,\n identitySig: signedPayload,\n extensions: extensions ?? { webtransportCerthashes: [] }\n }).subarray();\n}\nasync function signPayload(peerId, payload) {\n if (peerId.privateKey == null) {\n throw new Error('PrivateKey was missing from PeerId');\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n return privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)(payload.identityKey);\n}\nfunction decodePayload(payload) {\n return _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__.NoiseHandshakePayload.decode(payload);\n}\nfunction getHandshakePayload(publicKey) {\n const prefix = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('noise-libp2p-static-key:');\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([prefix, publicKey], prefix.length + publicKey.length);\n}\n/**\n * Verifies signed payload, throws on any irregularities.\n *\n * @param {bytes} noiseStaticKey - owner's noise static key\n * @param {bytes} payload - decoded payload\n * @param {PeerId} remotePeer - owner's libp2p peer ID\n * @returns {Promise} - peer ID of payload owner\n */\nasync function verifySignedPayload(noiseStaticKey, payload, remotePeer) {\n // Unmarshaling from PublicKey protobuf\n const payloadPeerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)(payload.identityKey);\n if (!payloadPeerId.equals(remotePeer)) {\n throw new Error(`Payload identity key ${payloadPeerId.toString()} does not match expected remote peer ${remotePeer.toString()}`);\n }\n const generatedPayload = getHandshakePayload(noiseStaticKey);\n if (payloadPeerId.publicKey == null) {\n throw new Error('PublicKey was missing from PeerId');\n }\n if (payload.identitySig == null) {\n throw new Error('Signature was missing from message');\n }\n const publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(payloadPeerId.publicKey);\n const valid = await publicKey.verify(generatedPayload, payload.identitySig);\n if (!valid) {\n throw new Error(\"Static key doesn't match to peer that signed payload!\");\n }\n return payloadPeerId;\n}\nfunction isValidPublicKey(pk) {\n if (!(pk instanceof Uint8Array)) {\n return false;\n }\n if (pk.length !== 32) {\n return false;\n }\n return true;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createHandshakePayload: () => (/* binding */ createHandshakePayload),\n/* harmony export */ decodePayload: () => (/* binding */ decodePayload),\n/* harmony export */ getHandshakePayload: () => (/* binding */ getHandshakePayload),\n/* harmony export */ getPayload: () => (/* binding */ getPayload),\n/* harmony export */ getPeerIdFromPayload: () => (/* binding */ getPeerIdFromPayload),\n/* harmony export */ isValidPublicKey: () => (/* binding */ isValidPublicKey),\n/* harmony export */ signPayload: () => (/* binding */ signPayload),\n/* harmony export */ verifySignedPayload: () => (/* binding */ verifySignedPayload)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proto/payload.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js\");\n\n\n\n\n\n\nasync function getPayload(localPeer, staticPublicKey, extensions) {\n const signedPayload = await signPayload(localPeer, getHandshakePayload(staticPublicKey));\n if (localPeer.publicKey == null) {\n throw new Error('PublicKey was missing from local PeerId');\n }\n return createHandshakePayload(localPeer.publicKey, signedPayload, extensions);\n}\nfunction createHandshakePayload(libp2pPublicKey, signedPayload, extensions) {\n return _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__.NoiseHandshakePayload.encode({\n identityKey: libp2pPublicKey,\n identitySig: signedPayload,\n extensions: extensions ?? { webtransportCerthashes: [] }\n }).subarray();\n}\nasync function signPayload(peerId, payload) {\n if (peerId.privateKey == null) {\n throw new Error('PrivateKey was missing from PeerId');\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n return privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromKeys)(payload.identityKey);\n}\nfunction decodePayload(payload) {\n return _proto_payload_js__WEBPACK_IMPORTED_MODULE_4__.NoiseHandshakePayload.decode(payload);\n}\nfunction getHandshakePayload(publicKey) {\n const prefix = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('noise-libp2p-static-key:');\n if (publicKey instanceof Uint8Array) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([prefix, publicKey], prefix.length + publicKey.length);\n }\n publicKey.prepend(prefix);\n return publicKey;\n}\n/**\n * Verifies signed payload, throws on any irregularities.\n *\n * @param {bytes} noiseStaticKey - owner's noise static key\n * @param {bytes} payload - decoded payload\n * @param {PeerId} remotePeer - owner's libp2p peer ID\n * @returns {Promise} - peer ID of payload owner\n */\nasync function verifySignedPayload(noiseStaticKey, payload, remotePeer) {\n // Unmarshaling from PublicKey protobuf\n const payloadPeerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromKeys)(payload.identityKey);\n if (!payloadPeerId.equals(remotePeer)) {\n throw new Error(`Payload identity key ${payloadPeerId.toString()} does not match expected remote peer ${remotePeer.toString()}`);\n }\n const generatedPayload = getHandshakePayload(noiseStaticKey);\n if (payloadPeerId.publicKey == null) {\n throw new Error('PublicKey was missing from PeerId');\n }\n if (payload.identitySig == null) {\n throw new Error('Signature was missing from message');\n }\n const publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(payloadPeerId.publicKey);\n const valid = await publicKey.verify(generatedPayload, payload.identitySig);\n if (!valid) {\n throw new Error(\"Static key doesn't match to peer that signed payload!\");\n }\n return payloadPeerId;\n}\nfunction isValidPublicKey(pk) {\n if (!(pk instanceof Uint8Array) && !((0,uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.isUint8ArrayList)(pk))) {\n return false;\n }\n if (pk.byteLength !== 32) {\n return false;\n }\n return true;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js?"); /***/ }), -/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-merge/dist/src/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-merge/dist/src/index.js ***! - \**************************************************************************************/ +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js": +/*!**************************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js ***! + \**************************************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Merge several (async)iterables into one, yield values as they arrive.\n *\n * Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.\n *\n * @example\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values1 = [0, 1, 2, 3, 4]\n * const values2 = [5, 6, 7, 8, 9]\n *\n * const arr = all(merge(values1, values2))\n *\n * console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const values1 = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n * const values2 = async function * () {\n * yield * [5, 6, 7, 8, 9]\n * }\n *\n * const arr = await all(merge(values1(), values2()))\n *\n * console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction merge(...sources) {\n const syncSources = [];\n for (const source of sources) {\n if (!isAsyncIterable(source)) {\n syncSources.push(source);\n }\n }\n if (syncSources.length === sources.length) {\n // all sources are synchronous\n return (function* () {\n for (const source of syncSources) {\n yield* source;\n }\n })();\n }\n return (async function* () {\n const output = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n void Promise.resolve().then(async () => {\n try {\n await Promise.all(sources.map(async (source) => {\n for await (const item of source) {\n output.push(item);\n }\n }));\n output.end();\n }\n catch (err) {\n output.end(err);\n }\n });\n yield* output;\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (merge);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-merge/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ derivedEmptyPasswordKey: () => (/* binding */ derivedEmptyPasswordKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n\n\n\n// WebKit on Linux does not support deriving a key from an empty PBKDF2 key.\n// So, as a workaround, we provide the generated key as a constant. We test that\n// this generated key is accurate in test/workaround.spec.ts\n// Generated via:\n// await crypto.subtle.exportKey('jwk',\n// await crypto.subtle.deriveKey(\n// { name: 'PBKDF2', salt: new Uint8Array(16), iterations: 32767, hash: { name: 'SHA-256' } },\n// await crypto.subtle.importKey('raw', new Uint8Array(0), { name: 'PBKDF2' }, false, ['deriveKey']),\n// { name: 'AES-GCM', length: 128 }, true, ['encrypt', 'decrypt'])\n// )\nconst derivedEmptyPasswordKey = { alg: 'A128GCM', ext: true, k: 'scm9jmO_4BJAgdwWGVulLg', key_ops: ['encrypt', 'decrypt'], kty: 'oct' };\n// Based off of code from https://github.com/luke-park/SecureCompatibleEncryptionExamples\nfunction create(opts) {\n const algorithm = opts?.algorithm ?? 'AES-GCM';\n let keyLength = opts?.keyLength ?? 16;\n const nonceLength = opts?.nonceLength ?? 12;\n const digest = opts?.digest ?? 'SHA-256';\n const saltLength = opts?.saltLength ?? 16;\n const iterations = opts?.iterations ?? 32767;\n const crypto = _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get();\n keyLength *= 8; // Browser crypto uses bits instead of bytes\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to encrypt the data.\n */\n async function encrypt(data, password) {\n const salt = crypto.getRandomValues(new Uint8Array(saltLength));\n const nonce = crypto.getRandomValues(new Uint8Array(nonceLength));\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n }\n }\n else {\n // Derive a key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n // Encrypt the string.\n const ciphertext = await crypto.subtle.encrypt(aesGcm, cryptoKey, data);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([salt, aesGcm.iv, new Uint8Array(ciphertext)]);\n }\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to decrypt the data. The options used to create\n * this decryption cipher must be the same as those used to create\n * the encryption cipher.\n */\n async function decrypt(data, password) {\n const salt = data.subarray(0, saltLength);\n const nonce = data.subarray(saltLength, saltLength + nonceLength);\n const ciphertext = data.subarray(saltLength + nonceLength);\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['decrypt']);\n }\n }\n else {\n // Derive the key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n // Decrypt the string.\n const plaintext = await crypto.subtle.decrypt(aesGcm, cryptoKey, ciphertext);\n return new Uint8Array(plaintext);\n }\n const cipher = {\n encrypt,\n decrypt\n };\n return cipher;\n}\n//# sourceMappingURL=aes-gcm.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js?"); /***/ }), -/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-pipe/dist/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-pipe/dist/src/index.js ***! - \*************************************************************************************/ +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js": +/*!*********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js ***! + \*********************************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pipe: () => (/* binding */ pipe),\n/* harmony export */ rawPipe: () => (/* binding */ rawPipe)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-merge/dist/src/index.js\");\n\n\nfunction pipe(first, ...rest) {\n if (first == null) {\n throw new Error('Empty pipeline');\n }\n // Duplex at start: wrap in function and return duplex source\n if (isDuplex(first)) {\n const duplex = first;\n first = () => duplex.source;\n // Iterable at start: wrap in function\n }\n else if (isIterable(first) || isAsyncIterable(first)) {\n const source = first;\n first = () => source;\n }\n const fns = [first, ...rest];\n if (fns.length > 1) {\n // Duplex at end: use duplex sink\n if (isDuplex(fns[fns.length - 1])) {\n fns[fns.length - 1] = fns[fns.length - 1].sink;\n }\n }\n if (fns.length > 2) {\n // Duplex in the middle, consume source with duplex sink and return duplex source\n for (let i = 1; i < fns.length - 1; i++) {\n if (isDuplex(fns[i])) {\n fns[i] = duplexPipelineFn(fns[i]);\n }\n }\n }\n return rawPipe(...fns);\n}\nconst rawPipe = (...fns) => {\n let res;\n while (fns.length > 0) {\n res = fns.shift()(res);\n }\n return res;\n};\nconst isAsyncIterable = (obj) => {\n return obj?.[Symbol.asyncIterator] != null;\n};\nconst isIterable = (obj) => {\n return obj?.[Symbol.iterator] != null;\n};\nconst isDuplex = (obj) => {\n if (obj == null) {\n return false;\n }\n return obj.sink != null && obj.source != null;\n};\nconst duplexPipelineFn = (duplex) => {\n return (source) => {\n const p = duplex.sink(source);\n if (p?.then != null) {\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n p.then(() => {\n stream.end();\n }, (err) => {\n stream.end(err);\n });\n let sourceWrap;\n const source = duplex.source;\n if (isAsyncIterable(source)) {\n sourceWrap = async function* () {\n yield* source;\n stream.end();\n };\n }\n else if (isIterable(source)) {\n sourceWrap = function* () {\n yield* source;\n stream.end();\n };\n }\n else {\n throw new Error('Unknown duplex source type - must be Iterable or AsyncIterable');\n }\n return (0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(stream, sourceWrap());\n }\n return duplex.source;\n };\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-pipe/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create)\n/* harmony export */ });\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _lengths_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lengths.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/lengths.js\");\n\n\nconst hashTypes = {\n SHA1: 'SHA-1',\n SHA256: 'SHA-256',\n SHA512: 'SHA-512'\n};\nconst sign = async (key, data) => {\n const buf = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.sign({ name: 'HMAC' }, key, data);\n return new Uint8Array(buf, 0, buf.byteLength);\n};\nasync function create(hashType, secret) {\n const hash = hashTypes[hashType];\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.importKey('raw', secret, {\n name: 'HMAC',\n hash: { name: hash }\n }, false, ['sign']);\n return {\n async digest(data) {\n return sign(key, data);\n },\n length: _lengths_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"][hashType]\n };\n}\n//# sourceMappingURL=index-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/lengths.js": +/*!***************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/lengths.js ***! + \***************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n SHA1: 20,\n SHA256: 32,\n SHA512: 64\n});\n//# sourceMappingURL=lengths.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/lengths.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js": +/*!********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js ***! + \********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateEphmeralKeyPair: () => (/* binding */ generateEphmeralKeyPair)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n\n\n\n\n\n\nconst bits = {\n 'P-256': 256,\n 'P-384': 384,\n 'P-521': 521\n};\nconst curveTypes = Object.keys(bits);\nconst names = curveTypes.join(' / ');\nasync function generateEphmeralKeyPair(curve) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.generateKey({\n name: 'ECDH',\n namedCurve: curve\n }, true, ['deriveBits']);\n // forcePrivate is used for testing only\n const genSharedKey = async (theirPub, forcePrivate) => {\n let privateKey;\n if (forcePrivate != null) {\n privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', unmarshalPrivateKey(curve, forcePrivate), {\n name: 'ECDH',\n namedCurve: curve\n }, false, ['deriveBits']);\n }\n else {\n privateKey = pair.privateKey;\n }\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', unmarshalPublicKey(curve, theirPub), {\n name: 'ECDH',\n namedCurve: curve\n }, false, []);\n const buffer = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.deriveBits({\n name: 'ECDH',\n // @ts-expect-error namedCurve is missing from the types\n namedCurve: curve,\n public: key\n }, privateKey, bits[curve]);\n return new Uint8Array(buffer, 0, buffer.byteLength);\n };\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey);\n const ecdhKey = {\n key: marshalPublicKey(publicKey),\n genSharedKey\n };\n return ecdhKey;\n}\nconst curveLengths = {\n 'P-256': 32,\n 'P-384': 48,\n 'P-521': 66\n};\n// Marshal converts a jwk encoded ECDH public key into the\n// form specified in section 4.3.6 of ANSI X9.62. (This is the format\n// go-ipfs uses)\nfunction marshalPublicKey(jwk) {\n if (jwk.crv == null || jwk.x == null || jwk.y == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n if (jwk.crv !== 'P-256' && jwk.crv !== 'P-384' && jwk.crv !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Unknown curve: ${jwk.crv}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[jwk.crv];\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([\n Uint8Array.from([4]), // uncompressed point\n (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBuffer)(jwk.x, byteLen),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBuffer)(jwk.y, byteLen)\n ], 1 + byteLen * 2);\n}\n// Unmarshal converts a point, serialized by Marshal, into an jwk encoded key\nfunction unmarshalPublicKey(curve, key) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[curve];\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(key.subarray(0, 1), Uint8Array.from([4]))) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError('Cannot unmarshal public key - invalid key format', 'ERR_INVALID_KEY_FORMAT');\n }\n return {\n kty: 'EC',\n crv: curve,\n x: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.subarray(1, byteLen + 1), 'base64url'),\n y: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.subarray(1 + byteLen), 'base64url'),\n ext: true\n };\n}\nconst unmarshalPrivateKey = (curve, key) => ({\n ...unmarshalPublicKey(curve, key.public),\n d: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.private, 'base64url')\n});\n//# sourceMappingURL=ecdh-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js": +/*!***********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js ***! + \***********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ generateKeyFromSeed: () => (/* binding */ generateKeyFromSeed),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ publicKeyLength: () => (/* binding */ PUBLIC_KEY_BYTE_LENGTH)\n/* harmony export */ });\n/* harmony import */ var _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/curves/ed25519 */ \"./node_modules/@noble/curves/esm/ed25519.js\");\n\nconst PUBLIC_KEY_BYTE_LENGTH = 32;\nconst PRIVATE_KEY_BYTE_LENGTH = 64; // private key is actually 32 bytes but for historical reasons we concat private and public keys\nconst KEYS_BYTE_LENGTH = 32;\n\n\nfunction generateKey() {\n // the actual private key (32 bytes)\n const privateKeyRaw = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.utils.randomPrivateKey();\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.getPublicKey(privateKeyRaw);\n // concatenated the public key to the private key\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\n/**\n * Generate keypair from a 32 byte uint8array\n */\nfunction generateKeyFromSeed(seed) {\n if (seed.length !== KEYS_BYTE_LENGTH) {\n throw new TypeError('\"seed\" must be 32 bytes in length.');\n }\n else if (!(seed instanceof Uint8Array)) {\n throw new TypeError('\"seed\" must be a node.js Buffer, or Uint8Array.');\n }\n // based on node forges algorithm, the seed is used directly as private key\n const privateKeyRaw = seed;\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.getPublicKey(privateKeyRaw);\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\nfunction hashAndSign(privateKey, msg) {\n const privateKeyRaw = privateKey.subarray(0, KEYS_BYTE_LENGTH);\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.sign(msg instanceof Uint8Array ? msg : msg.subarray(), privateKeyRaw);\n}\nfunction hashAndVerify(publicKey, sig, msg) {\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.verify(sig, msg instanceof Uint8Array ? msg : msg.subarray(), publicKey);\n}\nfunction concatKeys(privateKeyRaw, publicKey) {\n const privateKey = new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);\n for (let i = 0; i < KEYS_BYTE_LENGTH; i++) {\n privateKey[i] = privateKeyRaw[i];\n privateKey[KEYS_BYTE_LENGTH + i] = publicKey[i];\n }\n return privateKey;\n}\n//# sourceMappingURL=ed25519-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js": +/*!*********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js ***! + \*********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Ed25519PrivateKey: () => (/* binding */ Ed25519PrivateKey),\n/* harmony export */ Ed25519PublicKey: () => (/* binding */ Ed25519PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ unmarshalEd25519PrivateKey: () => (/* binding */ unmarshalEd25519PrivateKey),\n/* harmony export */ unmarshalEd25519PublicKey: () => (/* binding */ unmarshalEd25519PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _ed25519_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ed25519.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n\n\n\n\n\n\n\n\n\nclass Ed25519PublicKey {\n _key;\n constructor(key) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n verify(data, sig) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_4__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n}\nclass Ed25519PrivateKey {\n _key;\n _publicKey;\n // key - 64 byte Uint8Array containing private key\n // publicKey - 32 byte Uint8Array containing public key\n constructor(key, publicKey) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n this._publicKey = ensureKey(publicKey, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n sign(message) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.hashAndSign(this._key, message);\n }\n get public() {\n return new Ed25519PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n let bytes;\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_4__.isPromise)(p)) {\n ({ bytes } = await p);\n }\n else {\n bytes = p.bytes;\n }\n return bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the identity multihash containing its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n *\n * @returns {Promise}\n */\n async id() {\n const encoding = multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_1__.identity.digest(this.public.bytes);\n return multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.encode(encoding.bytes).substring(1);\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_6__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalEd25519PrivateKey(bytes) {\n // Try the old, redundant public key version\n if (bytes.length > _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength + _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength, bytes.length);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n }\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n}\nfunction unmarshalEd25519PublicKey(bytes) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n return new Ed25519PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const { privateKey, publicKey } = _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.generateKey();\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nasync function generateKeyPairFromSeed(seed) {\n const { privateKey, publicKey } = _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.generateKeyFromSeed(seed);\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nfunction ensureKey(key, length) {\n key = Uint8Array.from(key ?? []);\n if (key.length !== length) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError(`Key must be a Uint8Array of length ${length}, got ${key.length}`, 'ERR_INVALID_KEY_TYPE');\n }\n return key;\n}\n//# sourceMappingURL=ed25519-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js": +/*!**********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js ***! + \**********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _ecdh_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ecdh.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js\");\n\n/**\n * Generates an ephemeral public key and returns a function that will compute\n * the shared secret key.\n *\n * Focuses only on ECDH now, but can be made more general in the future.\n */\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_ecdh_js__WEBPACK_IMPORTED_MODULE_0__.generateEphmeralKeyPair);\n//# sourceMappingURL=ephemeral-keys.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js": +/*!****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js ***! + \****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ exporter: () => (/* binding */ exporter)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Exports the given PrivateKey as a base64 encoded string.\n * The PrivateKey is encrypted via a password derived PBKDF2 key\n * leveraging the aes-gcm cipher algorithm.\n */\nasync function exporter(privateKey, password) {\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n const encryptedKey = await cipher.encrypt(privateKey, password);\n return multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.encode(encryptedKey);\n}\n//# sourceMappingURL=exporter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/importer.js": +/*!****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/importer.js ***! + \****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ importer: () => (/* binding */ importer)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Attempts to decrypt a base64 encoded PrivateKey string\n * with the given password. The privateKey must have been exported\n * using the same password and underlying cipher (aes-gcm)\n */\nasync function importer(privateKey, password) {\n const encryptedKey = multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.decode(privateKey);\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n return cipher.decrypt(encryptedKey, password);\n}\n//# sourceMappingURL=importer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/importer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/index.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/index.js ***! + \*************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateEphemeralKeyPair: () => (/* reexport safe */ _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ importKey: () => (/* binding */ importKey),\n/* harmony export */ keyStretcher: () => (/* reexport safe */ _key_stretcher_js__WEBPACK_IMPORTED_MODULE_7__.keyStretcher),\n/* harmony export */ keysPBM: () => (/* reexport module object */ _keys_js__WEBPACK_IMPORTED_MODULE_8__),\n/* harmony export */ marshalPrivateKey: () => (/* binding */ marshalPrivateKey),\n/* harmony export */ marshalPublicKey: () => (/* binding */ marshalPublicKey),\n/* harmony export */ supportedKeys: () => (/* binding */ supportedKeys),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ unmarshalPublicKey: () => (/* binding */ unmarshalPublicKey)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/asn1.js */ \"./node_modules/node-forge/lib/asn1.js\");\n/* harmony import */ var node_forge_lib_pbe_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/pbe.js */ \"./node_modules/node-forge/lib/pbe.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ed25519-class.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js\");\n/* harmony import */ var _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ephemeral-keys.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js\");\n/* harmony import */ var _importer_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./importer.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/importer.js\");\n/* harmony import */ var _key_stretcher_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./key-stretcher.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n/* harmony import */ var _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./secp256k1-class.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js\");\n/**\n * @packageDocumentation\n *\n * **Supported Key Types**\n *\n * The {@link generateKeyPair}, {@link marshalPublicKey}, and {@link marshalPrivateKey} functions accept a string `type` argument.\n *\n * Currently the `'RSA'`, `'ed25519'`, and `secp256k1` types are supported, although ed25519 and secp256k1 keys support only signing and verification of messages.\n *\n * For encryption / decryption support, RSA keys should be used.\n */\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\n\n\n\n\n\n\n\n\nconst supportedKeys = {\n rsa: _rsa_class_js__WEBPACK_IMPORTED_MODULE_9__,\n ed25519: _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__,\n secp256k1: _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_10__\n};\nfunction unsupportedKey(type) {\n const supported = Object.keys(supportedKeys).join(' / ');\n return new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError(`invalid or unsupported key type ${type}. Must be ${supported}`, 'ERR_UNSUPPORTED_KEY_TYPE');\n}\nfunction typeToKey(type) {\n type = type.toLowerCase();\n if (type === 'rsa' || type === 'ed25519' || type === 'secp256k1') {\n return supportedKeys[type];\n }\n throw unsupportedKey(type);\n}\n/**\n * Generates a keypair of the given type and bitsize\n *\n * @param type\n * @param bits - Minimum of 1024\n */\nasync function generateKeyPair(type, bits) {\n return typeToKey(type).generateKeyPair(bits ?? 2048);\n}\n/**\n * Generates a keypair of the given type and bitsize.\n *\n * Seed is a 32 byte uint8array\n */\nasync function generateKeyPairFromSeed(type, seed, bits) {\n if (type.toLowerCase() !== 'ed25519') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE');\n }\n return _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__.generateKeyPairFromSeed(seed);\n}\n/**\n * Converts a protobuf serialized public key into its representative object\n */\nfunction unmarshalPublicKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_8__.PublicKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'unknown');\n }\n}\n/**\n * Converts a public key object into a protobuf serialized public key\n */\nfunction marshalPublicKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n/**\n * Converts a protobuf serialized private key into its representative object\n */\nasync function unmarshalPrivateKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_8__.PrivateKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_8__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'RSA');\n }\n}\n/**\n * Converts a private key object into a protobuf serialized private key\n */\nfunction marshalPrivateKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n/**\n * Converts an exported private key into its representative object.\n *\n * Supported formats are 'pem' (RSA only) and 'libp2p-key'.\n */\nasync function importKey(encryptedKey, password) {\n try {\n const key = await (0,_importer_js__WEBPACK_IMPORTED_MODULE_6__.importer)(encryptedKey, password);\n return await unmarshalPrivateKey(key);\n }\n catch (_) {\n // Ignore and try the old pem decrypt\n }\n // Only rsa supports pem right now\n const key = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.decryptRsaPrivateKey(encryptedKey, password);\n if (key === null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('Cannot read the key, most likely the password is wrong or not a RSA key', 'ERR_CANNOT_DECRYPT_PEM');\n }\n let der = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.toDer(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.privateKeyToAsn1(key));\n der = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(der.getBytes(), 'ascii');\n return supportedKeys.rsa.unmarshalRsaPrivateKey(der);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/index.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js": +/*!***************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js ***! + \***************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ jwk2priv: () => (/* binding */ jwk2priv),\n/* harmony export */ jwk2pub: () => (/* binding */ jwk2pub)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_rsa_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/rsa.js */ \"./node_modules/node-forge/lib/rsa.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n\n// @ts-expect-error types are missing\n\n\nfunction convert(key, types) {\n return types.map(t => (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.base64urlToBigInteger)(key[t]));\n}\nfunction jwk2priv(key) {\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.setRsaPrivateKey(...convert(key, ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi']));\n}\nfunction jwk2pub(key) {\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.setRsaPublicKey(...convert(key, ['n', 'e']));\n}\n//# sourceMappingURL=jwk2pem.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js": +/*!*********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js ***! + \*********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ keyStretcher: () => (/* binding */ keyStretcher)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../hmac/index.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n\n\n\n\nconst cipherMap = {\n 'AES-128': {\n ivSize: 16,\n keySize: 16\n },\n 'AES-256': {\n ivSize: 16,\n keySize: 32\n },\n Blowfish: {\n ivSize: 8,\n keySize: 32\n }\n};\n/**\n * Generates a set of keys for each party by stretching the shared key.\n * (myIV, theirIV, myCipherKey, theirCipherKey, myMACKey, theirMACKey)\n */\nasync function keyStretcher(cipherType, hash, secret) {\n const cipher = cipherMap[cipherType];\n if (cipher == null) {\n const allowed = Object.keys(cipherMap).join(' / ');\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`unknown cipher type '${cipherType}'. Must be ${allowed}`, 'ERR_INVALID_CIPHER_TYPE');\n }\n if (hash == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('missing hash type', 'ERR_MISSING_HASH_TYPE');\n }\n const cipherKeySize = cipher.keySize;\n const ivSize = cipher.ivSize;\n const hmacKeySize = 20;\n const seed = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)('key expansion');\n const resultLength = 2 * (ivSize + cipherKeySize + hmacKeySize);\n const m = await _hmac_index_js__WEBPACK_IMPORTED_MODULE_2__.create(hash, secret);\n let a = await m.digest(seed);\n const result = [];\n let j = 0;\n while (j < resultLength) {\n const b = await m.digest((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([a, seed]));\n let todo = b.length;\n if (j + todo > resultLength) {\n todo = resultLength - j;\n }\n result.push(b);\n j += todo;\n a = await m.digest(a);\n }\n const half = resultLength / 2;\n const resultBuffer = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)(result);\n const r1 = resultBuffer.subarray(0, half);\n const r2 = resultBuffer.subarray(half, resultLength);\n const createKey = (res) => ({\n iv: res.subarray(0, ivSize),\n cipherKey: res.subarray(ivSize, ivSize + cipherKeySize),\n macKey: res.subarray(ivSize + cipherKeySize)\n });\n return {\n k1: createKey(r1),\n k2: createKey(r2)\n };\n}\n//# sourceMappingURL=key-stretcher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js ***! + \************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KeyType: () => (/* binding */ KeyType),\n/* harmony export */ PrivateKey: () => (/* binding */ PrivateKey),\n/* harmony export */ PublicKey: () => (/* binding */ PublicKey)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar KeyType;\n(function (KeyType) {\n KeyType[\"RSA\"] = \"RSA\";\n KeyType[\"Ed25519\"] = \"Ed25519\";\n KeyType[\"Secp256k1\"] = \"Secp256k1\";\n})(KeyType || (KeyType = {}));\nvar __KeyTypeValues;\n(function (__KeyTypeValues) {\n __KeyTypeValues[__KeyTypeValues[\"RSA\"] = 0] = \"RSA\";\n __KeyTypeValues[__KeyTypeValues[\"Ed25519\"] = 1] = \"Ed25519\";\n __KeyTypeValues[__KeyTypeValues[\"Secp256k1\"] = 2] = \"Secp256k1\";\n})(__KeyTypeValues || (__KeyTypeValues = {}));\n(function (KeyType) {\n KeyType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__KeyTypeValues);\n };\n})(KeyType || (KeyType = {}));\nvar PublicKey;\n(function (PublicKey) {\n let _codec;\n PublicKey.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.Type != null) {\n w.uint32(8);\n KeyType.codec().encode(obj.Type, w);\n }\n if (obj.Data != null) {\n w.uint32(18);\n w.bytes(obj.Data);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.Type = KeyType.codec().decode(reader);\n break;\n case 2:\n obj.Data = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PublicKey.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PublicKey.codec());\n };\n PublicKey.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PublicKey.codec());\n };\n})(PublicKey || (PublicKey = {}));\nvar PrivateKey;\n(function (PrivateKey) {\n let _codec;\n PrivateKey.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.Type != null) {\n w.uint32(8);\n KeyType.codec().encode(obj.Type, w);\n }\n if (obj.Data != null) {\n w.uint32(18);\n w.bytes(obj.Data);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.Type = KeyType.codec().decode(reader);\n break;\n case 2:\n obj.Data = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PrivateKey.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PrivateKey.codec());\n };\n PrivateKey.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PrivateKey.codec());\n };\n})(PrivateKey || (PrivateKey = {}));\n//# sourceMappingURL=keys.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js": +/*!*******************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js ***! + \*******************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decrypt: () => (/* binding */ decrypt),\n/* harmony export */ encrypt: () => (/* binding */ encrypt),\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ getRandomValues: () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ keySize: () => (/* binding */ keySize),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ utils: () => (/* reexport module object */ _rsa_utils_js__WEBPACK_IMPORTED_MODULE_5__)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _random_bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _jwk2pem_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./jwk2pem.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js\");\n\n\n\n\n\n\n\n\nasync function generateKey(bits) {\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: { name: 'SHA-256' }\n }, true, ['sign', 'verify']);\n const keys = await exportKey(pair);\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n// Takes a jwk key\nasync function unmarshalPrivateKey(key) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['sign']);\n const pair = [\n privateKey,\n await derivePublicFromPrivate(key)\n ];\n const keys = await exportKey({\n privateKey: pair[0],\n publicKey: pair[1]\n });\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n\nasync function hashAndSign(key, msg) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['sign']);\n const sig = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.sign({ name: 'RSASSA-PKCS1-v1_5' }, privateKey, msg instanceof Uint8Array ? msg : msg.subarray());\n return new Uint8Array(sig, 0, sig.byteLength);\n}\nasync function hashAndVerify(key, sig, msg) {\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['verify']);\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.verify({ name: 'RSASSA-PKCS1-v1_5' }, publicKey, sig, msg instanceof Uint8Array ? msg : msg.subarray());\n}\nasync function exportKey(pair) {\n if (pair.privateKey == null || pair.publicKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS');\n }\n return Promise.all([\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.exportKey('jwk', pair.privateKey),\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey)\n ]);\n}\nasync function derivePublicFromPrivate(jwKey) {\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get().subtle.importKey('jwk', {\n kty: jwKey.kty,\n n: jwKey.n,\n e: jwKey.e\n }, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['verify']);\n}\n/*\n\nRSA encryption/decryption for the browser with webcrypto workaround\n\"bloody dark magic. webcrypto's why.\"\n\nExplanation:\n - Convert JWK to nodeForge\n - Convert msg Uint8Array to nodeForge buffer: ByteBuffer is a \"binary-string backed buffer\", so let's make our Uint8Array a binary string\n - Convert resulting nodeForge buffer to Uint8Array: it returns a binary string, turn that into a Uint8Array\n\n*/\nfunction convertKey(key, pub, msg, handle) {\n const fkey = pub ? (0,_jwk2pem_js__WEBPACK_IMPORTED_MODULE_4__.jwk2pub)(key) : (0,_jwk2pem_js__WEBPACK_IMPORTED_MODULE_4__.jwk2priv)(key);\n const fmsg = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(msg instanceof Uint8Array ? msg : msg.subarray(), 'ascii');\n const fomsg = handle(fmsg, fkey);\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(fomsg, 'ascii');\n}\nfunction encrypt(key, msg) {\n return convertKey(key, true, msg, (msg, key) => key.encrypt(msg));\n}\nfunction decrypt(key, msg) {\n return convertKey(key, false, msg, (msg, key) => key.decrypt(msg));\n}\nfunction keySize(jwk) {\n if (jwk.kty !== 'RSA') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('invalid key type', 'ERR_INVALID_KEY_TYPE');\n }\n else if (jwk.n == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('invalid key modulus', 'ERR_INVALID_KEY_MODULUS');\n }\n const bytes = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(jwk.n, 'base64url');\n return bytes.length * 8;\n}\n//# sourceMappingURL=rsa-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js": +/*!*****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js ***! + \*****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_KEY_SIZE: () => (/* binding */ MAX_KEY_SIZE),\n/* harmony export */ RsaPrivateKey: () => (/* binding */ RsaPrivateKey),\n/* harmony export */ RsaPublicKey: () => (/* binding */ RsaPublicKey),\n/* harmony export */ fromJwk: () => (/* binding */ fromJwk),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalRsaPrivateKey: () => (/* binding */ unmarshalRsaPrivateKey),\n/* harmony export */ unmarshalRsaPublicKey: () => (/* binding */ unmarshalRsaPublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var node_forge_lib_sha512_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! node-forge/lib/sha512.js */ \"./node_modules/node-forge/lib/sha512.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js\");\n\n\n// @ts-expect-error types are missing\n\n\n\n\n\n\n\n\nconst MAX_KEY_SIZE = 8192;\nclass RsaPublicKey {\n _key;\n constructor(key) {\n this._key = key;\n }\n verify(data, sig) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.jwkToPkix(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n encrypt(bytes) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.encrypt(this._key, bytes);\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_5__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n}\nclass RsaPrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey;\n }\n genSecret() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.getRandomValues(16);\n }\n sign(message) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.hashAndSign(this._key, message);\n }\n get public() {\n if (this._publicKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError('public key not provided', 'ERR_PUBKEY_NOT_PROVIDED');\n }\n return new RsaPublicKey(this._publicKey);\n }\n decrypt(bytes) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.decrypt(this._key, bytes);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.jwkToPkcs1(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_5__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key into a password protected PEM format\n */\n async export(password, format = 'pkcs-8') {\n if (format === 'pkcs-8') {\n const buffer = new node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.util.ByteBuffer(this.marshal());\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.asn1.fromDer(buffer);\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.privateKeyFromAsn1(asn1);\n const options = {\n algorithm: 'aes256',\n count: 10000,\n saltSize: 128 / 8,\n prfAlgorithm: 'sha512'\n };\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.encryptRsaPrivateKey(privateKey, password, options);\n }\n else if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_6__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nasync function unmarshalRsaPrivateKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.pkcs1ToJwk(bytes);\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_8__.keySize(jwk) > MAX_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nfunction unmarshalRsaPublicKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.pkixToJwk(bytes);\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_8__.keySize(jwk) > MAX_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n return new RsaPublicKey(jwk);\n}\nasync function fromJwk(jwk) {\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_8__.keySize(jwk) > MAX_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nasync function generateKeyPair(bits) {\n if (bits > MAX_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.generateKey(bits);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\n//# sourceMappingURL=rsa-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js": +/*!*****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js ***! + \*****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ jwkToPkcs1: () => (/* binding */ jwkToPkcs1),\n/* harmony export */ jwkToPkix: () => (/* binding */ jwkToPkix),\n/* harmony export */ pkcs1ToJwk: () => (/* binding */ pkcs1ToJwk),\n/* harmony export */ pkixToJwk: () => (/* binding */ pkixToJwk)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/asn1.js */ \"./node_modules/node-forge/lib/asn1.js\");\n/* harmony import */ var node_forge_lib_rsa_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/rsa.js */ \"./node_modules/node-forge/lib/rsa.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\n// Convert a PKCS#1 in ASN1 DER format to a JWK key\nfunction pkcs1ToJwk(bytes) {\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.fromDer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(bytes, 'ascii'));\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.privateKeyFromAsn1(asn1);\n // https://tools.ietf.org/html/rfc7518#section-6.3.1\n return {\n kty: 'RSA',\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.q),\n dp: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.dP),\n dq: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.dQ),\n qi: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(privateKey.qInv),\n alg: 'RS256'\n };\n}\n// Convert a JWK key into PKCS#1 in ASN1 DER format\nfunction jwkToPkcs1(jwk) {\n if (jwk.n == null || jwk.e == null || jwk.d == null || jwk.p == null || jwk.q == null || jwk.dp == null || jwk.dq == null || jwk.qi == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.privateKeyToAsn1({\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.q),\n dP: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.dp),\n dQ: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.dq),\n qInv: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.qi)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.toDer(asn1).getBytes(), 'ascii');\n}\n// Convert a PKCIX in ASN1 DER format to a JWK key\nfunction pkixToJwk(bytes) {\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.fromDer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(bytes, 'ascii'));\n const publicKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.publicKeyFromAsn1(asn1);\n return {\n kty: 'RSA',\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(publicKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.bigIntegerToUintBase64url)(publicKey.e)\n };\n}\n// Convert a JWK key to PKCIX in ASN1 DER format\nfunction jwkToPkix(jwk) {\n if (jwk.n == null || jwk.e == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.publicKeyToAsn1({\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBigInteger)(jwk.e)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.toDer(asn1).getBytes(), 'ascii');\n}\n//# sourceMappingURL=rsa-utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js": +/*!*************************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js ***! + \*************************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compressPublicKey: () => (/* binding */ compressPublicKey),\n/* harmony export */ computePublicKey: () => (/* binding */ computePublicKey),\n/* harmony export */ decompressPublicKey: () => (/* binding */ decompressPublicKey),\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ validatePrivateKey: () => (/* binding */ validatePrivateKey),\n/* harmony export */ validatePublicKey: () => (/* binding */ validatePublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/curves/secp256k1 */ \"./node_modules/@noble/curves/esm/secp256k1.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n\n\n\n\nconst PRIVATE_KEY_BYTE_LENGTH = 32;\n\nfunction generateKey() {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.utils.randomPrivateKey();\n}\n/**\n * Hash and sign message with private key\n */\nfunction hashAndSign(key, msg) {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray());\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_1__.isPromise)(p)) {\n return p.then(({ digest }) => _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.sign(digest, key).toDERRawBytes())\n .catch(err => {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n });\n }\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.sign(p.digest, key).toDERRawBytes();\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\n/**\n * Hash message and verify signature with public key\n */\nfunction hashAndVerify(key, sig, msg) {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray());\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_1__.isPromise)(p)) {\n return p.then(({ digest }) => _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.verify(sig, digest, key))\n .catch(err => {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n });\n }\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.verify(sig, p.digest, key);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\nfunction compressPublicKey(key) {\n const point = _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.ProjectivePoint.fromHex(key).toRawBytes(true);\n return point;\n}\nfunction decompressPublicKey(key) {\n const point = _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.ProjectivePoint.fromHex(key).toRawBytes(false);\n return point;\n}\nfunction validatePrivateKey(key) {\n try {\n _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.getPublicKey(key, true);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\nfunction validatePublicKey(key) {\n try {\n _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.ProjectivePoint.fromHex(key);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PUBLIC_KEY');\n }\n}\nfunction computePublicKey(privateKey) {\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_2__.secp256k1.getPublicKey(privateKey, true);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\n//# sourceMappingURL=secp256k1-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js": +/*!***********************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js ***! + \***********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Secp256k1PrivateKey: () => (/* binding */ Secp256k1PrivateKey),\n/* harmony export */ Secp256k1PublicKey: () => (/* binding */ Secp256k1PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalSecp256k1PrivateKey: () => (/* binding */ unmarshalSecp256k1PrivateKey),\n/* harmony export */ unmarshalSecp256k1PublicKey: () => (/* binding */ unmarshalSecp256k1PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./secp256k1.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js\");\n\n\n\n\n\n\n\n\nclass Secp256k1PublicKey {\n _key;\n constructor(key) {\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePublicKey(key);\n this._key = key;\n }\n verify(data, sig) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.compressPublicKey(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n let bytes;\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_3__.isPromise)(p)) {\n ({ bytes } = await p);\n }\n else {\n bytes = p.bytes;\n }\n return bytes;\n }\n}\nclass Secp256k1PrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey ?? _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.computePublicKey(key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePrivateKey(this._key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePublicKey(this._publicKey);\n }\n sign(message) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.hashAndSign(this._key, message);\n }\n get public() {\n return new Secp256k1PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_3__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_4__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalSecp256k1PrivateKey(bytes) {\n return new Secp256k1PrivateKey(bytes);\n}\nfunction unmarshalSecp256k1PublicKey(bytes) {\n return new Secp256k1PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const privateKeyBytes = _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.generateKey();\n return new Secp256k1PrivateKey(privateKeyBytes);\n}\n//# sourceMappingURL=secp256k1-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/random-bytes.js": +/*!***************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/random-bytes.js ***! + \***************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ randomBytes)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/utils */ \"./node_modules/@noble/hashes/esm/utils.js\");\n\n\n/**\n * Generates a Uint8Array with length `number` populated by random bytes\n */\nfunction randomBytes(length) {\n if (isNaN(length) || length <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('random bytes length must be a Number bigger than 0', 'ERR_INVALID_LENGTH');\n }\n return (0,_noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(length);\n}\n//# sourceMappingURL=random-bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/random-bytes.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64urlToBigInteger: () => (/* binding */ base64urlToBigInteger),\n/* harmony export */ base64urlToBuffer: () => (/* binding */ base64urlToBuffer),\n/* harmony export */ bigIntegerToUintBase64url: () => (/* binding */ bigIntegerToUintBase64url),\n/* harmony export */ isPromise: () => (/* binding */ isPromise)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/util.js */ \"./node_modules/node-forge/lib/util.js\");\n/* harmony import */ var node_forge_lib_jsbn_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/jsbn.js */ \"./node_modules/node-forge/lib/jsbn.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n// @ts-expect-error types are missing\n\n\n\n\nfunction bigIntegerToUintBase64url(num, len) {\n // Call `.abs()` to convert to unsigned\n let buf = Uint8Array.from(num.abs().toByteArray()); // toByteArray converts to big endian\n // toByteArray() gives us back a signed array, which will include a leading 0\n // byte if the most significant bit of the number is 1:\n // https://docs.microsoft.com/en-us/windows/win32/seccertenroll/about-integer\n // Our number will always be positive so we should remove the leading padding.\n buf = buf[0] === 0 ? buf.subarray(1) : buf;\n if (len != null) {\n if (buf.length > len)\n throw new Error('byte array longer than desired length');\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(buf, 'base64url');\n}\n// Convert a base64url encoded string to a BigInteger\nfunction base64urlToBigInteger(str) {\n const buf = base64urlToBuffer(str);\n return new node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.jsbn.BigInteger((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(buf, 'base16'), 16);\n}\nfunction base64urlToBuffer(str, len) {\n let buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(str, 'base64urlpad');\n if (len != null) {\n if (buf.length > len)\n throw new Error('byte array longer than desired length');\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return buf;\n}\nfunction isPromise(thing) {\n if (thing == null) {\n return false;\n }\n return typeof thing.then === 'function' &&\n typeof thing.catch === 'function' &&\n typeof thing.finally === 'function';\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/util.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js ***! + \************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-env browser */\n// Check native crypto exists and is enabled (In insecure context `self.crypto`\n// exists but `self.crypto.subtle` does not).\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n get(win = globalThis) {\n const nativeCrypto = win.crypto;\n if (nativeCrypto == null || nativeCrypto.subtle == null) {\n throw Object.assign(new Error('Missing Web Crypto API. ' +\n 'The most likely cause of this error is that this page is being accessed ' +\n 'from an insecure context (i.e. not HTTPS). For more information and ' +\n 'possible resolutions see ' +\n 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api'), { code: 'ERR_MISSING_WEB_CRYPTO' });\n }\n return nativeCrypto;\n }\n});\n//# sourceMappingURL=webcrypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/@libp2p/crypto/dist/src/webcrypto.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/compare.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/compare.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compare: () => (/* binding */ compare)\n/* harmony export */ });\n/**\n * Can be used with Array.sort to sort and array with Uint8Array entries\n */\nfunction compare(a, b) {\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] < b[i]) {\n return -1;\n }\n if (a[i] > b[i]) {\n return 1;\n }\n }\n if (a.byteLength > b.byteLength) {\n return 1;\n }\n if (a.byteLength < b.byteLength) {\n return -1;\n }\n return 0;\n}\n//# sourceMappingURL=compare.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/compare.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ concat: () => (/* binding */ concat)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns a new Uint8Array created by concatenating the passed Uint8Arrays\n */\nfunction concat(arrays, length) {\n if (length == null) {\n length = arrays.reduce((acc, curr) => acc + curr.length, 0);\n }\n const output = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(length);\n let offset = 0;\n for (const arr of arrays) {\n output.set(arr, offset);\n offset += arr.length;\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(output);\n}\n//# sourceMappingURL=concat.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js ***! + \***********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/index.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/index.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compare: () => (/* reexport safe */ _compare__WEBPACK_IMPORTED_MODULE_2__.compare),\n/* harmony export */ concat: () => (/* reexport safe */ _concat__WEBPACK_IMPORTED_MODULE_3__.concat),\n/* harmony export */ equals: () => (/* reexport safe */ _equals_js__WEBPACK_IMPORTED_MODULE_0__.equals),\n/* harmony export */ fromString: () => (/* reexport safe */ _from_string__WEBPACK_IMPORTED_MODULE_4__.fromString),\n/* harmony export */ toString: () => (/* reexport safe */ _to_string__WEBPACK_IMPORTED_MODULE_5__.toString),\n/* harmony export */ xor: () => (/* reexport safe */ _xor_js__WEBPACK_IMPORTED_MODULE_1__.xor)\n/* harmony export */ });\n/* harmony import */ var _equals_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./equals.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _xor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./xor.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/xor.js\");\n/* harmony import */ var _compare__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! #compare */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/compare.js\");\n/* harmony import */ var _concat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #concat */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #from-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! #to-string */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js\");\n/**\n * @packageDocumentation\n *\n * `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.\n *\n * This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.\n *\n * Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.\n *\n * ## alloc(size)\n *\n * Create a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n *\n * ### Example\n *\n * ```js\n * import { alloc } from 'uint8arrays/alloc'\n *\n * const buf = alloc(100)\n * ```\n *\n * ## allocUnsafe(size)\n *\n * Create a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n *\n * On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.\n *\n * ### Example\n *\n * ```js\n * import { allocUnsafe } from 'uint8arrays/alloc'\n *\n * const buf = allocUnsafe(100)\n * ```\n *\n * ## compare(a, b)\n *\n * Compare two `Uint8Arrays`\n *\n * ### Example\n *\n * ```js\n * import { compare } from 'uint8arrays/compare'\n *\n * const arrays = [\n * Uint8Array.from([3, 4, 5]),\n * Uint8Array.from([0, 1, 2])\n * ]\n *\n * const sorted = arrays.sort(compare)\n *\n * console.info(sorted)\n * // [\n * // Uint8Array[0, 1, 2]\n * // Uint8Array[3, 4, 5]\n * // ]\n * ```\n *\n * ## concat(arrays, \\[length])\n *\n * Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.\n *\n * If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.\n *\n * ### Example\n *\n * ```js\n * import { concat } from 'uint8arrays/concat'\n *\n * const arrays = [\n * Uint8Array.from([0, 1, 2]),\n * Uint8Array.from([3, 4, 5])\n * ]\n *\n * const all = concat(arrays, 6)\n *\n * console.info(all)\n * // Uint8Array[0, 1, 2, 3, 4, 5]\n * ```\n *\n * ## equals(a, b)\n *\n * Returns true if the two arrays are the same array or if they have the same length and contents.\n *\n * ### Example\n *\n * ```js\n * import { equals } from 'uint8arrays/equals'\n *\n * const a = Uint8Array.from([0, 1, 2])\n * const b = Uint8Array.from([3, 4, 5])\n * const c = Uint8Array.from([0, 1, 2])\n *\n * console.info(equals(a, b)) // false\n * console.info(equals(a, c)) // true\n * console.info(equals(a, a)) // true\n * ```\n *\n * ## fromString(string, encoding = 'utf8')\n *\n * Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.\n *\n * Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n *\n * ### Example\n *\n * ```js\n * import { fromString } from 'uint8arrays/from-string'\n *\n * console.info(fromString('hello world')) // Uint8Array[104, 101 ...\n * console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...\n * console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...\n * console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...\n * ```\n *\n * ## toString(array, encoding = 'utf8')\n *\n * Returns a string created from the passed `Uint8Array` in the passed encoding.\n *\n * Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n *\n * ### Example\n *\n * ```js\n * import { toString } from 'uint8arrays/to-string'\n *\n * console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'\n * console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'\n * console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'\n * console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'\n * ```\n *\n * ## xor(a, b)\n *\n * Returns a `Uint8Array` containing `a` and `b` xored together.\n *\n * ### Example\n *\n * ```js\n * import { xor } from 'uint8arrays/xor'\n *\n * console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]\n * ```\n */\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js ***! + \*********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/as-uint8array.js": +/*!******************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/as-uint8array.js ***! + \******************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ asUint8Array: () => (/* binding */ asUint8Array)\n/* harmony export */ });\n/**\n * To guarantee Uint8Array semantics, convert nodejs Buffers\n * into vanilla Uint8Arrays\n */\nfunction asUint8Array(buf) {\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/bases.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/bases.js ***! + \**********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/xor.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/xor.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ xor: () => (/* binding */ xor)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns the xor distance between two arrays\n */\nfunction xor(a, b) {\n if (a.length !== b.length) {\n throw new Error('Inputs should have the same length');\n }\n const result = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(a.length);\n for (let i = 0; i < a.length; i++) {\n result[i] = a[i] ^ b[i];\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(result);\n}\n//# sourceMappingURL=xor.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/uint8arrays/dist/src/xor.js?"); /***/ }), @@ -2401,36 +2661,14 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js": -/*!*****************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js ***! - \*****************************************************************/ +/***/ "./node_modules/@libp2p/bootstrap/dist/src/index.js": +/*!**********************************************************!*\ + !*** ./node_modules/@libp2p/bootstrap/dist/src/index.js ***! + \**********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ cipherMode: () => (/* binding */ cipherMode)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\nconst CIPHER_MODES = {\n 16: 'aes-128-ctr',\n 32: 'aes-256-ctr'\n};\nfunction cipherMode(key) {\n if (key.length === 16 || key.length === 32) {\n return CIPHER_MODES[key.length];\n }\n const modes = Object.entries(CIPHER_MODES).map(([k, v]) => `${k} (${v})`).join(' / ');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Invalid key length ${key.length} bytes. Must be ${modes}`, 'ERR_INVALID_KEY_LENGTH');\n}\n//# sourceMappingURL=cipher-mode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js ***! - \*********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createCipheriv: () => (/* binding */ createCipheriv),\n/* harmony export */ createDecipheriv: () => (/* binding */ createDecipheriv)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_aes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/aes.js */ \"./node_modules/node-forge/lib/aes.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n// @ts-expect-error types are missing\n\n\n\nfunction createCipheriv(mode, key, iv) {\n const cipher2 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.cipher.createCipher('AES-CTR', (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(iv, 'ascii') });\n return {\n update: (data) => {\n cipher2.update(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.util.createBuffer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(cipher2.output.getBytes(), 'ascii');\n }\n };\n}\nfunction createDecipheriv(mode, key, iv) {\n const cipher2 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.cipher.createDecipher('AES-CTR', (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(iv, 'ascii') });\n return {\n update: (data) => {\n cipher2.update(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.util.createBuffer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(cipher2.output.getBytes(), 'ascii');\n }\n };\n}\n//# sourceMappingURL=ciphers-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/dist/src/aes/index.js": -/*!***********************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/aes/index.js ***! - \***********************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create)\n/* harmony export */ });\n/* harmony import */ var _cipher_mode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cipher-mode.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js\");\n/* harmony import */ var _ciphers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ciphers.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js\");\n\n\nasync function create(key, iv) {\n const mode = (0,_cipher_mode_js__WEBPACK_IMPORTED_MODULE_0__.cipherMode)(key);\n const cipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_1__.createCipheriv(mode, key, iv);\n const decipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_1__.createDecipheriv(mode, key, iv);\n const res = {\n async encrypt(data) {\n return cipher.update(data);\n },\n async decrypt(data) {\n return decipher.update(data);\n }\n };\n return res;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/aes/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bootstrap: () => (/* binding */ bootstrap)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * The configured bootstrap peers will be discovered after the configured timeout. This will ensure there are some peers in the peer store for the node to use to discover other peers.\n *\n * They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire after two minutes which means the nodes connections may be closed if the maximum number of connections is reached.\n *\n * Clients that need constant connections to bootstrap nodes (e.g. browsers) can set the TTL to `Infinity`.\n *\n * @example Configuring a list of bootstrap nodes\n *\n * ```TypeScript\n * import { createLibp2p } from 'libp2p'\n * import { bootstrap } from '@libp2p/bootstrap'\n *\n * const libp2p = await createLibp2p({\n * peerDiscovery: [\n * bootstrap({\n * list: [\n * // a list of bootstrap peer multiaddrs to connect to on node startup\n * '/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',\n * '/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',\n * '/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa'\n * ]\n * })\n * ]\n * })\n *\n * libp2p.addEventListener('peer:discovery', (evt) => {\n * console.log('found peer: ', evt.detail.toString())\n * })\n * ```\n */\n\n\n\n\nconst DEFAULT_BOOTSTRAP_TAG_NAME = 'bootstrap';\nconst DEFAULT_BOOTSTRAP_TAG_VALUE = 50;\nconst DEFAULT_BOOTSTRAP_TAG_TTL = 120000;\nconst DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT = 1000;\n/**\n * Emits 'peer' events on a regular interval for each peer in the provided list.\n */\nclass Bootstrap extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.TypedEventEmitter {\n static tag = 'bootstrap';\n log;\n timer;\n list;\n timeout;\n components;\n _init;\n constructor(components, options = { list: [] }) {\n if (options.list == null || options.list.length === 0) {\n throw new Error('Bootstrap requires a list of peer addresses');\n }\n super();\n this.components = components;\n this.log = components.logger.forComponent('libp2p:bootstrap');\n this.timeout = options.timeout ?? DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT;\n this.list = [];\n for (const candidate of options.list) {\n if (!_multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.P2P.matches(candidate)) {\n this.log.error('Invalid multiaddr');\n continue;\n }\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(candidate);\n const peerIdStr = ma.getPeerId();\n if (peerIdStr == null) {\n this.log.error('Invalid bootstrap multiaddr without peer id');\n continue;\n }\n const peerData = {\n id: (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromString)(peerIdStr),\n multiaddrs: [ma]\n };\n this.list.push(peerData);\n }\n this._init = options;\n }\n [_libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.peerDiscoverySymbol] = this;\n [Symbol.toStringTag] = '@libp2p/bootstrap';\n isStarted() {\n return Boolean(this.timer);\n }\n /**\n * Start emitting events\n */\n start() {\n if (this.isStarted()) {\n return;\n }\n this.log('Starting bootstrap node discovery, discovering peers after %s ms', this.timeout);\n this.timer = setTimeout(() => {\n void this._discoverBootstrapPeers()\n .catch(err => {\n this.log.error(err);\n });\n }, this.timeout);\n }\n /**\n * Emit each address in the list as a PeerInfo\n */\n async _discoverBootstrapPeers() {\n if (this.timer == null) {\n return;\n }\n for (const peerData of this.list) {\n await this.components.peerStore.merge(peerData.id, {\n tags: {\n [this._init.tagName ?? DEFAULT_BOOTSTRAP_TAG_NAME]: {\n value: this._init.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._init.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL\n }\n }\n });\n // check we are still running\n if (this.timer == null) {\n return;\n }\n this.safeDispatchEvent('peer', { detail: peerData });\n }\n }\n /**\n * Stop emitting events\n */\n stop() {\n if (this.timer != null) {\n clearTimeout(this.timer);\n }\n this.timer = undefined;\n }\n}\nfunction bootstrap(init) {\n return (components) => new Bootstrap(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/bootstrap/dist/src/index.js?"); /***/ }), @@ -2441,7 +2679,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ derivedEmptyPasswordKey: () => (/* binding */ derivedEmptyPasswordKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n\n\n\n// WebKit on Linux does not support deriving a key from an empty PBKDF2 key.\n// So, as a workaround, we provide the generated key as a constant. We test that\n// this generated key is accurate in test/workaround.spec.ts\n// Generated via:\n// await crypto.subtle.exportKey('jwk',\n// await crypto.subtle.deriveKey(\n// { name: 'PBKDF2', salt: new Uint8Array(16), iterations: 32767, hash: { name: 'SHA-256' } },\n// await crypto.subtle.importKey('raw', new Uint8Array(0), { name: 'PBKDF2' }, false, ['deriveKey']),\n// { name: 'AES-GCM', length: 128 }, true, ['encrypt', 'decrypt'])\n// )\nconst derivedEmptyPasswordKey = { alg: 'A128GCM', ext: true, k: 'scm9jmO_4BJAgdwWGVulLg', key_ops: ['encrypt', 'decrypt'], kty: 'oct' };\n// Based off of code from https://github.com/luke-park/SecureCompatibleEncryptionExamples\nfunction create(opts) {\n const algorithm = opts?.algorithm ?? 'AES-GCM';\n let keyLength = opts?.keyLength ?? 16;\n const nonceLength = opts?.nonceLength ?? 12;\n const digest = opts?.digest ?? 'SHA-256';\n const saltLength = opts?.saltLength ?? 16;\n const iterations = opts?.iterations ?? 32767;\n const crypto = _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get();\n keyLength *= 8; // Browser crypto uses bits instead of bytes\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to encrypt the data.\n */\n async function encrypt(data, password) {\n const salt = crypto.getRandomValues(new Uint8Array(saltLength));\n const nonce = crypto.getRandomValues(new Uint8Array(nonceLength));\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n }\n }\n else {\n // Derive a key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n // Encrypt the string.\n const ciphertext = await crypto.subtle.encrypt(aesGcm, cryptoKey, data);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([salt, aesGcm.iv, new Uint8Array(ciphertext)]);\n }\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to decrypt the data. The options used to create\n * this decryption cipher must be the same as those used to create\n * the encryption cipher.\n */\n async function decrypt(data, password) {\n const salt = data.subarray(0, saltLength);\n const nonce = data.subarray(saltLength, saltLength + nonceLength);\n const ciphertext = data.subarray(saltLength + nonceLength);\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['decrypt']);\n }\n }\n else {\n // Derive the key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n // Decrypt the string.\n const plaintext = await crypto.subtle.decrypt(aesGcm, cryptoKey, ciphertext);\n return new Uint8Array(plaintext);\n }\n const cipher = {\n encrypt,\n decrypt\n };\n return cipher;\n}\n//# sourceMappingURL=aes-gcm.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ derivedEmptyPasswordKey: () => (/* binding */ derivedEmptyPasswordKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js\");\n\n\n\n// WebKit on Linux does not support deriving a key from an empty PBKDF2 key.\n// So, as a workaround, we provide the generated key as a constant. We test that\n// this generated key is accurate in test/workaround.spec.ts\n// Generated via:\n// await crypto.subtle.exportKey('jwk',\n// await crypto.subtle.deriveKey(\n// { name: 'PBKDF2', salt: new Uint8Array(16), iterations: 32767, hash: { name: 'SHA-256' } },\n// await crypto.subtle.importKey('raw', new Uint8Array(0), { name: 'PBKDF2' }, false, ['deriveKey']),\n// { name: 'AES-GCM', length: 128 }, true, ['encrypt', 'decrypt'])\n// )\nconst derivedEmptyPasswordKey = { alg: 'A128GCM', ext: true, k: 'scm9jmO_4BJAgdwWGVulLg', key_ops: ['encrypt', 'decrypt'], kty: 'oct' };\n// Based off of code from https://github.com/luke-park/SecureCompatibleEncryptionExamples\nfunction create(opts) {\n const algorithm = opts?.algorithm ?? 'AES-GCM';\n let keyLength = opts?.keyLength ?? 16;\n const nonceLength = opts?.nonceLength ?? 12;\n const digest = opts?.digest ?? 'SHA-256';\n const saltLength = opts?.saltLength ?? 16;\n const iterations = opts?.iterations ?? 32767;\n const crypto = _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get();\n keyLength *= 8; // Browser crypto uses bits instead of bytes\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to encrypt the data.\n */\n async function encrypt(data, password) {\n const salt = crypto.getRandomValues(new Uint8Array(saltLength));\n const nonce = crypto.getRandomValues(new Uint8Array(nonceLength));\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt']);\n }\n }\n else {\n // Derive a key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt']);\n }\n // Encrypt the string.\n const ciphertext = await crypto.subtle.encrypt(aesGcm, cryptoKey, data);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([salt, aesGcm.iv, new Uint8Array(ciphertext)]);\n }\n /**\n * Uses the provided password to derive a pbkdf2 key. The key\n * will then be used to decrypt the data. The options used to create\n * this decryption cipher must be the same as those used to create\n * the encryption cipher.\n */\n async function decrypt(data, password) {\n const salt = data.subarray(0, saltLength);\n const nonce = data.subarray(saltLength, saltLength + nonceLength);\n const ciphertext = data.subarray(saltLength + nonceLength);\n const aesGcm = { name: algorithm, iv: nonce };\n if (typeof password === 'string') {\n password = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(password);\n }\n let cryptoKey;\n if (password.length === 0) {\n try {\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const runtimeDerivedEmptyPassword = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, runtimeDerivedEmptyPassword, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n catch {\n cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['decrypt']);\n }\n }\n else {\n // Derive the key using PBKDF2.\n const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } };\n const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey']);\n cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['decrypt']);\n }\n // Decrypt the string.\n const plaintext = await crypto.subtle.decrypt(aesGcm, cryptoKey, ciphertext);\n return new Uint8Array(plaintext);\n }\n const cipher = {\n encrypt,\n decrypt\n };\n return cipher;\n}\n//# sourceMappingURL=aes-gcm.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js?"); /***/ }), @@ -2452,7 +2690,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create)\n/* harmony export */ });\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _lengths_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lengths.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/lengths.js\");\n\n\nconst hashTypes = {\n SHA1: 'SHA-1',\n SHA256: 'SHA-256',\n SHA512: 'SHA-512'\n};\nconst sign = async (key, data) => {\n const buf = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.sign({ name: 'HMAC' }, key, data);\n return new Uint8Array(buf, 0, buf.byteLength);\n};\nasync function create(hashType, secret) {\n const hash = hashTypes[hashType];\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.importKey('raw', secret, {\n name: 'HMAC',\n hash: { name: hash }\n }, false, ['sign']);\n return {\n async digest(data) {\n return sign(key, data);\n },\n length: _lengths_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"][hashType]\n };\n}\n//# sourceMappingURL=index-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ create: () => (/* binding */ create)\n/* harmony export */ });\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js\");\n/* harmony import */ var _lengths_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lengths.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/lengths.js\");\n\n\nconst hashTypes = {\n SHA1: 'SHA-1',\n SHA256: 'SHA-256',\n SHA512: 'SHA-512'\n};\nconst sign = async (key, data) => {\n const buf = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.sign({ name: 'HMAC' }, key, data);\n return new Uint8Array(buf, 0, buf.byteLength);\n};\nasync function create(hashType, secret) {\n const hash = hashTypes[hashType];\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.importKey('raw', secret, {\n name: 'HMAC',\n hash: { name: hash }\n }, false, ['sign']);\n return {\n async digest(data) {\n return sign(key, data);\n },\n length: _lengths_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"][hashType]\n };\n}\n//# sourceMappingURL=index-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js?"); /***/ }), @@ -2467,17 +2705,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/crypto/dist/src/index.js": -/*!*******************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/index.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ aes: () => (/* reexport module object */ _aes_index_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ hmac: () => (/* reexport module object */ _hmac_index_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ keys: () => (/* reexport module object */ _keys_index_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ pbkdf2: () => (/* reexport safe */ _pbkdf2_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]),\n/* harmony export */ randomBytes: () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"])\n/* harmony export */ });\n/* harmony import */ var _aes_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./aes/index.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/index.js\");\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hmac/index.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n/* harmony import */ var _keys_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keys/index.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _pbkdf2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbkdf2.js */ \"./node_modules/@libp2p/crypto/dist/src/pbkdf2.js\");\n/* harmony import */ var _random_bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js": /*!*******************************************************************!*\ !*** ./node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js ***! @@ -2485,7 +2712,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateEphmeralKeyPair: () => (/* binding */ generateEphmeralKeyPair)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n\n\n\n\n\n\nconst bits = {\n 'P-256': 256,\n 'P-384': 384,\n 'P-521': 521\n};\nconst curveTypes = Object.keys(bits);\nconst names = curveTypes.join(' / ');\nasync function generateEphmeralKeyPair(curve) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].get().subtle.generateKey({\n name: 'ECDH',\n namedCurve: curve\n }, true, ['deriveBits']);\n // forcePrivate is used for testing only\n const genSharedKey = async (theirPub, forcePrivate) => {\n let privateKey;\n if (forcePrivate != null) {\n privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].get().subtle.importKey('jwk', unmarshalPrivateKey(curve, forcePrivate), {\n name: 'ECDH',\n namedCurve: curve\n }, false, ['deriveBits']);\n }\n else {\n privateKey = pair.privateKey;\n }\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].get().subtle.importKey('jwk', unmarshalPublicKey(curve, theirPub), {\n name: 'ECDH',\n namedCurve: curve\n }, false, []);\n const buffer = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].get().subtle.deriveBits({\n name: 'ECDH',\n // @ts-expect-error namedCurve is missing from the types\n namedCurve: curve,\n public: key\n }, privateKey, bits[curve]);\n return new Uint8Array(buffer, 0, buffer.byteLength);\n };\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey);\n const ecdhKey = {\n key: marshalPublicKey(publicKey),\n genSharedKey\n };\n return ecdhKey;\n}\nconst curveLengths = {\n 'P-256': 32,\n 'P-384': 48,\n 'P-521': 66\n};\n// Marshal converts a jwk encoded ECDH public key into the\n// form specified in section 4.3.6 of ANSI X9.62. (This is the format\n// go-ipfs uses)\nfunction marshalPublicKey(jwk) {\n if (jwk.crv == null || jwk.x == null || jwk.y == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n if (jwk.crv !== 'P-256' && jwk.crv !== 'P-384' && jwk.crv !== 'P-521') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Unknown curve: ${jwk.crv}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[jwk.crv];\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([\n Uint8Array.from([4]),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_4__.base64urlToBuffer)(jwk.x, byteLen),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_4__.base64urlToBuffer)(jwk.y, byteLen)\n ], 1 + byteLen * 2);\n}\n// Unmarshal converts a point, serialized by Marshal, into an jwk encoded key\nfunction unmarshalPublicKey(curve, key) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[curve];\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(key.subarray(0, 1), Uint8Array.from([4]))) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Cannot unmarshal public key - invalid key format', 'ERR_INVALID_KEY_FORMAT');\n }\n return {\n kty: 'EC',\n crv: curve,\n x: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(key.subarray(1, byteLen + 1), 'base64url'),\n y: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(key.subarray(1 + byteLen), 'base64url'),\n ext: true\n };\n}\nconst unmarshalPrivateKey = (curve, key) => ({\n ...unmarshalPublicKey(curve, key.public),\n d: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(key.private, 'base64url')\n});\n//# sourceMappingURL=ecdh-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateEphmeralKeyPair: () => (/* binding */ generateEphmeralKeyPair)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js\");\n\n\n\n\n\n\nconst bits = {\n 'P-256': 256,\n 'P-384': 384,\n 'P-521': 521\n};\nconst curveTypes = Object.keys(bits);\nconst names = curveTypes.join(' / ');\nasync function generateEphmeralKeyPair(curve) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.generateKey({\n name: 'ECDH',\n namedCurve: curve\n }, true, ['deriveBits']);\n // forcePrivate is used for testing only\n const genSharedKey = async (theirPub, forcePrivate) => {\n let privateKey;\n if (forcePrivate != null) {\n privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', unmarshalPrivateKey(curve, forcePrivate), {\n name: 'ECDH',\n namedCurve: curve\n }, false, ['deriveBits']);\n }\n else {\n privateKey = pair.privateKey;\n }\n const key = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', unmarshalPublicKey(curve, theirPub), {\n name: 'ECDH',\n namedCurve: curve\n }, false, []);\n const buffer = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.deriveBits({\n name: 'ECDH',\n // @ts-expect-error namedCurve is missing from the types\n namedCurve: curve,\n public: key\n }, privateKey, bits[curve]);\n return new Uint8Array(buffer, 0, buffer.byteLength);\n };\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey);\n const ecdhKey = {\n key: marshalPublicKey(publicKey),\n genSharedKey\n };\n return ecdhKey;\n}\nconst curveLengths = {\n 'P-256': 32,\n 'P-384': 48,\n 'P-521': 66\n};\n// Marshal converts a jwk encoded ECDH public key into the\n// form specified in section 4.3.6 of ANSI X9.62. (This is the format\n// go-ipfs uses)\nfunction marshalPublicKey(jwk) {\n if (jwk.crv == null || jwk.x == null || jwk.y == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n if (jwk.crv !== 'P-256' && jwk.crv !== 'P-384' && jwk.crv !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`Unknown curve: ${jwk.crv}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[jwk.crv];\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([\n Uint8Array.from([4]), // uncompressed point\n (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBuffer)(jwk.x, byteLen),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.base64urlToBuffer)(jwk.y, byteLen)\n ], 1 + byteLen * 2);\n}\n// Unmarshal converts a point, serialized by Marshal, into an jwk encoded key\nfunction unmarshalPublicKey(curve, key) {\n if (curve !== 'P-256' && curve !== 'P-384' && curve !== 'P-521') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`Unknown curve: ${curve}. Must be ${names}`, 'ERR_INVALID_CURVE');\n }\n const byteLen = curveLengths[curve];\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(key.subarray(0, 1), Uint8Array.from([4]))) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Cannot unmarshal public key - invalid key format', 'ERR_INVALID_KEY_FORMAT');\n }\n return {\n kty: 'EC',\n crv: curve,\n x: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.subarray(1, byteLen + 1), 'base64url'),\n y: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.subarray(1 + byteLen), 'base64url'),\n ext: true\n };\n}\nconst unmarshalPrivateKey = (curve, key) => ({\n ...unmarshalPublicKey(curve, key.public),\n d: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(key.private, 'base64url')\n});\n//# sourceMappingURL=ecdh-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js?"); /***/ }), @@ -2496,7 +2723,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ generateKeyFromSeed: () => (/* binding */ generateKeyFromSeed),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ publicKeyLength: () => (/* binding */ PUBLIC_KEY_BYTE_LENGTH)\n/* harmony export */ });\n/* harmony import */ var _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/ed25519 */ \"./node_modules/@noble/ed25519/lib/esm/index.js\");\n\nconst PUBLIC_KEY_BYTE_LENGTH = 32;\nconst PRIVATE_KEY_BYTE_LENGTH = 64; // private key is actually 32 bytes but for historical reasons we concat private and public keys\nconst KEYS_BYTE_LENGTH = 32;\n\n\nasync function generateKey() {\n // the actual private key (32 bytes)\n const privateKeyRaw = _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.utils.randomPrivateKey();\n const publicKey = await _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.getPublicKey(privateKeyRaw);\n // concatenated the public key to the private key\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\n/**\n * Generate keypair from a 32 byte uint8array\n */\nasync function generateKeyFromSeed(seed) {\n if (seed.length !== KEYS_BYTE_LENGTH) {\n throw new TypeError('\"seed\" must be 32 bytes in length.');\n }\n else if (!(seed instanceof Uint8Array)) {\n throw new TypeError('\"seed\" must be a node.js Buffer, or Uint8Array.');\n }\n // based on node forges algorithm, the seed is used directly as private key\n const privateKeyRaw = seed;\n const publicKey = await _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.getPublicKey(privateKeyRaw);\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\nasync function hashAndSign(privateKey, msg) {\n const privateKeyRaw = privateKey.subarray(0, KEYS_BYTE_LENGTH);\n return _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.sign(msg, privateKeyRaw);\n}\nasync function hashAndVerify(publicKey, sig, msg) {\n return _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.verify(sig, msg, publicKey);\n}\nfunction concatKeys(privateKeyRaw, publicKey) {\n const privateKey = new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);\n for (let i = 0; i < KEYS_BYTE_LENGTH; i++) {\n privateKey[i] = privateKeyRaw[i];\n privateKey[KEYS_BYTE_LENGTH + i] = publicKey[i];\n }\n return privateKey;\n}\n//# sourceMappingURL=ed25519-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ generateKeyFromSeed: () => (/* binding */ generateKeyFromSeed),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ publicKeyLength: () => (/* binding */ PUBLIC_KEY_BYTE_LENGTH)\n/* harmony export */ });\n/* harmony import */ var _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/curves/ed25519 */ \"./node_modules/@noble/curves/esm/ed25519.js\");\n\nconst PUBLIC_KEY_BYTE_LENGTH = 32;\nconst PRIVATE_KEY_BYTE_LENGTH = 64; // private key is actually 32 bytes but for historical reasons we concat private and public keys\nconst KEYS_BYTE_LENGTH = 32;\n\n\nfunction generateKey() {\n // the actual private key (32 bytes)\n const privateKeyRaw = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.utils.randomPrivateKey();\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.getPublicKey(privateKeyRaw);\n // concatenated the public key to the private key\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\n/**\n * Generate keypair from a 32 byte uint8array\n */\nfunction generateKeyFromSeed(seed) {\n if (seed.length !== KEYS_BYTE_LENGTH) {\n throw new TypeError('\"seed\" must be 32 bytes in length.');\n }\n else if (!(seed instanceof Uint8Array)) {\n throw new TypeError('\"seed\" must be a node.js Buffer, or Uint8Array.');\n }\n // based on node forges algorithm, the seed is used directly as private key\n const privateKeyRaw = seed;\n const publicKey = _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.getPublicKey(privateKeyRaw);\n const privateKey = concatKeys(privateKeyRaw, publicKey);\n return {\n privateKey,\n publicKey\n };\n}\nfunction hashAndSign(privateKey, msg) {\n const privateKeyRaw = privateKey.subarray(0, KEYS_BYTE_LENGTH);\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.sign(msg instanceof Uint8Array ? msg : msg.subarray(), privateKeyRaw);\n}\nfunction hashAndVerify(publicKey, sig, msg) {\n return _noble_curves_ed25519__WEBPACK_IMPORTED_MODULE_0__.ed25519.verify(sig, msg instanceof Uint8Array ? msg : msg.subarray(), publicKey);\n}\nfunction concatKeys(privateKeyRaw, publicKey) {\n const privateKey = new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);\n for (let i = 0; i < KEYS_BYTE_LENGTH; i++) {\n privateKey[i] = privateKeyRaw[i];\n privateKey[KEYS_BYTE_LENGTH + i] = publicKey[i];\n }\n return privateKey;\n}\n//# sourceMappingURL=ed25519-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js?"); /***/ }), @@ -2507,7 +2734,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Ed25519PrivateKey: () => (/* binding */ Ed25519PrivateKey),\n/* harmony export */ Ed25519PublicKey: () => (/* binding */ Ed25519PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ unmarshalEd25519PrivateKey: () => (/* binding */ unmarshalEd25519PrivateKey),\n/* harmony export */ unmarshalEd25519PublicKey: () => (/* binding */ unmarshalEd25519PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/src/hashes/identity.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _ed25519_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ed25519.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n\n\n\n\n\n\n\n\nclass Ed25519PublicKey {\n _key;\n constructor(key) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n async verify(data, sig) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Ed25519PrivateKey {\n _key;\n _publicKey;\n // key - 64 byte Uint8Array containing private key\n // publicKey - 32 byte Uint8Array containing public key\n constructor(key, publicKey) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n this._publicKey = ensureKey(publicKey, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n async sign(message) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.hashAndSign(this._key, message);\n }\n get public() {\n return new Ed25519PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__.sha256.digest(this.bytes);\n return bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the identity multihash containing its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n *\n * @returns {Promise}\n */\n async id() {\n const encoding = multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_2__.identity.digest(this.public.bytes);\n return multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__.base58btc.encode(encoding.bytes).substring(1);\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_6__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalEd25519PrivateKey(bytes) {\n // Try the old, redundant public key version\n if (bytes.length > _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength + _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength, bytes.length);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n }\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n}\nfunction unmarshalEd25519PublicKey(bytes) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n return new Ed25519PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const { privateKey, publicKey } = await _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.generateKey();\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nasync function generateKeyPairFromSeed(seed) {\n const { privateKey, publicKey } = await _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.generateKeyFromSeed(seed);\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nfunction ensureKey(key, length) {\n key = Uint8Array.from(key ?? []);\n if (key.length !== length) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Key must be a Uint8Array of length ${length}, got ${key.length}`, 'ERR_INVALID_KEY_TYPE');\n }\n return key;\n}\n//# sourceMappingURL=ed25519-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Ed25519PrivateKey: () => (/* binding */ Ed25519PrivateKey),\n/* harmony export */ Ed25519PublicKey: () => (/* binding */ Ed25519PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ unmarshalEd25519PrivateKey: () => (/* binding */ unmarshalEd25519PrivateKey),\n/* harmony export */ unmarshalEd25519PublicKey: () => (/* binding */ unmarshalEd25519PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _ed25519_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ed25519.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n\n\n\n\n\n\n\n\n\nclass Ed25519PublicKey {\n _key;\n constructor(key) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.publicKeyLength);\n }\n verify(data, sig) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_6__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n}\nclass Ed25519PrivateKey {\n _key;\n _publicKey;\n // key - 64 byte Uint8Array containing private key\n // publicKey - 32 byte Uint8Array containing public key\n constructor(key, publicKey) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength);\n this._publicKey = ensureKey(publicKey, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.publicKeyLength);\n }\n sign(message) {\n return _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.hashAndSign(this._key, message);\n }\n get public() {\n return new Ed25519PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Ed25519,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n let bytes;\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_6__.isPromise)(p)) {\n ({ bytes } = await p);\n }\n else {\n bytes = p.bytes;\n }\n return bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the identity multihash containing its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n *\n * @returns {Promise}\n */\n async id() {\n const encoding = multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_1__.identity.digest(this.public.bytes);\n return multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.encode(encoding.bytes).substring(1);\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_7__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalEd25519PrivateKey(bytes) {\n // Try the old, redundant public key version\n if (bytes.length > _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength + _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.publicKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength, bytes.length);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n }\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength);\n const privateKeyBytes = bytes.subarray(0, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.privateKeyLength);\n const publicKeyBytes = bytes.subarray(_ed25519_js__WEBPACK_IMPORTED_MODULE_4__.publicKeyLength);\n return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes);\n}\nfunction unmarshalEd25519PublicKey(bytes) {\n bytes = ensureKey(bytes, _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.publicKeyLength);\n return new Ed25519PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const { privateKey, publicKey } = _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.generateKey();\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nasync function generateKeyPairFromSeed(seed) {\n const { privateKey, publicKey } = _ed25519_js__WEBPACK_IMPORTED_MODULE_4__.generateKeyFromSeed(seed);\n return new Ed25519PrivateKey(privateKey, publicKey);\n}\nfunction ensureKey(key, length) {\n key = Uint8Array.from(key ?? []);\n if (key.length !== length) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError(`Key must be a Uint8Array of length ${length}, got ${key.length}`, 'ERR_INVALID_KEY_TYPE');\n }\n return key;\n}\n//# sourceMappingURL=ed25519-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js?"); /***/ }), @@ -2529,7 +2756,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ exporter: () => (/* binding */ exporter)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Exports the given PrivateKey as a base64 encoded string.\n * The PrivateKey is encrypted via a password derived PBKDF2 key\n * leveraging the aes-gcm cipher algorithm.\n */\nasync function exporter(privateKey, password) {\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n const encryptedKey = await cipher.encrypt(privateKey, password);\n return multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.encode(encryptedKey);\n}\n//# sourceMappingURL=exporter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/exporter.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ exporter: () => (/* binding */ exporter)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Exports the given PrivateKey as a base64 encoded string.\n * The PrivateKey is encrypted via a password derived PBKDF2 key\n * leveraging the aes-gcm cipher algorithm.\n */\nasync function exporter(privateKey, password) {\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n const encryptedKey = await cipher.encrypt(privateKey, password);\n return multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.encode(encryptedKey);\n}\n//# sourceMappingURL=exporter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/exporter.js?"); /***/ }), @@ -2540,7 +2767,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ importer: () => (/* binding */ importer)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Attempts to decrypt a base64 encoded PrivateKey string\n * with the given password. The privateKey must have been exported\n * using the same password and underlying cipher (aes-gcm)\n */\nasync function importer(privateKey, password) {\n const encryptedKey = multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.decode(privateKey);\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n return cipher.decrypt(encryptedKey, password);\n}\n//# sourceMappingURL=importer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/importer.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ importer: () => (/* binding */ importer)\n/* harmony export */ });\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ciphers/aes-gcm.js */ \"./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js\");\n\n\n/**\n * Attempts to decrypt a base64 encoded PrivateKey string\n * with the given password. The privateKey must have been exported\n * using the same password and underlying cipher (aes-gcm)\n */\nasync function importer(privateKey, password) {\n const encryptedKey = multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_0__.base64.decode(privateKey);\n const cipher = _ciphers_aes_gcm_js__WEBPACK_IMPORTED_MODULE_1__.create();\n return cipher.decrypt(encryptedKey, password);\n}\n//# sourceMappingURL=importer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/importer.js?"); /***/ }), @@ -2551,18 +2778,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateEphemeralKeyPair: () => (/* reexport safe */ _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"]),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ importKey: () => (/* binding */ importKey),\n/* harmony export */ keyStretcher: () => (/* reexport safe */ _key_stretcher_js__WEBPACK_IMPORTED_MODULE_8__.keyStretcher),\n/* harmony export */ keysPBM: () => (/* reexport module object */ _keys_js__WEBPACK_IMPORTED_MODULE_9__),\n/* harmony export */ marshalPrivateKey: () => (/* binding */ marshalPrivateKey),\n/* harmony export */ marshalPublicKey: () => (/* binding */ marshalPublicKey),\n/* harmony export */ supportedKeys: () => (/* binding */ supportedKeys),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ unmarshalPublicKey: () => (/* binding */ unmarshalPublicKey)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/asn1.js */ \"./node_modules/node-forge/lib/asn1.js\");\n/* harmony import */ var node_forge_lib_pbe_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/pbe.js */ \"./node_modules/node-forge/lib/pbe.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _ed25519_class_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ed25519-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js\");\n/* harmony import */ var _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ephemeral-keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js\");\n/* harmony import */ var _importer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./importer.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/importer.js\");\n/* harmony import */ var _key_stretcher_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./key-stretcher.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n/* harmony import */ var _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./secp256k1-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js\");\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\n\n\n\n\n\n\n\n\nconst supportedKeys = {\n rsa: _rsa_class_js__WEBPACK_IMPORTED_MODULE_10__,\n ed25519: _ed25519_class_js__WEBPACK_IMPORTED_MODULE_5__,\n secp256k1: _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_11__\n};\nfunction unsupportedKey(type) {\n const supported = Object.keys(supportedKeys).join(' / ');\n return new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`invalid or unsupported key type ${type}. Must be ${supported}`, 'ERR_UNSUPPORTED_KEY_TYPE');\n}\nfunction typeToKey(type) {\n type = type.toLowerCase();\n if (type === 'rsa' || type === 'ed25519' || type === 'secp256k1') {\n return supportedKeys[type];\n }\n throw unsupportedKey(type);\n}\n// Generates a keypair of the given type and bitsize\nasync function generateKeyPair(type, bits) {\n return typeToKey(type).generateKeyPair(bits ?? 2048);\n}\n// Generates a keypair of the given type and bitsize\n// seed is a 32 byte uint8array\nasync function generateKeyPairFromSeed(type, seed, bits) {\n if (type.toLowerCase() !== 'ed25519') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE');\n }\n return _ed25519_class_js__WEBPACK_IMPORTED_MODULE_5__.generateKeyPairFromSeed(seed);\n}\n// Converts a protobuf serialized public key into its\n// representative object\nfunction unmarshalPublicKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_9__.PublicKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'RSA');\n }\n}\n// Converts a public key object into a protobuf serialized public key\nfunction marshalPublicKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n// Converts a protobuf serialized private key into its\n// representative object\nasync function unmarshalPrivateKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_9__.PrivateKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_9__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'RSA');\n }\n}\n// Converts a private key object into a protobuf serialized private key\nfunction marshalPrivateKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n/**\n *\n * @param {string} encryptedKey\n * @param {string} password\n */\nasync function importKey(encryptedKey, password) {\n try {\n const key = await (0,_importer_js__WEBPACK_IMPORTED_MODULE_7__.importer)(encryptedKey, password);\n return await unmarshalPrivateKey(key);\n }\n catch (_) {\n // Ignore and try the old pem decrypt\n }\n // Only rsa supports pem right now\n const key = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.decryptRsaPrivateKey(encryptedKey, password);\n if (key === null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Cannot read the key, most likely the password is wrong or not a RSA key', 'ERR_CANNOT_DECRYPT_PEM');\n }\n let der = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.asn1.toDer(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.privateKeyToAsn1(key));\n der = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(der.getBytes(), 'ascii');\n return supportedKeys.rsa.unmarshalRsaPrivateKey(der);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js": -/*!**************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js ***! - \**************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ jwk2priv: () => (/* binding */ jwk2priv),\n/* harmony export */ jwk2pub: () => (/* binding */ jwk2pub)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_rsa_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/rsa.js */ \"./node_modules/node-forge/lib/rsa.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n\n// @ts-expect-error types are missing\n\n\nfunction convert(key, types) {\n return types.map(t => (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.base64urlToBigInteger)(key[t]));\n}\nfunction jwk2priv(key) {\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.setRsaPrivateKey(...convert(key, ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi']));\n}\nfunction jwk2pub(key) {\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_1__.pki.setRsaPublicKey(...convert(key, ['n', 'e']));\n}\n//# sourceMappingURL=jwk2pem.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Ed25519PrivateKey: () => (/* reexport safe */ _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__.Ed25519PrivateKey),\n/* harmony export */ Ed25519PublicKey: () => (/* reexport safe */ _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__.Ed25519PublicKey),\n/* harmony export */ MAX_RSA_KEY_SIZE: () => (/* reexport safe */ _rsa_class_js__WEBPACK_IMPORTED_MODULE_3__.MAX_RSA_KEY_SIZE),\n/* harmony export */ RsaPrivateKey: () => (/* reexport safe */ _rsa_class_js__WEBPACK_IMPORTED_MODULE_3__.RsaPrivateKey),\n/* harmony export */ RsaPublicKey: () => (/* reexport safe */ _rsa_class_js__WEBPACK_IMPORTED_MODULE_3__.RsaPublicKey),\n/* harmony export */ Secp256k1PrivateKey: () => (/* reexport safe */ _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_5__.Secp256k1PrivateKey),\n/* harmony export */ Secp256k1PublicKey: () => (/* reexport safe */ _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_5__.Secp256k1PublicKey),\n/* harmony export */ generateEphemeralKeyPair: () => (/* reexport safe */ _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ generateKeyPairFromSeed: () => (/* binding */ generateKeyPairFromSeed),\n/* harmony export */ importKey: () => (/* binding */ importKey),\n/* harmony export */ keyStretcher: () => (/* reexport safe */ _key_stretcher_js__WEBPACK_IMPORTED_MODULE_0__.keyStretcher),\n/* harmony export */ keysPBM: () => (/* reexport module object */ _keys_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ marshalPrivateKey: () => (/* binding */ marshalPrivateKey),\n/* harmony export */ marshalPublicKey: () => (/* binding */ marshalPublicKey),\n/* harmony export */ supportedKeys: () => (/* binding */ supportedKeys),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ unmarshalPublicKey: () => (/* binding */ unmarshalPublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ed25519-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js\");\n/* harmony import */ var _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ephemeral-keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js\");\n/* harmony import */ var _importer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./importer.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/importer.js\");\n/* harmony import */ var _key_stretcher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./key-stretcher.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js\");\n/* harmony import */ var _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./secp256k1-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js\");\n/**\n * @packageDocumentation\n *\n * **Supported Key Types**\n *\n * The {@link generateKeyPair}, {@link marshalPublicKey}, and {@link marshalPrivateKey} functions accept a string `type` argument.\n *\n * Currently the `'RSA'`, `'ed25519'`, and `secp256k1` types are supported, although ed25519 and secp256k1 keys support only signing and verification of messages.\n *\n * For encryption / decryption support, RSA keys should be used.\n */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst supportedKeys = {\n rsa: _rsa_class_js__WEBPACK_IMPORTED_MODULE_3__,\n ed25519: _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__,\n secp256k1: _secp256k1_class_js__WEBPACK_IMPORTED_MODULE_5__\n};\nfunction unsupportedKey(type) {\n const supported = Object.keys(supportedKeys).join(' / ');\n return new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError(`invalid or unsupported key type ${type}. Must be ${supported}`, 'ERR_UNSUPPORTED_KEY_TYPE');\n}\nfunction typeToKey(type) {\n type = type.toLowerCase();\n if (type === 'rsa' || type === 'ed25519' || type === 'secp256k1') {\n return supportedKeys[type];\n }\n throw unsupportedKey(type);\n}\n/**\n * Generates a keypair of the given type and bitsize\n *\n * @param type\n * @param bits - Minimum of 1024\n */\nasync function generateKeyPair(type, bits) {\n return typeToKey(type).generateKeyPair(bits ?? 2048);\n}\n/**\n * Generates a keypair of the given type and bitsize.\n *\n * Seed is a 32 byte uint8array\n */\nasync function generateKeyPairFromSeed(type, seed, bits) {\n if (type.toLowerCase() !== 'ed25519') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE');\n }\n return _ed25519_class_js__WEBPACK_IMPORTED_MODULE_4__.generateKeyPairFromSeed(seed);\n}\n/**\n * Converts a protobuf serialized public key into its representative object\n */\nfunction unmarshalPublicKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_2__.PublicKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'unknown');\n }\n}\n/**\n * Converts a public key object into a protobuf serialized public key\n */\nfunction marshalPublicKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n/**\n * Converts a protobuf serialized private key into its representative object\n */\nasync function unmarshalPrivateKey(buf) {\n const decoded = _keys_js__WEBPACK_IMPORTED_MODULE_2__.PrivateKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_2__.KeyType.Secp256k1:\n return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(data);\n default:\n throw unsupportedKey(decoded.Type ?? 'RSA');\n }\n}\n/**\n * Converts a private key object into a protobuf serialized private key\n */\nfunction marshalPrivateKey(key, type) {\n type = (type ?? 'rsa').toLowerCase();\n typeToKey(type); // check type\n return key.bytes;\n}\n/**\n * Converts an exported private key into its representative object.\n *\n * Supported formats are 'pem' (RSA only) and 'libp2p-key'.\n */\nasync function importKey(encryptedKey, password) {\n try {\n const key = await (0,_importer_js__WEBPACK_IMPORTED_MODULE_7__.importer)(encryptedKey, password);\n return await unmarshalPrivateKey(key);\n }\n catch (_) {\n // Ignore and try the old pem decrypt\n }\n if (!encryptedKey.includes('BEGIN')) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Encrypted key was not a libp2p-key or a PEM file', 'ERR_INVALID_IMPORT_FORMAT');\n }\n return (0,_rsa_utils_js__WEBPACK_IMPORTED_MODULE_8__.importFromPem)(encryptedKey, password);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/index.js?"); /***/ }), @@ -2573,7 +2789,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ keyStretcher: () => (/* binding */ keyStretcher)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../hmac/index.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n\n\n\n\nconst cipherMap = {\n 'AES-128': {\n ivSize: 16,\n keySize: 16\n },\n 'AES-256': {\n ivSize: 16,\n keySize: 32\n },\n Blowfish: {\n ivSize: 8,\n keySize: 32\n }\n};\n/**\n * Generates a set of keys for each party by stretching the shared key.\n * (myIV, theirIV, myCipherKey, theirCipherKey, myMACKey, theirMACKey)\n */\nasync function keyStretcher(cipherType, hash, secret) {\n const cipher = cipherMap[cipherType];\n if (cipher == null) {\n const allowed = Object.keys(cipherMap).join(' / ');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`unknown cipher type '${cipherType}'. Must be ${allowed}`, 'ERR_INVALID_CIPHER_TYPE');\n }\n if (hash == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('missing hash type', 'ERR_MISSING_HASH_TYPE');\n }\n const cipherKeySize = cipher.keySize;\n const ivSize = cipher.ivSize;\n const hmacKeySize = 20;\n const seed = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)('key expansion');\n const resultLength = 2 * (ivSize + cipherKeySize + hmacKeySize);\n const m = await _hmac_index_js__WEBPACK_IMPORTED_MODULE_3__.create(hash, secret);\n let a = await m.digest(seed);\n const result = [];\n let j = 0;\n while (j < resultLength) {\n const b = await m.digest((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([a, seed]));\n let todo = b.length;\n if (j + todo > resultLength) {\n todo = resultLength - j;\n }\n result.push(b);\n j += todo;\n a = await m.digest(a);\n }\n const half = resultLength / 2;\n const resultBuffer = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)(result);\n const r1 = resultBuffer.subarray(0, half);\n const r2 = resultBuffer.subarray(half, resultLength);\n const createKey = (res) => ({\n iv: res.subarray(0, ivSize),\n cipherKey: res.subarray(ivSize, ivSize + cipherKeySize),\n macKey: res.subarray(ivSize + cipherKeySize)\n });\n return {\n k1: createKey(r1),\n k2: createKey(r2)\n };\n}\n//# sourceMappingURL=key-stretcher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ keyStretcher: () => (/* binding */ keyStretcher)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../hmac/index.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n\n\n\n\nconst cipherMap = {\n 'AES-128': {\n ivSize: 16,\n keySize: 16\n },\n 'AES-256': {\n ivSize: 16,\n keySize: 32\n },\n Blowfish: {\n ivSize: 8,\n keySize: 32\n }\n};\n/**\n * Generates a set of keys for each party by stretching the shared key.\n * (myIV, theirIV, myCipherKey, theirCipherKey, myMACKey, theirMACKey)\n */\nasync function keyStretcher(cipherType, hash, secret) {\n const cipher = cipherMap[cipherType];\n if (cipher == null) {\n const allowed = Object.keys(cipherMap).join(' / ');\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(`unknown cipher type '${cipherType}'. Must be ${allowed}`, 'ERR_INVALID_CIPHER_TYPE');\n }\n if (hash == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('missing hash type', 'ERR_MISSING_HASH_TYPE');\n }\n const cipherKeySize = cipher.keySize;\n const ivSize = cipher.ivSize;\n const hmacKeySize = 20;\n const seed = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)('key expansion');\n const resultLength = 2 * (ivSize + cipherKeySize + hmacKeySize);\n const m = await _hmac_index_js__WEBPACK_IMPORTED_MODULE_3__.create(hash, secret);\n let a = await m.digest(seed);\n const result = [];\n let j = 0;\n while (j < resultLength) {\n const b = await m.digest((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([a, seed]));\n let todo = b.length;\n if (j + todo > resultLength) {\n todo = resultLength - j;\n }\n result.push(b);\n j += todo;\n a = await m.digest(a);\n }\n const half = resultLength / 2;\n const resultBuffer = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)(result);\n const r1 = resultBuffer.subarray(0, half);\n const r2 = resultBuffer.subarray(half, resultLength);\n const createKey = (res) => ({\n iv: res.subarray(0, ivSize),\n cipherKey: res.subarray(ivSize, ivSize + cipherKeySize),\n macKey: res.subarray(ivSize + cipherKeySize)\n });\n return {\n k1: createKey(r1),\n k2: createKey(r2)\n };\n}\n//# sourceMappingURL=key-stretcher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js?"); /***/ }), @@ -2595,7 +2811,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decrypt: () => (/* binding */ decrypt),\n/* harmony export */ encrypt: () => (/* binding */ encrypt),\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ getRandomValues: () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ utils: () => (/* reexport module object */ _rsa_utils_js__WEBPACK_IMPORTED_MODULE_6__)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _jwk2pem_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./jwk2pem.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/jwk2pem.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js\");\n\n\n\n\n\n\n\n\nasync function generateKey(bits) {\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: { name: 'SHA-256' }\n }, true, ['sign', 'verify']);\n const keys = await exportKey(pair);\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n// Takes a jwk key\nasync function unmarshalPrivateKey(key) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['sign']);\n const pair = [\n privateKey,\n await derivePublicFromPrivate(key)\n ];\n const keys = await exportKey({\n privateKey: pair[0],\n publicKey: pair[1]\n });\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n\nasync function hashAndSign(key, msg) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['sign']);\n const sig = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.sign({ name: 'RSASSA-PKCS1-v1_5' }, privateKey, Uint8Array.from(msg));\n return new Uint8Array(sig, 0, sig.byteLength);\n}\nasync function hashAndVerify(key, sig, msg) {\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['verify']);\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.verify({ name: 'RSASSA-PKCS1-v1_5' }, publicKey, sig, msg);\n}\nasync function exportKey(pair) {\n if (pair.privateKey == null || pair.publicKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS');\n }\n return Promise.all([\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.exportKey('jwk', pair.privateKey),\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey)\n ]);\n}\nasync function derivePublicFromPrivate(jwKey) {\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get().subtle.importKey('jwk', {\n kty: jwKey.kty,\n n: jwKey.n,\n e: jwKey.e\n }, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['verify']);\n}\n/*\n\nRSA encryption/decryption for the browser with webcrypto workaround\n\"bloody dark magic. webcrypto's why.\"\n\nExplanation:\n - Convert JWK to nodeForge\n - Convert msg Uint8Array to nodeForge buffer: ByteBuffer is a \"binary-string backed buffer\", so let's make our Uint8Array a binary string\n - Convert resulting nodeForge buffer to Uint8Array: it returns a binary string, turn that into a Uint8Array\n\n*/\nfunction convertKey(key, pub, msg, handle) {\n const fkey = pub ? (0,_jwk2pem_js__WEBPACK_IMPORTED_MODULE_5__.jwk2pub)(key) : (0,_jwk2pem_js__WEBPACK_IMPORTED_MODULE_5__.jwk2priv)(key);\n const fmsg = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(Uint8Array.from(msg), 'ascii');\n const fomsg = handle(fmsg, fkey);\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(fomsg, 'ascii');\n}\nfunction encrypt(key, msg) {\n return convertKey(key, true, msg, (msg, key) => key.encrypt(msg));\n}\nfunction decrypt(key, msg) {\n return convertKey(key, false, msg, (msg, key) => key.decrypt(msg));\n}\n//# sourceMappingURL=rsa-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ getRandomValues: () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ keySize: () => (/* binding */ keySize),\n/* harmony export */ unmarshalPrivateKey: () => (/* binding */ unmarshalPrivateKey),\n/* harmony export */ utils: () => (/* reexport module object */ _rsa_utils_js__WEBPACK_IMPORTED_MODULE_1__)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js\");\n\n\n\n\n\n\nasync function generateKey(bits) {\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: { name: 'SHA-256' }\n }, true, ['sign', 'verify']);\n const keys = await exportKey(pair);\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n// Takes a jwk key\nasync function unmarshalPrivateKey(key) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['sign']);\n const pair = [\n privateKey,\n await derivePublicFromPrivate(key)\n ];\n const keys = await exportKey({\n privateKey: pair[0],\n publicKey: pair[1]\n });\n return {\n privateKey: keys[0],\n publicKey: keys[1]\n };\n}\n\nasync function hashAndSign(key, msg) {\n const privateKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['sign']);\n const sig = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.sign({ name: 'RSASSA-PKCS1-v1_5' }, privateKey, msg instanceof Uint8Array ? msg : msg.subarray());\n return new Uint8Array(sig, 0, sig.byteLength);\n}\nasync function hashAndVerify(key, sig, msg) {\n const publicKey = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['verify']);\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.verify({ name: 'RSASSA-PKCS1-v1_5' }, publicKey, sig, msg instanceof Uint8Array ? msg : msg.subarray());\n}\nasync function exportKey(pair) {\n if (pair.privateKey == null || pair.publicKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS');\n }\n return Promise.all([\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.exportKey('jwk', pair.privateKey),\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey)\n ]);\n}\nasync function derivePublicFromPrivate(jwKey) {\n return _webcrypto_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get().subtle.importKey('jwk', {\n kty: jwKey.kty,\n n: jwKey.n,\n e: jwKey.e\n }, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, true, ['verify']);\n}\nfunction keySize(jwk) {\n if (jwk.kty !== 'RSA') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('invalid key type', 'ERR_INVALID_KEY_TYPE');\n }\n else if (jwk.n == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('invalid key modulus', 'ERR_INVALID_KEY_MODULUS');\n }\n const bytes = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(jwk.n, 'base64url');\n return bytes.length * 8;\n}\n//# sourceMappingURL=rsa-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js?"); /***/ }), @@ -2606,7 +2822,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RsaPrivateKey: () => (/* binding */ RsaPrivateKey),\n/* harmony export */ RsaPublicKey: () => (/* binding */ RsaPublicKey),\n/* harmony export */ fromJwk: () => (/* binding */ fromJwk),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalRsaPrivateKey: () => (/* binding */ unmarshalRsaPrivateKey),\n/* harmony export */ unmarshalRsaPublicKey: () => (/* binding */ unmarshalRsaPublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var node_forge_lib_sha512_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! node-forge/lib/sha512.js */ \"./node_modules/node-forge/lib/sha512.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js\");\n\n\n// @ts-expect-error types are missing\n\n\n\n\n\n\n\nclass RsaPublicKey {\n _key;\n constructor(key) {\n this._key = key;\n }\n async verify(data, sig) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.jwkToPkix(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n encrypt(bytes) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.encrypt(this._key, bytes);\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass RsaPrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey;\n }\n genSecret() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.getRandomValues(16);\n }\n async sign(message) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.hashAndSign(this._key, message);\n }\n get public() {\n if (this._publicKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('public key not provided', 'ERR_PUBKEY_NOT_PROVIDED');\n }\n return new RsaPublicKey(this._publicKey);\n }\n decrypt(bytes) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.decrypt(this._key, bytes);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.jwkToPkcs1(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_7__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_7__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(this.bytes);\n return bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key into a password protected PEM format\n */\n async export(password, format = 'pkcs-8') {\n if (format === 'pkcs-8') {\n const buffer = new node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.util.ByteBuffer(this.marshal());\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.asn1.fromDer(buffer);\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.privateKeyFromAsn1(asn1);\n const options = {\n algorithm: 'aes256',\n count: 10000,\n saltSize: 128 / 8,\n prfAlgorithm: 'sha512'\n };\n return node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.pki.encryptRsaPrivateKey(privateKey, password, options);\n }\n else if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_6__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nasync function unmarshalRsaPrivateKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.pkcs1ToJwk(bytes);\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nfunction unmarshalRsaPublicKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_8__.utils.pkixToJwk(bytes);\n return new RsaPublicKey(jwk);\n}\nasync function fromJwk(jwk) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nasync function generateKeyPair(bits) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_8__.generateKey(bits);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\n//# sourceMappingURL=rsa-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_RSA_KEY_SIZE: () => (/* binding */ MAX_RSA_KEY_SIZE),\n/* harmony export */ RsaPrivateKey: () => (/* binding */ RsaPrivateKey),\n/* harmony export */ RsaPublicKey: () => (/* binding */ RsaPublicKey),\n/* harmony export */ fromJwk: () => (/* binding */ fromJwk),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalRsaPrivateKey: () => (/* binding */ unmarshalRsaPrivateKey),\n/* harmony export */ unmarshalRsaPublicKey: () => (/* binding */ unmarshalRsaPublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n\n\n\n\n\n\n\n\nconst MAX_RSA_KEY_SIZE = 8192;\nclass RsaPublicKey {\n _key;\n constructor(key) {\n this._key = key;\n }\n verify(data, sig) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_3__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_4__.jwkToPkix(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_6__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n}\nclass RsaPrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey;\n }\n genSecret() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"](16);\n }\n sign(message) {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_3__.hashAndSign(this._key, message);\n }\n get public() {\n if (this._publicKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('public key not provided', 'ERR_PUBKEY_NOT_PROVIDED');\n }\n return new RsaPublicKey(this._publicKey);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_4__.jwkToPkcs1(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.RSA,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_6__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key as libp2p-key - a aes-gcm encrypted value with the key\n * derived from the password.\n *\n * To export it as a password protected PEM file, please use the `exportPEM`\n * function from `@libp2p/rsa`.\n */\n async export(password, format = 'pkcs-8') {\n if (format === 'pkcs-8') {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_4__.exportToPem(this, password);\n }\n else if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_9__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nasync function unmarshalRsaPrivateKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_4__.pkcs1ToJwk(bytes);\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_3__.keySize(jwk) > MAX_RSA_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_3__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nfunction unmarshalRsaPublicKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_4__.pkixToJwk(bytes);\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_3__.keySize(jwk) > MAX_RSA_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n return new RsaPublicKey(jwk);\n}\nasync function fromJwk(jwk) {\n if (_rsa_js__WEBPACK_IMPORTED_MODULE_3__.keySize(jwk) > MAX_RSA_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_3__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nasync function generateKeyPair(bits) {\n if (bits > MAX_RSA_KEY_SIZE) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('key size is too large', 'ERR_KEY_SIZE_TOO_LARGE');\n }\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_3__.generateKey(bits);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\n//# sourceMappingURL=rsa-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js?"); /***/ }), @@ -2617,7 +2833,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ jwkToPkcs1: () => (/* binding */ jwkToPkcs1),\n/* harmony export */ jwkToPkix: () => (/* binding */ jwkToPkix),\n/* harmony export */ pkcs1ToJwk: () => (/* binding */ pkcs1ToJwk),\n/* harmony export */ pkixToJwk: () => (/* binding */ pkixToJwk)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/asn1.js */ \"./node_modules/node-forge/lib/asn1.js\");\n/* harmony import */ var node_forge_lib_rsa_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/rsa.js */ \"./node_modules/node-forge/lib/rsa.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\n// Convert a PKCS#1 in ASN1 DER format to a JWK key\nfunction pkcs1ToJwk(bytes) {\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.asn1.fromDer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(bytes, 'ascii'));\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.privateKeyFromAsn1(asn1);\n // https://tools.ietf.org/html/rfc7518#section-6.3.1\n return {\n kty: 'RSA',\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.q),\n dp: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.dP),\n dq: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.dQ),\n qi: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(privateKey.qInv),\n alg: 'RS256'\n };\n}\n// Convert a JWK key into PKCS#1 in ASN1 DER format\nfunction jwkToPkcs1(jwk) {\n if (jwk.n == null || jwk.e == null || jwk.d == null || jwk.p == null || jwk.q == null || jwk.dp == null || jwk.dq == null || jwk.qi == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.privateKeyToAsn1({\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.q),\n dP: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.dp),\n dQ: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.dq),\n qInv: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.qi)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.asn1.toDer(asn1).getBytes(), 'ascii');\n}\n// Convert a PKCIX in ASN1 DER format to a JWK key\nfunction pkixToJwk(bytes) {\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.asn1.fromDer((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(bytes, 'ascii'));\n const publicKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.publicKeyFromAsn1(asn1);\n return {\n kty: 'RSA',\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(publicKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.bigIntegerToUintBase64url)(publicKey.e)\n };\n}\n// Convert a JWK key to PKCIX in ASN1 DER format\nfunction jwkToPkix(jwk) {\n if (jwk.n == null || jwk.e == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.pki.publicKeyToAsn1({\n n: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__.base64urlToBigInteger)(jwk.e)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_3__.asn1.toDer(asn1).getBytes(), 'ascii');\n}\n//# sourceMappingURL=rsa-utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ exportToPem: () => (/* binding */ exportToPem),\n/* harmony export */ importFromPem: () => (/* binding */ importFromPem),\n/* harmony export */ jwkToPkcs1: () => (/* binding */ jwkToPkcs1),\n/* harmony export */ jwkToPkix: () => (/* binding */ jwkToPkix),\n/* harmony export */ pkcs1ToJwk: () => (/* binding */ pkcs1ToJwk),\n/* harmony export */ pkixToJwk: () => (/* binding */ pkixToJwk)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _noble_hashes_pbkdf2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @noble/hashes/pbkdf2 */ \"./node_modules/@noble/hashes/esm/pbkdf2.js\");\n/* harmony import */ var _noble_hashes_sha512__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @noble/hashes/sha512 */ \"./node_modules/@noble/hashes/esm/sha512.js\");\n/* harmony import */ var asn1js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! asn1js */ \"./node_modules/asn1js/build/index.es.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _random_bytes_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n\n\n\n\n\n\n\n\n\n/**\n * Convert a PKCS#1 in ASN1 DER format to a JWK key\n */\nfunction pkcs1ToJwk(bytes) {\n const { result } = asn1js__WEBPACK_IMPORTED_MODULE_0__.fromBER(bytes);\n // @ts-expect-error this looks fragile but DER is a canonical format so we are\n // safe to have deeply property chains like this\n const values = result.valueBlock.value;\n const key = {\n n: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[1].toBigInt()), 'base64url'),\n e: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[2].toBigInt()), 'base64url'),\n d: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[3].toBigInt()), 'base64url'),\n p: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[4].toBigInt()), 'base64url'),\n q: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[5].toBigInt()), 'base64url'),\n dp: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[6].toBigInt()), 'base64url'),\n dq: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[7].toBigInt()), 'base64url'),\n qi: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[8].toBigInt()), 'base64url'),\n kty: 'RSA',\n alg: 'RS256'\n };\n return key;\n}\n/**\n * Convert a JWK key into PKCS#1 in ASN1 DER format\n */\nfunction jwkToPkcs1(jwk) {\n if (jwk.n == null || jwk.e == null || jwk.d == null || jwk.p == null || jwk.q == null || jwk.dp == null || jwk.dq == null || jwk.qi == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const root = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer({ value: 0 }),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.n, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.e, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.d, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.p, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.q, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.dp, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.dq, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.qi, 'base64url')))\n ]\n });\n const der = root.toBER();\n return new Uint8Array(der, 0, der.byteLength);\n}\n/**\n * Convert a PKCIX in ASN1 DER format to a JWK key\n */\nfunction pkixToJwk(bytes) {\n const { result } = asn1js__WEBPACK_IMPORTED_MODULE_0__.fromBER(bytes);\n // @ts-expect-error this looks fragile but DER is a canonical format so we are\n // safe to have deeply property chains like this\n const values = result.valueBlock.value[1].valueBlock.value[0].valueBlock.value;\n return {\n kty: 'RSA',\n n: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[0].toBigInt()), 'base64url'),\n e: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bnToBuf(values[1].toBigInt()), 'base64url')\n };\n}\n/**\n * Convert a JWK key to PKCIX in ASN1 DER format\n */\nfunction jwkToPkix(jwk) {\n if (jwk.n == null || jwk.e == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('JWK was missing components', 'ERR_INVALID_PARAMETERS');\n }\n const root = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // rsaEncryption\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({\n value: '1.2.840.113549.1.1.1'\n }),\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Null()\n ]\n }),\n // this appears to be a bug in asn1js.js - this should really be a Sequence\n // and not a BitString but it generates the same bytes as node-forge so 🤷‍♂️\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.BitString({\n valueHex: new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.n, 'base64url'))),\n asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer.fromBigInt(bufToBn((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(jwk.e, 'base64url')))\n ]\n }).toBER()\n })\n ]\n });\n const der = root.toBER();\n return new Uint8Array(der, 0, der.byteLength);\n}\nfunction bnToBuf(bn) {\n let hex = bn.toString(16);\n if (hex.length % 2 > 0) {\n hex = `0${hex}`;\n }\n const len = hex.length / 2;\n const u8 = new Uint8Array(len);\n let i = 0;\n let j = 0;\n while (i < len) {\n u8[i] = parseInt(hex.slice(j, j + 2), 16);\n i += 1;\n j += 2;\n }\n return u8;\n}\nfunction bufToBn(u8) {\n const hex = [];\n u8.forEach(function (i) {\n let h = i.toString(16);\n if (h.length % 2 > 0) {\n h = `0${h}`;\n }\n hex.push(h);\n });\n return BigInt('0x' + hex.join(''));\n}\nconst SALT_LENGTH = 16;\nconst KEY_SIZE = 32;\nconst ITERATIONS = 10000;\nasync function exportToPem(privateKey, password) {\n const crypto = _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get();\n // PrivateKeyInfo\n const keyWrapper = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // version (0)\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer({ value: 0 }),\n // privateKeyAlgorithm\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // rsaEncryption OID\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({\n value: '1.2.840.113549.1.1.1'\n }),\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Null()\n ]\n }),\n // PrivateKey\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.OctetString({\n valueHex: privateKey.marshal()\n })\n ]\n });\n const keyBuf = keyWrapper.toBER();\n const keyArr = new Uint8Array(keyBuf, 0, keyBuf.byteLength);\n const salt = (0,_random_bytes_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(SALT_LENGTH);\n const encryptionKey = await (0,_noble_hashes_pbkdf2__WEBPACK_IMPORTED_MODULE_6__.pbkdf2Async)(_noble_hashes_sha512__WEBPACK_IMPORTED_MODULE_7__.sha512, password, salt, {\n c: ITERATIONS,\n dkLen: KEY_SIZE\n });\n const iv = (0,_random_bytes_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(16);\n const cryptoKey = await crypto.subtle.importKey('raw', encryptionKey, 'AES-CBC', false, ['encrypt']);\n const encrypted = await crypto.subtle.encrypt({\n name: 'AES-CBC',\n iv\n }, cryptoKey, keyArr);\n const pbkdf2Params = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // salt\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.OctetString({ valueHex: salt }),\n // iteration count\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer({ value: ITERATIONS }),\n // key length\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Integer({ value: KEY_SIZE }),\n // AlgorithmIdentifier\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // hmacWithSHA512\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({ value: '1.2.840.113549.2.11' }),\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Null()\n ]\n })\n ]\n });\n const encryptionAlgorithm = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // pkcs5PBES2\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({\n value: '1.2.840.113549.1.5.13'\n }),\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // keyDerivationFunc\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // pkcs5PBKDF2\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({\n value: '1.2.840.113549.1.5.12'\n }),\n // PBKDF2-params\n pbkdf2Params\n ]\n }),\n // encryptionScheme\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n // aes256-CBC\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.ObjectIdentifier({\n value: '2.16.840.1.101.3.4.1.42'\n }),\n // iv\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.OctetString({\n valueHex: iv\n })\n ]\n })\n ]\n })\n ]\n });\n const finalWrapper = new asn1js__WEBPACK_IMPORTED_MODULE_0__.Sequence({\n value: [\n encryptionAlgorithm,\n new asn1js__WEBPACK_IMPORTED_MODULE_0__.OctetString({ valueHex: encrypted })\n ]\n });\n const finalWrapperBuf = finalWrapper.toBER();\n const finalWrapperArr = new Uint8Array(finalWrapperBuf, 0, finalWrapperBuf.byteLength);\n return [\n '-----BEGIN ENCRYPTED PRIVATE KEY-----',\n ...(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(finalWrapperArr, 'base64pad').split(/(.{64})/).filter(Boolean),\n '-----END ENCRYPTED PRIVATE KEY-----'\n ].join('\\n');\n}\nasync function importFromPem(pem, password) {\n const crypto = _webcrypto_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].get();\n let plaintext;\n if (pem.includes('-----BEGIN ENCRYPTED PRIVATE KEY-----')) {\n const key = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(pem\n .replace('-----BEGIN ENCRYPTED PRIVATE KEY-----', '')\n .replace('-----END ENCRYPTED PRIVATE KEY-----', '')\n .replace(/\\n/g, '')\n .trim(), 'base64pad');\n const { result } = asn1js__WEBPACK_IMPORTED_MODULE_0__.fromBER(key);\n const { iv, salt, iterations, keySize, cipherText } = findEncryptedPEMData(result);\n const encryptionKey = await (0,_noble_hashes_pbkdf2__WEBPACK_IMPORTED_MODULE_6__.pbkdf2Async)(_noble_hashes_sha512__WEBPACK_IMPORTED_MODULE_7__.sha512, password, salt, {\n c: iterations,\n dkLen: keySize\n });\n const cryptoKey = await crypto.subtle.importKey('raw', encryptionKey, 'AES-CBC', false, ['decrypt']);\n const decrypted = toUint8Array(await crypto.subtle.decrypt({\n name: 'AES-CBC',\n iv\n }, cryptoKey, cipherText));\n const { result: decryptedResult } = asn1js__WEBPACK_IMPORTED_MODULE_0__.fromBER(decrypted);\n plaintext = findPEMData(decryptedResult);\n }\n else if (pem.includes('-----BEGIN PRIVATE KEY-----')) {\n const key = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(pem\n .replace('-----BEGIN PRIVATE KEY-----', '')\n .replace('-----END PRIVATE KEY-----', '')\n .replace(/\\n/g, '')\n .trim(), 'base64pad');\n const { result } = asn1js__WEBPACK_IMPORTED_MODULE_0__.fromBER(key);\n plaintext = findPEMData(result);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Could not parse private key from PEM data', 'ERR_INVALID_PARAMETERS');\n }\n return (0,_rsa_class_js__WEBPACK_IMPORTED_MODULE_8__.unmarshalRsaPrivateKey)(plaintext);\n}\nfunction findEncryptedPEMData(root) {\n const encryptionAlgorithm = root.valueBlock.value[0];\n const scheme = encryptionAlgorithm.valueBlock.value[0].toString();\n if (scheme !== 'OBJECT IDENTIFIER : 1.2.840.113549.1.5.13') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Only pkcs5PBES2 encrypted private keys are supported', 'ERR_INVALID_PARAMS');\n }\n const keyDerivationFunc = encryptionAlgorithm.valueBlock.value[1].valueBlock.value[0];\n const keyDerivationFuncName = keyDerivationFunc.valueBlock.value[0].toString();\n if (keyDerivationFuncName !== 'OBJECT IDENTIFIER : 1.2.840.113549.1.5.12') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Only pkcs5PBKDF2 key derivation functions are supported', 'ERR_INVALID_PARAMS');\n }\n const pbkdf2Params = keyDerivationFunc.valueBlock.value[1];\n const salt = toUint8Array(pbkdf2Params.valueBlock.value[0].getValue());\n let iterations = ITERATIONS;\n let keySize = KEY_SIZE;\n if (pbkdf2Params.valueBlock.value.length === 3) {\n iterations = Number(pbkdf2Params.valueBlock.value[1].toBigInt());\n keySize = Number((pbkdf2Params.valueBlock.value[2]).toBigInt());\n }\n else if (pbkdf2Params.valueBlock.value.length === 2) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key', 'ERR_INVALID_PARAMS');\n }\n const encryptionScheme = encryptionAlgorithm.valueBlock.value[1].valueBlock.value[1];\n const encryptionSchemeName = encryptionScheme.valueBlock.value[0].toString();\n if (encryptionSchemeName === 'OBJECT IDENTIFIER : 1.2.840.113549.3.7') {\n // des-EDE3-CBC\n }\n else if (encryptionSchemeName === 'OBJECT IDENTIFIER : 1.3.14.3.2.7') {\n // des-CBC\n }\n else if (encryptionSchemeName === 'OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2') {\n // aes128-CBC\n }\n else if (encryptionSchemeName === 'OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22') {\n // aes192-CBC\n }\n else if (encryptionSchemeName === 'OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42') {\n // aes256-CBC\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Only AES-CBC encryption schemes are supported', 'ERR_INVALID_PARAMS');\n }\n const iv = toUint8Array(encryptionScheme.valueBlock.value[1].getValue());\n return {\n cipherText: toUint8Array(root.valueBlock.value[1].getValue()),\n salt,\n iterations,\n keySize,\n iv\n };\n}\nfunction findPEMData(seq) {\n return toUint8Array(seq.valueBlock.value[2].getValue());\n}\nfunction toUint8Array(buf) {\n return new Uint8Array(buf, 0, buf.byteLength);\n}\n//# sourceMappingURL=rsa-utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js": +/*!************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compressPublicKey: () => (/* binding */ compressPublicKey),\n/* harmony export */ computePublicKey: () => (/* binding */ computePublicKey),\n/* harmony export */ decompressPublicKey: () => (/* binding */ decompressPublicKey),\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ validatePrivateKey: () => (/* binding */ validatePrivateKey),\n/* harmony export */ validatePublicKey: () => (/* binding */ validatePublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/curves/secp256k1 */ \"./node_modules/@noble/curves/esm/secp256k1.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n\n\n\n\nconst PRIVATE_KEY_BYTE_LENGTH = 32;\n\nfunction generateKey() {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.utils.randomPrivateKey();\n}\n/**\n * Hash and sign message with private key\n */\nfunction hashAndSign(key, msg) {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray());\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_2__.isPromise)(p)) {\n return p.then(({ digest }) => _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.sign(digest, key).toDERRawBytes())\n .catch(err => {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n });\n }\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.sign(p.digest, key).toDERRawBytes();\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\n/**\n * Hash message and verify signature with public key\n */\nfunction hashAndVerify(key, sig, msg) {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray());\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_2__.isPromise)(p)) {\n return p.then(({ digest }) => _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.verify(sig, digest, key))\n .catch(err => {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n });\n }\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.verify(sig, p.digest, key);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\nfunction compressPublicKey(key) {\n const point = _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.ProjectivePoint.fromHex(key).toRawBytes(true);\n return point;\n}\nfunction decompressPublicKey(key) {\n const point = _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.ProjectivePoint.fromHex(key).toRawBytes(false);\n return point;\n}\nfunction validatePrivateKey(key) {\n try {\n _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.getPublicKey(key, true);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\nfunction validatePublicKey(key) {\n try {\n _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.ProjectivePoint.fromHex(key);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PUBLIC_KEY');\n }\n}\nfunction computePublicKey(privateKey) {\n try {\n return _noble_curves_secp256k1__WEBPACK_IMPORTED_MODULE_1__.secp256k1.getPublicKey(privateKey, true);\n }\n catch (err) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\n//# sourceMappingURL=secp256k1-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js?"); /***/ }), @@ -2628,29 +2855,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Secp256k1PrivateKey: () => (/* binding */ Secp256k1PrivateKey),\n/* harmony export */ Secp256k1PublicKey: () => (/* binding */ Secp256k1PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalSecp256k1PrivateKey: () => (/* binding */ unmarshalSecp256k1PrivateKey),\n/* harmony export */ unmarshalSecp256k1PublicKey: () => (/* binding */ unmarshalSecp256k1PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./secp256k1.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js\");\n\n\n\n\n\n\n\nclass Secp256k1PublicKey {\n _key;\n constructor(key) {\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePublicKey(key);\n this._key = key;\n }\n async verify(data, sig) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.compressPublicKey(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Secp256k1PrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey ?? _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.computePublicKey(key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePrivateKey(this._key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.validatePublicKey(this._publicKey);\n }\n async sign(message) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.hashAndSign(this._key, message);\n }\n get public() {\n return new Secp256k1PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_5__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_5__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(this.bytes);\n return bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_4__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalSecp256k1PrivateKey(bytes) {\n return new Secp256k1PrivateKey(bytes);\n}\nfunction unmarshalSecp256k1PublicKey(bytes) {\n return new Secp256k1PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const privateKeyBytes = _secp256k1_js__WEBPACK_IMPORTED_MODULE_6__.generateKey();\n return new Secp256k1PrivateKey(privateKeyBytes);\n}\n//# sourceMappingURL=secp256k1-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js": -/*!****************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js ***! - \****************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compressPublicKey: () => (/* binding */ compressPublicKey),\n/* harmony export */ computePublicKey: () => (/* binding */ computePublicKey),\n/* harmony export */ decompressPublicKey: () => (/* binding */ decompressPublicKey),\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ hashAndSign: () => (/* binding */ hashAndSign),\n/* harmony export */ hashAndVerify: () => (/* binding */ hashAndVerify),\n/* harmony export */ privateKeyLength: () => (/* binding */ PRIVATE_KEY_BYTE_LENGTH),\n/* harmony export */ validatePrivateKey: () => (/* binding */ validatePrivateKey),\n/* harmony export */ validatePublicKey: () => (/* binding */ validatePublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n\n\n\nconst PRIVATE_KEY_BYTE_LENGTH = 32;\n\nfunction generateKey() {\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.utils.randomPrivateKey();\n}\n/**\n * Hash and sign message with private key\n */\nasync function hashAndSign(key, msg) {\n const { digest } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(msg);\n try {\n return await _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.sign(digest, key);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\n/**\n * Hash message and verify signature with public key\n */\nasync function hashAndVerify(key, sig, msg) {\n try {\n const { digest } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(msg);\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.verify(sig, digest, key);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(String(err), 'ERR_INVALID_INPUT');\n }\n}\nfunction compressPublicKey(key) {\n const point = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.Point.fromHex(key).toRawBytes(true);\n return point;\n}\nfunction decompressPublicKey(key) {\n const point = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.Point.fromHex(key).toRawBytes(false);\n return point;\n}\nfunction validatePrivateKey(key) {\n try {\n _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.getPublicKey(key, true);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\nfunction validatePublicKey(key) {\n try {\n _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.Point.fromHex(key);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(String(err), 'ERR_INVALID_PUBLIC_KEY');\n }\n}\nfunction computePublicKey(privateKey) {\n try {\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.getPublicKey(privateKey, true);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY');\n }\n}\n//# sourceMappingURL=secp256k1.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/dist/src/pbkdf2.js": -/*!********************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/pbkdf2.js ***! - \********************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ pbkdf2)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var node_forge_lib_pbkdf2_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/pbkdf2.js */ \"./node_modules/node-forge/lib/pbkdf2.js\");\n/* harmony import */ var node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/util.js */ \"./node_modules/node-forge/lib/util.js\");\n\n// @ts-expect-error types are missing\n\n// @ts-expect-error types are missing\n\n/**\n * Maps an IPFS hash name to its node-forge equivalent.\n *\n * See https://github.com/multiformats/multihash/blob/master/hashtable.csv\n *\n * @private\n */\nconst hashName = {\n sha1: 'sha1',\n 'sha2-256': 'sha256',\n 'sha2-512': 'sha512'\n};\n/**\n * Computes the Password-Based Key Derivation Function 2.\n */\nfunction pbkdf2(password, salt, iterations, keySize, hash) {\n if (hash !== 'sha1' && hash !== 'sha2-256' && hash !== 'sha2-512') {\n const types = Object.keys(hashName).join(' / ');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`Hash '${hash}' is unknown or not supported. Must be ${types}`, 'ERR_UNSUPPORTED_HASH_TYPE');\n }\n const hasher = hashName[hash];\n const dek = node_forge_lib_pbkdf2_js__WEBPACK_IMPORTED_MODULE_1__(password, salt, iterations, keySize, hasher);\n return node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_2__.encode64(dek, null);\n}\n//# sourceMappingURL=pbkdf2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/pbkdf2.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Secp256k1PrivateKey: () => (/* binding */ Secp256k1PrivateKey),\n/* harmony export */ Secp256k1PublicKey: () => (/* binding */ Secp256k1PublicKey),\n/* harmony export */ generateKeyPair: () => (/* binding */ generateKeyPair),\n/* harmony export */ unmarshalSecp256k1PrivateKey: () => (/* binding */ unmarshalSecp256k1PrivateKey),\n/* harmony export */ unmarshalSecp256k1PublicKey: () => (/* binding */ unmarshalSecp256k1PublicKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./secp256k1.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-browser.js\");\n\n\n\n\n\n\n\n\nclass Secp256k1PublicKey {\n _key;\n constructor(key) {\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.validatePublicKey(key);\n this._key = key;\n }\n verify(data, sig) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.compressPublicKey(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_4__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_4__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n async hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n let bytes;\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_5__.isPromise)(p)) {\n ({ bytes } = await p);\n }\n else {\n bytes = p.bytes;\n }\n return bytes;\n }\n}\nclass Secp256k1PrivateKey {\n _key;\n _publicKey;\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey ?? _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.computePublicKey(key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.validatePrivateKey(this._key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.validatePublicKey(this._publicKey);\n }\n sign(message) {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.hashAndSign(this._key, message);\n }\n get public() {\n return new Secp256k1PublicKey(this._publicKey);\n }\n marshal() {\n return this._key;\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_4__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_4__.KeyType.Secp256k1,\n Data: this.marshal()\n }).subarray();\n }\n equals(key) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.bytes, key.bytes);\n }\n hash() {\n const p = multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.digest(this.bytes);\n if ((0,_util_js__WEBPACK_IMPORTED_MODULE_5__.isPromise)(p)) {\n return p.then(({ bytes }) => bytes);\n }\n return p.bytes;\n }\n /**\n * Gets the ID of the key.\n *\n * The key id is the base58 encoding of the SHA-256 multihash of its public key.\n * The public key is a protobuf encoding containing a type and the DER encoding\n * of the PKCS SubjectPublicKeyInfo.\n */\n async id() {\n const hash = await this.public.hash();\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(hash, 'base58btc');\n }\n /**\n * Exports the key into a password protected `format`\n */\n async export(password, format = 'libp2p-key') {\n if (format === 'libp2p-key') {\n return (0,_exporter_js__WEBPACK_IMPORTED_MODULE_6__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT');\n }\n }\n}\nfunction unmarshalSecp256k1PrivateKey(bytes) {\n return new Secp256k1PrivateKey(bytes);\n}\nfunction unmarshalSecp256k1PublicKey(bytes) {\n return new Secp256k1PublicKey(bytes);\n}\nasync function generateKeyPair() {\n const privateKeyBytes = _secp256k1_js__WEBPACK_IMPORTED_MODULE_3__.generateKey();\n return new Secp256k1PrivateKey(privateKeyBytes);\n}\n//# sourceMappingURL=secp256k1-class.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js?"); /***/ }), @@ -2661,7 +2866,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ randomBytes)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n\n\nfunction randomBytes(length) {\n if (isNaN(length) || length <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('random bytes length must be a Number bigger than 0', 'ERR_INVALID_LENGTH');\n }\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_1__.utils.randomBytes(length);\n}\n//# sourceMappingURL=random-bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/random-bytes.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ randomBytes)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/utils */ \"./node_modules/@noble/hashes/esm/utils.js\");\n\n\n/**\n * Generates a Uint8Array with length `number` populated by random bytes\n */\nfunction randomBytes(length) {\n if (isNaN(length) || length <= 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.CodeError('random bytes length must be a Number bigger than 0', 'ERR_INVALID_LENGTH');\n }\n return (0,_noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(length);\n}\n//# sourceMappingURL=random-bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/random-bytes.js?"); /***/ }), @@ -2672,128 +2877,205 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64urlToBigInteger: () => (/* binding */ base64urlToBigInteger),\n/* harmony export */ base64urlToBuffer: () => (/* binding */ base64urlToBuffer),\n/* harmony export */ bigIntegerToUintBase64url: () => (/* binding */ bigIntegerToUintBase64url)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/util.js */ \"./node_modules/node-forge/lib/util.js\");\n/* harmony import */ var node_forge_lib_jsbn_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/jsbn.js */ \"./node_modules/node-forge/lib/jsbn.js\");\n/* harmony import */ var node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n// @ts-expect-error types are missing\n\n\n\n\nfunction bigIntegerToUintBase64url(num, len) {\n // Call `.abs()` to convert to unsigned\n let buf = Uint8Array.from(num.abs().toByteArray()); // toByteArray converts to big endian\n // toByteArray() gives us back a signed array, which will include a leading 0\n // byte if the most significant bit of the number is 1:\n // https://docs.microsoft.com/en-us/windows/win32/seccertenroll/about-integer\n // Our number will always be positive so we should remove the leading padding.\n buf = buf[0] === 0 ? buf.subarray(1) : buf;\n if (len != null) {\n if (buf.length > len)\n throw new Error('byte array longer than desired length');\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(buf, 'base64url');\n}\n// Convert a base64url encoded string to a BigInteger\nfunction base64urlToBigInteger(str) {\n const buf = base64urlToBuffer(str);\n return new node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_2__.jsbn.BigInteger((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(buf, 'base16'), 16);\n}\nfunction base64urlToBuffer(str, len) {\n let buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(str, 'base64urlpad');\n if (len != null) {\n if (buf.length > len)\n throw new Error('byte array longer than desired length');\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return buf;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/util.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64urlToBuffer: () => (/* binding */ base64urlToBuffer),\n/* harmony export */ isPromise: () => (/* binding */ isPromise)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js\");\n\n\nfunction base64urlToBuffer(str, len) {\n let buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(str, 'base64urlpad');\n if (len != null) {\n if (buf.length > len)\n throw new Error('byte array longer than desired length');\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return buf;\n}\nfunction isPromise(thing) {\n if (thing == null) {\n return false;\n }\n return typeof thing.then === 'function' &&\n typeof thing.catch === 'function' &&\n typeof thing.finally === 'function';\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/util.js?"); /***/ }), -/***/ "./node_modules/@libp2p/crypto/dist/src/webcrypto.js": -/*!***********************************************************!*\ - !*** ./node_modules/@libp2p/crypto/dist/src/webcrypto.js ***! - \***********************************************************/ +/***/ "./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js ***! + \*******************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-env browser */\n// Check native crypto exists and is enabled (In insecure context `self.crypto`\n// exists but `self.crypto.subtle` does not).\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n get(win = globalThis) {\n const nativeCrypto = win.crypto;\n if (nativeCrypto == null || nativeCrypto.subtle == null) {\n throw Object.assign(new Error('Missing Web Crypto API. ' +\n 'The most likely cause of this error is that this page is being accessed ' +\n 'from an insecure context (i.e. not HTTPS). For more information and ' +\n 'possible resolutions see ' +\n 'https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api'), { code: 'ERR_MISSING_WEB_CRYPTO' });\n }\n return nativeCrypto;\n }\n});\n//# sourceMappingURL=webcrypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/webcrypto.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-env browser */\n// Check native crypto exists and is enabled (In insecure context `self.crypto`\n// exists but `self.crypto.subtle` does not).\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n get(win = globalThis) {\n const nativeCrypto = win.crypto;\n if (nativeCrypto == null || nativeCrypto.subtle == null) {\n throw Object.assign(new Error('Missing Web Crypto API. ' +\n 'The most likely cause of this error is that this page is being accessed ' +\n 'from an insecure context (i.e. not HTTPS). For more information and ' +\n 'possible resolutions see ' +\n 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api'), { code: 'ERR_MISSING_WEB_CRYPTO' });\n }\n return nativeCrypto;\n }\n});\n//# sourceMappingURL=webcrypto-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/dist/src/webcrypto-browser.js?"); /***/ }), -/***/ "./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js": +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/alloc.js": /*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js ***! + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/alloc.js ***! \********************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InvalidCryptoExchangeError: () => (/* binding */ InvalidCryptoExchangeError),\n/* harmony export */ InvalidCryptoTransmissionError: () => (/* binding */ InvalidCryptoTransmissionError),\n/* harmony export */ UnexpectedPeerError: () => (/* binding */ UnexpectedPeerError)\n/* harmony export */ });\nclass UnexpectedPeerError extends Error {\n code;\n constructor(message = 'Unexpected Peer') {\n super(message);\n this.code = UnexpectedPeerError.code;\n }\n static code = 'ERR_UNEXPECTED_PEER';\n}\nclass InvalidCryptoExchangeError extends Error {\n code;\n constructor(message = 'Invalid crypto exchange') {\n super(message);\n this.code = InvalidCryptoExchangeError.code;\n }\n static code = 'ERR_INVALID_CRYPTO_EXCHANGE';\n}\nclass InvalidCryptoTransmissionError extends Error {\n code;\n constructor(message = 'Invalid crypto transmission') {\n super(message);\n this.code = InvalidCryptoTransmissionError.code;\n }\n static code = 'ERR_INVALID_CRYPTO_TRANSMISSION';\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/alloc.js?"); /***/ }), -/***/ "./node_modules/@libp2p/interface-content-routing/dist/src/index.js": +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ concat: () => (/* binding */ concat)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns a new Uint8Array created by concatenating the passed Uint8Arrays\n */\nfunction concat(arrays, length) {\n if (length == null) {\n length = arrays.reduce((acc, curr) => acc + curr.length, 0);\n }\n const output = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(length);\n let offset = 0;\n for (const arr of arrays) {\n output.set(arr, offset);\n offset += arr.length;\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(output);\n}\n//# sourceMappingURL=concat.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/concat.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/as-uint8array.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/as-uint8array.js ***! + \*********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ asUint8Array: () => (/* binding */ asUint8Array)\n/* harmony export */ });\n/**\n * To guarantee Uint8Array semantics, convert nodejs Buffers\n * into vanilla Uint8Arrays\n */\nfunction asUint8Array(buf) {\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/bases.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/bases.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/dist/src/consts.js": +/*!**********************************************************!*\ + !*** ./node_modules/@libp2p/identify/dist/src/consts.js ***! + \**********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ IDENTIFY_PROTOCOL_VERSION: () => (/* binding */ IDENTIFY_PROTOCOL_VERSION),\n/* harmony export */ MULTICODEC_IDENTIFY: () => (/* binding */ MULTICODEC_IDENTIFY),\n/* harmony export */ MULTICODEC_IDENTIFY_PROTOCOL_NAME: () => (/* binding */ MULTICODEC_IDENTIFY_PROTOCOL_NAME),\n/* harmony export */ MULTICODEC_IDENTIFY_PROTOCOL_VERSION: () => (/* binding */ MULTICODEC_IDENTIFY_PROTOCOL_VERSION),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION),\n/* harmony export */ PROTOCOL_VERSION: () => (/* binding */ PROTOCOL_VERSION)\n/* harmony export */ });\nconst PROTOCOL_VERSION = 'ipfs/0.1.0'; // deprecated\nconst MULTICODEC_IDENTIFY = '/ipfs/id/1.0.0'; // deprecated\nconst MULTICODEC_IDENTIFY_PUSH = '/ipfs/id/push/1.0.0'; // deprecated\nconst IDENTIFY_PROTOCOL_VERSION = '0.1.0';\nconst MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id';\nconst MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push';\nconst MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0';\nconst MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0';\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/dist/src/consts.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/dist/src/identify.js": +/*!************************************************************!*\ + !*** ./node_modules/@libp2p/identify/dist/src/identify.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Identify: () => (/* binding */ Identify)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr-matcher */ \"./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js\");\n/* harmony import */ var it_protobuf_stream__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-protobuf-stream */ \"./node_modules/it-protobuf-stream/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/identify/dist/src/consts.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/@libp2p/identify/dist/src/pb/message.js\");\n/* eslint-disable complexity */\n\n\n\n\n\n\n\n\n\n\n\n// https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52\nconst MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;\nconst defaultValues = {\n protocolPrefix: 'ipfs',\n // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L48\n timeout: 60000,\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n maxPushIncomingStreams: 1,\n maxPushOutgoingStreams: 1,\n maxObservedAddresses: 10,\n maxIdentifyMessageSize: 8192,\n runOnConnectionOpen: true,\n runOnTransientConnection: true\n};\nclass Identify {\n identifyProtocolStr;\n identifyPushProtocolStr;\n host;\n started;\n timeout;\n peerId;\n peerStore;\n registrar;\n connectionManager;\n addressManager;\n maxInboundStreams;\n maxOutboundStreams;\n maxPushIncomingStreams;\n maxPushOutgoingStreams;\n maxIdentifyMessageSize;\n maxObservedAddresses;\n events;\n runOnTransientConnection;\n log;\n constructor(components, init = {}) {\n this.started = false;\n this.peerId = components.peerId;\n this.peerStore = components.peerStore;\n this.registrar = components.registrar;\n this.addressManager = components.addressManager;\n this.connectionManager = components.connectionManager;\n this.events = components.events;\n this.log = components.logger.forComponent('libp2p:identify');\n this.identifyProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_6__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_6__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_6__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_6__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n this.timeout = init.timeout ?? defaultValues.timeout;\n this.maxInboundStreams = init.maxInboundStreams ?? defaultValues.maxInboundStreams;\n this.maxOutboundStreams = init.maxOutboundStreams ?? defaultValues.maxOutboundStreams;\n this.maxPushIncomingStreams = init.maxPushIncomingStreams ?? defaultValues.maxPushIncomingStreams;\n this.maxPushOutgoingStreams = init.maxPushOutgoingStreams ?? defaultValues.maxPushOutgoingStreams;\n this.maxIdentifyMessageSize = init.maxIdentifyMessageSize ?? defaultValues.maxIdentifyMessageSize;\n this.maxObservedAddresses = init.maxObservedAddresses ?? defaultValues.maxObservedAddresses;\n this.runOnTransientConnection = init.runOnTransientConnection ?? defaultValues.runOnTransientConnection;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_6__.IDENTIFY_PROTOCOL_VERSION}`,\n agentVersion: init.agentVersion ?? `${components.nodeInfo.name}/${components.nodeInfo.version}`\n };\n if (init.runOnConnectionOpen ?? defaultValues.runOnConnectionOpen) {\n // When a new connection happens, trigger identify\n components.events.addEventListener('connection:open', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(err => { this.log.error('error during identify trigged by connection:open', err); });\n });\n }\n // When self peer record changes, trigger identify-push\n components.events.addEventListener('self:peer:update', (evt) => {\n void this.push().catch(err => { this.log.error(err); });\n });\n // Append user agent version to default AGENT_VERSION depending on the environment\n if (this.host.agentVersion === `${components.nodeInfo.name}/${components.nodeInfo.version}`) {\n if (wherearewe__WEBPACK_IMPORTED_MODULE_5__.isNode || wherearewe__WEBPACK_IMPORTED_MODULE_5__.isElectronMain) {\n this.host.agentVersion += ` UserAgent=${globalThis.process.version}`;\n }\n else if (wherearewe__WEBPACK_IMPORTED_MODULE_5__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_5__.isWebWorker || wherearewe__WEBPACK_IMPORTED_MODULE_5__.isElectronRenderer || wherearewe__WEBPACK_IMPORTED_MODULE_5__.isReactNative) {\n this.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;\n }\n }\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.peerStore.merge(this.peerId, {\n metadata: {\n AgentVersion: (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(this.host.agentVersion),\n ProtocolVersion: (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(this.host.protocolVersion)\n }\n });\n await this.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n this.log.error(err);\n });\n }, {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams,\n runOnTransientConnection: this.runOnTransientConnection\n });\n await this.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n this.log.error(err);\n });\n }, {\n maxInboundStreams: this.maxPushIncomingStreams,\n maxOutboundStreams: this.maxPushOutgoingStreams,\n runOnTransientConnection: this.runOnTransientConnection\n });\n this.started = true;\n }\n async stop() {\n await this.registrar.unhandle(this.identifyProtocolStr);\n await this.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async pushToConnections(connections) {\n const listenAddresses = this.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('p2p').code));\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__.PeerRecord({\n peerId: this.peerId,\n multiaddrs: listenAddresses\n });\n const signedPeerRecord = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.peerId);\n const supportedProtocols = this.registrar.getProtocols();\n const peer = await this.peerStore.get(this.peerId);\n const agentVersion = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(peer.metadata.get('AgentVersion') ?? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(this.host.agentVersion));\n const protocolVersion = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(peer.metadata.get('ProtocolVersion') ?? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(this.host.protocolVersion));\n const pushes = connections.map(async (connection) => {\n let stream;\n const signal = AbortSignal.timeout(this.timeout);\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, signal);\n try {\n stream = await connection.newStream(this.identifyPushProtocolStr, {\n signal,\n runOnTransientConnection: this.runOnTransientConnection\n });\n const pb = (0,it_protobuf_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(stream, {\n maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }).pb(_pb_message_js__WEBPACK_IMPORTED_MODULE_10__.Identify);\n await pb.write({\n listenAddrs: listenAddresses.map(ma => ma.bytes),\n signedPeerRecord: signedPeerRecord.marshal(),\n protocols: supportedProtocols,\n agentVersion,\n protocolVersion\n }, {\n signal\n });\n await stream.close({\n signal\n });\n }\n catch (err) {\n // Just log errors\n this.log.error('could not push identify update to peer', err);\n stream?.abort(err);\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async push() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n await Promise.all(this.connectionManager.getConnections().map(async (conn) => {\n try {\n const peer = await this.peerStore.get(conn.remotePeer);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n return;\n }\n connections.push(conn);\n }\n catch (err) {\n if (err.code !== _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.ERR_NOT_FOUND) {\n throw err;\n }\n }\n }));\n await this.pushToConnections(connections);\n }\n async _identify(connection, options = {}) {\n let stream;\n if (options.signal == null) {\n const signal = AbortSignal.timeout(this.timeout);\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, signal);\n options = {\n ...options,\n signal\n };\n }\n try {\n stream = await connection.newStream(this.identifyProtocolStr, {\n ...options,\n runOnTransientConnection: this.runOnTransientConnection\n });\n const pb = (0,it_protobuf_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(stream, {\n maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }).pb(_pb_message_js__WEBPACK_IMPORTED_MODULE_10__.Identify);\n const message = await pb.read(options);\n await stream.close(options);\n return message;\n }\n catch (err) {\n this.log.error('error while reading identify message', err);\n stream?.abort(err);\n throw err;\n }\n }\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, protocols, observedAddr } = message;\n if (publicKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('public key was missing from identify message', 'ERR_MISSING_PUBLIC_KEY');\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_12__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('identified peer does not match the expected peer', 'ERR_INVALID_PEER');\n }\n if (this.peerId.equals(id)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('identified peer is our own peer id?', 'ERR_INVALID_PEER');\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = getCleanMultiaddr(observedAddr);\n this.log('identify completed for peer %p and protocols %o', id, protocols);\n this.log('our observed address is %a', cleanObservedAddr);\n if (cleanObservedAddr != null &&\n this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {\n this.log('storing our observed address %a', cleanObservedAddr);\n this.addressManager.addObservedAddr(cleanObservedAddr);\n }\n return this.#consumeIdentifyMessage(connection, message);\n }\n /**\n * Sends the `Identify` response with the Signed Peer Record\n * to the requesting peer over the given `connection`\n */\n async _handleIdentify(data) {\n const { connection, stream } = data;\n const signal = AbortSignal.timeout(this.timeout);\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, signal);\n try {\n const publicKey = this.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.peerStore.get(this.peerId);\n const multiaddrs = this.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('p2p').code));\n let signedPeerRecord = peerData.peerRecordEnvelope;\n if (multiaddrs.length > 0 && signedPeerRecord == null) {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__.PeerRecord({\n peerId: this.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.peerId);\n signedPeerRecord = envelope.marshal().subarray();\n }\n let observedAddr = connection.remoteAddr.bytes;\n if (!_multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_1__.IP_OR_DOMAIN.matches(connection.remoteAddr)) {\n observedAddr = undefined;\n }\n const pb = (0,it_protobuf_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(stream).pb(_pb_message_js__WEBPACK_IMPORTED_MODULE_10__.Identify);\n await pb.write({\n protocolVersion: this.host.protocolVersion,\n agentVersion: this.host.agentVersion,\n publicKey,\n listenAddrs: multiaddrs.map(addr => addr.bytes),\n signedPeerRecord,\n observedAddr,\n protocols: peerData.protocols\n }, {\n signal\n });\n await stream.close({\n signal\n });\n }\n catch (err) {\n this.log.error('could not respond to identify request', err);\n stream.abort(err);\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n try {\n if (this.peerId.equals(connection.remotePeer)) {\n throw new Error('received push from ourselves?');\n }\n const options = {\n signal: AbortSignal.timeout(this.timeout)\n };\n const pb = (0,it_protobuf_stream__WEBPACK_IMPORTED_MODULE_2__.pbStream)(stream, {\n maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }).pb(_pb_message_js__WEBPACK_IMPORTED_MODULE_10__.Identify);\n const message = await pb.read(options);\n await stream.close(options);\n await this.#consumeIdentifyMessage(connection, message);\n }\n catch (err) {\n this.log.error('received invalid message', err);\n stream.abort(err);\n return;\n }\n this.log('handled push from %p', connection.remotePeer);\n }\n async #consumeIdentifyMessage(connection, message) {\n this.log('received identify from %p', connection.remotePeer);\n if (message == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('message was null or undefined', 'ERR_INVALID_MESSAGE');\n }\n const peer = {};\n if (message.listenAddrs.length > 0) {\n peer.addresses = message.listenAddrs.map(buf => ({\n isCertified: false,\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(buf)\n }));\n }\n if (message.protocols.length > 0) {\n peer.protocols = message.protocols;\n }\n if (message.publicKey != null) {\n peer.publicKey = message.publicKey;\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_12__.peerIdFromKeys)(message.publicKey);\n if (!peerId.equals(connection.remotePeer)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('public key did not match remote PeerId', 'ERR_INVALID_PUBLIC_KEY');\n }\n }\n let output;\n // if the peer record has been sent, prefer the addresses in the record as they are signed by the remote peer\n if (message.signedPeerRecord != null) {\n this.log('received signedPeerRecord from %p', connection.remotePeer);\n let peerRecordEnvelope = message.signedPeerRecord;\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(peerRecordEnvelope, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__.PeerRecord.DOMAIN);\n let peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__.PeerRecord.createFromProtobuf(envelope.payload);\n // Verify peerId\n if (!peerRecord.peerId.equals(envelope.peerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('signing key does not match PeerId in the PeerRecord', 'ERR_INVALID_SIGNING_KEY');\n }\n // Make sure remote peer is the one sending the record\n if (!connection.remotePeer.equals(peerRecord.peerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_11__.CodeError('signing key does not match remote PeerId', 'ERR_INVALID_PEER_RECORD_KEY');\n }\n let existingPeer;\n try {\n existingPeer = await this.peerStore.get(peerRecord.peerId);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n if (existingPeer != null) {\n // don't lose any existing metadata\n peer.metadata = existingPeer.metadata;\n // if we have previously received a signed record for this peer, compare it to the incoming one\n if (existingPeer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.createFromProtobuf(existingPeer.peerRecordEnvelope);\n const storedRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_7__.PeerRecord.createFromProtobuf(storedEnvelope.payload);\n // ensure seq is greater than, or equal to, the last received\n if (storedRecord.seqNumber >= peerRecord.seqNumber) {\n this.log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);\n peerRecord = storedRecord;\n peerRecordEnvelope = existingPeer.peerRecordEnvelope;\n }\n }\n }\n // store the signed record for next time\n peer.peerRecordEnvelope = peerRecordEnvelope;\n // override the stored addresses with the signed multiaddrs\n peer.addresses = peerRecord.multiaddrs.map(multiaddr => ({\n isCertified: true,\n multiaddr\n }));\n output = {\n seq: peerRecord.seqNumber,\n addresses: peerRecord.multiaddrs\n };\n }\n else {\n this.log('%p did not send a signed peer record', connection.remotePeer);\n }\n this.log('patching %p with', connection.remotePeer, peer);\n await this.peerStore.patch(connection.remotePeer, peer);\n if (message.agentVersion != null || message.protocolVersion != null) {\n const metadata = {};\n if (message.agentVersion != null) {\n metadata.AgentVersion = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(message.agentVersion);\n }\n if (message.protocolVersion != null) {\n metadata.ProtocolVersion = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(message.protocolVersion);\n }\n this.log('merging %p metadata', connection.remotePeer, metadata);\n await this.peerStore.merge(connection.remotePeer, {\n metadata\n });\n }\n const result = {\n peerId: connection.remotePeer,\n protocolVersion: message.protocolVersion,\n agentVersion: message.agentVersion,\n publicKey: message.publicKey,\n listenAddrs: message.listenAddrs.map(buf => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(buf)),\n observedAddr: message.observedAddr == null ? undefined : (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(message.observedAddr),\n protocols: message.protocols,\n signedPeerRecord: output,\n connection\n };\n this.events.safeDispatchEvent('peer:identify', { detail: result });\n return result;\n }\n}\n/**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\nfunction getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(addr);\n }\n catch {\n }\n }\n}\n//# sourceMappingURL=identify.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/dist/src/identify.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/dist/src/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/@libp2p/identify/dist/src/index.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identify: () => (/* binding */ identify),\n/* harmony export */ multicodecs: () => (/* binding */ multicodecs)\n/* harmony export */ });\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/identify/dist/src/consts.js\");\n/* harmony import */ var _identify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./identify.js */ \"./node_modules/@libp2p/identify/dist/src/identify.js\");\n/**\n * @packageDocumentation\n *\n * Use the `identify` function to add support for the [Identify protocol](https://github.com/libp2p/specs/blob/master/identify/README.md) to libp2p.\n *\n * @example\n *\n * ```typescript\n * import { createLibp2p } from 'libp2p'\n * import { identify } from '@libp2p/identify'\n *\n * const node = await createLibp2p({\n * // ...other options\n * services: {\n * identify: identify()\n * }\n * })\n * ```\n */\n\n\n/**\n * The protocols the Identify service supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_0__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_0__.MULTICODEC_IDENTIFY_PUSH\n};\nfunction identify(init = {}) {\n return (components) => new _identify_js__WEBPACK_IMPORTED_MODULE_1__.Identify(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/dist/src/pb/message.js": +/*!**************************************************************!*\ + !*** ./node_modules/@libp2p/identify/dist/src/pb/message.js ***! + \**************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Identify: () => (/* binding */ Identify)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Identify;\n(function (Identify) {\n let _codec;\n Identify.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.protocolVersion != null) {\n w.uint32(42);\n w.string(obj.protocolVersion);\n }\n if (obj.agentVersion != null) {\n w.uint32(50);\n w.string(obj.agentVersion);\n }\n if (obj.publicKey != null) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if (obj.listenAddrs != null) {\n for (const value of obj.listenAddrs) {\n w.uint32(18);\n w.bytes(value);\n }\n }\n if (obj.observedAddr != null) {\n w.uint32(34);\n w.bytes(obj.observedAddr);\n }\n if (obj.protocols != null) {\n for (const value of obj.protocols) {\n w.uint32(26);\n w.string(value);\n }\n }\n if (obj.signedPeerRecord != null) {\n w.uint32(66);\n w.bytes(obj.signedPeerRecord);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n listenAddrs: [],\n protocols: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 5:\n obj.protocolVersion = reader.string();\n break;\n case 6:\n obj.agentVersion = reader.string();\n break;\n case 1:\n obj.publicKey = reader.bytes();\n break;\n case 2:\n obj.listenAddrs.push(reader.bytes());\n break;\n case 4:\n obj.observedAddr = reader.bytes();\n break;\n case 3:\n obj.protocols.push(reader.string());\n break;\n case 8:\n obj.signedPeerRecord = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Identify.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Identify.codec());\n };\n Identify.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Identify.codec());\n };\n})(Identify || (Identify = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/dist/src/pb/message.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/alloc.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/alloc.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/from-string.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/from-string.js ***! + \****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/to-string.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/to-string.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/util/bases.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/util/bases.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/identify/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/connection/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/connection/index.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ connectionSymbol: () => (/* binding */ connectionSymbol),\n/* harmony export */ isConnection: () => (/* binding */ isConnection)\n/* harmony export */ });\nconst connectionSymbol = Symbol.for('@libp2p/connection');\nfunction isConnection(other) {\n return other != null && Boolean(other[connectionSymbol]);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/connection/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/content-routing/index.js": /*!**************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-content-routing/dist/src/index.js ***! + !*** ./node_modules/@libp2p/interface/dist/src/content-routing/index.js ***! \**************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentRouting: () => (/* binding */ contentRouting)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * ContentRouting instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```js\n * import { contentRouting, ContentRouting } from '@libp2p/content-routing'\n *\n * class MyContentRouter implements ContentRouting {\n * get [contentRouting] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst contentRouting = Symbol.for('@libp2p/content-routing');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-content-routing/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ peerDiscovery: () => (/* binding */ peerDiscovery)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * PeerDiscovery instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```js\n * import { peerDiscovery, PeerDiscovery } from '@libp2p/peer-discovery'\n *\n * class MyPeerDiscoverer implements PeerDiscovery {\n * get [peerDiscovery] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst peerDiscovery = Symbol.for('@libp2p/peer-discovery');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!******************************************************************!*\ - !*** ./node_modules/@libp2p/interface-peer-id/dist/src/index.js ***! - \******************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPeerId: () => (/* binding */ isPeerId),\n/* harmony export */ symbol: () => (/* binding */ symbol)\n/* harmony export */ });\nconst symbol = Symbol.for('@libp2p/peer-id');\nfunction isPeerId(other) {\n return other != null && Boolean(other[symbol]);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-peer-routing/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@libp2p/interface-peer-routing/dist/src/index.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ peerRouting: () => (/* binding */ peerRouting)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * PeerRouting instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```js\n * import { peerRouting, PeerRouting } from '@libp2p/peer-routing'\n *\n * class MyPeerRouter implements PeerRouting {\n * get [peerRouting] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst peerRouting = Symbol.for('@libp2p/peer-routing');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-peer-routing/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-registrar/dist/src/index.js": -/*!********************************************************************!*\ - !*** ./node_modules/@libp2p/interface-registrar/dist/src/index.js ***! - \********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isTopology: () => (/* binding */ isTopology),\n/* harmony export */ topologySymbol: () => (/* binding */ topologySymbol)\n/* harmony export */ });\nconst topologySymbol = Symbol.for('@libp2p/topology');\nfunction isTopology(other) {\n return other != null && Boolean(other[topologySymbol]);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-registrar/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-stream-muxer/dist/src/stream.js": -/*!************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-stream-muxer/dist/src/stream.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbstractStream: () => (/* binding */ AbstractStream)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:stream');\nconst ERR_STREAM_RESET = 'ERR_STREAM_RESET';\nconst ERR_STREAM_ABORT = 'ERR_STREAM_ABORT';\nconst ERR_SINK_ENDED = 'ERR_SINK_ENDED';\nconst ERR_DOUBLE_SINK = 'ERR_DOUBLE_SINK';\nfunction isPromise(res) {\n return res != null && typeof res.then === 'function';\n}\nclass AbstractStream {\n id;\n stat;\n metadata;\n source;\n abortController;\n resetController;\n closeController;\n sourceEnded;\n sinkEnded;\n sinkSunk;\n endErr;\n streamSource;\n onEnd;\n maxDataSize;\n constructor(init) {\n this.abortController = new AbortController();\n this.resetController = new AbortController();\n this.closeController = new AbortController();\n this.sourceEnded = false;\n this.sinkEnded = false;\n this.sinkSunk = false;\n this.id = init.id;\n this.metadata = init.metadata ?? {};\n this.stat = {\n direction: init.direction,\n timeline: {\n open: Date.now()\n }\n };\n this.maxDataSize = init.maxDataSize;\n this.onEnd = init.onEnd;\n this.source = this.streamSource = (0,it_pushable__WEBPACK_IMPORTED_MODULE_4__.pushable)({\n onEnd: () => {\n // already sent a reset message\n if (this.stat.timeline.reset !== null) {\n const res = this.sendCloseRead();\n if (isPromise(res)) {\n res.catch(err => {\n log.error('error while sending close read', err);\n });\n }\n }\n this.onSourceEnd();\n }\n });\n // necessary because the libp2p upgrader wraps the sink function\n this.sink = this.sink.bind(this);\n }\n onSourceEnd(err) {\n if (this.sourceEnded) {\n return;\n }\n this.stat.timeline.closeRead = Date.now();\n this.sourceEnded = true;\n log.trace('%s stream %s source end - err: %o', this.stat.direction, this.id, err);\n if (err != null && this.endErr == null) {\n this.endErr = err;\n }\n if (this.sinkEnded) {\n this.stat.timeline.close = Date.now();\n if (this.onEnd != null) {\n this.onEnd(this.endErr);\n }\n }\n }\n onSinkEnd(err) {\n if (this.sinkEnded) {\n return;\n }\n this.stat.timeline.closeWrite = Date.now();\n this.sinkEnded = true;\n log.trace('%s stream %s sink end - err: %o', this.stat.direction, this.id, err);\n if (err != null && this.endErr == null) {\n this.endErr = err;\n }\n if (this.sourceEnded) {\n this.stat.timeline.close = Date.now();\n if (this.onEnd != null) {\n this.onEnd(this.endErr);\n }\n }\n }\n // Close for both Reading and Writing\n close() {\n log.trace('%s stream %s close', this.stat.direction, this.id);\n this.closeRead();\n this.closeWrite();\n }\n // Close for reading\n closeRead() {\n log.trace('%s stream %s closeRead', this.stat.direction, this.id);\n if (this.sourceEnded) {\n return;\n }\n this.streamSource.end();\n }\n // Close for writing\n closeWrite() {\n log.trace('%s stream %s closeWrite', this.stat.direction, this.id);\n if (this.sinkEnded) {\n return;\n }\n this.closeController.abort();\n try {\n // need to call this here as the sink method returns in the catch block\n // when the close controller is aborted\n const res = this.sendCloseWrite();\n if (isPromise(res)) {\n res.catch(err => {\n log.error('error while sending close write', err);\n });\n }\n }\n catch (err) {\n log.trace('%s stream %s error sending close', this.stat.direction, this.id, err);\n }\n this.onSinkEnd();\n }\n // Close for reading and writing (local error)\n abort(err) {\n log.trace('%s stream %s abort', this.stat.direction, this.id, err);\n // End the source with the passed error\n this.streamSource.end(err);\n this.abortController.abort();\n this.onSinkEnd(err);\n }\n // Close immediately for reading and writing (remote error)\n reset() {\n const err = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('stream reset', ERR_STREAM_RESET);\n this.resetController.abort();\n this.streamSource.end(err);\n this.onSinkEnd(err);\n }\n async sink(source) {\n if (this.sinkSunk) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('sink already called on stream', ERR_DOUBLE_SINK);\n }\n this.sinkSunk = true;\n if (this.sinkEnded) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('stream closed for writing', ERR_SINK_ENDED);\n }\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_3__.anySignal)([\n this.abortController.signal,\n this.resetController.signal,\n this.closeController.signal\n ]);\n try {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_2__.abortableSource)(source, signal);\n if (this.stat.direction === 'outbound') { // If initiator, open a new stream\n const res = this.sendNewStream();\n if (isPromise(res)) {\n await res;\n }\n }\n for await (let data of source) {\n while (data.length > 0) {\n if (data.length <= this.maxDataSize) {\n const res = this.sendData(data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList(data) : data);\n if (isPromise(res)) { // eslint-disable-line max-depth\n await res;\n }\n break;\n }\n data = data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList(data) : data;\n const res = this.sendData(data.sublist(0, this.maxDataSize));\n if (isPromise(res)) {\n await res;\n }\n data.consume(this.maxDataSize);\n }\n }\n }\n catch (err) {\n if (err.type === 'aborted' && err.message === 'The operation was aborted') {\n if (this.closeController.signal.aborted) {\n return;\n }\n if (this.resetController.signal.aborted) {\n err.message = 'stream reset';\n err.code = ERR_STREAM_RESET;\n }\n if (this.abortController.signal.aborted) {\n err.message = 'stream aborted';\n err.code = ERR_STREAM_ABORT;\n }\n }\n // Send no more data if this stream was remotely reset\n if (err.code === ERR_STREAM_RESET) {\n log.trace('%s stream %s reset', this.stat.direction, this.id);\n }\n else {\n log.trace('%s stream %s error', this.stat.direction, this.id, err);\n try {\n const res = this.sendReset();\n if (isPromise(res)) {\n await res;\n }\n this.stat.timeline.reset = Date.now();\n }\n catch (err) {\n log.trace('%s stream %s error sending reset', this.stat.direction, this.id, err);\n }\n }\n this.streamSource.end(err);\n this.onSinkEnd(err);\n throw err;\n }\n finally {\n signal.clear();\n }\n try {\n const res = this.sendCloseWrite();\n if (isPromise(res)) {\n await res;\n }\n }\n catch (err) {\n log.trace('%s stream %s error sending close', this.stat.direction, this.id, err);\n }\n this.onSinkEnd();\n }\n /**\n * When an extending class reads data from it's implementation-specific source,\n * call this method to allow the stream consumer to read the data.\n */\n sourcePush(data) {\n this.streamSource.push(data);\n }\n /**\n * Returns the amount of unread data - can be used to prevent large amounts of\n * data building up when the stream consumer is too slow.\n */\n sourceReadableLength() {\n return this.streamSource.readableLength;\n }\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-stream-muxer/dist/src/stream.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/abort-error.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/abort-error.js ***! - \*************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/abort-error.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/index.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/index.js ***! - \*******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-stream-muxer/node_modules/abortable-iterator/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/interface-transport/dist/src/index.js": -/*!********************************************************************!*\ - !*** ./node_modules/@libp2p/interface-transport/dist/src/index.js ***! - \********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FaultTolerance: () => (/* binding */ FaultTolerance),\n/* harmony export */ isTransport: () => (/* binding */ isTransport),\n/* harmony export */ symbol: () => (/* binding */ symbol)\n/* harmony export */ });\nconst symbol = Symbol.for('@libp2p/transport');\nfunction isTransport(other) {\n return other != null && Boolean(other[symbol]);\n}\n/**\n * Enum Transport Manager Fault Tolerance values\n */\nvar FaultTolerance;\n(function (FaultTolerance) {\n /**\n * should be used for failing in any listen circumstance\n */\n FaultTolerance[FaultTolerance[\"FATAL_ALL\"] = 0] = \"FATAL_ALL\";\n /**\n * should be used for not failing when not listening\n */\n FaultTolerance[FaultTolerance[\"NO_FATAL\"] = 1] = \"NO_FATAL\";\n})(FaultTolerance || (FaultTolerance = {}));\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-transport/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentRoutingSymbol: () => (/* binding */ contentRoutingSymbol)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * ContentRouting instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```TypeScript\n * import { contentRoutingSymbol, ContentRouting } from '@libp2p/content-routing'\n *\n * class MyContentRouter implements ContentRouting {\n * get [contentRoutingSymbol] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst contentRoutingSymbol = Symbol.for('@libp2p/content-routing');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/content-routing/index.js?"); /***/ }), @@ -2808,58 +3090,113 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/interfaces/dist/src/errors.js": -/*!************************************************************!*\ - !*** ./node_modules/@libp2p/interfaces/dist/src/errors.js ***! - \************************************************************/ +/***/ "./node_modules/@libp2p/interface/dist/src/event-target.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/event-target.js ***! + \*****************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ CodeError: () => (/* binding */ CodeError)\n/* harmony export */ });\n/**\n * When this error is thrown it means an operation was aborted,\n * usually in response to the `abort` event being emitted by an\n * AbortSignal.\n */\nclass AbortError extends Error {\n code;\n type;\n constructor(message = 'The operation was aborted') {\n super(message);\n this.code = AbortError.code;\n this.type = AbortError.type;\n }\n static code = 'ABORT_ERR';\n static type = 'aborted';\n}\nclass CodeError extends Error {\n code;\n props;\n constructor(message, code, props) {\n super(message);\n this.code = code;\n this.name = props?.name ?? 'CodeError';\n this.props = props ?? {}; // eslint-disable-line @typescript-eslint/consistent-type-assertions\n }\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interfaces/dist/src/errors.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CustomEvent: () => (/* binding */ CustomEvent),\n/* harmony export */ TypedEventEmitter: () => (/* binding */ TypedEventEmitter)\n/* harmony export */ });\n/* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./events.js */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n\n/**\n * An implementation of a typed event target\n * etc\n */\nclass TypedEventEmitter extends EventTarget {\n #listeners = new Map();\n constructor() {\n super();\n // silence MaxListenersExceededWarning warning on Node.js, this is a red\n // herring almost all of the time\n (0,_events_js__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)(Infinity, this);\n }\n listenerCount(type) {\n const listeners = this.#listeners.get(type);\n if (listeners == null) {\n return 0;\n }\n return listeners.length;\n }\n addEventListener(type, listener, options) {\n super.addEventListener(type, listener, options);\n let list = this.#listeners.get(type);\n if (list == null) {\n list = [];\n this.#listeners.set(type, list);\n }\n list.push({\n callback: listener,\n once: (options !== true && options !== false && options?.once) ?? false\n });\n }\n removeEventListener(type, listener, options) {\n super.removeEventListener(type.toString(), listener ?? null, options);\n let list = this.#listeners.get(type);\n if (list == null) {\n return;\n }\n list = list.filter(({ callback }) => callback !== listener);\n this.#listeners.set(type, list);\n }\n dispatchEvent(event) {\n const result = super.dispatchEvent(event);\n let list = this.#listeners.get(event.type);\n if (list == null) {\n return result;\n }\n list = list.filter(({ once }) => !once);\n this.#listeners.set(event.type, list);\n return result;\n }\n safeDispatchEvent(type, detail = {}) {\n return this.dispatchEvent(new CustomEvent(type, detail));\n }\n}\n/**\n * CustomEvent is a standard event but it's not supported by node.\n *\n * Remove this when https://github.com/nodejs/node/issues/40678 is closed.\n *\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent\n */\nclass CustomEventPolyfill extends Event {\n /** Returns any custom data event was created with. Typically used for synthetic events. */\n detail;\n constructor(message, data) {\n super(message, data);\n // @ts-expect-error could be undefined\n this.detail = data?.detail;\n }\n}\nconst CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;\n//# sourceMappingURL=event-target.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/event-target.js?"); /***/ }), -/***/ "./node_modules/@libp2p/interfaces/dist/src/events.js": -/*!************************************************************!*\ - !*** ./node_modules/@libp2p/interfaces/dist/src/events.js ***! - \************************************************************/ +/***/ "./node_modules/@libp2p/interface/dist/src/events.browser.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/events.browser.js ***! + \*******************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CustomEvent: () => (/* binding */ CustomEvent),\n/* harmony export */ EventEmitter: () => (/* binding */ EventEmitter)\n/* harmony export */ });\n/**\n * Adds types to the EventTarget class. Hopefully this won't be necessary forever.\n *\n * https://github.com/microsoft/TypeScript/issues/28357\n * https://github.com/microsoft/TypeScript/issues/43477\n * https://github.com/microsoft/TypeScript/issues/299\n * etc\n */\nclass EventEmitter extends EventTarget {\n #listeners = new Map();\n listenerCount(type) {\n const listeners = this.#listeners.get(type);\n if (listeners == null) {\n return 0;\n }\n return listeners.length;\n }\n addEventListener(type, listener, options) {\n super.addEventListener(type, listener, options);\n let list = this.#listeners.get(type);\n if (list == null) {\n list = [];\n this.#listeners.set(type, list);\n }\n list.push({\n callback: listener,\n once: (options !== true && options !== false && options?.once) ?? false\n });\n }\n removeEventListener(type, listener, options) {\n super.removeEventListener(type.toString(), listener ?? null, options);\n let list = this.#listeners.get(type);\n if (list == null) {\n return;\n }\n list = list.filter(({ callback }) => callback !== listener);\n this.#listeners.set(type, list);\n }\n dispatchEvent(event) {\n const result = super.dispatchEvent(event);\n let list = this.#listeners.get(event.type);\n if (list == null) {\n return result;\n }\n list = list.filter(({ once }) => !once);\n this.#listeners.set(event.type, list);\n return result;\n }\n safeDispatchEvent(type, detail) {\n return this.dispatchEvent(new CustomEvent(type, detail));\n }\n}\n/**\n * CustomEvent is a standard event but it's not supported by node.\n *\n * Remove this when https://github.com/nodejs/node/issues/40678 is closed.\n *\n * Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent\n */\nclass CustomEventPolyfill extends Event {\n /** Returns any custom data event was created with. Typically used for synthetic events. */\n detail;\n constructor(message, data) {\n super(message, data);\n // @ts-expect-error could be undefined\n this.detail = data?.detail;\n }\n}\nconst CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;\n//# sourceMappingURL=events.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interfaces/dist/src/events.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ setMaxListeners: () => (/* binding */ setMaxListeners)\n/* harmony export */ });\n/** Noop for browser compatibility */\nfunction setMaxListeners() { }\n//# sourceMappingURL=events.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/events.browser.js?"); /***/ }), -/***/ "./node_modules/@libp2p/interfaces/dist/src/startable.js": -/*!***************************************************************!*\ - !*** ./node_modules/@libp2p/interfaces/dist/src/startable.js ***! - \***************************************************************/ +/***/ "./node_modules/@libp2p/interface/dist/src/events.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/events.js ***! + \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isStartable: () => (/* binding */ isStartable),\n/* harmony export */ start: () => (/* binding */ start),\n/* harmony export */ stop: () => (/* binding */ stop)\n/* harmony export */ });\nfunction isStartable(obj) {\n return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function';\n}\nasync function start(...objs) {\n const startables = [];\n for (const obj of objs) {\n if (isStartable(obj)) {\n startables.push(obj);\n }\n }\n await Promise.all(startables.map(async (s) => {\n if (s.beforeStart != null) {\n await s.beforeStart();\n }\n }));\n await Promise.all(startables.map(async (s) => {\n await s.start();\n }));\n await Promise.all(startables.map(async (s) => {\n if (s.afterStart != null) {\n await s.afterStart();\n }\n }));\n}\nasync function stop(...objs) {\n const startables = [];\n for (const obj of objs) {\n if (isStartable(obj)) {\n startables.push(obj);\n }\n }\n await Promise.all(startables.map(async (s) => {\n if (s.beforeStop != null) {\n await s.beforeStop();\n }\n }));\n await Promise.all(startables.map(async (s) => {\n await s.stop();\n }));\n await Promise.all(startables.map(async (s) => {\n if (s.afterStop != null) {\n await s.afterStop();\n }\n }));\n}\n//# sourceMappingURL=startable.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interfaces/dist/src/startable.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ setMaxListeners: () => (/* binding */ setMaxListeners)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/@libp2p/interface/dist/src/events.browser.js\");\n\n// create a setMaxListeners that doesn't break browser usage\nconst setMaxListeners = (n, ...eventTargets) => {\n try {\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)(n, ...eventTargets);\n }\n catch {\n // swallow error, gulp\n }\n};\n//# sourceMappingURL=events.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/events.js?"); /***/ }), -/***/ "./node_modules/@libp2p/keychain/dist/src/errors.js": -/*!**********************************************************!*\ - !*** ./node_modules/@libp2p/keychain/dist/src/errors.js ***! - \**********************************************************/ +/***/ "./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js ***! + \*************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes)\n/* harmony export */ });\nvar codes;\n(function (codes) {\n codes[\"ERR_INVALID_PARAMETERS\"] = \"ERR_INVALID_PARAMETERS\";\n codes[\"ERR_INVALID_KEY_NAME\"] = \"ERR_INVALID_KEY_NAME\";\n codes[\"ERR_INVALID_KEY_TYPE\"] = \"ERR_INVALID_KEY_TYPE\";\n codes[\"ERR_KEY_ALREADY_EXISTS\"] = \"ERR_KEY_ALREADY_EXISTS\";\n codes[\"ERR_INVALID_KEY_SIZE\"] = \"ERR_INVALID_KEY_SIZE\";\n codes[\"ERR_KEY_NOT_FOUND\"] = \"ERR_KEY_NOT_FOUND\";\n codes[\"ERR_OLD_KEY_NAME_INVALID\"] = \"ERR_OLD_KEY_NAME_INVALID\";\n codes[\"ERR_NEW_KEY_NAME_INVALID\"] = \"ERR_NEW_KEY_NAME_INVALID\";\n codes[\"ERR_PASSWORD_REQUIRED\"] = \"ERR_PASSWORD_REQUIRED\";\n codes[\"ERR_PEM_REQUIRED\"] = \"ERR_PEM_REQUIRED\";\n codes[\"ERR_CANNOT_READ_KEY\"] = \"ERR_CANNOT_READ_KEY\";\n codes[\"ERR_MISSING_PRIVATE_KEY\"] = \"ERR_MISSING_PRIVATE_KEY\";\n codes[\"ERR_INVALID_OLD_PASS_TYPE\"] = \"ERR_INVALID_OLD_PASS_TYPE\";\n codes[\"ERR_INVALID_NEW_PASS_TYPE\"] = \"ERR_INVALID_NEW_PASS_TYPE\";\n codes[\"ERR_INVALID_PASS_LENGTH\"] = \"ERR_INVALID_PASS_LENGTH\";\n})(codes || (codes = {}));\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/keychain/dist/src/errors.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ peerDiscoverySymbol: () => (/* binding */ peerDiscoverySymbol)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * PeerDiscovery instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```TypeScript\n * import { peerDiscovery, PeerDiscovery } from '@libp2p/peer-discovery'\n *\n * class MyPeerDiscoverer implements PeerDiscovery {\n * get [peerDiscovery] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst peerDiscoverySymbol = Symbol.for('@libp2p/peer-discovery');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js?"); /***/ }), -/***/ "./node_modules/@libp2p/keychain/dist/src/index.js": -/*!*********************************************************!*\ - !*** ./node_modules/@libp2p/keychain/dist/src/index.js ***! - \*********************************************************/ +/***/ "./node_modules/@libp2p/interface/dist/src/peer-id/index.js": +/*!******************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/peer-id/index.js ***! + \******************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultKeyChain: () => (/* binding */ DefaultKeyChain)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var sanitize_filename__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! sanitize-filename */ \"./node_modules/sanitize-filename/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/keychain/dist/src/errors.js\");\n/* eslint max-nested-callbacks: [\"error\", 5] */\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.logger)('libp2p:keychain');\nconst keyPrefix = '/pkcs8/';\nconst infoPrefix = '/info/';\nconst privates = new WeakMap();\n// NIST SP 800-132\nconst NIST = {\n minKeyLength: 112 / 8,\n minSaltLength: 128 / 8,\n minIterationCount: 1000\n};\nconst defaultOptions = {\n // See https://cryptosense.com/parametesr-choice-for-pbkdf2/\n dek: {\n keyLength: 512 / 8,\n iterationCount: 10000,\n salt: 'you should override this value with a crypto secure random number',\n hash: 'sha2-512'\n }\n};\nfunction validateKeyName(name) {\n if (name == null) {\n return false;\n }\n if (typeof name !== 'string') {\n return false;\n }\n return name === sanitize_filename__WEBPACK_IMPORTED_MODULE_7__(name.trim()) && name.length > 0;\n}\n/**\n * Throws an error after a delay\n *\n * This assumes than an error indicates that the keychain is under attack. Delay returning an\n * error to make brute force attacks harder.\n */\nasync function randomDelay() {\n const min = 200;\n const max = 1000;\n const delay = Math.random() * (max - min) + min;\n await new Promise(resolve => setTimeout(resolve, delay));\n}\n/**\n * Converts a key name into a datastore name\n */\nfunction DsName(name) {\n return new interface_datastore_key__WEBPACK_IMPORTED_MODULE_5__.Key(keyPrefix + name);\n}\n/**\n * Converts a key name into a datastore info name\n */\nfunction DsInfoName(name) {\n return new interface_datastore_key__WEBPACK_IMPORTED_MODULE_5__.Key(infoPrefix + name);\n}\n/**\n * Manages the lifecycle of a key. Keys are encrypted at rest using PKCS #8.\n *\n * A key in the store has two entries\n * - '/info/*key-name*', contains the KeyInfo for the key\n * - '/pkcs8/*key-name*', contains the PKCS #8 for the key\n *\n */\nclass DefaultKeyChain {\n components;\n init;\n /**\n * Creates a new instance of a key chain\n */\n constructor(components, init) {\n this.components = components;\n this.init = (0,merge_options__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(defaultOptions, init);\n // Enforce NIST SP 800-132\n if (this.init.pass != null && this.init.pass?.length < 20) {\n throw new Error('pass must be least 20 characters');\n }\n if (this.init.dek?.keyLength != null && this.init.dek.keyLength < NIST.minKeyLength) {\n throw new Error(`dek.keyLength must be least ${NIST.minKeyLength} bytes`);\n }\n if (this.init.dek?.salt?.length != null && this.init.dek.salt.length < NIST.minSaltLength) {\n throw new Error(`dek.saltLength must be least ${NIST.minSaltLength} bytes`);\n }\n if (this.init.dek?.iterationCount != null && this.init.dek.iterationCount < NIST.minIterationCount) {\n throw new Error(`dek.iterationCount must be least ${NIST.minIterationCount}`);\n }\n const dek = this.init.pass != null && this.init.dek?.salt != null\n ? (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__.pbkdf2)(this.init.pass, this.init.dek?.salt, this.init.dek?.iterationCount, this.init.dek?.keyLength, this.init.dek?.hash)\n : '';\n privates.set(this, { dek });\n }\n /**\n * Generates the options for a keychain. A random salt is produced.\n *\n * @returns {object}\n */\n static generateOptions() {\n const options = Object.assign({}, defaultOptions);\n const saltLength = Math.ceil(NIST.minSaltLength / 3) * 3; // no base64 padding\n options.dek.salt = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__.randomBytes)(saltLength), 'base64');\n return options;\n }\n /**\n * Gets an object that can encrypt/decrypt protected data.\n * The default options for a keychain.\n *\n * @returns {object}\n */\n static get options() {\n return defaultOptions;\n }\n /**\n * Create a new key.\n *\n * @param {string} name - The local key name; cannot already exist.\n * @param {string} type - One of the key types; 'rsa'.\n * @param {number} [size = 2048] - The key size in bits. Used for rsa keys only\n */\n async createKey(name, type, size = 2048) {\n if (!validateKeyName(name) || name === 'self') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Invalid key name', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n if (typeof type !== 'string') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Invalid key type', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_TYPE);\n }\n const dsname = DsName(name);\n const exists = await this.components.datastore.has(dsname);\n if (exists) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Key name already exists', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n switch (type.toLowerCase()) {\n case 'rsa':\n if (!Number.isSafeInteger(size) || size < 2048) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Invalid RSA key size', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_SIZE);\n }\n break;\n default:\n break;\n }\n let keyInfo;\n try {\n const keypair = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)(type, size);\n const kid = await keypair.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('dek missing', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await keypair.export(dek);\n keyInfo = {\n name,\n id: kid\n };\n const batch = this.components.datastore.batch();\n batch.put(dsname, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(pem));\n batch.put(DsInfoName(name), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(JSON.stringify(keyInfo)));\n await batch.commit();\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n return keyInfo;\n }\n /**\n * List all the keys.\n *\n * @returns {Promise}\n */\n async listKeys() {\n const query = {\n prefix: infoPrefix\n };\n const info = [];\n for await (const value of this.components.datastore.query(query)) {\n info.push(JSON.parse((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(value.value)));\n }\n return info;\n }\n /**\n * Find a key by it's id\n */\n async findKeyById(id) {\n try {\n const keys = await this.listKeys();\n const key = keys.find((k) => k.id === id);\n if (key == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key with id '${id}' does not exist.`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_NOT_FOUND);\n }\n return key;\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n }\n /**\n * Find a key by it's name.\n *\n * @param {string} name - The local key name.\n * @returns {Promise}\n */\n async findKeyByName(name) {\n if (!validateKeyName(name)) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n const dsname = DsInfoName(name);\n try {\n const res = await this.components.datastore.get(dsname);\n return JSON.parse((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(res));\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key '${name}' does not exist.`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_NOT_FOUND);\n }\n }\n /**\n * Remove an existing key.\n *\n * @param {string} name - The local key name; must already exist.\n * @returns {Promise}\n */\n async removeKey(name) {\n if (!validateKeyName(name) || name === 'self') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n const dsname = DsName(name);\n const keyInfo = await this.findKeyByName(name);\n const batch = this.components.datastore.batch();\n batch.delete(dsname);\n batch.delete(DsInfoName(name));\n await batch.commit();\n return keyInfo;\n }\n /**\n * Rename a key\n *\n * @param {string} oldName - The old local key name; must already exist.\n * @param {string} newName - The new local key name; must not already exist.\n * @returns {Promise}\n */\n async renameKey(oldName, newName) {\n if (!validateKeyName(oldName) || oldName === 'self') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid old key name '${oldName}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_OLD_KEY_NAME_INVALID);\n }\n if (!validateKeyName(newName) || newName === 'self') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid new key name '${newName}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_NEW_KEY_NAME_INVALID);\n }\n const oldDsname = DsName(oldName);\n const newDsname = DsName(newName);\n const oldInfoName = DsInfoName(oldName);\n const newInfoName = DsInfoName(newName);\n const exists = await this.components.datastore.has(newDsname);\n if (exists) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key '${newName}' already exists`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n try {\n const pem = await this.components.datastore.get(oldDsname);\n const res = await this.components.datastore.get(oldInfoName);\n const keyInfo = JSON.parse((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(res));\n keyInfo.name = newName;\n const batch = this.components.datastore.batch();\n batch.put(newDsname, pem);\n batch.put(newInfoName, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(JSON.stringify(keyInfo)));\n batch.delete(oldDsname);\n batch.delete(oldInfoName);\n await batch.commit();\n return keyInfo;\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n }\n /**\n * Export an existing key as a PEM encrypted PKCS #8 string\n */\n async exportKey(name, password) {\n if (!validateKeyName(name)) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n if (password == null) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Password is required', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_PASSWORD_REQUIRED);\n }\n const dsname = DsName(name);\n try {\n const res = await this.components.datastore.get(dsname);\n const pem = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(res);\n const cached = privates.get(this);\n if (cached == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('dek missing', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.importKey)(pem, dek);\n return await privateKey.export(password);\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n }\n /**\n * Export an existing key as a PeerId\n */\n async exportPeerId(name) {\n const password = 'temporary-password';\n const pem = await this.exportKey(name, password);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.importKey)(pem, password);\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromKeys)(privateKey.public.bytes, privateKey.bytes);\n }\n /**\n * Import a new key from a PEM encoded PKCS #8 string\n *\n * @param {string} name - The local key name; must not already exist.\n * @param {string} pem - The PEM encoded PKCS #8 string\n * @param {string} password - The password.\n * @returns {Promise}\n */\n async importKey(name, pem, password) {\n if (!validateKeyName(name) || name === 'self') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n if (pem == null) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('PEM encoded key is required', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_PEM_REQUIRED);\n }\n const dsname = DsName(name);\n const exists = await this.components.datastore.has(dsname);\n if (exists) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key '${name}' already exists`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n let privateKey;\n try {\n privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.importKey)(pem, password);\n }\n catch (err) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Cannot read the key, most likely the password is wrong', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_CANNOT_READ_KEY);\n }\n let kid;\n try {\n kid = await privateKey.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('dek missing', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n pem = await privateKey.export(dek);\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n const keyInfo = {\n name,\n id: kid\n };\n const batch = this.components.datastore.batch();\n batch.put(dsname, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(pem));\n batch.put(DsInfoName(name), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(JSON.stringify(keyInfo)));\n await batch.commit();\n return keyInfo;\n }\n /**\n * Import a peer key\n */\n async importPeer(name, peer) {\n try {\n if (!validateKeyName(name)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n if (peer == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('PeerId is required', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n if (peer.privateKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('PeerId.privKey is required', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.unmarshalPrivateKey)(peer.privateKey);\n const dsname = DsName(name);\n const exists = await this.components.datastore.has(dsname);\n if (exists) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key '${name}' already exists`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n const cached = privates.get(this);\n if (cached == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('dek missing', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await privateKey.export(dek);\n const keyInfo = {\n name,\n id: peer.toString()\n };\n const batch = this.components.datastore.batch();\n batch.put(dsname, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(pem));\n batch.put(DsInfoName(name), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(JSON.stringify(keyInfo)));\n await batch.commit();\n return keyInfo;\n }\n catch (err) {\n await randomDelay();\n throw err;\n }\n }\n /**\n * Gets the private key as PEM encoded PKCS #8 string\n */\n async getPrivateKey(name) {\n if (!validateKeyName(name)) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid key name '${name}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_KEY_NAME);\n }\n try {\n const dsname = DsName(name);\n const res = await this.components.datastore.get(dsname);\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(res);\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Key '${name}' does not exist.`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_KEY_NOT_FOUND);\n }\n }\n /**\n * Rotate keychain password and re-encrypt all associated keys\n */\n async rotateKeychainPass(oldPass, newPass) {\n if (typeof oldPass !== 'string') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid old pass type '${typeof oldPass}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_OLD_PASS_TYPE);\n }\n if (typeof newPass !== 'string') {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid new pass type '${typeof newPass}'`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_NEW_PASS_TYPE);\n }\n if (newPass.length < 20) {\n await randomDelay();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Invalid pass length ${newPass.length}`, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PASS_LENGTH);\n }\n log('recreating keychain');\n const cached = privates.get(this);\n if (cached == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('dek missing', _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PARAMETERS);\n }\n const oldDek = cached.dek;\n this.init.pass = newPass;\n const newDek = newPass != null && this.init.dek?.salt != null\n ? (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__.pbkdf2)(newPass, this.init.dek.salt, this.init.dek?.iterationCount, this.init.dek?.keyLength, this.init.dek?.hash)\n : '';\n privates.set(this, { dek: newDek });\n const keys = await this.listKeys();\n for (const key of keys) {\n const res = await this.components.datastore.get(DsName(key.name));\n const pem = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(res);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.importKey)(pem, oldDek);\n const password = newDek.toString();\n const keyAsPEM = await privateKey.export(password);\n // Update stored key\n const batch = this.components.datastore.batch();\n const keyInfo = {\n name: key.name,\n id: key.id\n };\n batch.put(DsName(key.name), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(keyAsPEM));\n batch.put(DsInfoName(key.name), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(JSON.stringify(keyInfo)));\n await batch.commit();\n }\n log('keychain reconstructed');\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/keychain/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPeerId: () => (/* binding */ isPeerId),\n/* harmony export */ peerIdSymbol: () => (/* binding */ peerIdSymbol)\n/* harmony export */ });\nconst peerIdSymbol = Symbol.for('@libp2p/peer-id');\nfunction isPeerId(other) {\n return other != null && Boolean(other[peerIdSymbol]);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/peer-id/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/peer-routing/index.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/peer-routing/index.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ peerRoutingSymbol: () => (/* binding */ peerRoutingSymbol)\n/* harmony export */ });\n/**\n * Any object that implements this Symbol as a property should return a\n * PeerRouting instance as the property value, similar to how\n * `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.\n *\n * @example\n *\n * ```TypeScript\n * import { peerRouting, PeerRouting } from '@libp2p/peer-routing'\n *\n * class MyPeerRouter implements PeerRouting {\n * get [peerRouting] () {\n * return this\n * }\n *\n * // ...other methods\n * }\n * ```\n */\nconst peerRoutingSymbol = Symbol.for('@libp2p/peer-routing');\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/peer-routing/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/peer-store/tags.js": +/*!********************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/peer-store/tags.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KEEP_ALIVE: () => (/* binding */ KEEP_ALIVE)\n/* harmony export */ });\nconst KEEP_ALIVE = 'keep-alive';\n//# sourceMappingURL=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/peer-store/tags.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/pubsub/index.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/pubsub/index.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StrictNoSign: () => (/* binding */ StrictNoSign),\n/* harmony export */ StrictSign: () => (/* binding */ StrictSign),\n/* harmony export */ TopicValidatorResult: () => (/* binding */ TopicValidatorResult)\n/* harmony export */ });\n/**\n * On the producing side:\n * * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.\n *\n * On the consuming side:\n * * Enforce the fields to be present, reject otherwise.\n * * Propagate only if the fields are valid and signature can be verified, reject otherwise.\n */\nconst StrictSign = 'StrictSign';\n/**\n * On the producing side:\n * * Build messages without the signature, key, from and seqno fields.\n * * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty.\n *\n * On the consuming side:\n * * Enforce the fields to be absent, reject otherwise.\n * * Propagate only if the fields are absent, reject otherwise.\n * * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.\n */\nconst StrictNoSign = 'StrictNoSign';\nvar TopicValidatorResult;\n(function (TopicValidatorResult) {\n /**\n * The message is considered valid, and it should be delivered and forwarded to the network\n */\n TopicValidatorResult[\"Accept\"] = \"accept\";\n /**\n * The message is neither delivered nor forwarded to the network\n */\n TopicValidatorResult[\"Ignore\"] = \"ignore\";\n /**\n * The message is considered invalid, and it should be rejected\n */\n TopicValidatorResult[\"Reject\"] = \"reject\";\n})(TopicValidatorResult || (TopicValidatorResult = {}));\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/pubsub/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/startable.js": +/*!**************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/startable.js ***! + \**************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isStartable: () => (/* binding */ isStartable),\n/* harmony export */ start: () => (/* binding */ start),\n/* harmony export */ stop: () => (/* binding */ stop)\n/* harmony export */ });\nfunction isStartable(obj) {\n return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function';\n}\nasync function start(...objs) {\n const startables = [];\n for (const obj of objs) {\n if (isStartable(obj)) {\n startables.push(obj);\n }\n }\n await Promise.all(startables.map(async (s) => {\n if (s.beforeStart != null) {\n await s.beforeStart();\n }\n }));\n await Promise.all(startables.map(async (s) => {\n await s.start();\n }));\n await Promise.all(startables.map(async (s) => {\n if (s.afterStart != null) {\n await s.afterStart();\n }\n }));\n}\nasync function stop(...objs) {\n const startables = [];\n for (const obj of objs) {\n if (isStartable(obj)) {\n startables.push(obj);\n }\n }\n await Promise.all(startables.map(async (s) => {\n if (s.beforeStop != null) {\n await s.beforeStop();\n }\n }));\n await Promise.all(startables.map(async (s) => {\n await s.stop();\n }));\n await Promise.all(startables.map(async (s) => {\n if (s.afterStop != null) {\n await s.afterStop();\n }\n }));\n}\n//# sourceMappingURL=startable.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/startable.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/interface/dist/src/transport/index.js": +/*!********************************************************************!*\ + !*** ./node_modules/@libp2p/interface/dist/src/transport/index.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FaultTolerance: () => (/* binding */ FaultTolerance),\n/* harmony export */ isTransport: () => (/* binding */ isTransport),\n/* harmony export */ transportSymbol: () => (/* binding */ transportSymbol)\n/* harmony export */ });\nconst transportSymbol = Symbol.for('@libp2p/transport');\nfunction isTransport(other) {\n return other != null && Boolean(other[transportSymbol]);\n}\n/**\n * Enum Transport Manager Fault Tolerance values\n */\nvar FaultTolerance;\n(function (FaultTolerance) {\n /**\n * should be used for failing in any listen circumstance\n */\n FaultTolerance[FaultTolerance[\"FATAL_ALL\"] = 0] = \"FATAL_ALL\";\n /**\n * should be used for not failing when not listening\n */\n FaultTolerance[FaultTolerance[\"NO_FATAL\"] = 1] = \"NO_FATAL\";\n})(FaultTolerance || (FaultTolerance = {}));\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface/dist/src/transport/index.js?"); /***/ }), @@ -2870,18 +3207,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ disable: () => (/* binding */ disable),\n/* harmony export */ enable: () => (/* binding */ enable),\n/* harmony export */ enabled: () => (/* binding */ enabled),\n/* harmony export */ logger: () => (/* binding */ logger)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/src/bases/base64.js\");\n\n\n\n\n// Add a formatter for converting to a base58 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.b = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__.base58btc.baseEncode(v);\n};\n// Add a formatter for converting to a base32 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.t = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_2__.base32.baseEncode(v);\n};\n// Add a formatter for converting to a base64 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.m = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__.base64.baseEncode(v);\n};\n// Add a formatter for stringifying peer ids\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.p = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying CIDs\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.c = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying Datastore keys\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.k = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying Multiaddrs\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.a = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\nfunction createDisabledLogger(namespace) {\n const logger = () => { };\n logger.enabled = false;\n logger.color = '';\n logger.diff = 0;\n logger.log = () => { };\n logger.namespace = namespace;\n logger.destroy = () => true;\n logger.extend = () => logger;\n return logger;\n}\nfunction logger(name) {\n // trace logging is a no-op by default\n let trace = createDisabledLogger(`${name}:trace`);\n // look at all the debug names and see if trace logging has explicitly been enabled\n if (debug__WEBPACK_IMPORTED_MODULE_0__.enabled(`${name}:trace`) && debug__WEBPACK_IMPORTED_MODULE_0__.names.map(r => r.toString()).find(n => n.includes(':trace')) != null) {\n trace = debug__WEBPACK_IMPORTED_MODULE_0__(`${name}:trace`);\n }\n return Object.assign(debug__WEBPACK_IMPORTED_MODULE_0__(name), {\n error: debug__WEBPACK_IMPORTED_MODULE_0__(`${name}:error`),\n trace\n });\n}\nfunction disable() {\n debug__WEBPACK_IMPORTED_MODULE_0__.disable();\n}\nfunction enable(namespaces) {\n debug__WEBPACK_IMPORTED_MODULE_0__.enable(namespaces);\n}\nfunction enabled(namespaces) {\n return debug__WEBPACK_IMPORTED_MODULE_0__.enabled(namespaces);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/logger/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultLogger: () => (/* binding */ defaultLogger),\n/* harmony export */ disable: () => (/* binding */ disable),\n/* harmony export */ enable: () => (/* binding */ enable),\n/* harmony export */ enabled: () => (/* binding */ enabled),\n/* harmony export */ logger: () => (/* binding */ logger),\n/* harmony export */ peerLogger: () => (/* binding */ peerLogger),\n/* harmony export */ prefixLogger: () => (/* binding */ prefixLogger)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/logger/dist/src/utils.js\");\n/**\n * @packageDocumentation\n *\n * A logger for libp2p based on the venerable [debug](https://www.npmjs.com/package/debug) module.\n *\n * @example\n *\n * ```TypeScript\n * import { logger } from '@libp2p/logger'\n *\n * const log = logger('libp2p:my:component:name')\n *\n * try {\n * // an operation\n * log('something happened: %s', 'it was ok')\n * } catch (err) {\n * log.error('something bad happened: %o', err)\n * }\n *\n * log('with this peer: %p', {})\n * log('and this base58btc: %b', Uint8Array.from([0, 1, 2, 3]))\n * log('and this base32: %t', Uint8Array.from([4, 5, 6, 7]))\n * ```\n *\n * ```console\n * $ DEBUG=libp2p:* node index.js\n * something happened: it was ok\n * something bad happened: \n * with this peer: 12D3Foo\n * with this base58btc: Qmfoo\n * with this base32: bafyfoo\n * ```\n */\n\n\n\n\n\n// Add a formatter for converting to a base58 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.b = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.baseEncode(v);\n};\n// Add a formatter for converting to a base32 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.t = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.baseEncode(v);\n};\n// Add a formatter for converting to a base64 string\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.m = (v) => {\n return v == null ? 'undefined' : multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__.base64.baseEncode(v);\n};\n// Add a formatter for stringifying peer ids\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.p = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying CIDs\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.c = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying Datastore keys\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.k = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\n// Add a formatter for stringifying Multiaddrs\ndebug__WEBPACK_IMPORTED_MODULE_0__.formatters.a = (v) => {\n return v == null ? 'undefined' : v.toString();\n};\nfunction createDisabledLogger(namespace) {\n const logger = () => { };\n logger.enabled = false;\n logger.color = '';\n logger.diff = 0;\n logger.log = () => { };\n logger.namespace = namespace;\n logger.destroy = () => true;\n logger.extend = () => logger;\n return logger;\n}\n/**\n * Create a component logger that will prefix any log messages with a truncated\n * peer id.\n *\n * @example\n *\n * ```TypeScript\n * import { peerLogger } from '@libp2p/logger'\n * import { peerIdFromString } from '@libp2p/peer-id'\n *\n * const peerId = peerIdFromString('12D3FooBar')\n * const logger = peerLogger(peerId)\n *\n * const log = logger.forComponent('my-component')\n * log.info('hello world')\n * // logs \"12…oBar:my-component hello world\"\n * ```\n */\nfunction peerLogger(peerId, options = {}) {\n return prefixLogger((0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.truncatePeerId)(peerId, options));\n}\n/**\n * Create a component logger that will prefix any log messages with the passed\n * string.\n *\n * @example\n *\n * ```TypeScript\n * import { prefixLogger } from '@libp2p/logger'\n *\n * const logger = prefixLogger('my-node')\n *\n * const log = logger.forComponent('my-component')\n * log.info('hello world')\n * // logs \"my-node:my-component hello world\"\n * ```\n */\nfunction prefixLogger(prefix) {\n return {\n forComponent(name) {\n return logger(`${prefix}:${name}`);\n }\n };\n}\n/**\n * Create a component logger\n *\n * @example\n *\n * ```TypeScript\n * import { defaultLogger } from '@libp2p/logger'\n * import { peerIdFromString } from '@libp2p/peer-id'\n *\n * const logger = defaultLogger()\n *\n * const log = logger.forComponent('my-component')\n * log.info('hello world')\n * // logs \"my-component hello world\"\n * ```\n */\nfunction defaultLogger() {\n return {\n forComponent(name) {\n return logger(name);\n }\n };\n}\n/**\n * Creates a logger for the passed component name.\n *\n * @example\n *\n * ```TypeScript\n * import { logger } from '@libp2p/logger'\n *\n * const log = logger('my-component')\n * log.info('hello world')\n * // logs \"my-component hello world\"\n * ```\n */\nfunction logger(name) {\n // trace logging is a no-op by default\n let trace = createDisabledLogger(`${name}:trace`);\n // look at all the debug names and see if trace logging has explicitly been enabled\n if (debug__WEBPACK_IMPORTED_MODULE_0__.enabled(`${name}:trace`) && debug__WEBPACK_IMPORTED_MODULE_0__.names.map(r => r.toString()).find(n => n.includes(':trace')) != null) {\n trace = debug__WEBPACK_IMPORTED_MODULE_0__(`${name}:trace`);\n }\n return Object.assign(debug__WEBPACK_IMPORTED_MODULE_0__(name), {\n error: debug__WEBPACK_IMPORTED_MODULE_0__(`${name}:error`),\n trace\n });\n}\nfunction disable() {\n debug__WEBPACK_IMPORTED_MODULE_0__.disable();\n}\nfunction enable(namespaces) {\n debug__WEBPACK_IMPORTED_MODULE_0__.enable(namespaces);\n}\nfunction enabled(namespaces) {\n return debug__WEBPACK_IMPORTED_MODULE_0__.enabled(namespaces);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/logger/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js ***! - \*********************************************************************/ +/***/ "./node_modules/@libp2p/logger/dist/src/utils.js": +/*!*******************************************************!*\ + !*** ./node_modules/@libp2p/logger/dist/src/utils.js ***! + \*******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\nfunction allocUnsafe(size) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc-unsafe-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ truncatePeerId: () => (/* binding */ truncatePeerId)\n/* harmony export */ });\nfunction truncatePeerId(peerId, options = {}) {\n const prefixLength = options.prefixLength ?? 2;\n const suffixLength = options.suffixLength ?? 4;\n const peerIdString = peerId.toString();\n return `${peerIdString.substring(0, prefixLength)}…${peerIdString.substring(peerIdString.length, peerIdString.length - suffixLength)}`;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/logger/dist/src/utils.js?"); /***/ }), @@ -2903,7 +3240,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encode: () => (/* binding */ encode)\n/* harmony export */ });\n/* harmony import */ var it_batched_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-batched-bytes */ \"./node_modules/it-batched-bytes/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var _alloc_unsafe_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./alloc-unsafe.js */ \"./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n\n\n\n\n\nconst POOL_SIZE = 10 * 1024;\nclass Encoder {\n _pool;\n _poolOffset;\n constructor() {\n this._pool = (0,_alloc_unsafe_js__WEBPACK_IMPORTED_MODULE_3__.allocUnsafe)(POOL_SIZE);\n this._poolOffset = 0;\n }\n /**\n * Encodes the given message and adds it to the passed list\n */\n write(msg, list) {\n const pool = this._pool;\n let offset = this._poolOffset;\n varint__WEBPACK_IMPORTED_MODULE_2__.encode(msg.id << 3 | msg.type, pool, offset);\n offset += varint__WEBPACK_IMPORTED_MODULE_2__.encode.bytes ?? 0;\n if ((msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.NEW_STREAM || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {\n varint__WEBPACK_IMPORTED_MODULE_2__.encode(msg.data.length, pool, offset);\n }\n else {\n varint__WEBPACK_IMPORTED_MODULE_2__.encode(0, pool, offset);\n }\n offset += varint__WEBPACK_IMPORTED_MODULE_2__.encode.bytes ?? 0;\n const header = pool.subarray(this._poolOffset, offset);\n if (POOL_SIZE - offset < 100) {\n this._pool = (0,_alloc_unsafe_js__WEBPACK_IMPORTED_MODULE_3__.allocUnsafe)(POOL_SIZE);\n this._poolOffset = 0;\n }\n else {\n this._poolOffset = offset;\n }\n list.append(header);\n if ((msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.NEW_STREAM || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {\n list.append(msg.data);\n }\n }\n}\nconst encoder = new Encoder();\n/**\n * Encode and yield one or more messages\n */\nasync function* encode(source, minSendBytes = 0) {\n if (minSendBytes == null || minSendBytes === 0) {\n // just send the messages\n for await (const messages of source) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList();\n for (const msg of messages) {\n encoder.write(msg, list);\n }\n yield list.subarray();\n }\n return;\n }\n // batch messages up for sending\n yield* (0,it_batched_bytes__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source, {\n size: minSendBytes,\n serialize: (obj, list) => {\n for (const m of obj) {\n encoder.write(m, list);\n }\n }\n });\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/encode.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encode: () => (/* binding */ encode)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n\n\n\n\nconst POOL_SIZE = 10 * 1024;\nclass Encoder {\n _pool;\n _poolOffset;\n constructor() {\n this._pool = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(POOL_SIZE);\n this._poolOffset = 0;\n }\n /**\n * Encodes the given message and adds it to the passed list\n */\n write(msg, list) {\n const pool = this._pool;\n let offset = this._poolOffset;\n uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.id << 3 | msg.type, pool, offset);\n offset += uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(msg.id << 3 | msg.type);\n if ((msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.NEW_STREAM || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {\n uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.data.length, pool, offset);\n offset += uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(msg.data.length);\n }\n else {\n uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(0, pool, offset);\n offset += uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(0);\n }\n const header = pool.subarray(this._poolOffset, offset);\n if (POOL_SIZE - offset < 100) {\n this._pool = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(POOL_SIZE);\n this._poolOffset = 0;\n }\n else {\n this._poolOffset = offset;\n }\n list.append(header);\n if ((msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.NEW_STREAM || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {\n list.append(msg.data);\n }\n }\n}\nconst encoder = new Encoder();\n/**\n * Encode and yield one or more messages\n */\nasync function* encode(source) {\n for await (const message of source) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList();\n encoder.write(message, list);\n yield list;\n }\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/encode.js?"); /***/ }), @@ -2914,7 +3251,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ mplex: () => (/* binding */ mplex)\n/* harmony export */ });\n/* harmony import */ var _mplex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mplex.js */ \"./node_modules/@libp2p/mplex/dist/src/mplex.js\");\n\nclass Mplex {\n protocol = '/mplex/6.7.0';\n _init;\n constructor(init = {}) {\n this._init = init;\n }\n createStreamMuxer(init = {}) {\n return new _mplex_js__WEBPACK_IMPORTED_MODULE_0__.MplexStreamMuxer({\n ...init,\n ...this._init\n });\n }\n}\nfunction mplex(init = {}) {\n return () => new Mplex(init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ mplex: () => (/* binding */ mplex)\n/* harmony export */ });\n/* harmony import */ var _mplex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mplex.js */ \"./node_modules/@libp2p/mplex/dist/src/mplex.js\");\n/**\n * @packageDocumentation\n *\n * This is a [simple stream multiplexer(https://docs.libp2p.io/concepts/multiplex/mplex/) that has been deprecated.\n *\n * Please use [@chainsafe/libp2p-yamux](https://www.npmjs.com/package/@chainsafe/libp2p-yamux) instead.\n *\n * @example\n *\n * ```TypeScript\n * import { mplex } from '@libp2p/mplex'\n * import { pipe } from 'it-pipe'\n *\n * const factory = mplex()\n *\n * const muxer = factory.createStreamMuxer(components, {\n * onStream: stream => { // Receive a duplex stream from the remote\n * // ...receive data from the remote and optionally send data back\n * },\n * onStreamEnd: stream => {\n * // ...handle any tracking you may need of stream closures\n * }\n * })\n *\n * pipe(conn, muxer, conn) // conn is duplex connection to another peer\n *\n * const stream = muxer.newStream() // Create a new duplex stream to the remote\n *\n * // Use the duplex stream to send some data to the remote...\n * pipe([1, 2, 3], stream)\n * ```\n */\n\nclass Mplex {\n protocol = '/mplex/6.7.0';\n _init;\n components;\n constructor(components, init = {}) {\n this.components = components;\n this._init = init;\n }\n createStreamMuxer(init = {}) {\n return new _mplex_js__WEBPACK_IMPORTED_MODULE_0__.MplexStreamMuxer(this.components, {\n ...init,\n ...this._init\n });\n }\n}\nfunction mplex(init = {}) {\n return (components) => new Mplex(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/index.js?"); /***/ }), @@ -2936,7 +3273,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MplexStreamMuxer: () => (/* binding */ MplexStreamMuxer)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/mplex/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/mplex/dist/src/encode.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@libp2p/mplex/dist/src/stream.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:mplex');\nconst MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION = 1024;\nconst MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION = 1024;\nconst MAX_STREAM_BUFFER_SIZE = 1024 * 1024 * 4; // 4MB\nconst DISCONNECT_THRESHOLD = 5;\nfunction printMessage(msg) {\n const output = {\n ...msg,\n type: `${_message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypeNames[msg.type]} (${msg.type})`\n };\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.NEW_STREAM) {\n output.data = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_6__.toString)(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray());\n }\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.MESSAGE_RECEIVER) {\n output.data = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_6__.toString)(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray(), 'base16');\n }\n return output;\n}\nclass MplexStreamMuxer {\n protocol = '/mplex/6.7.0';\n sink;\n source;\n _streamId;\n _streams;\n _init;\n _source;\n closeController;\n rateLimiter;\n constructor(init) {\n init = init ?? {};\n this._streamId = 0;\n this._streams = {\n /**\n * Stream to ids map\n */\n initiators: new Map(),\n /**\n * Stream to ids map\n */\n receivers: new Map()\n };\n this._init = init;\n /**\n * An iterable sink\n */\n this.sink = this._createSink();\n /**\n * An iterable source\n */\n const source = this._createSource();\n this._source = source;\n this.source = source;\n /**\n * Close controller\n */\n this.closeController = new AbortController();\n this.rateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_5__.RateLimiterMemory({\n points: init.disconnectThreshold ?? DISCONNECT_THRESHOLD,\n duration: 1\n });\n }\n /**\n * Returns a Map of streams and their ids\n */\n get streams() {\n // Inbound and Outbound streams may have the same ids, so we need to make those unique\n const streams = [];\n for (const stream of this._streams.initiators.values()) {\n streams.push(stream);\n }\n for (const stream of this._streams.receivers.values()) {\n streams.push(stream);\n }\n return streams;\n }\n /**\n * Initiate a new stream with the given name. If no name is\n * provided, the id of the stream will be used.\n */\n newStream(name) {\n if (this.closeController.signal.aborted) {\n throw new Error('Muxer already closed');\n }\n const id = this._streamId++;\n name = name == null ? id.toString() : name.toString();\n const registry = this._streams.initiators;\n return this._newStream({ id, name, type: 'initiator', registry });\n }\n /**\n * Close or abort all tracked streams and stop the muxer\n */\n close(err) {\n if (this.closeController.signal.aborted)\n return;\n if (err != null) {\n this.streams.forEach(s => { s.abort(err); });\n }\n else {\n this.streams.forEach(s => { s.close(); });\n }\n this.closeController.abort();\n }\n /**\n * Called whenever an inbound stream is created\n */\n _newReceiverStream(options) {\n const { id, name } = options;\n const registry = this._streams.receivers;\n return this._newStream({ id, name, type: 'receiver', registry });\n }\n _newStream(options) {\n const { id, name, type, registry } = options;\n log('new %s stream %s', type, id);\n if (type === 'initiator' && this._streams.initiators.size === (this._init.maxOutboundStreams ?? MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Too many outbound streams open', 'ERR_TOO_MANY_OUTBOUND_STREAMS');\n }\n if (registry.has(id)) {\n throw new Error(`${type} stream ${id} already exists!`);\n }\n const send = (msg) => {\n if (log.enabled) {\n log.trace('%s stream %s send', type, id, printMessage(msg));\n }\n this._source.push(msg);\n };\n const onEnd = () => {\n log('%s stream with id %s and protocol %s ended', type, id, stream.stat.protocol);\n registry.delete(id);\n if (this._init.onStreamEnd != null) {\n this._init.onStreamEnd(stream);\n }\n };\n const stream = (0,_stream_js__WEBPACK_IMPORTED_MODULE_10__.createStream)({ id, name, send, type, onEnd, maxMsgSize: this._init.maxMsgSize });\n registry.set(id, stream);\n return stream;\n }\n /**\n * Creates a sink with an abortable source. Incoming messages will\n * also have their size restricted. All messages will be varint decoded.\n */\n _createSink() {\n const sink = async (source) => {\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_3__.anySignal)([this.closeController.signal, this._init.signal]);\n try {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_2__.abortableSource)(source, signal);\n const decoder = new _decode_js__WEBPACK_IMPORTED_MODULE_7__.Decoder(this._init.maxMsgSize, this._init.maxUnprocessedMessageQueueSize);\n for await (const chunk of source) {\n for (const msg of decoder.write(chunk)) {\n await this._handleIncoming(msg);\n }\n }\n this._source.end();\n }\n catch (err) {\n log('error in sink', err);\n this._source.end(err); // End the source with an error\n }\n finally {\n signal.clear();\n }\n };\n return sink;\n }\n /**\n * Creates a source that restricts outgoing message sizes\n * and varint encodes them\n */\n _createSource() {\n const onEnd = (err) => {\n this.close(err);\n };\n const source = (0,it_pushable__WEBPACK_IMPORTED_MODULE_4__.pushableV)({\n objectMode: true,\n onEnd\n });\n return Object.assign((0,_encode_js__WEBPACK_IMPORTED_MODULE_8__.encode)(source, this._init.minSendBytes), {\n push: source.push,\n end: source.end,\n return: source.return\n });\n }\n async _handleIncoming(message) {\n const { id, type } = message;\n if (log.enabled) {\n log.trace('incoming message', printMessage(message));\n }\n // Create a new stream?\n if (message.type === _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.NEW_STREAM) {\n if (this._streams.receivers.size === (this._init.maxInboundStreams ?? MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)) {\n log('too many inbound streams open');\n // not going to allow this stream, send the reset message manually\n // instead of setting it up just to tear it down\n this._source.push({\n id,\n type: _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.RESET_RECEIVER\n });\n // if we've hit our stream limit, and the remote keeps trying to open\n // more new streams, if they are doing this very quickly maybe they\n // are attacking us and we should close the connection\n try {\n await this.rateLimiter.consume('new-stream', 1);\n }\n catch {\n log('rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection');\n // since there's no backpressure in mplex, the only thing we can really do to protect ourselves is close the connection\n this._source.end(new Error('Too many open streams'));\n return;\n }\n return;\n }\n const stream = this._newReceiverStream({ id, name: (0,uint8arrays__WEBPACK_IMPORTED_MODULE_6__.toString)(message.data instanceof Uint8Array ? message.data : message.data.subarray()) });\n if (this._init.onIncomingStream != null) {\n this._init.onIncomingStream(stream);\n }\n return;\n }\n const list = (type & 1) === 1 ? this._streams.initiators : this._streams.receivers;\n const stream = list.get(id);\n if (stream == null) {\n log('missing stream %s for message type %s', id, _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypeNames[type]);\n return;\n }\n const maxBufferSize = this._init.maxStreamBufferSize ?? MAX_STREAM_BUFFER_SIZE;\n switch (type) {\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.MESSAGE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.MESSAGE_RECEIVER:\n if (stream.sourceReadableLength() > maxBufferSize) {\n // Stream buffer has got too large, reset the stream\n this._source.push({\n id: message.id,\n type: type === _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.MESSAGE_INITIATOR ? _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.RESET_RECEIVER : _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.RESET_INITIATOR\n });\n // Inform the stream consumer they are not fast enough\n const error = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers', 'ERR_STREAM_INPUT_BUFFER_FULL');\n stream.abort(error);\n return;\n }\n // We got data from the remote, push it into our local stream\n stream.sourcePush(message.data);\n break;\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.CLOSE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.CLOSE_RECEIVER:\n // We should expect no more data from the remote, stop reading\n stream.closeRead();\n break;\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.RESET_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_9__.MessageTypes.RESET_RECEIVER:\n // Stop reading and writing to the stream immediately\n stream.reset();\n break;\n default:\n log('unknown message type %s', type);\n }\n }\n}\n//# sourceMappingURL=mplex.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/mplex.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MplexStreamMuxer: () => (/* binding */ MplexStreamMuxer)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_utils_close_source__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/utils/close-source */ \"./node_modules/@libp2p/utils/dist/src/close-source.js\");\n/* harmony import */ var _libp2p_utils_rate_limiter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/utils/rate-limiter */ \"./node_modules/@libp2p/utils/dist/src/rate-limiter.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/mplex/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/mplex/dist/src/encode.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@libp2p/mplex/dist/src/stream.js\");\n\n\n\n\n\n\n\n\n\n\nconst MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION = 1024;\nconst MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION = 1024;\nconst MAX_STREAM_BUFFER_SIZE = 1024 * 1024 * 4; // 4MB\nconst DISCONNECT_THRESHOLD = 5;\nconst CLOSE_TIMEOUT = 500;\nfunction printMessage(msg) {\n const output = {\n ...msg,\n type: `${_message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypeNames[msg.type]} (${msg.type})`\n };\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.NEW_STREAM) {\n output.data = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_2__.toString)(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray());\n }\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_RECEIVER) {\n output.data = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_2__.toString)(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray(), 'base16');\n }\n return output;\n}\nclass MplexStreamMuxer {\n protocol = '/mplex/6.7.0';\n sink;\n source;\n log;\n _streamId;\n _streams;\n _init;\n _source;\n closeController;\n rateLimiter;\n closeTimeout;\n logger;\n constructor(components, init) {\n init = init ?? {};\n this.log = components.logger.forComponent('libp2p:mplex');\n this.logger = components.logger;\n this._streamId = 0;\n this._streams = {\n /**\n * Stream to ids map\n */\n initiators: new Map(),\n /**\n * Stream to ids map\n */\n receivers: new Map()\n };\n this._init = init;\n this.closeTimeout = init.closeTimeout ?? CLOSE_TIMEOUT;\n /**\n * An iterable sink\n */\n this.sink = this._createSink();\n /**\n * An iterable source\n */\n this._source = (0,it_pushable__WEBPACK_IMPORTED_MODULE_1__.pushable)({\n objectMode: true,\n onEnd: () => {\n // the source has ended, we can't write any more messages to gracefully\n // close streams so all we can do is destroy them\n for (const stream of this._streams.initiators.values()) {\n stream.destroy();\n }\n for (const stream of this._streams.receivers.values()) {\n stream.destroy();\n }\n }\n });\n this.source = (0,it_pipe__WEBPACK_IMPORTED_MODULE_0__.pipe)(this._source, source => (0,_encode_js__WEBPACK_IMPORTED_MODULE_4__.encode)(source));\n /**\n * Close controller\n */\n this.closeController = new AbortController();\n this.rateLimiter = new _libp2p_utils_rate_limiter__WEBPACK_IMPORTED_MODULE_5__.RateLimiter({\n points: init.disconnectThreshold ?? DISCONNECT_THRESHOLD,\n duration: 1\n });\n }\n /**\n * Returns a Map of streams and their ids\n */\n get streams() {\n // Inbound and Outbound streams may have the same ids, so we need to make those unique\n const streams = [];\n for (const stream of this._streams.initiators.values()) {\n streams.push(stream);\n }\n for (const stream of this._streams.receivers.values()) {\n streams.push(stream);\n }\n return streams;\n }\n /**\n * Initiate a new stream with the given name. If no name is\n * provided, the id of the stream will be used.\n */\n newStream(name) {\n if (this.closeController.signal.aborted) {\n throw new Error('Muxer already closed');\n }\n const id = this._streamId++;\n name = name == null ? id.toString() : name.toString();\n const registry = this._streams.initiators;\n return this._newStream({ id, name, type: 'initiator', registry });\n }\n /**\n * Close or abort all tracked streams and stop the muxer\n */\n async close(options) {\n if (this.closeController.signal.aborted) {\n return;\n }\n const signal = options?.signal ?? AbortSignal.timeout(this.closeTimeout);\n try {\n // try to gracefully close all streams\n await Promise.all(this.streams.map(async (s) => s.close({\n signal\n })));\n this._source.end();\n // try to gracefully close the muxer\n await this._source.onEmpty({\n signal\n });\n this.closeController.abort();\n }\n catch (err) {\n this.abort(err);\n }\n }\n abort(err) {\n if (this.closeController.signal.aborted) {\n return;\n }\n this.streams.forEach(s => { s.abort(err); });\n this.closeController.abort(err);\n }\n /**\n * Called whenever an inbound stream is created\n */\n _newReceiverStream(options) {\n const { id, name } = options;\n const registry = this._streams.receivers;\n return this._newStream({ id, name, type: 'receiver', registry });\n }\n _newStream(options) {\n const { id, name, type, registry } = options;\n this.log('new %s stream %s', type, id);\n if (type === 'initiator' && this._streams.initiators.size === (this._init.maxOutboundStreams ?? MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Too many outbound streams open', 'ERR_TOO_MANY_OUTBOUND_STREAMS');\n }\n if (registry.has(id)) {\n throw new Error(`${type} stream ${id} already exists!`);\n }\n const send = async (msg) => {\n if (this.log.enabled) {\n this.log.trace('%s stream %s send', type, id, printMessage(msg));\n }\n this._source.push(msg);\n };\n const onEnd = () => {\n this.log('%s stream with id %s and protocol %s ended', type, id, stream.protocol);\n registry.delete(id);\n if (this._init.onStreamEnd != null) {\n this._init.onStreamEnd(stream);\n }\n };\n const stream = (0,_stream_js__WEBPACK_IMPORTED_MODULE_7__.createStream)({ id, name, send, type, onEnd, maxMsgSize: this._init.maxMsgSize, logger: this.logger });\n registry.set(id, stream);\n return stream;\n }\n /**\n * Creates a sink with an abortable source. Incoming messages will\n * also have their size restricted. All messages will be varint decoded.\n */\n _createSink() {\n const sink = async (source) => {\n const abortListener = () => {\n (0,_libp2p_utils_close_source__WEBPACK_IMPORTED_MODULE_8__.closeSource)(source, this.log);\n };\n this.closeController.signal.addEventListener('abort', abortListener);\n try {\n const decoder = new _decode_js__WEBPACK_IMPORTED_MODULE_9__.Decoder(this._init.maxMsgSize, this._init.maxUnprocessedMessageQueueSize);\n for await (const chunk of source) {\n for (const msg of decoder.write(chunk)) {\n await this._handleIncoming(msg);\n }\n }\n this._source.end();\n }\n catch (err) {\n this.log('error in sink', err);\n this._source.end(err); // End the source with an error\n }\n finally {\n this.closeController.signal.removeEventListener('abort', abortListener);\n }\n };\n return sink;\n }\n async _handleIncoming(message) {\n const { id, type } = message;\n if (this.log.enabled) {\n this.log.trace('incoming message', printMessage(message));\n }\n // Create a new stream?\n if (message.type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.NEW_STREAM) {\n if (this._streams.receivers.size === (this._init.maxInboundStreams ?? MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)) {\n this.log('too many inbound streams open');\n // not going to allow this stream, send the reset message manually\n // instead of setting it up just to tear it down\n this._source.push({\n id,\n type: _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.RESET_RECEIVER\n });\n // if we've hit our stream limit, and the remote keeps trying to open\n // more new streams, if they are doing this very quickly maybe they\n // are attacking us and we should close the connection\n try {\n await this.rateLimiter.consume('new-stream', 1);\n }\n catch {\n this.log('rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection');\n // since there's no backpressure in mplex, the only thing we can really do to protect ourselves is close the connection\n this.abort(new Error('Too many open streams'));\n return;\n }\n return;\n }\n const stream = this._newReceiverStream({ id, name: (0,uint8arrays__WEBPACK_IMPORTED_MODULE_2__.toString)(message.data instanceof Uint8Array ? message.data : message.data.subarray()) });\n if (this._init.onIncomingStream != null) {\n this._init.onIncomingStream(stream);\n }\n return;\n }\n const list = (type & 1) === 1 ? this._streams.initiators : this._streams.receivers;\n const stream = list.get(id);\n if (stream == null) {\n this.log('missing stream %s for message type %s', id, _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypeNames[type]);\n // if the remote keeps sending us messages for streams that have been\n // closed or were never opened they may be attacking us so if they do\n // this very quickly all we can do is close the connection\n try {\n await this.rateLimiter.consume('missing-stream', 1);\n }\n catch {\n this.log('rate limit hit when receiving messages for streams that do not exist - closing remote connection');\n // since there's no backpressure in mplex, the only thing we can really do to protect ourselves is close the connection\n this.abort(new Error('Too many messages for missing streams'));\n return;\n }\n return;\n }\n const maxBufferSize = this._init.maxStreamBufferSize ?? MAX_STREAM_BUFFER_SIZE;\n try {\n switch (type) {\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_RECEIVER:\n if (stream.sourceReadableLength() > maxBufferSize) {\n // Stream buffer has got too large, reset the stream\n this._source.push({\n id: message.id,\n type: type === _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.MESSAGE_INITIATOR ? _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.RESET_RECEIVER : _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.RESET_INITIATOR\n });\n // Inform the stream consumer they are not fast enough\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers', 'ERR_STREAM_INPUT_BUFFER_FULL');\n }\n // We got data from the remote, push it into our local stream\n stream.sourcePush(message.data);\n break;\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.CLOSE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.CLOSE_RECEIVER:\n // The remote has stopped writing, so we can stop reading\n stream.remoteCloseWrite();\n break;\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.RESET_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_3__.MessageTypes.RESET_RECEIVER:\n // The remote has errored, stop reading and writing to the stream immediately\n stream.reset();\n break;\n default:\n this.log('unknown message type %s', type);\n }\n }\n catch (err) {\n this.log.error('error while processing message', err);\n stream.abort(err);\n }\n }\n}\n//# sourceMappingURL=mplex.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/mplex.js?"); /***/ }), @@ -2947,29 +3284,117 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createStream: () => (/* binding */ createStream)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_stream_muxer_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-stream-muxer/stream */ \"./node_modules/@libp2p/interface-stream-muxer/dist/src/stream.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/mplex/dist/src/decode.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n\n\n\n\n\nclass MplexStream extends _libp2p_interface_stream_muxer_stream__WEBPACK_IMPORTED_MODULE_0__.AbstractStream {\n name;\n streamId;\n send;\n types;\n constructor(init) {\n super(init);\n this.types = init.direction === 'outbound' ? _message_types_js__WEBPACK_IMPORTED_MODULE_4__.InitiatorMessageTypes : _message_types_js__WEBPACK_IMPORTED_MODULE_4__.ReceiverMessageTypes;\n this.send = init.send;\n this.name = init.name;\n this.streamId = init.streamId;\n }\n sendNewStream() {\n this.send({ id: this.streamId, type: _message_types_js__WEBPACK_IMPORTED_MODULE_4__.InitiatorMessageTypes.NEW_STREAM, data: new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(this.name)) });\n }\n sendData(data) {\n this.send({ id: this.streamId, type: this.types.MESSAGE, data });\n }\n sendReset() {\n this.send({ id: this.streamId, type: this.types.RESET });\n }\n sendCloseWrite() {\n this.send({ id: this.streamId, type: this.types.CLOSE });\n }\n sendCloseRead() {\n // mplex does not support close read, only close write\n }\n}\nfunction createStream(options) {\n const { id, name, send, onEnd, type = 'initiator', maxMsgSize = _decode_js__WEBPACK_IMPORTED_MODULE_3__.MAX_MSG_SIZE } = options;\n return new MplexStream({\n id: type === 'initiator' ? (`i${id}`) : `r${id}`,\n streamId: id,\n name: `${name == null ? id : name}`,\n direction: type === 'initiator' ? 'outbound' : 'inbound',\n maxDataSize: maxMsgSize,\n onEnd,\n send\n });\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/stream.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MplexStream: () => (/* binding */ MplexStream),\n/* harmony export */ createStream: () => (/* binding */ createStream)\n/* harmony export */ });\n/* harmony import */ var _libp2p_utils_abstract_stream__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/utils/abstract-stream */ \"./node_modules/@libp2p/utils/dist/src/abstract-stream.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/mplex/dist/src/decode.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n\n\n\n\n\nclass MplexStream extends _libp2p_utils_abstract_stream__WEBPACK_IMPORTED_MODULE_2__.AbstractStream {\n name;\n streamId;\n send;\n types;\n maxDataSize;\n constructor(init) {\n super(init);\n this.types = init.direction === 'outbound' ? _message_types_js__WEBPACK_IMPORTED_MODULE_3__.InitiatorMessageTypes : _message_types_js__WEBPACK_IMPORTED_MODULE_3__.ReceiverMessageTypes;\n this.send = init.send;\n this.name = init.name;\n this.streamId = init.streamId;\n this.maxDataSize = init.maxDataSize;\n }\n async sendNewStream() {\n await this.send({ id: this.streamId, type: _message_types_js__WEBPACK_IMPORTED_MODULE_3__.InitiatorMessageTypes.NEW_STREAM, data: new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(this.name)) });\n }\n async sendData(data) {\n data = data.sublist();\n while (data.byteLength > 0) {\n const toSend = Math.min(data.byteLength, this.maxDataSize);\n await this.send({\n id: this.streamId,\n type: this.types.MESSAGE,\n data: data.sublist(0, toSend)\n });\n data.consume(toSend);\n }\n }\n async sendReset() {\n await this.send({ id: this.streamId, type: this.types.RESET });\n }\n async sendCloseWrite() {\n await this.send({ id: this.streamId, type: this.types.CLOSE });\n }\n async sendCloseRead() {\n // mplex does not support close read, only close write\n }\n}\nfunction createStream(options) {\n const { id, name, send, onEnd, type = 'initiator', maxMsgSize = _decode_js__WEBPACK_IMPORTED_MODULE_4__.MAX_MSG_SIZE } = options;\n return new MplexStream({\n id: type === 'initiator' ? (`i${id}`) : `r${id}`,\n streamId: id,\n name: `${name == null ? id : name}`,\n direction: type === 'initiator' ? 'outbound' : 'inbound',\n maxDataSize: maxMsgSize,\n onEnd,\n send,\n log: options.logger.forComponent(`libp2p:mplex:stream:${type}:${id}`)\n });\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/stream.js?"); /***/ }), -/***/ "./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/abort-error.js": +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/compare.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/compare.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compare: () => (/* binding */ compare)\n/* harmony export */ });\n/**\n * Can be used with Array.sort to sort and array with Uint8Array entries\n */\nfunction compare(a, b) {\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] < b[i]) {\n return -1;\n }\n if (a[i] > b[i]) {\n return 1;\n }\n }\n if (a.byteLength > b.byteLength) {\n return 1;\n }\n if (a.byteLength < b.byteLength) {\n return -1;\n }\n return 0;\n}\n//# sourceMappingURL=compare.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/compare.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/concat.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/concat.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ concat: () => (/* binding */ concat)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns a new Uint8Array created by concatenating the passed Uint8Arrays\n */\nfunction concat(arrays, length) {\n if (length == null) {\n length = arrays.reduce((acc, curr) => acc + curr.length, 0);\n }\n const output = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(length);\n let offset = 0;\n for (const arr of arrays) {\n output.set(arr, offset);\n offset += arr.length;\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(output);\n}\n//# sourceMappingURL=concat.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/concat.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/equals.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/equals.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/from-string.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/from-string.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/index.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compare: () => (/* reexport safe */ _compare__WEBPACK_IMPORTED_MODULE_2__.compare),\n/* harmony export */ concat: () => (/* reexport safe */ _concat__WEBPACK_IMPORTED_MODULE_3__.concat),\n/* harmony export */ equals: () => (/* reexport safe */ _equals_js__WEBPACK_IMPORTED_MODULE_0__.equals),\n/* harmony export */ fromString: () => (/* reexport safe */ _from_string__WEBPACK_IMPORTED_MODULE_4__.fromString),\n/* harmony export */ toString: () => (/* reexport safe */ _to_string__WEBPACK_IMPORTED_MODULE_5__.toString),\n/* harmony export */ xor: () => (/* reexport safe */ _xor_js__WEBPACK_IMPORTED_MODULE_1__.xor)\n/* harmony export */ });\n/* harmony import */ var _equals_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./equals.js */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _xor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./xor.js */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/xor.js\");\n/* harmony import */ var _compare__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! #compare */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/compare.js\");\n/* harmony import */ var _concat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #concat */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #from-string */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! #to-string */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/to-string.js\");\n/**\n * @packageDocumentation\n *\n * `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.\n *\n * This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.\n *\n * Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.\n *\n * ## alloc(size)\n *\n * Create a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n *\n * ### Example\n *\n * ```js\n * import { alloc } from 'uint8arrays/alloc'\n *\n * const buf = alloc(100)\n * ```\n *\n * ## allocUnsafe(size)\n *\n * Create a new `Uint8Array`. When running under Node.js, `Buffer` will be used in preference to `Uint8Array`.\n *\n * On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.\n *\n * ### Example\n *\n * ```js\n * import { allocUnsafe } from 'uint8arrays/alloc'\n *\n * const buf = allocUnsafe(100)\n * ```\n *\n * ## compare(a, b)\n *\n * Compare two `Uint8Arrays`\n *\n * ### Example\n *\n * ```js\n * import { compare } from 'uint8arrays/compare'\n *\n * const arrays = [\n * Uint8Array.from([3, 4, 5]),\n * Uint8Array.from([0, 1, 2])\n * ]\n *\n * const sorted = arrays.sort(compare)\n *\n * console.info(sorted)\n * // [\n * // Uint8Array[0, 1, 2]\n * // Uint8Array[3, 4, 5]\n * // ]\n * ```\n *\n * ## concat(arrays, \\[length])\n *\n * Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.\n *\n * If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.\n *\n * ### Example\n *\n * ```js\n * import { concat } from 'uint8arrays/concat'\n *\n * const arrays = [\n * Uint8Array.from([0, 1, 2]),\n * Uint8Array.from([3, 4, 5])\n * ]\n *\n * const all = concat(arrays, 6)\n *\n * console.info(all)\n * // Uint8Array[0, 1, 2, 3, 4, 5]\n * ```\n *\n * ## equals(a, b)\n *\n * Returns true if the two arrays are the same array or if they have the same length and contents.\n *\n * ### Example\n *\n * ```js\n * import { equals } from 'uint8arrays/equals'\n *\n * const a = Uint8Array.from([0, 1, 2])\n * const b = Uint8Array.from([3, 4, 5])\n * const c = Uint8Array.from([0, 1, 2])\n *\n * console.info(equals(a, b)) // false\n * console.info(equals(a, c)) // true\n * console.info(equals(a, a)) // true\n * ```\n *\n * ## fromString(string, encoding = 'utf8')\n *\n * Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.\n *\n * Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n *\n * ### Example\n *\n * ```js\n * import { fromString } from 'uint8arrays/from-string'\n *\n * console.info(fromString('hello world')) // Uint8Array[104, 101 ...\n * console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...\n * console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...\n * console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...\n * ```\n *\n * ## toString(array, encoding = 'utf8')\n *\n * Returns a string created from the passed `Uint8Array` in the passed encoding.\n *\n * Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).\n *\n * ### Example\n *\n * ```js\n * import { toString } from 'uint8arrays/to-string'\n *\n * console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'\n * console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'\n * console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'\n * console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'\n * ```\n *\n * ## xor(a, b)\n *\n * Returns a `Uint8Array` containing `a` and `b` xored together.\n *\n * ### Example\n *\n * ```js\n * import { xor } from 'uint8arrays/xor'\n *\n * console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]\n * ```\n */\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/to-string.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/to-string.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/as-uint8array.js": /*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/abort-error.js ***! + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/as-uint8array.js ***! \********************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/abort-error.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ asUint8Array: () => (/* binding */ asUint8Array)\n/* harmony export */ });\n/**\n * To guarantee Uint8Array semantics, convert nodejs Buffers\n * into vanilla Uint8Arrays\n */\nfunction asUint8Array(buf) {\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); /***/ }), -/***/ "./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/index.js ***! - \**************************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/bases.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/bases.js ***! + \************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/abortable-iterator/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/xor.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/xor.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ xor: () => (/* binding */ xor)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns the xor distance between two arrays\n */\nfunction xor(a, b) {\n if (a.length !== b.length) {\n throw new Error('Inputs should have the same length');\n }\n const result = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(a.length);\n for (let i = 0; i < a.length; i++) {\n result[i] = a[i] ^ b[i];\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(result);\n}\n//# sourceMappingURL=xor.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/node_modules/uint8arrays/dist/src/xor.js?"); /***/ }), @@ -2991,18 +3416,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ handle: () => (/* binding */ handle)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var it_handshake__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:mss:handle');\nasync function handle(stream, protocols, options) {\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n const { writer, reader, rest, stream: shakeStream } = (0,it_handshake__WEBPACK_IMPORTED_MODULE_1__.handshake)(stream);\n while (true) {\n const protocol = await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.readString(reader, options);\n log.trace('read \"%s\"', protocol);\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID) {\n log.trace('respond with \"%s\" for \"%s\"', _constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID, protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(_constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID), options);\n continue;\n }\n if (protocols.includes(protocol)) {\n _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(protocol), options);\n log.trace('respond with \"%s\" for \"%s\"', protocol, protocol);\n rest();\n return { stream: shakeStream, protocol };\n }\n if (protocol === 'ls') {\n // \\n\\n\\n\n _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(writer, new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList(...protocols.map(p => _multistream_js__WEBPACK_IMPORTED_MODULE_5__.encode((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(p)))), options);\n // multistream.writeAll(writer, protocols.map(p => uint8ArrayFromString(p)))\n log.trace('respond with \"%s\" for %s', protocols, protocol);\n continue;\n }\n _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('na'), options);\n log('respond with \"na\" for \"%s\"', protocol);\n }\n}\n//# sourceMappingURL=handle.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/handle.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/multistream-select/dist/src/index.js": -/*!*******************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/dist/src/index.js ***! - \*******************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PROTOCOL_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.PROTOCOL_ID),\n/* harmony export */ handle: () => (/* reexport safe */ _handle_js__WEBPACK_IMPORTED_MODULE_2__.handle),\n/* harmony export */ lazySelect: () => (/* reexport safe */ _select_js__WEBPACK_IMPORTED_MODULE_1__.lazySelect),\n/* harmony export */ select: () => (/* reexport safe */ _select_js__WEBPACK_IMPORTED_MODULE_1__.select)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _select_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./select.js */ \"./node_modules/@libp2p/multistream-select/dist/src/select.js\");\n/* harmony import */ var _handle_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./handle.js */ \"./node_modules/@libp2p/multistream-select/dist/src/handle.js\");\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ handle: () => (/* binding */ handle)\n/* harmony export */ });\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-length-prefixed-stream */ \"./node_modules/it-length-prefixed-stream/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n\n\n\n\n\n\n/**\n * Handle multistream protocol selections for the given list of protocols.\n *\n * Note that after a protocol is handled `listener` can no longer be used.\n *\n * @param stream - A duplex iterable stream to listen on\n * @param protocols - A list of protocols (or single protocol) that this listener is able to speak.\n * @param options - an options object containing an AbortSignal and an optional boolean `writeBytes` - if this is true, `Uint8Array`s will be written into `duplex`, otherwise `Uint8ArrayList`s will\n * @returns A stream for the selected protocol and the protocol that was selected from the list of protocols provided to `select`\n * @example\n *\n * ```TypeScript\n * import { pipe } from 'it-pipe'\n * import * as mss from '@libp2p/multistream-select'\n * import { Mplex } from '@libp2p/mplex'\n *\n * const muxer = new Mplex({\n * async onStream (muxedStream) {\n * // mss.handle(handledProtocols)\n * // Returns selected stream and protocol\n * const { stream, protocol } = await mss.handle(muxedStream, [\n * '/ipfs-dht/1.0.0',\n * '/ipfs-bitswap/1.0.0'\n * ])\n *\n * // Typically here we'd call the handler function that was registered in\n * // libp2p for the given protocol:\n * // e.g. handlers[protocol].handler(stream)\n * //\n * // If protocol was /ipfs-dht/1.0.0 it might do something like this:\n * // try {\n * // await pipe(\n * // dhtStream,\n * // source => (async function * () {\n * // for await (const chunk of source)\n * // // Incoming DHT data -> process and yield to respond\n * // })(),\n * // dhtStream\n * // )\n * // } catch (err) {\n * // // Error in stream\n * // }\n * }\n * })\n * ```\n */\nasync function handle(stream, protocols, options) {\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n options.log.trace('handle: available protocols %s', protocols);\n const lp = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_1__.lpStream)(stream, {\n ...options,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_4__.MAX_PROTOCOL_LENGTH,\n maxLengthLength: 2 // 2 bytes is enough to length-prefix MAX_PROTOCOL_LENGTH\n });\n while (true) {\n options.log.trace('handle: reading incoming string');\n const protocol = await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.readString(lp, options);\n options.log.trace('handle: read \"%s\"', protocol);\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID) {\n options.log.trace('handle: respond with \"%s\" for \"%s\"', _constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID, protocol);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(lp, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(`${_constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID}\\n`), options);\n options.log.trace('handle: responded with \"%s\" for \"%s\"', _constants_js__WEBPACK_IMPORTED_MODULE_4__.PROTOCOL_ID, protocol);\n continue;\n }\n if (protocols.includes(protocol)) {\n options.log.trace('handle: respond with \"%s\" for \"%s\"', protocol, protocol);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(lp, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(`${protocol}\\n`), options);\n options.log.trace('handle: responded with \"%s\" for \"%s\"', protocol, protocol);\n return { stream: lp.unwrap(), protocol };\n }\n if (protocol === 'ls') {\n // \\n\\n\\n\n const protos = new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList(...protocols.map(p => it_length_prefixed__WEBPACK_IMPORTED_MODULE_0__.encode.single((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(`${p}\\n`))), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('\\n'));\n options.log.trace('handle: respond with \"%s\" for %s', protocols, protocol);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(lp, protos, options);\n options.log.trace('handle: responded with \"%s\" for %s', protocols, protocol);\n continue;\n }\n options.log('handle: respond with \"na\" for \"%s\"', protocol);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_5__.write(lp, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('na\\n'), options);\n options.log('handle: responded with \"na\" for \"%s\"', protocol);\n }\n}\n//# sourceMappingURL=handle.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/handle.js?"); /***/ }), @@ -3013,7 +3427,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ read: () => (/* binding */ read),\n/* harmony export */ readString: () => (/* binding */ readString),\n/* harmony export */ write: () => (/* binding */ write),\n/* harmony export */ writeAll: () => (/* binding */ writeAll)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-first */ \"./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@libp2p/multistream-select/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:mss');\nconst NewLine = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)('\\n');\nfunction encode(buffer) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList(buffer, NewLine);\n return it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode.single(list);\n}\n/**\n * `write` encodes and writes a single buffer\n */\nfunction write(writer, buffer, options = {}) {\n const encoded = encode(buffer);\n if (options.writeBytes === true) {\n writer.push(encoded.subarray());\n }\n else {\n writer.push(encoded);\n }\n}\n/**\n * `writeAll` behaves like `write`, except it encodes an array of items as a single write\n */\nfunction writeAll(writer, buffers, options = {}) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList();\n for (const buf of buffers) {\n list.append(encode(buf));\n }\n if (options.writeBytes === true) {\n writer.push(list.subarray());\n }\n else {\n writer.push(list);\n }\n}\nasync function read(reader, options) {\n let byteLength = 1; // Read single byte chunks until the length is known\n const varByteSource = {\n [Symbol.asyncIterator]: () => varByteSource,\n next: async () => reader.next(byteLength)\n };\n let input = varByteSource;\n // If we have been passed an abort signal, wrap the input source in an abortable\n // iterator that will throw if the operation is aborted\n if (options?.signal != null) {\n input = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_2__.abortableSource)(varByteSource, options.signal);\n }\n // Once the length has been parsed, read chunk for that length\n const onLength = (l) => {\n byteLength = l;\n };\n const buf = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(input, (source) => it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode(source, { onLength, maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_9__.MAX_PROTOCOL_LENGTH }), async (source) => (0,it_first__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n if (buf == null || buf.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('no buffer returned', 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE');\n }\n if (buf.get(buf.byteLength - 1) !== NewLine[0]) {\n log.error('Invalid mss message - missing newline - %s', buf.subarray());\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('missing newline', 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE');\n }\n return buf.sublist(0, -1); // Remove newline\n}\nasync function readString(reader, options) {\n const buf = await read(reader, options);\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(buf.subarray());\n}\n//# sourceMappingURL=multistream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/multistream.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ read: () => (/* binding */ read),\n/* harmony export */ readString: () => (/* binding */ readString),\n/* harmony export */ write: () => (/* binding */ write),\n/* harmony export */ writeAll: () => (/* binding */ writeAll)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\nconst NewLine = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)('\\n');\n/**\n * `write` encodes and writes a single buffer\n */\nasync function write(writer, buffer, options) {\n await writer.write(buffer, options);\n}\n/**\n * `writeAll` behaves like `write`, except it encodes an array of items as a single write\n */\nasync function writeAll(writer, buffers, options) {\n await writer.writeV(buffers, options);\n}\n/**\n * Read a length-prefixed buffer from the passed stream, stripping the final newline character\n */\nasync function read(reader, options) {\n const buf = await reader.read(options);\n if (buf.byteLength === 0 || buf.get(buf.byteLength - 1) !== NewLine[0]) {\n options.log.error('Invalid mss message - missing newline', buf);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('missing newline', 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE');\n }\n return buf.sublist(0, -1); // Remove newline\n}\n/**\n * Read a length-prefixed string from the passed stream, stripping the final newline character\n */\nasync function readString(reader, options) {\n const buf = await read(reader, options);\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(buf.subarray());\n}\n//# sourceMappingURL=multistream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/multistream.js?"); /***/ }), @@ -3024,84 +3438,51 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ lazySelect: () => (/* binding */ lazySelect),\n/* harmony export */ select: () => (/* binding */ select)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var it_handshake__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-merge */ \"./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_reader__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-reader */ \"./node_modules/it-reader/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/multistream-select/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:mss:select');\nasync function select(stream, protocols, options = {}) {\n protocols = Array.isArray(protocols) ? [...protocols] : [protocols];\n const { reader, writer, rest, stream: shakeStream } = (0,it_handshake__WEBPACK_IMPORTED_MODULE_2__.handshake)(stream);\n const protocol = protocols.shift();\n if (protocol == null) {\n throw new Error('At least one protocol must be specified');\n }\n log.trace('select: write [\"%s\", \"%s\"]', _index_js__WEBPACK_IMPORTED_MODULE_9__.PROTOCOL_ID, protocol);\n const p1 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_9__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)(protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_8__.writeAll(writer, [p1, p2], options);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_8__.readString(reader, options);\n log.trace('select: read \"%s\"', response);\n // Read the protocol response if we got the protocolId in return\n if (response === _index_js__WEBPACK_IMPORTED_MODULE_9__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_8__.readString(reader, options);\n log.trace('select: read \"%s\"', response);\n }\n // We're done\n if (response === protocol) {\n rest();\n return { stream: shakeStream, protocol };\n }\n // We haven't gotten a valid ack, try the other protocols\n for (const protocol of protocols) {\n log.trace('select: write \"%s\"', protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_8__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)(protocol), options);\n const response = await _multistream_js__WEBPACK_IMPORTED_MODULE_8__.readString(reader, options);\n log.trace('select: read \"%s\" for \"%s\"', response, protocol);\n if (response === protocol) {\n rest(); // End our writer so others can start writing to stream\n return { stream: shakeStream, protocol };\n }\n }\n rest();\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL');\n}\nfunction lazySelect(stream, protocol) {\n // This is a signal to write the multistream headers if the consumer tries to\n // read from the source\n const negotiateTrigger = (0,it_pushable__WEBPACK_IMPORTED_MODULE_4__.pushable)();\n let negotiated = false;\n return {\n stream: {\n sink: async (source) => {\n await stream.sink((async function* () {\n let first = true;\n for await (const chunk of (0,it_merge__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source, negotiateTrigger)) {\n if (first) {\n first = false;\n negotiated = true;\n negotiateTrigger.end();\n const p1 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_9__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_7__.fromString)(protocol);\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList(_multistream_js__WEBPACK_IMPORTED_MODULE_8__.encode(p1), _multistream_js__WEBPACK_IMPORTED_MODULE_8__.encode(p2));\n if (chunk.length > 0)\n list.append(chunk);\n yield* list;\n }\n else {\n yield chunk;\n }\n }\n })());\n },\n source: (async function* () {\n if (!negotiated)\n negotiateTrigger.push(new Uint8Array());\n const byteReader = (0,it_reader__WEBPACK_IMPORTED_MODULE_5__.reader)(stream.source);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_8__.readString(byteReader);\n if (response === _index_js__WEBPACK_IMPORTED_MODULE_9__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_8__.readString(byteReader);\n }\n if (response !== protocol) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL');\n }\n for await (const chunk of byteReader) {\n yield* chunk;\n }\n })()\n },\n protocol\n };\n}\n//# sourceMappingURL=select.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/select.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ select: () => (/* binding */ select)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed-stream */ \"./node_modules/it-length-prefixed-stream/dist/src/index.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var race_signal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! race-signal */ \"./node_modules/race-signal/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n\n\n\n\n\n\n\n\n\n\n/**\n * Negotiate a protocol to use from a list of protocols.\n *\n * @param stream - A duplex iterable stream to dial on\n * @param protocols - A list of protocols (or single protocol) to negotiate with. Protocols are attempted in order until a match is made.\n * @param options - An options object containing an AbortSignal and an optional boolean `writeBytes` - if this is true, `Uint8Array`s will be written into `duplex`, otherwise `Uint8ArrayList`s will\n * @returns A stream for the selected protocol and the protocol that was selected from the list of protocols provided to `select`.\n * @example\n *\n * ```TypeScript\n * import { pipe } from 'it-pipe'\n * import * as mss from '@libp2p/multistream-select'\n * import { Mplex } from '@libp2p/mplex'\n *\n * const muxer = new Mplex()\n * const muxedStream = muxer.newStream()\n *\n * // mss.select(protocol(s))\n * // Select from one of the passed protocols (in priority order)\n * // Returns selected stream and protocol\n * const { stream: dhtStream, protocol } = await mss.select(muxedStream, [\n * // This might just be different versions of DHT, but could be different impls\n * '/ipfs-dht/2.0.0', // Most of the time this will probably just be one item.\n * '/ipfs-dht/1.0.0'\n * ])\n *\n * // Typically this stream will be passed back to the caller of libp2p.dialProtocol\n * //\n * // ...it might then do something like this:\n * // try {\n * // await pipe(\n * // [uint8ArrayFromString('Some DHT data')]\n * // dhtStream,\n * // async source => {\n * // for await (const chunk of source)\n * // // DHT response data\n * // }\n * // )\n * // } catch (err) {\n * // // Error in stream\n * // }\n * ```\n */\nasync function select(stream, protocols, options) {\n protocols = Array.isArray(protocols) ? [...protocols] : [protocols];\n if (protocols.length === 1 && options.negotiateFully === false) {\n return optimisticSelect(stream, protocols[0], options);\n }\n const lp = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_0__.lpStream)(stream, {\n ...options,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_5__.MAX_PROTOCOL_LENGTH\n });\n const protocol = protocols.shift();\n if (protocol == null) {\n throw new Error('At least one protocol must be specified');\n }\n options.log.trace('select: write [\"%s\", \"%s\"]', _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol);\n const p1 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID}\\n`);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${protocol}\\n`);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.writeAll(lp, [p1, p2], options);\n options.log.trace('select: reading multistream-select header');\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.readString(lp, options);\n options.log.trace('select: read \"%s\"', response);\n // Read the protocol response if we got the protocolId in return\n if (response === _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID) {\n options.log.trace('select: reading protocol response');\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.readString(lp, options);\n options.log.trace('select: read \"%s\"', response);\n }\n // We're done\n if (response === protocol) {\n return { stream: lp.unwrap(), protocol };\n }\n // We haven't gotten a valid ack, try the other protocols\n for (const protocol of protocols) {\n options.log.trace('select: write \"%s\"', protocol);\n await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.write(lp, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${protocol}\\n`), options);\n options.log.trace('select: reading protocol response');\n const response = await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.readString(lp, options);\n options.log.trace('select: read \"%s\" for \"%s\"', response, protocol);\n if (response === protocol) {\n return { stream: lp.unwrap(), protocol };\n }\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL');\n}\n/**\n * Optimistically negotiates a protocol.\n *\n * It *does not* block writes waiting for the other end to respond. Instead, it\n * simply assumes the negotiation went successfully and starts writing data.\n *\n * Use when it is known that the receiver supports the desired protocol.\n */\nfunction optimisticSelect(stream, protocol, options) {\n const originalSink = stream.sink.bind(stream);\n const originalSource = stream.source;\n let negotiated = false;\n let negotiating = false;\n const doneNegotiating = (0,p_defer__WEBPACK_IMPORTED_MODULE_8__[\"default\"])();\n let sentProtocol = false;\n let sendingProtocol = false;\n const doneSendingProtocol = (0,p_defer__WEBPACK_IMPORTED_MODULE_8__[\"default\"])();\n let readProtocol = false;\n let readingProtocol = false;\n const doneReadingProtocol = (0,p_defer__WEBPACK_IMPORTED_MODULE_8__[\"default\"])();\n const lp = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_0__.lpStream)({\n sink: originalSink,\n source: originalSource\n }, {\n ...options,\n maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_5__.MAX_PROTOCOL_LENGTH\n });\n stream.sink = async (source) => {\n const { sink } = lp.unwrap();\n await sink(async function* () {\n let sentData = false;\n for await (const buf of source) {\n // started reading before the source yielded, wait for protocol send\n if (sendingProtocol) {\n await doneSendingProtocol.promise;\n }\n // writing before reading, send the protocol and the first chunk of data\n if (!sentProtocol) {\n sendingProtocol = true;\n options.log.trace('optimistic: write [\"%s\", \"%s\", data(%d)] in sink', _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol, buf.byteLength);\n const protocolString = `${protocol}\\n`;\n // send protocols in first chunk of data written to transport\n yield new uint8arraylist__WEBPACK_IMPORTED_MODULE_3__.Uint8ArrayList(Uint8Array.from([19]), // length of PROTOCOL_ID plus newline\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID}\\n`), uint8_varint__WEBPACK_IMPORTED_MODULE_2__.encode(protocolString.length), (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocolString), buf).subarray();\n options.log.trace('optimistic: wrote [\"%s\", \"%s\", data(%d)] in sink', _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol, buf.byteLength);\n sentProtocol = true;\n sendingProtocol = false;\n doneSendingProtocol.resolve();\n // read the negotiation response but don't block more sending\n negotiate()\n .catch(err => {\n options.log.error('could not finish optimistic protocol negotiation of %s', protocol, err);\n });\n }\n else {\n yield buf;\n }\n sentData = true;\n }\n // special case - the source passed to the sink has ended but we didn't\n // negotiated the protocol yet so do it now\n if (!sentData) {\n await negotiate();\n }\n }());\n };\n async function negotiate() {\n if (negotiating) {\n options.log.trace('optimistic: already negotiating %s stream', protocol);\n await doneNegotiating.promise;\n return;\n }\n negotiating = true;\n try {\n // we haven't sent the protocol yet, send it now\n if (!sentProtocol) {\n options.log.trace('optimistic: doing send protocol for %s stream', protocol);\n await doSendProtocol();\n }\n // if we haven't read the protocol response yet, do it now\n if (!readProtocol) {\n options.log.trace('optimistic: doing read protocol for %s stream', protocol);\n await doReadProtocol();\n }\n }\n finally {\n negotiating = false;\n negotiated = true;\n doneNegotiating.resolve();\n }\n }\n async function doSendProtocol() {\n if (sendingProtocol) {\n await doneSendingProtocol.promise;\n return;\n }\n sendingProtocol = true;\n try {\n options.log.trace('optimistic: write [\"%s\", \"%s\", data] in source', _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol);\n await lp.writeV([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID}\\n`),\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(`${protocol}\\n`)\n ]);\n options.log.trace('optimistic: wrote [\"%s\", \"%s\", data] in source', _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol);\n }\n finally {\n sentProtocol = true;\n sendingProtocol = false;\n doneSendingProtocol.resolve();\n }\n }\n async function doReadProtocol() {\n if (readingProtocol) {\n await doneReadingProtocol.promise;\n return;\n }\n readingProtocol = true;\n try {\n options.log.trace('optimistic: reading multistream select header');\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.readString(lp, options);\n options.log.trace('optimistic: read multistream select header \"%s\"', response);\n if (response === _constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_6__.readString(lp, options);\n }\n options.log.trace('optimistic: read protocol \"%s\", expecting \"%s\"', response, protocol);\n if (response !== protocol) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError('protocol selection failed', 'ERR_UNSUPPORTED_PROTOCOL');\n }\n }\n finally {\n readProtocol = true;\n readingProtocol = false;\n doneReadingProtocol.resolve();\n }\n }\n stream.source = (async function* () {\n // make sure we've done protocol negotiation before we read stream data\n await negotiate();\n options.log.trace('optimistic: reading data from \"%s\" stream', protocol);\n yield* lp.unwrap().source;\n })();\n if (stream.closeRead != null) {\n const originalCloseRead = stream.closeRead.bind(stream);\n stream.closeRead = async (opts) => {\n // we need to read & write to negotiate the protocol so ensure we've done\n // this before closing the readable end of the stream\n if (!negotiated) {\n await negotiate().catch(err => {\n options.log.error('could not negotiate protocol before close read', err);\n });\n }\n // protocol has been negotiated, ok to close the readable end\n await originalCloseRead(opts);\n };\n }\n if (stream.closeWrite != null) {\n const originalCloseWrite = stream.closeWrite.bind(stream);\n stream.closeWrite = async (opts) => {\n // we need to read & write to negotiate the protocol so ensure we've done\n // this before closing the writable end of the stream\n if (!negotiated) {\n await negotiate().catch(err => {\n options.log.error('could not negotiate protocol before close write', err);\n });\n }\n // protocol has been negotiated, ok to close the writable end\n await originalCloseWrite(opts);\n };\n }\n if (stream.close != null) {\n const originalClose = stream.close.bind(stream);\n stream.close = async (opts) => {\n // if we are in the process of negotiation, let it finish before closing\n // because we may have unsent early data\n const tasks = [];\n if (sendingProtocol) {\n tasks.push(doneSendingProtocol.promise);\n }\n if (readingProtocol) {\n tasks.push(doneReadingProtocol.promise);\n }\n if (tasks.length > 0) {\n // let the in-flight protocol negotiation finish gracefully\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_1__.raceSignal)(Promise.all(tasks), opts?.signal);\n }\n else {\n // no protocol negotiation attempt has occurred so don't start one\n negotiated = true;\n negotiating = false;\n doneNegotiating.resolve();\n }\n // protocol has been negotiated, ok to close the writable end\n await originalClose(opts);\n };\n }\n return {\n stream,\n protocol\n };\n}\n//# sourceMappingURL=select.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/dist/src/select.js?"); /***/ }), -/***/ "./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/abort-error.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/abort-error.js ***! - \*********************************************************************************************************/ +/***/ "./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/alloc.js": +/*!********************************************************************************************!*\ + !*** ./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/alloc.js ***! + \********************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/abort-error.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/alloc.js?"); /***/ }), -/***/ "./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/index.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/index.js ***! - \***************************************************************************************************/ +/***/ "./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js": +/*!**************************************************************************************************!*\ + !*** ./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js ***! + \**************************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/from-string.js?"); /***/ }), -/***/ "./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/to-string.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/to-string.js ***! + \************************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Return the first value in an (async)iterable\n *\n * @example\n *\n * ```javascript\n * import first from 'it-first'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const res = first(values)\n *\n * console.info(res) // 0\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import first from 'it-first'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const res = await first(values())\n *\n * console.info(res) // 0\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction first(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n })();\n }\n for (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (first);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/to-string.js?"); /***/ }), -/***/ "./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/util/bases.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/util/bases.js ***! + \*************************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Merge several (async)iterables into one, yield values as they arrive.\n *\n * Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.\n *\n * @example\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values1 = [0, 1, 2, 3, 4]\n * const values2 = [5, 6, 7, 8, 9]\n *\n * const arr = all(merge(values1, values2))\n *\n * console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const values1 = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n * const values2 = async function * () {\n * yield * [5, 6, 7, 8, 9]\n * }\n *\n * const arr = await all(merge(values1(), values2()))\n *\n * console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction merge(...sources) {\n const syncSources = [];\n for (const source of sources) {\n if (!isAsyncIterable(source)) {\n syncSources.push(source);\n }\n }\n if (syncSources.length === sources.length) {\n // all sources are synchronous\n return (function* () {\n for (const source of syncSources) {\n yield* source;\n }\n })();\n }\n return (async function* () {\n const output = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n void Promise.resolve().then(async () => {\n try {\n await Promise.all(sources.map(async (source) => {\n for await (const item of source) {\n output.push(item);\n }\n }));\n output.end();\n }\n catch (err) {\n output.end(err);\n }\n });\n yield* output;\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (merge);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/multistream-select/node_modules/it-pipe/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/multistream-select/node_modules/it-pipe/dist/src/index.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pipe: () => (/* binding */ pipe),\n/* harmony export */ rawPipe: () => (/* binding */ rawPipe)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js\");\n\n\nfunction pipe(first, ...rest) {\n if (first == null) {\n throw new Error('Empty pipeline');\n }\n // Duplex at start: wrap in function and return duplex source\n if (isDuplex(first)) {\n const duplex = first;\n first = () => duplex.source;\n // Iterable at start: wrap in function\n }\n else if (isIterable(first) || isAsyncIterable(first)) {\n const source = first;\n first = () => source;\n }\n const fns = [first, ...rest];\n if (fns.length > 1) {\n // Duplex at end: use duplex sink\n if (isDuplex(fns[fns.length - 1])) {\n fns[fns.length - 1] = fns[fns.length - 1].sink;\n }\n }\n if (fns.length > 2) {\n // Duplex in the middle, consume source with duplex sink and return duplex source\n for (let i = 1; i < fns.length - 1; i++) {\n if (isDuplex(fns[i])) {\n fns[i] = duplexPipelineFn(fns[i]);\n }\n }\n }\n return rawPipe(...fns);\n}\nconst rawPipe = (...fns) => {\n let res;\n while (fns.length > 0) {\n res = fns.shift()(res);\n }\n return res;\n};\nconst isAsyncIterable = (obj) => {\n return obj?.[Symbol.asyncIterator] != null;\n};\nconst isIterable = (obj) => {\n return obj?.[Symbol.iterator] != null;\n};\nconst isDuplex = (obj) => {\n if (obj == null) {\n return false;\n }\n return obj.sink != null && obj.source != null;\n};\nconst duplexPipelineFn = (duplex) => {\n return (source) => {\n const p = duplex.sink(source);\n if (p?.then != null) {\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n p.then(() => {\n stream.end();\n }, (err) => {\n stream.end(err);\n });\n let sourceWrap;\n const source = duplex.source;\n if (isAsyncIterable(source)) {\n sourceWrap = async function* () {\n yield* source;\n stream.end();\n };\n }\n else if (isIterable(source)) {\n sourceWrap = function* () {\n yield* source;\n stream.end();\n };\n }\n else {\n throw new Error('Unknown duplex source type - must be Iterable or AsyncIterable');\n }\n return (0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(stream, sourceWrap());\n }\n return duplex.source;\n };\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/it-pipe/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-collections/dist/src/index.js": -/*!*****************************************************************!*\ - !*** ./node_modules/@libp2p/peer-collections/dist/src/index.js ***! - \*****************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerList: () => (/* reexport safe */ _list_js__WEBPACK_IMPORTED_MODULE_2__.PeerList),\n/* harmony export */ PeerMap: () => (/* reexport safe */ _map_js__WEBPACK_IMPORTED_MODULE_0__.PeerMap),\n/* harmony export */ PeerSet: () => (/* reexport safe */ _set_js__WEBPACK_IMPORTED_MODULE_1__.PeerSet)\n/* harmony export */ });\n/* harmony import */ var _map_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./map.js */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _set_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./set.js */ \"./node_modules/@libp2p/peer-collections/dist/src/set.js\");\n/* harmony import */ var _list_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./list.js */ \"./node_modules/@libp2p/peer-collections/dist/src/list.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-collections/dist/src/list.js": -/*!****************************************************************!*\ - !*** ./node_modules/@libp2p/peer-collections/dist/src/list.js ***! - \****************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerList: () => (/* binding */ PeerList)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./node_modules/@libp2p/peer-collections/dist/src/util.js\");\n\n\n/**\n * We can't use PeerIds as list entries because list entries are\n * compared using same-value-zero equality, so this is just\n * a map that stringifies the PeerIds before storing them.\n *\n * PeerIds cache stringified versions of themselves so this\n * should be a cheap operation.\n *\n * @example\n *\n * ```JavaScript\n * import { peerList } from '@libp2p/peer-collections'\n *\n * const list = peerList()\n * list.push(peerId)\n * ```\n */\nclass PeerList {\n list;\n constructor(list) {\n this.list = [];\n if (list != null) {\n for (const value of list) {\n this.list.push(value.toString());\n }\n }\n }\n [Symbol.iterator]() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.list.entries(), (val) => {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val[1]);\n });\n }\n concat(list) {\n const output = new PeerList(this);\n for (const value of list) {\n output.push(value);\n }\n return output;\n }\n entries() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.list.entries(), (val) => {\n return [val[0], (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val[1])];\n });\n }\n every(predicate) {\n return this.list.every((str, index) => {\n return predicate((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str), index, this);\n });\n }\n filter(predicate) {\n const output = new PeerList();\n this.list.forEach((str, index) => {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str);\n if (predicate(peerId, index, this)) {\n output.push(peerId);\n }\n });\n return output;\n }\n find(predicate) {\n const str = this.list.find((str, index) => {\n return predicate((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str), index, this);\n });\n if (str == null) {\n return undefined;\n }\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str);\n }\n findIndex(predicate) {\n return this.list.findIndex((str, index) => {\n return predicate((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str), index, this);\n });\n }\n forEach(predicate) {\n this.list.forEach((str, index) => {\n predicate((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str), index, this);\n });\n }\n includes(peerId) {\n return this.list.includes(peerId.toString());\n }\n indexOf(peerId) {\n return this.list.indexOf(peerId.toString());\n }\n pop() {\n const str = this.list.pop();\n if (str == null) {\n return undefined;\n }\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str);\n }\n push(...peerIds) {\n for (const peerId of peerIds) {\n this.list.push(peerId.toString());\n }\n }\n shift() {\n const str = this.list.shift();\n if (str == null) {\n return undefined;\n }\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str);\n }\n unshift(...peerIds) {\n let len = this.list.length;\n for (let i = peerIds.length - 1; i > -1; i--) {\n len = this.list.unshift(peerIds[i].toString());\n }\n return len;\n }\n get length() {\n return this.list.length;\n }\n}\n//# sourceMappingURL=list.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/list.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/multistream-select/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -3112,7 +3493,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerMap: () => (/* binding */ PeerMap)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./node_modules/@libp2p/peer-collections/dist/src/util.js\");\n\n\n/**\n * We can't use PeerIds as map keys because map keys are\n * compared using same-value-zero equality, so this is just\n * a map that stringifies the PeerIds before storing them.\n *\n * PeerIds cache stringified versions of themselves so this\n * should be a cheap operation.\n *\n * @example\n *\n * ```JavaScript\n * import { peerMap } from '@libp2p/peer-collections'\n *\n * const map = peerMap()\n * map.set(peerId, 'value')\n * ```\n */\nclass PeerMap {\n map;\n constructor(map) {\n this.map = new Map();\n if (map != null) {\n for (const [key, value] of map.entries()) {\n this.map.set(key.toString(), value);\n }\n }\n }\n [Symbol.iterator]() {\n return this.entries();\n }\n clear() {\n this.map.clear();\n }\n delete(peer) {\n this.map.delete(peer.toString());\n }\n entries() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.map.entries(), (val) => {\n return [(0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val[0]), val[1]];\n });\n }\n forEach(fn) {\n this.map.forEach((value, key) => {\n fn(value, (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(key), this);\n });\n }\n get(peer) {\n return this.map.get(peer.toString());\n }\n has(peer) {\n return this.map.has(peer.toString());\n }\n set(peer, value) {\n this.map.set(peer.toString(), value);\n }\n keys() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.map.keys(), (val) => {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val);\n });\n }\n values() {\n return this.map.values();\n }\n get size() {\n return this.map.size;\n }\n}\n//# sourceMappingURL=map.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/map.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerMap: () => (/* binding */ PeerMap),\n/* harmony export */ peerMap: () => (/* binding */ peerMap)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./node_modules/@libp2p/peer-collections/dist/src/util.js\");\n\n\n/**\n * We can't use PeerIds as map keys because map keys are\n * compared using same-value-zero equality, so this is just\n * a map that stringifies the PeerIds before storing them.\n *\n * PeerIds cache stringified versions of themselves so this\n * should be a cheap operation.\n *\n * @example\n *\n * ```TypeScript\n * import { peerMap } from '@libp2p/peer-collections'\n *\n * const map = peerMap()\n * map.set(peerId, 'value')\n * ```\n */\nclass PeerMap {\n map;\n constructor(map) {\n this.map = new Map();\n if (map != null) {\n for (const [key, value] of map.entries()) {\n this.map.set(key.toString(), value);\n }\n }\n }\n [Symbol.iterator]() {\n return this.entries();\n }\n clear() {\n this.map.clear();\n }\n delete(peer) {\n return this.map.delete(peer.toString());\n }\n entries() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_0__.mapIterable)(this.map.entries(), (val) => {\n return [(0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(val[0]), val[1]];\n });\n }\n forEach(fn) {\n this.map.forEach((value, key) => {\n fn(value, (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(key), this);\n });\n }\n get(peer) {\n return this.map.get(peer.toString());\n }\n has(peer) {\n return this.map.has(peer.toString());\n }\n set(peer, value) {\n this.map.set(peer.toString(), value);\n }\n keys() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_0__.mapIterable)(this.map.keys(), (val) => {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(val);\n });\n }\n values() {\n return this.map.values();\n }\n get size() {\n return this.map.size;\n }\n}\nfunction peerMap() {\n return new PeerMap();\n}\n//# sourceMappingURL=map.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/map.js?"); /***/ }), @@ -3123,7 +3504,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerSet: () => (/* binding */ PeerSet)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./node_modules/@libp2p/peer-collections/dist/src/util.js\");\n\n\n/**\n * We can't use PeerIds as set entries because set entries are\n * compared using same-value-zero equality, so this is just\n * a map that stringifies the PeerIds before storing them.\n *\n * PeerIds cache stringified versions of themselves so this\n * should be a cheap operation.\n *\n * @example\n *\n * ```JavaScript\n * import { peerSet } from '@libp2p/peer-collections'\n *\n * const set = peerSet()\n * set.add(peerId)\n * ```\n */\nclass PeerSet {\n set;\n constructor(set) {\n this.set = new Set();\n if (set != null) {\n for (const key of set) {\n this.set.add(key.toString());\n }\n }\n }\n get size() {\n return this.set.size;\n }\n [Symbol.iterator]() {\n return this.values();\n }\n add(peer) {\n this.set.add(peer.toString());\n }\n clear() {\n this.set.clear();\n }\n delete(peer) {\n this.set.delete(peer.toString());\n }\n entries() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.set.entries(), (val) => {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val[0]);\n return [peerId, peerId];\n });\n }\n forEach(predicate) {\n this.set.forEach((str) => {\n const id = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(str);\n predicate(id, id, this);\n });\n }\n has(peer) {\n return this.set.has(peer.toString());\n }\n values() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.mapIterable)(this.set.values(), (val) => {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(val);\n });\n }\n intersection(other) {\n const output = new PeerSet();\n for (const peerId of other) {\n if (this.has(peerId)) {\n output.add(peerId);\n }\n }\n return output;\n }\n difference(other) {\n const output = new PeerSet();\n for (const peerId of this) {\n if (!other.has(peerId)) {\n output.add(peerId);\n }\n }\n return output;\n }\n union(other) {\n const output = new PeerSet();\n for (const peerId of other) {\n output.add(peerId);\n }\n for (const peerId of this) {\n output.add(peerId);\n }\n return output;\n }\n}\n//# sourceMappingURL=set.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/set.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerSet: () => (/* binding */ PeerSet),\n/* harmony export */ peerSet: () => (/* binding */ peerSet)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./node_modules/@libp2p/peer-collections/dist/src/util.js\");\n\n\n/**\n * We can't use PeerIds as set entries because set entries are\n * compared using same-value-zero equality, so this is just\n * a map that stringifies the PeerIds before storing them.\n *\n * PeerIds cache stringified versions of themselves so this\n * should be a cheap operation.\n *\n * @example\n *\n * ```TypeScript\n * import { peerSet } from '@libp2p/peer-collections'\n *\n * const set = peerSet()\n * set.add(peerId)\n * ```\n */\nclass PeerSet {\n set;\n constructor(set) {\n this.set = new Set();\n if (set != null) {\n for (const key of set) {\n this.set.add(key.toString());\n }\n }\n }\n get size() {\n return this.set.size;\n }\n [Symbol.iterator]() {\n return this.values();\n }\n add(peer) {\n this.set.add(peer.toString());\n }\n clear() {\n this.set.clear();\n }\n delete(peer) {\n this.set.delete(peer.toString());\n }\n entries() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_0__.mapIterable)(this.set.entries(), (val) => {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(val[0]);\n return [peerId, peerId];\n });\n }\n forEach(predicate) {\n this.set.forEach((str) => {\n const id = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(str);\n predicate(id, id, this);\n });\n }\n has(peer) {\n return this.set.has(peer.toString());\n }\n values() {\n return (0,_util_js__WEBPACK_IMPORTED_MODULE_0__.mapIterable)(this.set.values(), (val) => {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(val);\n });\n }\n intersection(other) {\n const output = new PeerSet();\n for (const peerId of other) {\n if (this.has(peerId)) {\n output.add(peerId);\n }\n }\n return output;\n }\n difference(other) {\n const output = new PeerSet();\n for (const peerId of this) {\n if (!other.has(peerId)) {\n output.add(peerId);\n }\n }\n return output;\n }\n union(other) {\n const output = new PeerSet();\n for (const peerId of other) {\n output.add(peerId);\n }\n for (const peerId of this) {\n output.add(peerId);\n }\n return output;\n }\n}\nfunction peerSet() {\n return new PeerSet();\n}\n//# sourceMappingURL=set.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/set.js?"); /***/ }), @@ -3145,7 +3526,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createEd25519PeerId: () => (/* binding */ createEd25519PeerId),\n/* harmony export */ createFromJSON: () => (/* binding */ createFromJSON),\n/* harmony export */ createFromPrivKey: () => (/* binding */ createFromPrivKey),\n/* harmony export */ createFromProtobuf: () => (/* binding */ createFromProtobuf),\n/* harmony export */ createFromPubKey: () => (/* binding */ createFromPubKey),\n/* harmony export */ createRSAPeerId: () => (/* binding */ createRSAPeerId),\n/* harmony export */ createSecp256k1PeerId: () => (/* binding */ createSecp256k1PeerId),\n/* harmony export */ exportToProtobuf: () => (/* binding */ exportToProtobuf)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _proto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proto.js */ \"./node_modules/@libp2p/peer-id-factory/dist/src/proto.js\");\n\n\n\n\nconst createEd25519PeerId = async () => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.generateKeyPair)('Ed25519');\n const id = await createFromPrivKey(key);\n if (id.type === 'Ed25519') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nconst createSecp256k1PeerId = async () => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.generateKeyPair)('secp256k1');\n const id = await createFromPrivKey(key);\n if (id.type === 'secp256k1') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nconst createRSAPeerId = async (opts) => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.generateKeyPair)('RSA', opts?.bits ?? 2048);\n const id = await createFromPrivKey(key);\n if (id.type === 'RSA') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nasync function createFromPubKey(publicKey) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(privateKey.public), (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPrivateKey)(privateKey));\n}\nfunction exportToProtobuf(peerId, excludePrivateKey) {\n return _proto_js__WEBPACK_IMPORTED_MODULE_3__.PeerIdProto.encode({\n id: peerId.multihash.bytes,\n pubKey: peerId.publicKey,\n privKey: excludePrivateKey === true || peerId.privateKey == null ? undefined : peerId.privateKey\n });\n}\nasync function createFromProtobuf(buf) {\n const { id, privKey, pubKey } = _proto_js__WEBPACK_IMPORTED_MODULE_3__.PeerIdProto.decode(buf);\n return createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(obj.pubKey, 'base64pad') : undefined);\n}\nasync function createFromParts(multihash, privKey, pubKey) {\n if (privKey != null) {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(privKey);\n return createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(pubKey);\n return createFromPubKey(key);\n }\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(multihash);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createEd25519PeerId: () => (/* binding */ createEd25519PeerId),\n/* harmony export */ createFromJSON: () => (/* binding */ createFromJSON),\n/* harmony export */ createFromPrivKey: () => (/* binding */ createFromPrivKey),\n/* harmony export */ createFromProtobuf: () => (/* binding */ createFromProtobuf),\n/* harmony export */ createFromPubKey: () => (/* binding */ createFromPubKey),\n/* harmony export */ createRSAPeerId: () => (/* binding */ createRSAPeerId),\n/* harmony export */ createSecp256k1PeerId: () => (/* binding */ createSecp256k1PeerId),\n/* harmony export */ exportToProtobuf: () => (/* binding */ exportToProtobuf)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _proto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proto.js */ \"./node_modules/@libp2p/peer-id-factory/dist/src/proto.js\");\n/**\n * @packageDocumentation\n *\n * Generate, import, and export PeerIDs.\n *\n * A Peer ID is the SHA-256 [multihash](https://github.com/multiformats/multihash) of a public key.\n *\n * The public key is a base64 encoded string of a protobuf containing an RSA DER buffer. This uses a node buffer to pass the base64 encoded public key protobuf to the multihash for ID generation.\n *\n * @example\n *\n * ```TypeScript\n * import { createEd25519PeerId } from '@libp2p/peer-id-factory'\n *\n * const peerId = await createEd25519PeerId()\n * console.log(peerId.toString())\n * ```\n *\n * ```bash\n * 12D3KooWRm8J3iL796zPFi2EtGGtUJn58AG67gcqzMFHZnnsTzqD\n * ```\n */\n\n\n\n\nconst createEd25519PeerId = async () => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)('Ed25519');\n const id = await createFromPrivKey(key);\n if (id.type === 'Ed25519') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nconst createSecp256k1PeerId = async () => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)('secp256k1');\n const id = await createFromPrivKey(key);\n if (id.type === 'secp256k1') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nconst createRSAPeerId = async (opts) => {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair)('RSA', opts?.bits ?? 2048);\n const id = await createFromPrivKey(key);\n if (id.type === 'RSA') {\n return id;\n }\n throw new Error(`Generated unexpected PeerId type \"${id.type}\"`);\n};\nasync function createFromPubKey(publicKey) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.marshalPublicKey)(privateKey.public), (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.marshalPrivateKey)(privateKey));\n}\nfunction exportToProtobuf(peerId, excludePrivateKey) {\n return _proto_js__WEBPACK_IMPORTED_MODULE_3__.PeerIdProto.encode({\n id: peerId.multihash.bytes,\n pubKey: peerId.publicKey,\n privKey: excludePrivateKey === true || peerId.privateKey == null ? undefined : peerId.privateKey\n });\n}\nasync function createFromProtobuf(buf) {\n const { id, privKey, pubKey } = _proto_js__WEBPACK_IMPORTED_MODULE_3__.PeerIdProto.decode(buf);\n return createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(obj.pubKey, 'base64pad') : undefined);\n}\nasync function createFromParts(multihash, privKey, pubKey) {\n if (privKey != null) {\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.unmarshalPrivateKey)(privKey);\n return createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.unmarshalPublicKey)(pubKey);\n return createFromPubKey(key);\n }\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(multihash);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/dist/src/index.js?"); /***/ }), @@ -3160,6 +3541,39 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/alloc.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/alloc.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/from-string.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/from-string.js ***! + \***********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/util/bases.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/util/bases.js ***! + \**********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/peer-id/dist/src/index.js": /*!********************************************************!*\ !*** ./node_modules/@libp2p/peer-id/dist/src/index.js ***! @@ -3167,7 +3581,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerId: () => (/* binding */ createPeerId),\n/* harmony export */ peerIdFromBytes: () => (/* binding */ peerIdFromBytes),\n/* harmony export */ peerIdFromCID: () => (/* binding */ peerIdFromCID),\n/* harmony export */ peerIdFromKeys: () => (/* binding */ peerIdFromKeys),\n/* harmony export */ peerIdFromPeerId: () => (/* binding */ peerIdFromPeerId),\n/* harmony export */ peerIdFromString: () => (/* binding */ peerIdFromString)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/src/hashes/identity.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst baseDecoder = Object\n .values(multiformats_basics__WEBPACK_IMPORTED_MODULE_3__.bases)\n .map(codec => codec.decoder)\n // @ts-expect-error https://github.com/multiformats/js-multiformats/issues/141\n .reduce((acc, curr) => acc.or(curr), multiformats_basics__WEBPACK_IMPORTED_MODULE_3__.bases.identity.decoder);\n// these values are from https://github.com/multiformats/multicodec/blob/master/table.csv\nconst LIBP2P_KEY_CODE = 0x72;\nconst MARSHALLED_ED225519_PUBLIC_KEY_LENGTH = 36;\nconst MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH = 37;\nclass PeerIdImpl {\n type;\n multihash;\n privateKey;\n publicKey;\n string;\n constructor(init) {\n this.type = init.type;\n this.multihash = init.multihash;\n this.privateKey = init.privateKey;\n // mark string cache as non-enumerable\n Object.defineProperty(this, 'string', {\n enumerable: false,\n writable: true\n });\n }\n get [Symbol.toStringTag]() {\n return `PeerId(${this.toString()})`;\n }\n [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__.symbol] = true;\n toString() {\n if (this.string == null) {\n this.string = multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.encode(this.multihash.bytes).slice(1);\n }\n return this.string;\n }\n // return self-describing String representation\n // in default format from RFC 0001: https://github.com/libp2p/specs/pull/209\n toCID() {\n return multiformats_cid__WEBPACK_IMPORTED_MODULE_4__.CID.createV1(LIBP2P_KEY_CODE, this.multihash);\n }\n toBytes() {\n return this.multihash.bytes;\n }\n /**\n * Returns Multiaddr as a JSON string\n */\n toJSON() {\n return this.toString();\n }\n /**\n * Checks the equality of `this` peer against a given PeerId\n */\n equals(id) {\n if (id instanceof Uint8Array) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_8__.equals)(this.multihash.bytes, id);\n }\n else if (typeof id === 'string') {\n return peerIdFromString(id).equals(this);\n }\n else if (id?.multihash?.bytes != null) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_8__.equals)(this.multihash.bytes, id.multihash.bytes);\n }\n else {\n throw new Error('not valid Id');\n }\n }\n /**\n * Returns PeerId as a human-readable string\n * https://nodejs.org/api/util.html#utilinspectcustom\n *\n * @example\n * ```js\n * import { peerIdFromString } from '@libp2p/peer-id'\n *\n * console.info(peerIdFromString('QmFoo'))\n * // 'PeerId(QmFoo)'\n * ```\n */\n [inspect]() {\n return `PeerId(${this.toString()})`;\n }\n}\nclass RSAPeerIdImpl extends PeerIdImpl {\n type = 'RSA';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'RSA' });\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n type = 'Ed25519';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n type = 'secp256k1';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.publicKey = init.multihash.digest;\n }\n}\nfunction createPeerId(init) {\n if (init.type === 'RSA') {\n return new RSAPeerIdImpl(init);\n }\n if (init.type === 'Ed25519') {\n return new Ed25519PeerIdImpl(init);\n }\n if (init.type === 'secp256k1') {\n return new Secp256k1PeerIdImpl(init);\n }\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Type must be \"RSA\", \"Ed25519\" or \"secp256k1\"', 'ERR_INVALID_PARAMETERS');\n}\nfunction peerIdFromPeerId(other) {\n if (other.type === 'RSA') {\n return new RSAPeerIdImpl(other);\n }\n if (other.type === 'Ed25519') {\n return new Ed25519PeerIdImpl(other);\n }\n if (other.type === 'secp256k1') {\n return new Secp256k1PeerIdImpl(other);\n }\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Not a PeerId', 'ERR_INVALID_PARAMETERS');\n}\nfunction peerIdFromString(str, decoder) {\n decoder = decoder ?? baseDecoder;\n if (str.charAt(0) === '1' || str.charAt(0) === 'Q') {\n // identity hash ed25519/secp256k1 key or sha2-256 hash of\n // rsa public key - base58btc encoded either way\n const multihash = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.decode(`z${str}`));\n if (str.startsWith('12D')) {\n return new Ed25519PeerIdImpl({ multihash });\n }\n else if (str.startsWith('16U')) {\n return new Secp256k1PeerIdImpl({ multihash });\n }\n else {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n return peerIdFromBytes(baseDecoder.decode(str));\n}\nfunction peerIdFromBytes(buf) {\n try {\n const multihash = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.decode(buf);\n if (multihash.code === multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_6__.identity.code) {\n if (multihash.digest.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash });\n }\n else if (multihash.digest.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash });\n }\n }\n if (multihash.code === multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_7__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_4__.CID.decode(buf));\n }\n throw new Error('Supplied PeerID CID is invalid');\n}\nfunction peerIdFromCID(cid) {\n if (cid == null || cid.multihash == null || cid.version == null || (cid.version === 1 && cid.code !== LIBP2P_KEY_CODE)) {\n throw new Error('Supplied PeerID CID is invalid');\n }\n const multihash = cid.multihash;\n if (multihash.code === multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_7__.sha256.code) {\n return new RSAPeerIdImpl({ multihash: cid.multihash });\n }\n else if (multihash.code === multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_6__.identity.code) {\n if (multihash.digest.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash: cid.multihash });\n }\n else if (multihash.digest.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash: cid.multihash });\n }\n }\n throw new Error('Supplied PeerID CID is invalid');\n}\n/**\n * @param publicKey - A marshalled public key\n * @param privateKey - A marshalled private key\n */\nasync function peerIdFromKeys(publicKey, privateKey) {\n if (publicKey.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash: multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.create(multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_6__.identity.code, publicKey), privateKey });\n }\n if (publicKey.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash: multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.create(multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_6__.identity.code, publicKey), privateKey });\n }\n return new RSAPeerIdImpl({ multihash: await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_7__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerId: () => (/* binding */ createPeerId),\n/* harmony export */ peerIdFromBytes: () => (/* binding */ peerIdFromBytes),\n/* harmony export */ peerIdFromCID: () => (/* binding */ peerIdFromCID),\n/* harmony export */ peerIdFromKeys: () => (/* binding */ peerIdFromKeys),\n/* harmony export */ peerIdFromPeerId: () => (/* binding */ peerIdFromPeerId),\n/* harmony export */ peerIdFromString: () => (/* binding */ peerIdFromString)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-id/index.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/peer-id/node_modules/uint8arrays/dist/src/equals.js\");\n/**\n * @packageDocumentation\n *\n * An implementation of a peer id\n *\n * @example\n *\n * ```TypeScript\n * import { peerIdFromString } from '@libp2p/peer-id'\n * const peer = peerIdFromString('k51qzi5uqu5dkwkqm42v9j9kqcam2jiuvloi16g72i4i4amoo2m8u3ol3mqu6s')\n *\n * console.log(peer.toCID()) // CID(bafzaa...)\n * console.log(peer.toString()) // \"12D3K...\"\n * ```\n */\n\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst baseDecoder = Object\n .values(multiformats_basics__WEBPACK_IMPORTED_MODULE_1__.bases)\n .map(codec => codec.decoder)\n // @ts-expect-error https://github.com/multiformats/js-multiformats/issues/141\n .reduce((acc, curr) => acc.or(curr), multiformats_basics__WEBPACK_IMPORTED_MODULE_1__.bases.identity.decoder);\n// these values are from https://github.com/multiformats/multicodec/blob/master/table.csv\nconst LIBP2P_KEY_CODE = 0x72;\nconst MARSHALLED_ED225519_PUBLIC_KEY_LENGTH = 36;\nconst MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH = 37;\nclass PeerIdImpl {\n type;\n multihash;\n privateKey;\n publicKey;\n string;\n constructor(init) {\n this.type = init.type;\n this.multihash = init.multihash;\n this.privateKey = init.privateKey;\n // mark string cache as non-enumerable\n Object.defineProperty(this, 'string', {\n enumerable: false,\n writable: true\n });\n }\n get [Symbol.toStringTag]() {\n return `PeerId(${this.toString()})`;\n }\n [_libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.peerIdSymbol] = true;\n toString() {\n if (this.string == null) {\n this.string = multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.encode(this.multihash.bytes).slice(1);\n }\n return this.string;\n }\n // return self-describing String representation\n // in default format from RFC 0001: https://github.com/libp2p/specs/pull/209\n toCID() {\n return multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.createV1(LIBP2P_KEY_CODE, this.multihash);\n }\n toBytes() {\n return this.multihash.bytes;\n }\n /**\n * Returns Multiaddr as a JSON string\n */\n toJSON() {\n return this.toString();\n }\n /**\n * Checks the equality of `this` peer against a given PeerId\n */\n equals(id) {\n if (id == null) {\n return false;\n }\n if (id instanceof Uint8Array) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__.equals)(this.multihash.bytes, id);\n }\n else if (typeof id === 'string') {\n return peerIdFromString(id).equals(this);\n }\n else if (id?.multihash?.bytes != null) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__.equals)(this.multihash.bytes, id.multihash.bytes);\n }\n else {\n throw new Error('not valid Id');\n }\n }\n /**\n * Returns PeerId as a human-readable string\n * https://nodejs.org/api/util.html#utilinspectcustom\n *\n * @example\n * ```TypeScript\n * import { peerIdFromString } from '@libp2p/peer-id'\n *\n * console.info(peerIdFromString('QmFoo'))\n * // 'PeerId(QmFoo)'\n * ```\n */\n [inspect]() {\n return `PeerId(${this.toString()})`;\n }\n}\nclass RSAPeerIdImpl extends PeerIdImpl {\n type = 'RSA';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'RSA' });\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n type = 'Ed25519';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n type = 'secp256k1';\n publicKey;\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.publicKey = init.multihash.digest;\n }\n}\nfunction createPeerId(init) {\n if (init.type === 'RSA') {\n return new RSAPeerIdImpl(init);\n }\n if (init.type === 'Ed25519') {\n return new Ed25519PeerIdImpl(init);\n }\n if (init.type === 'secp256k1') {\n return new Secp256k1PeerIdImpl(init);\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('Type must be \"RSA\", \"Ed25519\" or \"secp256k1\"', 'ERR_INVALID_PARAMETERS');\n}\nfunction peerIdFromPeerId(other) {\n if (other.type === 'RSA') {\n return new RSAPeerIdImpl(other);\n }\n if (other.type === 'Ed25519') {\n return new Ed25519PeerIdImpl(other);\n }\n if (other.type === 'secp256k1') {\n return new Secp256k1PeerIdImpl(other);\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_8__.CodeError('Not a PeerId', 'ERR_INVALID_PARAMETERS');\n}\nfunction peerIdFromString(str, decoder) {\n decoder = decoder ?? baseDecoder;\n if (str.charAt(0) === '1' || str.charAt(0) === 'Q') {\n // identity hash ed25519/secp256k1 key or sha2-256 hash of\n // rsa public key - base58btc encoded either way\n const multihash = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.decode(`z${str}`));\n if (str.startsWith('12D')) {\n return new Ed25519PeerIdImpl({ multihash });\n }\n else if (str.startsWith('16U')) {\n return new Secp256k1PeerIdImpl({ multihash });\n }\n else {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n return peerIdFromBytes(baseDecoder.decode(str));\n}\nfunction peerIdFromBytes(buf) {\n try {\n const multihash = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__.decode(buf);\n if (multihash.code === multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__.identity.code) {\n if (multihash.digest.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash });\n }\n else if (multihash.digest.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash });\n }\n }\n if (multihash.code === multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_5__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.decode(buf));\n }\n throw new Error('Supplied PeerID CID is invalid');\n}\nfunction peerIdFromCID(cid) {\n if (cid == null || cid.multihash == null || cid.version == null || (cid.version === 1 && cid.code !== LIBP2P_KEY_CODE)) {\n throw new Error('Supplied PeerID CID is invalid');\n }\n const multihash = cid.multihash;\n if (multihash.code === multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_5__.sha256.code) {\n return new RSAPeerIdImpl({ multihash: cid.multihash });\n }\n else if (multihash.code === multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__.identity.code) {\n if (multihash.digest.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash: cid.multihash });\n }\n else if (multihash.digest.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash: cid.multihash });\n }\n }\n throw new Error('Supplied PeerID CID is invalid');\n}\n/**\n * @param publicKey - A marshalled public key\n * @param privateKey - A marshalled private key\n */\nasync function peerIdFromKeys(publicKey, privateKey) {\n if (publicKey.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {\n return new Ed25519PeerIdImpl({ multihash: multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__.create(multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__.identity.code, publicKey), privateKey });\n }\n if (publicKey.length === MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH) {\n return new Secp256k1PeerIdImpl({ multihash: multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__.create(multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__.identity.code, publicKey), privateKey });\n }\n return new RSAPeerIdImpl({ multihash: await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_5__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/uint8arrays/dist/src/equals.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/uint8arrays/dist/src/equals.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id/node_modules/uint8arrays/dist/src/equals.js?"); /***/ }), @@ -3189,7 +3614,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RecordEnvelope: () => (/* binding */ RecordEnvelope)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\n /**\n * Unmarshal a serialized Envelope protobuf message\n */\n static createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_8__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)(envelopeData.publicKey);\n return new RecordEnvelope({\n peerId,\n payloadType: envelopeData.payloadType,\n payload: envelopeData.payload,\n signature: envelopeData.signature\n });\n };\n /**\n * Seal marshals the given Record, places the marshaled bytes inside an Envelope\n * and signs it with the given peerId's private key\n */\n static seal = async (record, peerId) => {\n if (peerId.privateKey == null) {\n throw new Error('Missing private key');\n }\n const domain = record.domain;\n const payloadType = record.codec;\n const payload = record.marshal();\n const signData = formatSignaturePayload(domain, payloadType, payload);\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n const signature = await key.sign(signData.subarray());\n return new RecordEnvelope({\n peerId,\n payloadType,\n payload,\n signature\n });\n };\n /**\n * Open and certify a given marshalled envelope.\n * Data is unmarshalled and the signature validated for the given domain.\n */\n static openAndCertify = async (data, domain) => {\n const envelope = await RecordEnvelope.createFromProtobuf(data);\n const valid = await envelope.validate(domain);\n if (!valid) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\n };\n peerId;\n payloadType;\n payload;\n signature;\n marshaled;\n /**\n * The Envelope is responsible for keeping an arbitrary signed record\n * by a libp2p peer.\n */\n constructor(init) {\n const { peerId, payloadType, payload, signature } = init;\n this.peerId = peerId;\n this.payloadType = payloadType;\n this.payload = payload;\n this.signature = signature;\n }\n /**\n * Marshal the envelope content\n */\n marshal() {\n if (this.peerId.publicKey == null) {\n throw new Error('Missing public key');\n }\n if (this.marshaled == null) {\n this.marshaled = _envelope_js__WEBPACK_IMPORTED_MODULE_8__.Envelope.encode({\n publicKey: this.peerId.publicKey,\n payloadType: this.payloadType,\n payload: this.payload.subarray(),\n signature: this.signature\n });\n }\n return this.marshaled;\n }\n /**\n * Verifies if the other Envelope is identical to this one\n */\n equals(other) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(this.marshal(), other.marshal());\n }\n /**\n * Validate envelope data signature for the given domain\n */\n async validate(domain) {\n const signData = formatSignaturePayload(domain, this.payloadType, this.payload);\n if (this.peerId.publicKey == null) {\n throw new Error('Missing public key');\n }\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(this.peerId.publicKey);\n return key.verify(signData.subarray(), this.signature);\n }\n}\n/**\n * Helper function that prepares a Uint8Array to sign or verify a signature\n */\nconst formatSignaturePayload = (domain, payloadType, payload) => {\n // When signing, a peer will prepare a Uint8Array by concatenating the following:\n // - The length of the domain separation string string in bytes\n // - The domain separation string, encoded as UTF-8\n // - The length of the payload_type field in bytes\n // - The value of the payload_type field\n // - The length of the payload field in bytes\n // - The value of the payload field\n const domainUint8Array = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_6__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_3__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_3__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_3__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_4__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RecordEnvelope: () => (/* binding */ RecordEnvelope)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\n /**\n * Unmarshal a serialized Envelope protobuf message\n */\n static createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_4__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromKeys)(envelopeData.publicKey);\n return new RecordEnvelope({\n peerId,\n payloadType: envelopeData.payloadType,\n payload: envelopeData.payload,\n signature: envelopeData.signature\n });\n };\n /**\n * Seal marshals the given Record, places the marshaled bytes inside an Envelope\n * and signs it with the given peerId's private key\n */\n static seal = async (record, peerId) => {\n if (peerId.privateKey == null) {\n throw new Error('Missing private key');\n }\n const domain = record.domain;\n const payloadType = record.codec;\n const payload = record.marshal();\n const signData = formatSignaturePayload(domain, payloadType, payload);\n const key = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_6__.unmarshalPrivateKey)(peerId.privateKey);\n const signature = await key.sign(signData.subarray());\n return new RecordEnvelope({\n peerId,\n payloadType,\n payload,\n signature\n });\n };\n /**\n * Open and certify a given marshalled envelope.\n * Data is unmarshalled and the signature validated for the given domain.\n */\n static openAndCertify = async (data, domain) => {\n const envelope = await RecordEnvelope.createFromProtobuf(data);\n const valid = await envelope.validate(domain);\n if (!valid) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\n };\n peerId;\n payloadType;\n payload;\n signature;\n marshaled;\n /**\n * The Envelope is responsible for keeping an arbitrary signed record\n * by a libp2p peer.\n */\n constructor(init) {\n const { peerId, payloadType, payload, signature } = init;\n this.peerId = peerId;\n this.payloadType = payloadType;\n this.payload = payload;\n this.signature = signature;\n }\n /**\n * Marshal the envelope content\n */\n marshal() {\n if (this.peerId.publicKey == null) {\n throw new Error('Missing public key');\n }\n if (this.marshaled == null) {\n this.marshaled = _envelope_js__WEBPACK_IMPORTED_MODULE_4__.Envelope.encode({\n publicKey: this.peerId.publicKey,\n payloadType: this.payloadType,\n payload: this.payload.subarray(),\n signature: this.signature\n });\n }\n return this.marshaled;\n }\n /**\n * Verifies if the other Envelope is identical to this one\n */\n equals(other) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.marshal(), other.marshal());\n }\n /**\n * Validate envelope data signature for the given domain\n */\n async validate(domain) {\n const signData = formatSignaturePayload(domain, this.payloadType, this.payload);\n if (this.peerId.publicKey == null) {\n throw new Error('Missing public key');\n }\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_6__.unmarshalPublicKey)(this.peerId.publicKey);\n return key.verify(signData.subarray(), this.signature);\n }\n}\n/**\n * Helper function that prepares a Uint8Array to sign or verify a signature\n */\nconst formatSignaturePayload = (domain, payloadType, payload) => {\n // When signing, a peer will prepare a Uint8Array by concatenating the following:\n // - The length of the domain separation string string in bytes\n // - The domain separation string, encoded as UTF-8\n // - The length of the payload_type field in bytes\n // - The value of the payload_type field\n // - The length of the payload field in bytes\n // - The value of the payload field\n const domainUint8Array = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); /***/ }), @@ -3204,17 +3629,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/peer-record/dist/src/index.js": -/*!************************************************************!*\ - !*** ./node_modules/@libp2p/peer-record/dist/src/index.js ***! - \************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerRecord: () => (/* reexport safe */ _peer_record_index_js__WEBPACK_IMPORTED_MODULE_1__.PeerRecord),\n/* harmony export */ RecordEnvelope: () => (/* reexport safe */ _envelope_index_js__WEBPACK_IMPORTED_MODULE_0__.RecordEnvelope)\n/* harmony export */ });\n/* harmony import */ var _envelope_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./envelope/index.js */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/index.js\");\n/* harmony import */ var _peer_record_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./peer-record/index.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": /*!*************************************************************************!*\ !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js ***! @@ -3233,7 +3647,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerRecord: () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_utils_array_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/utils/array-equals */ \"./node_modules/@libp2p/utils/dist/src/array-equals.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n\n\n\n\n\n/**\n * The PeerRecord is used for distributing peer routing records across the network.\n * It contains the peer's reachable listen addresses.\n */\nclass PeerRecord {\n /**\n * Unmarshal Peer Record Protobuf\n */\n static createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.decode(buf);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromBytes)(peerRecord.peerId);\n const multiaddrs = (peerRecord.addresses ?? []).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(a.multiaddr));\n const seqNumber = peerRecord.seq;\n return new PeerRecord({ peerId, multiaddrs, seqNumber });\n };\n static DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_3__.ENVELOPE_DOMAIN_PEER_RECORD;\n static CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_3__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n peerId;\n multiaddrs;\n seqNumber;\n domain = PeerRecord.DOMAIN;\n codec = PeerRecord.CODEC;\n marshaled;\n constructor(init) {\n const { peerId, multiaddrs, seqNumber } = init;\n this.peerId = peerId;\n this.multiaddrs = multiaddrs ?? [];\n this.seqNumber = seqNumber ?? BigInt(Date.now());\n }\n /**\n * Marshal a record to be used in an envelope\n */\n marshal() {\n if (this.marshaled == null) {\n this.marshaled = _peer_record_js__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.encode({\n peerId: this.peerId.toBytes(),\n seq: BigInt(this.seqNumber),\n addresses: this.multiaddrs.map((m) => ({\n multiaddr: m.bytes\n }))\n });\n }\n return this.marshaled;\n }\n /**\n * Returns true if `this` record equals the `other`\n */\n equals(other) {\n if (!(other instanceof PeerRecord)) {\n return false;\n }\n // Validate PeerId\n if (!this.peerId.equals(other.peerId)) {\n return false;\n }\n // Validate seqNumber\n if (this.seqNumber !== other.seqNumber) {\n return false;\n }\n // Validate multiaddrs\n if (!(0,_libp2p_utils_array_equals__WEBPACK_IMPORTED_MODULE_1__.arrayEquals)(this.multiaddrs, other.multiaddrs)) {\n return false;\n }\n return true;\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerRecord: () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_utils_array_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/utils/array-equals */ \"./node_modules/@libp2p/utils/dist/src/array-equals.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n\n\n\n\n\n/**\n * The PeerRecord is used for distributing peer routing records across the network.\n * It contains the peer's reachable listen addresses.\n */\nclass PeerRecord {\n /**\n * Unmarshal Peer Record Protobuf\n */\n static createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_1__.PeerRecord.decode(buf);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(peerRecord.peerId);\n const multiaddrs = (peerRecord.addresses ?? []).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a.multiaddr));\n const seqNumber = peerRecord.seq;\n return new PeerRecord({ peerId, multiaddrs, seqNumber });\n };\n static DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_3__.ENVELOPE_DOMAIN_PEER_RECORD;\n static CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_3__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n peerId;\n multiaddrs;\n seqNumber;\n domain = PeerRecord.DOMAIN;\n codec = PeerRecord.CODEC;\n marshaled;\n constructor(init) {\n const { peerId, multiaddrs, seqNumber } = init;\n this.peerId = peerId;\n this.multiaddrs = multiaddrs ?? [];\n this.seqNumber = seqNumber ?? BigInt(Date.now());\n }\n /**\n * Marshal a record to be used in an envelope\n */\n marshal() {\n if (this.marshaled == null) {\n this.marshaled = _peer_record_js__WEBPACK_IMPORTED_MODULE_1__.PeerRecord.encode({\n peerId: this.peerId.toBytes(),\n seq: BigInt(this.seqNumber),\n addresses: this.multiaddrs.map((m) => ({\n multiaddr: m.bytes\n }))\n });\n }\n return this.marshaled;\n }\n /**\n * Returns true if `this` record equals the `other`\n */\n equals(other) {\n if (!(other instanceof PeerRecord)) {\n return false;\n }\n // Validate PeerId\n if (!this.peerId.equals(other.peerId)) {\n return false;\n }\n // Validate seqNumber\n if (this.seqNumber !== other.seqNumber) {\n return false;\n }\n // Validate multiaddrs\n if (!(0,_libp2p_utils_array_equals__WEBPACK_IMPORTED_MODULE_4__.arrayEquals)(this.multiaddrs, other.multiaddrs)) {\n return false;\n }\n return true;\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); /***/ }), @@ -3248,25 +3662,267 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/topology/dist/src/index.js": -/*!*********************************************************!*\ - !*** ./node_modules/@libp2p/topology/dist/src/index.js ***! - \*********************************************************/ +/***/ "./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/alloc.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/alloc.js ***! + \*************************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createTopology: () => (/* binding */ createTopology)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-registrar */ \"./node_modules/@libp2p/interface-registrar/dist/src/index.js\");\n\nconst noop = () => { };\nclass TopologyImpl {\n min;\n max;\n /**\n * Set of peers that support the protocol\n */\n peers;\n onConnect;\n onDisconnect;\n registrar;\n constructor(init) {\n this.min = init.min ?? 0;\n this.max = init.max ?? Infinity;\n this.peers = new Set();\n this.onConnect = init.onConnect ?? noop;\n this.onDisconnect = init.onDisconnect ?? noop;\n }\n get [Symbol.toStringTag]() {\n return _libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol.toString();\n }\n [_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol] = true;\n async setRegistrar(registrar) {\n this.registrar = registrar;\n }\n /**\n * Notify about peer disconnected event\n */\n disconnect(peerId) {\n this.onDisconnect(peerId);\n }\n}\nfunction createTopology(init) {\n return new TopologyImpl(init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/topology/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/alloc.js?"); /***/ }), -/***/ "./node_modules/@libp2p/tracked-map/dist/src/index.js": +/***/ "./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/equals.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/equals.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/from-string.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/from-string.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/util/bases.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/util/bases.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/errors.js": /*!************************************************************!*\ - !*** ./node_modules/@libp2p/tracked-map/dist/src/index.js ***! + !*** ./node_modules/@libp2p/peer-store/dist/src/errors.js ***! \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ trackedMap: () => (/* binding */ trackedMap)\n/* harmony export */ });\nclass TrackedMap extends Map {\n metric;\n constructor(init) {\n super();\n const { name, metrics } = init;\n this.metric = metrics.registerMetric(name);\n this.updateComponentMetric();\n }\n set(key, value) {\n super.set(key, value);\n this.updateComponentMetric();\n return this;\n }\n delete(key) {\n const deleted = super.delete(key);\n this.updateComponentMetric();\n return deleted;\n }\n clear() {\n super.clear();\n this.updateComponentMetric();\n }\n updateComponentMetric() {\n this.metric.update(this.size);\n }\n}\nfunction trackedMap(config) {\n const { name, metrics } = config;\n let map;\n if (metrics != null) {\n map = new TrackedMap({ name, metrics });\n }\n else {\n map = new Map();\n }\n return map;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/tracked-map/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes)\n/* harmony export */ });\nconst codes = {\n ERR_INVALID_PARAMETERS: 'ERR_INVALID_PARAMETERS'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/errors.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/index.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PersistentPeerStore: () => (/* binding */ PersistentPeerStore)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@libp2p/peer-store/dist/src/store.js\");\n/**\n * @packageDocumentation\n *\n * The peer store is where libp2p stores data about the peers it has encountered on the network.\n */\n\n\n\n/**\n * An implementation of PeerStore that stores data in a Datastore\n */\nclass PersistentPeerStore {\n store;\n events;\n peerId;\n log;\n constructor(components, init = {}) {\n this.log = components.logger.forComponent('libp2p:peer-store');\n this.events = components.events;\n this.peerId = components.peerId;\n this.store = new _store_js__WEBPACK_IMPORTED_MODULE_1__.PersistentStore(components, init);\n }\n async forEach(fn, query) {\n this.log.trace('forEach await read lock');\n const release = await this.store.lock.readLock();\n this.log.trace('forEach got read lock');\n try {\n for await (const peer of this.store.all(query)) {\n fn(peer);\n }\n }\n finally {\n this.log.trace('forEach release read lock');\n release();\n }\n }\n async all(query) {\n this.log.trace('all await read lock');\n const release = await this.store.lock.readLock();\n this.log.trace('all got read lock');\n try {\n return await (0,it_all__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.store.all(query));\n }\n finally {\n this.log.trace('all release read lock');\n release();\n }\n }\n async delete(peerId) {\n this.log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n this.log.trace('delete got write lock');\n try {\n await this.store.delete(peerId);\n }\n finally {\n this.log.trace('delete release write lock');\n release();\n }\n }\n async has(peerId) {\n this.log.trace('has await read lock');\n const release = await this.store.lock.readLock();\n this.log.trace('has got read lock');\n try {\n return await this.store.has(peerId);\n }\n finally {\n this.log.trace('has release read lock');\n release();\n }\n }\n async get(peerId) {\n this.log.trace('get await read lock');\n const release = await this.store.lock.readLock();\n this.log.trace('get got read lock');\n try {\n return await this.store.load(peerId);\n }\n finally {\n this.log.trace('get release read lock');\n release();\n }\n }\n async save(id, data) {\n this.log.trace('save await write lock');\n const release = await this.store.lock.writeLock();\n this.log.trace('save got write lock');\n try {\n const result = await this.store.save(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n this.log.trace('save release write lock');\n release();\n }\n }\n async patch(id, data) {\n this.log.trace('patch await write lock');\n const release = await this.store.lock.writeLock();\n this.log.trace('patch got write lock');\n try {\n const result = await this.store.patch(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n this.log.trace('patch release write lock');\n release();\n }\n }\n async merge(id, data) {\n this.log.trace('merge await write lock');\n const release = await this.store.lock.writeLock();\n this.log.trace('merge got write lock');\n try {\n const result = await this.store.merge(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n this.log.trace('merge release write lock');\n release();\n }\n }\n async consumePeerRecord(buf, expectedPeer) {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_2__.RecordEnvelope.openAndCertify(buf, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_3__.PeerRecord.DOMAIN);\n if (expectedPeer?.equals(envelope.peerId) === false) {\n this.log('envelope peer id was not the expected peer id - expected: %p received: %p', expectedPeer, envelope.peerId);\n return false;\n }\n const peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_3__.PeerRecord.createFromProtobuf(envelope.payload);\n let peer;\n try {\n peer = await this.get(envelope.peerId);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n // ensure seq is greater than, or equal to, the last received\n if (peer?.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_2__.RecordEnvelope.createFromProtobuf(peer.peerRecordEnvelope);\n const storedRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_3__.PeerRecord.createFromProtobuf(storedEnvelope.payload);\n if (storedRecord.seqNumber >= peerRecord.seqNumber) {\n this.log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);\n return false;\n }\n }\n await this.patch(peerRecord.peerId, {\n peerRecordEnvelope: buf,\n addresses: peerRecord.multiaddrs.map(multiaddr => ({\n isCertified: true,\n multiaddr\n }))\n });\n return true;\n }\n #emitIfUpdated(id, result) {\n if (!result.updated) {\n return;\n }\n if (this.peerId.equals(id)) {\n this.events.safeDispatchEvent('self:peer:update', { detail: result });\n }\n else {\n this.events.safeDispatchEvent('peer:update', { detail: result });\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/pb/peer.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/pb/peer.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Address: () => (/* binding */ Address),\n/* harmony export */ Peer: () => (/* binding */ Peer),\n/* harmony export */ Tag: () => (/* binding */ Tag)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Peer;\n(function (Peer) {\n let Peer$metadataEntry;\n (function (Peer$metadataEntry) {\n let _codec;\n Peer$metadataEntry.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.key != null && obj.key !== '')) {\n w.uint32(10);\n w.string(obj.key);\n }\n if ((obj.value != null && obj.value.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.value);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n key: '',\n value: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.key = reader.string();\n break;\n case 2:\n obj.value = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer$metadataEntry.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer$metadataEntry.codec());\n };\n Peer$metadataEntry.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer$metadataEntry.codec());\n };\n })(Peer$metadataEntry = Peer.Peer$metadataEntry || (Peer.Peer$metadataEntry = {}));\n let Peer$tagsEntry;\n (function (Peer$tagsEntry) {\n let _codec;\n Peer$tagsEntry.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.key != null && obj.key !== '')) {\n w.uint32(10);\n w.string(obj.key);\n }\n if (obj.value != null) {\n w.uint32(18);\n Tag.codec().encode(obj.value, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n key: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.key = reader.string();\n break;\n case 2:\n obj.value = Tag.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer$tagsEntry.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer$tagsEntry.codec());\n };\n Peer$tagsEntry.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer$tagsEntry.codec());\n };\n })(Peer$tagsEntry = Peer.Peer$tagsEntry || (Peer.Peer$tagsEntry = {}));\n let _codec;\n Peer.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(10);\n Address.codec().encode(value, w);\n }\n }\n if (obj.protocols != null) {\n for (const value of obj.protocols) {\n w.uint32(18);\n w.string(value);\n }\n }\n if (obj.publicKey != null) {\n w.uint32(34);\n w.bytes(obj.publicKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (obj.metadata != null && obj.metadata.size !== 0) {\n for (const [key, value] of obj.metadata.entries()) {\n w.uint32(50);\n Peer.Peer$metadataEntry.codec().encode({ key, value }, w);\n }\n }\n if (obj.tags != null && obj.tags.size !== 0) {\n for (const [key, value] of obj.tags.entries()) {\n w.uint32(58);\n Peer.Peer$tagsEntry.codec().encode({ key, value }, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: new Map(),\n tags: new Map()\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.addresses.push(Address.codec().decode(reader, reader.uint32()));\n break;\n case 2:\n obj.protocols.push(reader.string());\n break;\n case 4:\n obj.publicKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = reader.bytes();\n break;\n case 6: {\n const entry = Peer.Peer$metadataEntry.codec().decode(reader, reader.uint32());\n obj.metadata.set(entry.key, entry.value);\n break;\n }\n case 7: {\n const entry = Peer.Peer$tagsEntry.codec().decode(reader, reader.uint32());\n obj.tags.set(entry.key, entry.value);\n break;\n }\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer.codec());\n };\n Peer.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer.codec());\n };\n})(Peer || (Peer = {}));\nvar Address;\n(function (Address) {\n let _codec;\n Address.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.multiaddr != null && obj.multiaddr.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.multiaddr);\n }\n if (obj.isCertified != null) {\n w.uint32(16);\n w.bool(obj.isCertified);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n multiaddr: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.multiaddr = reader.bytes();\n break;\n case 2:\n obj.isCertified = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Address.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Address.codec());\n };\n Address.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Address.codec());\n };\n})(Address || (Address = {}));\nvar Tag;\n(function (Tag) {\n let _codec;\n Tag.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.value != null && obj.value !== 0)) {\n w.uint32(8);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(16);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n value: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.value = reader.uint32();\n break;\n case 2:\n obj.expiry = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Tag.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tag.codec());\n };\n Tag.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tag.codec());\n };\n})(Tag || (Tag = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/pb/peer.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/store.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/store.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PersistentStore: () => (/* binding */ PersistentStore)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/peer-store/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var _utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/bytes-to-peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js\");\n/* harmony import */ var _utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/peer-id-to-datastore-key.js */ \"./node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js\");\n/* harmony import */ var _utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils/to-peer-pb.js */ \"./node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js\");\n\n\n\n\n\n\n\n\n\n\n\nfunction decodePeer(key, value, cache) {\n // /peers/${peer-id-as-libp2p-key-cid-string-in-base-32}\n const base32Str = key.toString().split('/')[2];\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.decode(base32Str);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromBytes)(buf);\n const cached = cache.get(peerId);\n if (cached != null) {\n return cached;\n }\n const peer = (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__.bytesToPeer)(peerId, value);\n cache.set(peerId, peer);\n return peer;\n}\nfunction mapQuery(query, cache) {\n if (query == null) {\n return {};\n }\n return {\n prefix: _utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.NAMESPACE_COMMON,\n filters: (query.filters ?? []).map(fn => ({ key, value }) => {\n return fn(decodePeer(key, value, cache));\n }),\n orders: (query.orders ?? []).map(fn => (a, b) => {\n return fn(decodePeer(a.key, a.value, cache), decodePeer(b.key, b.value, cache));\n })\n };\n}\nclass PersistentStore {\n peerId;\n datastore;\n lock;\n addressFilter;\n constructor(components, init = {}) {\n this.peerId = components.peerId;\n this.datastore = components.datastore;\n this.addressFilter = init.addressFilter;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_0__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n async has(peerId) {\n return this.datastore.has((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.peerIdToDatastoreKey)(peerId));\n }\n async delete(peerId) {\n if (this.peerId.equals(peerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_6__.CodeError('Cannot delete self peer', _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PARAMETERS);\n }\n await this.datastore.delete((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.peerIdToDatastoreKey)(peerId));\n }\n async load(peerId) {\n const buf = await this.datastore.get((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.peerIdToDatastoreKey)(peerId));\n return (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__.bytesToPeer)(peerId, buf);\n }\n async save(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_8__.toPeerPB)(peerId, data, 'patch', {\n addressFilter: this.addressFilter\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async patch(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_8__.toPeerPB)(peerId, data, 'patch', {\n addressFilter: this.addressFilter,\n existingPeer\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async merge(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_8__.toPeerPB)(peerId, data, 'merge', {\n addressFilter: this.addressFilter,\n existingPeer\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async *all(query) {\n const peerCache = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_9__.PeerMap();\n for await (const { key, value } of this.datastore.query(mapQuery(query ?? {}, peerCache))) {\n const peer = decodePeer(key, value, peerCache);\n if (peer.id.equals(this.peerId)) {\n // Skip self peer if present\n continue;\n }\n yield peer;\n }\n }\n async #findExistingPeer(peerId) {\n try {\n const existingBuf = await this.datastore.get((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.peerIdToDatastoreKey)(peerId));\n const existingPeer = (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__.bytesToPeer)(peerId, existingBuf);\n return {\n existingBuf,\n existingPeer\n };\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n return {};\n }\n async #saveIfDifferent(peerId, peer, existingBuf, existingPeer) {\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_10__.Peer.encode(peer);\n if (existingBuf != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(buf, existingBuf)) {\n return {\n peer: (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__.bytesToPeer)(peerId, buf),\n previous: existingPeer,\n updated: false\n };\n }\n await this.datastore.put((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_5__.peerIdToDatastoreKey)(peerId), buf);\n return {\n peer: (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_4__.bytesToPeer)(peerId, buf),\n previous: existingPeer,\n updated: true\n };\n }\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/store.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bytesToPeer: () => (/* binding */ bytesToPeer)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n\n\n\nfunction bytesToPeer(peerId, buf) {\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_1__.Peer.decode(buf);\n if (peer.publicKey != null && peerId.publicKey == null) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromPeerId)({\n ...peerId,\n publicKey: peerId.publicKey\n });\n }\n const tags = new Map();\n // remove any expired tags\n const now = BigInt(Date.now());\n for (const [key, tag] of peer.tags.entries()) {\n if (tag.expiry != null && tag.expiry < now) {\n continue;\n }\n tags.set(key, tag);\n }\n return {\n ...peer,\n id: peerId,\n addresses: peer.addresses.map(({ multiaddr: ma, isCertified }) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata: peer.metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined,\n tags\n };\n}\n//# sourceMappingURL=bytes-to-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ dedupeFilterAndSortAddresses: () => (/* binding */ dedupeFilterAndSortAddresses)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n\n\n\nasync function dedupeFilterAndSortAddresses(peerId, filter, addresses) {\n const addressMap = new Map();\n for (const addr of addresses) {\n if (addr == null) {\n continue;\n }\n if (addr.multiaddr instanceof Uint8Array) {\n addr.multiaddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(addr.multiaddr);\n }\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.isMultiaddr)(addr.multiaddr)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Multiaddr was invalid', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (!(await filter(peerId, addr.multiaddr))) {\n continue;\n }\n const isCertified = addr.isCertified ?? false;\n const maStr = addr.multiaddr.toString();\n const existingAddr = addressMap.get(maStr);\n if (existingAddr != null) {\n addr.isCertified = existingAddr.isCertified || isCertified;\n }\n else {\n addressMap.set(maStr, {\n multiaddr: addr.multiaddr,\n isCertified\n });\n }\n }\n return [...addressMap.values()]\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ isCertified, multiaddr }) => ({\n isCertified,\n multiaddr: multiaddr.bytes\n }));\n}\n//# sourceMappingURL=dedupe-addresses.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NAMESPACE_COMMON: () => (/* binding */ NAMESPACE_COMMON),\n/* harmony export */ peerIdToDatastoreKey: () => (/* binding */ peerIdToDatastoreKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-id/index.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n\n\n\n\nconst NAMESPACE_COMMON = '/peers/';\nfunction peerIdToDatastoreKey(peerId) {\n if (!(0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.isPeerId)(peerId) || peerId.type == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('Invalid PeerId', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const b32key = peerId.toCID().toString();\n return new interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__.Key(`${NAMESPACE_COMMON}${b32key}`);\n}\n//# sourceMappingURL=peer-id-to-datastore-key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toPeerPB: () => (/* binding */ toPeerPB)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/peer-store/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var _dedupe_addresses_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dedupe-addresses.js */ \"./node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js\");\n\n\n\n\nasync function toPeerPB(peerId, data, strategy, options) {\n if (data == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Invalid PeerData', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (data.publicKey != null && peerId.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_0__.equals)(data.publicKey, peerId.publicKey)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n const existingPeer = options.existingPeer;\n if (existingPeer != null && !peerId.equals(existingPeer.id)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('peer id did not match existing peer id', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n let addresses = existingPeer?.addresses ?? [];\n let protocols = new Set(existingPeer?.protocols ?? []);\n let metadata = existingPeer?.metadata ?? new Map();\n let tags = existingPeer?.tags ?? new Map();\n let peerRecordEnvelope = existingPeer?.peerRecordEnvelope;\n // when patching, we replace the original fields with passed values\n if (strategy === 'patch') {\n if (data.multiaddrs != null || data.addresses != null) {\n addresses = [];\n if (data.multiaddrs != null) {\n addresses.push(...data.multiaddrs.map(multiaddr => ({\n isCertified: false,\n multiaddr\n })));\n }\n if (data.addresses != null) {\n addresses.push(...data.addresses);\n }\n }\n if (data.protocols != null) {\n protocols = new Set(data.protocols);\n }\n if (data.metadata != null) {\n const metadataEntries = data.metadata instanceof Map ? [...data.metadata.entries()] : Object.entries(data.metadata);\n metadata = createSortedMap(metadataEntries, {\n validate: validateMetadata\n });\n }\n if (data.tags != null) {\n const tagsEntries = data.tags instanceof Map ? [...data.tags.entries()] : Object.entries(data.tags);\n tags = createSortedMap(tagsEntries, {\n validate: validateTag,\n map: mapTag\n });\n }\n if (data.peerRecordEnvelope != null) {\n peerRecordEnvelope = data.peerRecordEnvelope;\n }\n }\n // when merging, we join the original fields with passed values\n if (strategy === 'merge') {\n if (data.multiaddrs != null) {\n addresses.push(...data.multiaddrs.map(multiaddr => ({\n isCertified: false,\n multiaddr\n })));\n }\n if (data.addresses != null) {\n addresses.push(...data.addresses);\n }\n if (data.protocols != null) {\n protocols = new Set([...protocols, ...data.protocols]);\n }\n if (data.metadata != null) {\n const metadataEntries = data.metadata instanceof Map ? [...data.metadata.entries()] : Object.entries(data.metadata);\n for (const [key, value] of metadataEntries) {\n if (value == null) {\n metadata.delete(key);\n }\n else {\n metadata.set(key, value);\n }\n }\n metadata = createSortedMap([...metadata.entries()], {\n validate: validateMetadata\n });\n }\n if (data.tags != null) {\n const tagsEntries = data.tags instanceof Map ? [...data.tags.entries()] : Object.entries(data.tags);\n const mergedTags = new Map(tags);\n for (const [key, value] of tagsEntries) {\n if (value == null) {\n mergedTags.delete(key);\n }\n else {\n mergedTags.set(key, value);\n }\n }\n tags = createSortedMap([...mergedTags.entries()], {\n validate: validateTag,\n map: mapTag\n });\n }\n if (data.peerRecordEnvelope != null) {\n peerRecordEnvelope = data.peerRecordEnvelope;\n }\n }\n const output = {\n addresses: await (0,_dedupe_addresses_js__WEBPACK_IMPORTED_MODULE_3__.dedupeFilterAndSortAddresses)(peerId, options.addressFilter ?? (async () => true), addresses),\n protocols: [...protocols.values()].sort((a, b) => {\n return a.localeCompare(b);\n }),\n metadata,\n tags,\n publicKey: existingPeer?.id.publicKey ?? data.publicKey ?? peerId.publicKey,\n peerRecordEnvelope\n };\n // Ed25519 and secp256k1 have their public key embedded in them so no need to duplicate it\n if (peerId.type !== 'RSA') {\n delete output.publicKey;\n }\n return output;\n}\n/**\n * In JS maps are ordered by insertion order so create a new map with the\n * keys inserted in alphabetical order.\n */\nfunction createSortedMap(entries, options) {\n const output = new Map();\n for (const [key, value] of entries) {\n if (value == null) {\n continue;\n }\n options.validate(key, value);\n }\n for (const [key, value] of entries.sort(([a], [b]) => {\n return a.localeCompare(b);\n })) {\n if (value != null) {\n output.set(key, options.map?.(key, value) ?? value);\n }\n }\n return output;\n}\nfunction validateMetadata(key, value) {\n if (typeof key !== 'string') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Metadata key must be a string', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (!(value instanceof Uint8Array)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Metadata value must be a Uint8Array', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n}\nfunction validateTag(key, tag) {\n if (typeof key !== 'string') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tag name must be a string', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.value != null) {\n if (parseInt(`${tag.value}`, 10) !== tag.value) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tag value must be an integer', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.value < 0 || tag.value > 100) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tag value must be between 0-100', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n if (tag.ttl != null) {\n if (parseInt(`${tag.ttl}`, 10) !== tag.ttl) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tag ttl must be an integer', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.ttl < 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tag ttl must be between greater than 0', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n}\nfunction mapTag(key, tag) {\n let expiry;\n if (tag.expiry != null) {\n expiry = tag.expiry;\n }\n if (tag.ttl != null) {\n expiry = BigInt(Date.now() + Number(tag.ttl));\n }\n return {\n value: tag.value ?? 0,\n expiry\n };\n}\n//# sourceMappingURL=to-peer-pb.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-store/node_modules/uint8arrays/dist/src/equals.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-store/node_modules/uint8arrays/dist/src/equals.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/ping/dist/src/constants.js": +/*!*********************************************************!*\ + !*** ./node_modules/@libp2p/ping/dist/src/constants.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ERR_WRONG_PING_ACK: () => (/* binding */ ERR_WRONG_PING_ACK),\n/* harmony export */ MAX_INBOUND_STREAMS: () => (/* binding */ MAX_INBOUND_STREAMS),\n/* harmony export */ MAX_OUTBOUND_STREAMS: () => (/* binding */ MAX_OUTBOUND_STREAMS),\n/* harmony export */ PING_LENGTH: () => (/* binding */ PING_LENGTH),\n/* harmony export */ PING_PROTOCOL: () => (/* binding */ PING_PROTOCOL),\n/* harmony export */ PROTOCOL_NAME: () => (/* binding */ PROTOCOL_NAME),\n/* harmony export */ PROTOCOL_PREFIX: () => (/* binding */ PROTOCOL_PREFIX),\n/* harmony export */ PROTOCOL_VERSION: () => (/* binding */ PROTOCOL_VERSION),\n/* harmony export */ TIMEOUT: () => (/* binding */ TIMEOUT)\n/* harmony export */ });\nconst PING_PROTOCOL = '/ipfs/ping/1.0.0';\nconst PING_LENGTH = 32;\nconst PROTOCOL_VERSION = '1.0.0';\nconst PROTOCOL_NAME = 'ping';\nconst PROTOCOL_PREFIX = 'ipfs';\nconst TIMEOUT = 10000;\n// See https://github.com/libp2p/specs/blob/d4b5fb0152a6bb86cfd9ea/ping/ping.md?plain=1#L38-L43\n// The dialing peer MUST NOT keep more than one outbound stream for the ping protocol per peer.\n// The listening peer SHOULD accept at most two streams per peer since cross-stream behavior is\n// non-linear and stream writes occur asynchronously. The listening peer may perceive the\n// dialing peer closing and opening the wrong streams (for instance, closing stream B and\n// opening stream A even though the dialing peer is opening stream B and closing stream A).\nconst MAX_INBOUND_STREAMS = 2;\nconst MAX_OUTBOUND_STREAMS = 1;\nconst ERR_WRONG_PING_ACK = 'ERR_WRONG_PING_ACK';\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/ping/dist/src/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/ping/dist/src/index.js": +/*!*****************************************************!*\ + !*** ./node_modules/@libp2p/ping/dist/src/index.js ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PING_PROTOCOL: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_1__.PING_PROTOCOL),\n/* harmony export */ ping: () => (/* binding */ ping)\n/* harmony export */ });\n/* harmony import */ var _ping_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ping.js */ \"./node_modules/@libp2p/ping/dist/src/ping.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/ping/dist/src/constants.js\");\n/**\n * @packageDocumentation\n *\n * The ping service implements the [libp2p ping spec](https://github.com/libp2p/specs/blob/master/ping/ping.md) allowing you to make a latency measurement to a remote peer.\n *\n * @example\n *\n * ```typescript\n * import { createLibp2p } from 'libp2p'\n * import { ping } from '@libp2p/ping'\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * const node = await createLibp2p({\n * services: {\n * ping: ping()\n * }\n * })\n *\n * const rtt = await node.services.ping.ping(multiaddr('/ip4/...'))\n *\n * console.info(rtt)\n * ```\n */\n\nfunction ping(init = {}) {\n return (components) => new _ping_js__WEBPACK_IMPORTED_MODULE_0__.PingService(components, init);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/ping/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/ping/dist/src/ping.js": +/*!****************************************************!*\ + !*** ./node_modules/@libp2p/ping/dist/src/ping.js ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PingService: () => (/* binding */ PingService)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-first */ \"./node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@libp2p/ping/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/ping/dist/src/constants.js\");\n\n\n\n\n\n\nclass PingService {\n protocol;\n components;\n started;\n timeout;\n maxInboundStreams;\n maxOutboundStreams;\n runOnTransientConnection;\n log;\n constructor(components, init = {}) {\n this.components = components;\n this.log = components.logger.forComponent('libp2p:ping');\n this.started = false;\n this.protocol = `/${init.protocolPrefix ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_PREFIX}/${_constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_VERSION}`;\n this.timeout = init.timeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.TIMEOUT;\n this.maxInboundStreams = init.maxInboundStreams ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.MAX_INBOUND_STREAMS;\n this.maxOutboundStreams = init.maxOutboundStreams ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.MAX_OUTBOUND_STREAMS;\n this.runOnTransientConnection = init.runOnTransientConnection ?? true;\n this.handleMessage = this.handleMessage.bind(this);\n }\n async start() {\n await this.components.registrar.handle(this.protocol, this.handleMessage, {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams,\n runOnTransientConnection: this.runOnTransientConnection\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.protocol);\n this.started = false;\n }\n isStarted() {\n return this.started;\n }\n /**\n * A handler to register with Libp2p to process ping messages\n */\n handleMessage(data) {\n this.log('incoming ping from %p', data.connection.remotePeer);\n const { stream } = data;\n const start = Date.now();\n void (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(stream, stream)\n .catch(err => {\n this.log.error('incoming ping from %p failed with error', data.connection.remotePeer, err);\n })\n .finally(() => {\n const ms = Date.now() - start;\n this.log('incoming ping from %p complete in %dms', data.connection.remotePeer, ms);\n });\n }\n /**\n * Ping a given peer and wait for its response, getting the operation latency.\n */\n async ping(peer, options = {}) {\n this.log('pinging %p', peer);\n const start = Date.now();\n const data = (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(_constants_js__WEBPACK_IMPORTED_MODULE_3__.PING_LENGTH);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let stream;\n let onAbort = () => { };\n if (options.signal == null) {\n const signal = AbortSignal.timeout(this.timeout);\n options = {\n ...options,\n signal\n };\n }\n try {\n stream = await connection.newStream(this.protocol, {\n ...options,\n runOnTransientConnection: this.runOnTransientConnection\n });\n onAbort = () => {\n stream?.abort(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError('ping timeout', _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.ERR_TIMEOUT));\n };\n // make stream abortable\n options.signal?.addEventListener('abort', onAbort, { once: true });\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)([data], stream, async (source) => (0,it_first__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source));\n const ms = Date.now() - start;\n if (result == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Did not receive a ping ack after ${ms}ms`, _constants_js__WEBPACK_IMPORTED_MODULE_3__.ERR_WRONG_PING_ACK);\n }\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(data, result.subarray())) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Received wrong ping ack after ${ms}ms`, _constants_js__WEBPACK_IMPORTED_MODULE_3__.ERR_WRONG_PING_ACK);\n }\n this.log('ping %p complete in %dms', connection.remotePeer, ms);\n return ms;\n }\n catch (err) {\n this.log.error('error while pinging %p', connection.remotePeer, err);\n stream?.abort(err);\n throw err;\n }\n finally {\n options.signal?.removeEventListener('abort', onAbort);\n if (stream != null) {\n await stream.close();\n }\n }\n }\n}\n//# sourceMappingURL=ping.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/ping/dist/src/ping.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/ping/node_modules/uint8arrays/dist/src/equals.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@libp2p/ping/node_modules/uint8arrays/dist/src/equals.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/**\n * Returns true if the two passed Uint8Arrays have the same content\n */\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=equals.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/ping/node_modules/uint8arrays/dist/src/equals.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/dist/src/errors.js": +/*!********************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/dist/src/errors.js ***! + \********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes)\n/* harmony export */ });\nconst codes = {\n /**\n * Signature policy is invalid\n */\n ERR_INVALID_SIGNATURE_POLICY: 'ERR_INVALID_SIGNATURE_POLICY',\n /**\n * Signature policy is unhandled\n */\n ERR_UNHANDLED_SIGNATURE_POLICY: 'ERR_UNHANDLED_SIGNATURE_POLICY',\n // Strict signing codes\n /**\n * Message expected to have a `signature`, but doesn't\n */\n ERR_MISSING_SIGNATURE: 'ERR_MISSING_SIGNATURE',\n /**\n * Message expected to have a `seqno`, but doesn't\n */\n ERR_MISSING_SEQNO: 'ERR_MISSING_SEQNO',\n /**\n * Message expected to have a `key`, but doesn't\n */\n ERR_MISSING_KEY: 'ERR_MISSING_KEY',\n /**\n * Message `signature` is invalid\n */\n ERR_INVALID_SIGNATURE: 'ERR_INVALID_SIGNATURE',\n /**\n * Message expected to have a `from`, but doesn't\n */\n ERR_MISSING_FROM: 'ERR_MISSING_FROM',\n // Strict no-signing codes\n /**\n * Message expected to not have a `from`, but does\n */\n ERR_UNEXPECTED_FROM: 'ERR_UNEXPECTED_FROM',\n /**\n * Message expected to not have a `signature`, but does\n */\n ERR_UNEXPECTED_SIGNATURE: 'ERR_UNEXPECTED_SIGNATURE',\n /**\n * Message expected to not have a `key`, but does\n */\n ERR_UNEXPECTED_KEY: 'ERR_UNEXPECTED_KEY',\n /**\n * Message expected to not have a `seqno`, but does\n */\n ERR_UNEXPECTED_SEQNO: 'ERR_UNEXPECTED_SEQNO',\n /**\n * Message failed topic validator\n */\n ERR_TOPIC_VALIDATOR_REJECT: 'ERR_TOPIC_VALIDATOR_REJECT'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/dist/src/errors.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/dist/src/utils.js": +/*!*******************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/dist/src/utils.js ***! + \*******************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ anyMatch: () => (/* binding */ anyMatch),\n/* harmony export */ bigIntFromBytes: () => (/* binding */ bigIntFromBytes),\n/* harmony export */ bigIntToBytes: () => (/* binding */ bigIntToBytes),\n/* harmony export */ ensureArray: () => (/* binding */ ensureArray),\n/* harmony export */ msgId: () => (/* binding */ msgId),\n/* harmony export */ noSignMsgId: () => (/* binding */ noSignMsgId),\n/* harmony export */ randomSeqno: () => (/* binding */ randomSeqno),\n/* harmony export */ toMessage: () => (/* binding */ toMessage),\n/* harmony export */ toRpcMessage: () => (/* binding */ toRpcMessage)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/pubsub/dist/src/errors.js\");\n\n\n\n\n\n\n\n/**\n * Generate a random sequence number\n */\nfunction randomSeqno() {\n return BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(8), 'base16')}`);\n}\n/**\n * Generate a message id, based on the `key` and `seqno`\n */\nconst msgId = (key, seqno) => {\n const seqnoBytes = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(seqno.toString(16).padStart(16, '0'), 'base16');\n const msgId = new Uint8Array(key.length + seqnoBytes.length);\n msgId.set(key, 0);\n msgId.set(seqnoBytes, key.length);\n return msgId;\n};\n/**\n * Generate a message id, based on message `data`\n */\nconst noSignMsgId = (data) => {\n return multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.encode(data);\n};\n/**\n * Check if any member of the first set is also a member\n * of the second set\n */\nconst anyMatch = (a, b) => {\n let bHas;\n if (Array.isArray(b)) {\n bHas = (val) => b.includes(val);\n }\n else {\n bHas = (val) => b.has(val);\n }\n for (const val of a) {\n if (bHas(val)) {\n return true;\n }\n }\n return false;\n};\n/**\n * Make everything an array\n */\nconst ensureArray = function (maybeArray) {\n if (!Array.isArray(maybeArray)) {\n return [maybeArray];\n }\n return maybeArray;\n};\nconst isSigned = async (message) => {\n if ((message.sequenceNumber == null) || (message.from == null) || (message.signature == null)) {\n return false;\n }\n // if a public key is present in the `from` field, the message should be signed\n const fromID = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromBytes)(message.from);\n if (fromID.publicKey != null) {\n return true;\n }\n if (message.key != null) {\n const signingID = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromKeys)(message.key);\n return signingID.equals(fromID);\n }\n return false;\n};\nconst toMessage = async (message) => {\n if (message.from == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_FROM);\n }\n if (!await isSigned(message)) {\n return {\n type: 'unsigned',\n topic: message.topic ?? '',\n data: message.data ?? new Uint8Array(0)\n };\n }\n const from = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromBytes)(message.from);\n const msg = {\n type: 'signed',\n from: (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromBytes)(message.from),\n topic: message.topic ?? '',\n sequenceNumber: bigIntFromBytes(message.sequenceNumber ?? new Uint8Array(0)),\n data: message.data ?? new Uint8Array(0),\n signature: message.signature ?? new Uint8Array(0),\n key: message.key ?? from.publicKey ?? new Uint8Array(0)\n };\n if (msg.key.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_KEY);\n }\n return msg;\n};\nconst toRpcMessage = (message) => {\n if (message.type === 'signed') {\n return {\n from: message.from.multihash.bytes,\n data: message.data,\n sequenceNumber: bigIntToBytes(message.sequenceNumber),\n topic: message.topic,\n signature: message.signature,\n key: message.key\n };\n }\n return {\n data: message.data,\n topic: message.topic\n };\n};\nconst bigIntToBytes = (num) => {\n let str = num.toString(16);\n if (str.length % 2 !== 0) {\n str = `0${str}`;\n }\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(str, 'base16');\n};\nconst bigIntFromBytes = (num) => {\n return BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(num, 'base16')}`);\n};\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/dist/src/utils.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/alloc.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/alloc.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/from-string.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/from-string.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/to-string.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/to-string.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/util/bases.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/util/bases.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/pubsub/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/abstract-stream.js": +/*!****************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/abstract-stream.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbstractStream: () => (/* binding */ AbstractStream)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var race_signal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! race-signal */ \"./node_modules/race-signal/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _close_source_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./close-source.js */ \"./node_modules/@libp2p/utils/dist/src/close-source.js\");\n\n\n\n\n\n\n\nconst ERR_STREAM_RESET = 'ERR_STREAM_RESET';\nconst ERR_SINK_INVALID_STATE = 'ERR_SINK_INVALID_STATE';\nconst DEFAULT_SEND_CLOSE_WRITE_TIMEOUT = 5000;\nfunction isPromise(thing) {\n if (thing == null) {\n return false;\n }\n return typeof thing.then === 'function' &&\n typeof thing.catch === 'function' &&\n typeof thing.finally === 'function';\n}\nclass AbstractStream {\n id;\n direction;\n timeline;\n protocol;\n metadata;\n source;\n status;\n readStatus;\n writeStatus;\n log;\n sinkController;\n sinkEnd;\n closed;\n endErr;\n streamSource;\n onEnd;\n onCloseRead;\n onCloseWrite;\n onReset;\n onAbort;\n sendCloseWriteTimeout;\n sendingData;\n constructor(init) {\n this.sinkController = new AbortController();\n this.sinkEnd = (0,p_defer__WEBPACK_IMPORTED_MODULE_3__[\"default\"])();\n this.closed = (0,p_defer__WEBPACK_IMPORTED_MODULE_3__[\"default\"])();\n this.log = init.log;\n // stream status\n this.status = 'open';\n this.readStatus = 'ready';\n this.writeStatus = 'ready';\n this.id = init.id;\n this.metadata = init.metadata ?? {};\n this.direction = init.direction;\n this.timeline = {\n open: Date.now()\n };\n this.sendCloseWriteTimeout = init.sendCloseWriteTimeout ?? DEFAULT_SEND_CLOSE_WRITE_TIMEOUT;\n this.onEnd = init.onEnd;\n this.onCloseRead = init?.onCloseRead;\n this.onCloseWrite = init?.onCloseWrite;\n this.onReset = init?.onReset;\n this.onAbort = init?.onAbort;\n this.source = this.streamSource = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n onEnd: (err) => {\n if (err != null) {\n this.log.trace('source ended with error', err);\n }\n else {\n this.log.trace('source ended');\n }\n this.onSourceEnd(err);\n }\n });\n // necessary because the libp2p upgrader wraps the sink function\n this.sink = this.sink.bind(this);\n }\n async sink(source) {\n if (this.writeStatus !== 'ready') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError(`writable end state is \"${this.writeStatus}\" not \"ready\"`, ERR_SINK_INVALID_STATE);\n }\n try {\n this.writeStatus = 'writing';\n const options = {\n signal: this.sinkController.signal\n };\n if (this.direction === 'outbound') { // If initiator, open a new stream\n const res = this.sendNewStream(options);\n if (isPromise(res)) {\n await res;\n }\n }\n const abortListener = () => {\n (0,_close_source_js__WEBPACK_IMPORTED_MODULE_5__.closeSource)(source, this.log);\n };\n try {\n this.sinkController.signal.addEventListener('abort', abortListener);\n this.log.trace('sink reading from source');\n for await (let data of source) {\n data = data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList(data) : data;\n const res = this.sendData(data, options);\n if (isPromise(res)) {\n this.sendingData = (0,p_defer__WEBPACK_IMPORTED_MODULE_3__[\"default\"])();\n await res;\n this.sendingData.resolve();\n this.sendingData = undefined;\n }\n }\n }\n finally {\n this.sinkController.signal.removeEventListener('abort', abortListener);\n }\n this.log.trace('sink finished reading from source, write status is \"%s\"', this.writeStatus);\n if (this.writeStatus === 'writing') {\n this.writeStatus = 'closing';\n this.log.trace('send close write to remote');\n await this.sendCloseWrite({\n signal: AbortSignal.timeout(this.sendCloseWriteTimeout)\n });\n this.writeStatus = 'closed';\n }\n this.onSinkEnd();\n }\n catch (err) {\n this.log.trace('sink ended with error, calling abort with error', err);\n this.abort(err);\n throw err;\n }\n finally {\n this.log.trace('resolve sink end');\n this.sinkEnd.resolve();\n }\n }\n onSourceEnd(err) {\n if (this.timeline.closeRead != null) {\n return;\n }\n this.timeline.closeRead = Date.now();\n this.readStatus = 'closed';\n if (err != null && this.endErr == null) {\n this.endErr = err;\n }\n this.onCloseRead?.();\n if (this.timeline.closeWrite != null) {\n this.log.trace('source and sink ended');\n this.timeline.close = Date.now();\n if (this.status !== 'aborted' && this.status !== 'reset') {\n this.status = 'closed';\n }\n if (this.onEnd != null) {\n this.onEnd(this.endErr);\n }\n this.closed.resolve();\n }\n else {\n this.log.trace('source ended, waiting for sink to end');\n }\n }\n onSinkEnd(err) {\n if (this.timeline.closeWrite != null) {\n return;\n }\n this.timeline.closeWrite = Date.now();\n this.writeStatus = 'closed';\n if (err != null && this.endErr == null) {\n this.endErr = err;\n }\n this.onCloseWrite?.();\n if (this.timeline.closeRead != null) {\n this.log.trace('sink and source ended');\n this.timeline.close = Date.now();\n if (this.status !== 'aborted' && this.status !== 'reset') {\n this.status = 'closed';\n }\n if (this.onEnd != null) {\n this.onEnd(this.endErr);\n }\n this.closed.resolve();\n }\n else {\n this.log.trace('sink ended, waiting for source to end');\n }\n }\n // Close for both Reading and Writing\n async close(options) {\n this.log.trace('closing gracefully');\n this.status = 'closing';\n // wait for read and write ends to close\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_1__.raceSignal)(Promise.all([\n this.closeWrite(options),\n this.closeRead(options),\n this.closed.promise\n ]), options?.signal);\n this.status = 'closed';\n this.log.trace('closed gracefully');\n }\n async closeRead(options = {}) {\n if (this.readStatus === 'closing' || this.readStatus === 'closed') {\n return;\n }\n this.log.trace('closing readable end of stream with starting read status \"%s\"', this.readStatus);\n const readStatus = this.readStatus;\n this.readStatus = 'closing';\n if (this.status !== 'reset' && this.status !== 'aborted' && this.timeline.closeRead == null) {\n this.log.trace('send close read to remote');\n await this.sendCloseRead(options);\n }\n if (readStatus === 'ready') {\n this.log.trace('ending internal source queue with %d queued bytes', this.streamSource.readableLength);\n this.streamSource.end();\n }\n this.log.trace('closed readable end of stream');\n }\n async closeWrite(options = {}) {\n if (this.writeStatus === 'closing' || this.writeStatus === 'closed') {\n return;\n }\n this.log.trace('closing writable end of stream with starting write status \"%s\"', this.writeStatus);\n if (this.writeStatus === 'ready') {\n this.log.trace('sink was never sunk, sink an empty array');\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_1__.raceSignal)(this.sink([]), options.signal);\n }\n if (this.writeStatus === 'writing') {\n // try to let sending outgoing data succeed\n if (this.sendingData != null) {\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_1__.raceSignal)(this.sendingData.promise, options.signal);\n }\n // stop reading from the source passed to `.sink`\n this.log.trace('aborting source passed to .sink');\n this.sinkController.abort();\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_1__.raceSignal)(this.sinkEnd.promise, options.signal);\n }\n this.writeStatus = 'closed';\n this.log.trace('closed writable end of stream');\n }\n /**\n * Close immediately for reading and writing and send a reset message (local\n * error)\n */\n abort(err) {\n if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {\n return;\n }\n this.log('abort with error', err);\n // try to send a reset message\n this.log('try to send reset to remote');\n const res = this.sendReset();\n if (isPromise(res)) {\n res.catch((err) => {\n this.log.error('error sending reset message', err);\n });\n }\n this.status = 'aborted';\n this.timeline.abort = Date.now();\n this._closeSinkAndSource(err);\n this.onAbort?.(err);\n }\n /**\n * Receive a reset message - close immediately for reading and writing (remote\n * error)\n */\n reset() {\n if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {\n return;\n }\n const err = new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('stream reset', ERR_STREAM_RESET);\n this.status = 'reset';\n this.timeline.reset = Date.now();\n this._closeSinkAndSource(err);\n this.onReset?.();\n }\n _closeSinkAndSource(err) {\n this._closeSink(err);\n this._closeSource(err);\n }\n _closeSink(err) {\n // if the sink function is running, cause it to end\n if (this.writeStatus === 'writing') {\n this.log.trace('end sink source');\n this.sinkController.abort();\n }\n this.onSinkEnd(err);\n }\n _closeSource(err) {\n // if the source is not ending, end it\n if (this.readStatus !== 'closing' && this.readStatus !== 'closed') {\n this.log.trace('ending source with %d bytes to be read by consumer', this.streamSource.readableLength);\n this.readStatus = 'closing';\n this.streamSource.end(err);\n }\n }\n /**\n * The remote closed for writing so we should expect to receive no more\n * messages\n */\n remoteCloseWrite() {\n if (this.readStatus === 'closing' || this.readStatus === 'closed') {\n this.log('received remote close write but local source is already closed');\n return;\n }\n this.log.trace('remote close write');\n this._closeSource();\n }\n /**\n * The remote closed for reading so we should not send any more\n * messages\n */\n remoteCloseRead() {\n if (this.writeStatus === 'closing' || this.writeStatus === 'closed') {\n this.log('received remote close read but local sink is already closed');\n return;\n }\n this.log.trace('remote close read');\n this._closeSink();\n }\n /**\n * The underlying muxer has closed, no more messages can be sent or will\n * be received, close immediately to free up resources\n */\n destroy() {\n if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {\n this.log('received destroy but we are already closed');\n return;\n }\n this.log.trace('stream destroyed');\n this._closeSinkAndSource();\n }\n /**\n * When an extending class reads data from it's implementation-specific source,\n * call this method to allow the stream consumer to read the data.\n */\n sourcePush(data) {\n this.streamSource.push(data);\n }\n /**\n * Returns the amount of unread data - can be used to prevent large amounts of\n * data building up when the stream consumer is too slow.\n */\n sourceReadableLength() {\n return this.streamSource.readableLength;\n }\n}\n//# sourceMappingURL=abstract-stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/abstract-stream.js?"); /***/ }), @@ -3277,7 +3933,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ publicAddressesFirst: () => (/* binding */ publicAddressesFirst),\n/* harmony export */ something: () => (/* binding */ something)\n/* harmony export */ });\n/* harmony import */ var _multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./multiaddr/is-private.js */ \"./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js\");\n/**\n * @packageDocumentation\n *\n * Provides strategies to sort a list of multiaddrs.\n *\n * @example\n *\n * ```typescript\n * import { publicAddressesFirst } from '@libp2p/utils/address-sort'\n * import { multiaddr } from '@multformats/multiaddr'\n *\n *\n * const addresses = [\n * multiaddr('/ip4/127.0.0.1/tcp/9000'),\n * multiaddr('/ip4/82.41.53.1/tcp/9000')\n * ].sort(publicAddressesFirst)\n *\n * console.info(addresses)\n * // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']\n * ```\n */\n\n/**\n * Compare function for array.sort().\n * This sort aims to move the private addresses to the end of the array.\n * In case of equality, a certified address will come first.\n */\nfunction publicAddressesFirst(a, b) {\n const isAPrivate = (0,_multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_0__.isPrivate)(a.multiaddr);\n const isBPrivate = (0,_multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_0__.isPrivate)(b.multiaddr);\n if (isAPrivate && !isBPrivate) {\n return 1;\n }\n else if (!isAPrivate && isBPrivate) {\n return -1;\n }\n // Check certified?\n if (a.isCertified && !b.isCertified) {\n return -1;\n }\n else if (!a.isCertified && b.isCertified) {\n return 1;\n }\n return 0;\n}\n/**\n * A test thing\n */\nasync function something() {\n return Uint8Array.from([0, 1, 2]);\n}\n//# sourceMappingURL=address-sort.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/address-sort.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ certifiedAddressesFirst: () => (/* binding */ certifiedAddressesFirst),\n/* harmony export */ circuitRelayAddressesLast: () => (/* binding */ circuitRelayAddressesLast),\n/* harmony export */ defaultAddressSort: () => (/* binding */ defaultAddressSort),\n/* harmony export */ publicAddressesFirst: () => (/* binding */ publicAddressesFirst)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr-matcher */ \"./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js\");\n/* harmony import */ var _multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./multiaddr/is-private.js */ \"./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js\");\n/**\n * @packageDocumentation\n *\n * Provides strategies to sort a list of multiaddrs.\n *\n * @example\n *\n * ```typescript\n * import { publicAddressesFirst } from '@libp2p/utils/address-sort'\n * import { multiaddr } from '@multformats/multiaddr'\n *\n *\n * const addresses = [\n * multiaddr('/ip4/127.0.0.1/tcp/9000'),\n * multiaddr('/ip4/82.41.53.1/tcp/9000')\n * ].sort(publicAddressesFirst)\n *\n * console.info(addresses)\n * // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']\n * ```\n */\n\n\n/**\n * Compare function for array.sort() that moves public addresses to the start\n * of the array.\n */\nfunction publicAddressesFirst(a, b) {\n const isAPrivate = (0,_multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_1__.isPrivate)(a.multiaddr);\n const isBPrivate = (0,_multiaddr_is_private_js__WEBPACK_IMPORTED_MODULE_1__.isPrivate)(b.multiaddr);\n if (isAPrivate && !isBPrivate) {\n return 1;\n }\n else if (!isAPrivate && isBPrivate) {\n return -1;\n }\n return 0;\n}\n/**\n * Compare function for array.sort() that moves certified addresses to the start\n * of the array.\n */\nfunction certifiedAddressesFirst(a, b) {\n if (a.isCertified && !b.isCertified) {\n return -1;\n }\n else if (!a.isCertified && b.isCertified) {\n return 1;\n }\n return 0;\n}\n/**\n * Compare function for array.sort() that moves circuit relay addresses to the\n * start of the array.\n */\nfunction circuitRelayAddressesLast(a, b) {\n const isACircuit = _multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_0__.Circuit.exactMatch(a.multiaddr);\n const isBCircuit = _multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_0__.Circuit.exactMatch(b.multiaddr);\n if (isACircuit && !isBCircuit) {\n return 1;\n }\n else if (!isACircuit && isBCircuit) {\n return -1;\n }\n return 0;\n}\nfunction defaultAddressSort(a, b) {\n const publicResult = publicAddressesFirst(a, b);\n if (publicResult !== 0) {\n return publicResult;\n }\n const relayResult = circuitRelayAddressesLast(a, b);\n if (relayResult !== 0) {\n return relayResult;\n }\n const certifiedResult = certifiedAddressesFirst(a, b);\n return certifiedResult;\n}\n//# sourceMappingURL=address-sort.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/address-sort.js?"); /***/ }), @@ -3292,6 +3948,28 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@libp2p/utils/dist/src/close-source.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/close-source.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ closeSource: () => (/* binding */ closeSource)\n/* harmony export */ });\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/* harmony import */ var _is_promise_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./is-promise.js */ \"./node_modules/@libp2p/utils/dist/src/is-promise.js\");\n\n\nfunction closeSource(source, log) {\n const res = (0,get_iterator__WEBPACK_IMPORTED_MODULE_0__.getIterator)(source).return?.();\n if ((0,_is_promise_js__WEBPACK_IMPORTED_MODULE_1__.isPromise)(res)) {\n res.catch(err => {\n log.error('could not cause iterator to return', err);\n });\n }\n}\n//# sourceMappingURL=close-source.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/close-source.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/is-promise.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/is-promise.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPromise: () => (/* binding */ isPromise)\n/* harmony export */ });\nfunction isPromise(thing) {\n if (thing == null) {\n return false;\n }\n return typeof thing.then === 'function' &&\n typeof thing.catch === 'function' &&\n typeof thing.finally === 'function';\n}\n//# sourceMappingURL=is-promise.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/is-promise.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js": /*!*********************************************************************!*\ !*** ./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js ***! @@ -3299,7 +3977,84 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPrivate: () => (/* binding */ isPrivate)\n/* harmony export */ });\n/* harmony import */ var private_ip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! private-ip */ \"./node_modules/private-ip/index.js\");\n\n/**\n * Check if a given multiaddr has a private address.\n */\nfunction isPrivate(ma) {\n try {\n const { address } = ma.nodeAddress();\n return Boolean((0,private_ip__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(address));\n }\n catch {\n return true;\n }\n}\n//# sourceMappingURL=is-private.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPrivate: () => (/* binding */ isPrivate)\n/* harmony export */ });\n/* harmony import */ var _private_ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../private-ip.js */ \"./node_modules/@libp2p/utils/dist/src/private-ip.js\");\n\n/**\n * Check if a given multiaddr has a private address.\n */\nfunction isPrivate(ma) {\n try {\n const { address } = ma.nodeAddress();\n return Boolean((0,_private_ip_js__WEBPACK_IMPORTED_MODULE_0__.isPrivateIp)(address));\n }\n catch {\n return true;\n }\n}\n//# sourceMappingURL=is-private.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/multiaddr/is-private.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/peer-queue.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/peer-queue.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerQueue: () => (/* binding */ PeerQueue)\n/* harmony export */ });\n/* harmony import */ var _queue_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queue/index.js */ \"./node_modules/@libp2p/utils/dist/src/queue/index.js\");\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\n/**\n * Extends Queue to add support for querying queued jobs by peer id\n */\nclass PeerQueue extends _queue_index_js__WEBPACK_IMPORTED_MODULE_0__.Queue {\n has(peerId) {\n return this.find(peerId) != null;\n }\n find(peerId) {\n return this.queue.find(job => {\n return peerId.equals(job.options.peerId);\n });\n }\n}\n//# sourceMappingURL=peer-queue.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/peer-queue.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/private-ip.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/private-ip.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isPrivateIp: () => (/* binding */ isPrivateIp)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/is-ip */ \"./node_modules/@chainsafe/is-ip/lib/is-ip.js\");\n/* harmony import */ var netmask__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! netmask */ \"./node_modules/netmask/lib/netmask.js\");\n\n\nconst PRIVATE_IP_RANGES = [\n '0.0.0.0/8',\n '10.0.0.0/8',\n '100.64.0.0/10',\n '127.0.0.0/8',\n '169.254.0.0/16',\n '172.16.0.0/12',\n '192.0.0.0/24',\n '192.0.0.0/29',\n '192.0.0.8/32',\n '192.0.0.9/32',\n '192.0.0.10/32',\n '192.0.0.170/32',\n '192.0.0.171/32',\n '192.0.2.0/24',\n '192.31.196.0/24',\n '192.52.193.0/24',\n '192.88.99.0/24',\n '192.168.0.0/16',\n '192.175.48.0/24',\n '198.18.0.0/15',\n '198.51.100.0/24',\n '203.0.113.0/24',\n '240.0.0.0/4',\n '255.255.255.255/32'\n];\nconst NETMASK_RANGES = PRIVATE_IP_RANGES.map(ipRange => new netmask__WEBPACK_IMPORTED_MODULE_1__.Netmask(ipRange));\nfunction ipv4Check(ipAddr) {\n for (const r of NETMASK_RANGES) {\n if (r.contains(ipAddr))\n return true;\n }\n return false;\n}\nfunction ipv6Check(ipAddr) {\n return /^::$/.test(ipAddr) ||\n /^::1$/.test(ipAddr) ||\n /^::f{4}:([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ipAddr) ||\n /^::f{4}:0.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ipAddr) ||\n /^64:ff9b::([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ipAddr) ||\n /^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ipAddr) ||\n /^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ipAddr) ||\n /^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ipAddr) ||\n /^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ipAddr) ||\n /^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ipAddr) ||\n /^f[c-d]([0-9a-fA-F]{2,2}):/i.test(ipAddr) ||\n /^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(ipAddr) ||\n /^ff([0-9a-fA-F]{2,2}):/i.test(ipAddr);\n}\nfunction isPrivateIp(ip) {\n if ((0,_chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4)(ip))\n return ipv4Check(ip);\n else if ((0,_chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6)(ip))\n return ipv6Check(ip);\n else\n return undefined;\n}\n//# sourceMappingURL=private-ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/private-ip.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/queue/index.js": +/*!************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/queue/index.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Queue: () => (/* binding */ Queue)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var race_event__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! race-event */ \"./node_modules/race-event/dist/src/index.js\");\n/* harmony import */ var _job_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./job.js */ \"./node_modules/@libp2p/utils/dist/src/queue/job.js\");\n\n\n\n\n// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nfunction lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = Math.trunc(count / 2);\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\n/**\n * Heavily influence by `p-queue` with the following differences:\n *\n * 1. Items remain at the head of the queue while they are running so `queue.size` includes `queue.pending` items - this is so interested parties can join the results of a queue item while it is running\n * 2. The options for a job are stored separately to the job in order for them to be modified while they are still in the queue\n */\nclass Queue extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.TypedEventEmitter {\n concurrency;\n queue;\n pending;\n constructor(init = {}) {\n super();\n this.concurrency = init.concurrency ?? Number.POSITIVE_INFINITY;\n this.pending = 0;\n if (init.metricName != null) {\n init.metrics?.registerMetricGroup(init.metricName, {\n calculate: () => {\n return {\n size: this.queue.length,\n running: this.pending,\n queued: this.queue.length - this.pending\n };\n }\n });\n }\n this.queue = [];\n }\n tryToStartAnother() {\n if (this.size === 0) {\n // do this in the microtask queue so all job recipients receive the\n // result before the \"empty\" event fires\n queueMicrotask(() => {\n this.safeDispatchEvent('empty');\n });\n if (this.running === 0) {\n // do this in the microtask queue so all job recipients receive the\n // result before the \"idle\" event fires\n queueMicrotask(() => {\n this.safeDispatchEvent('idle');\n });\n }\n return false;\n }\n if (this.pending < this.concurrency) {\n let job;\n for (const j of this.queue) {\n if (j.status === 'queued') {\n job = j;\n break;\n }\n }\n if (job == null) {\n return false;\n }\n this.safeDispatchEvent('active');\n this.pending++;\n job.run()\n .finally(() => {\n // remove the job from the queue\n for (let i = 0; i < this.queue.length; i++) {\n if (this.queue[i] === job) {\n this.queue.splice(i, 1);\n break;\n }\n }\n this.pending--;\n this.tryToStartAnother();\n this.safeDispatchEvent('next');\n });\n return true;\n }\n return false;\n }\n enqueue(job) {\n if (this.queue[this.size - 1]?.priority >= job.priority) {\n this.queue.push(job);\n return;\n }\n const index = lowerBound(this.queue, job, (a, b) => b.priority - a.priority);\n this.queue.splice(index, 0, job);\n }\n /**\n * Adds a sync or async task to the queue. Always returns a promise.\n */\n async add(fn, options) {\n options?.signal?.throwIfAborted();\n const job = new _job_js__WEBPACK_IMPORTED_MODULE_3__.Job(fn, options, options?.priority);\n const p = job.join(options)\n .then(result => {\n this.safeDispatchEvent('completed', { detail: result });\n this.safeDispatchEvent('success', { detail: { job, result } });\n return result;\n })\n .catch(err => {\n if (job.status === 'queued') {\n // job was aborted before it started - remove the job from the queue\n for (let i = 0; i < this.queue.length; i++) {\n if (this.queue[i] === job) {\n this.queue.splice(i, 1);\n break;\n }\n }\n }\n this.safeDispatchEvent('error', { detail: err });\n this.safeDispatchEvent('failure', { detail: { job, error: err } });\n throw err;\n });\n this.enqueue(job);\n this.safeDispatchEvent('add');\n this.tryToStartAnother();\n return p;\n }\n /**\n * Clear the queue\n */\n clear() {\n this.queue.splice(0, this.queue.length);\n }\n /**\n * Abort all jobs in the queue and clear it\n */\n abort() {\n this.queue.forEach(job => {\n job.abort(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.AbortError());\n });\n this.clear();\n }\n /**\n * Can be called multiple times. Useful if you for example add additional items at a later time.\n *\n * @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty(options) {\n // Instantly resolve if the queue is empty\n if (this.size === 0) {\n return;\n }\n await (0,race_event__WEBPACK_IMPORTED_MODULE_1__.raceEvent)(this, 'empty', options?.signal);\n }\n /**\n * @returns A promise that settles when the queue size is less than the given\n * limit: `queue.size < limit`.\n *\n * If you want to avoid having the queue grow beyond a certain size you can\n * `await queue.onSizeLessThan()` before adding a new item.\n *\n * Note that this only limits the number of items waiting to start. There\n * could still be up to `concurrency` jobs already running that this call does\n * not include in its calculation.\n */\n async onSizeLessThan(limit, options) {\n // Instantly resolve if the queue is empty.\n if (this.size < limit) {\n return;\n }\n await (0,race_event__WEBPACK_IMPORTED_MODULE_1__.raceEvent)(this, 'next', options?.signal, {\n filter: () => this.size < limit\n });\n }\n /**\n * The difference with `.onEmpty` is that `.onIdle` guarantees that all work\n * from the queue has finished. `.onEmpty` merely signals that the queue is\n * empty, but it could mean that some promises haven't completed yet.\n *\n * @returns A promise that settles when the queue becomes empty, and all\n * promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle(options) {\n // Instantly resolve if none pending and if nothing else is queued\n if (this.pending === 0 && this.size === 0) {\n return;\n }\n await (0,race_event__WEBPACK_IMPORTED_MODULE_1__.raceEvent)(this, 'idle', options?.signal);\n }\n /**\n * Size of the queue including running items\n */\n get size() {\n return this.queue.length;\n }\n /**\n * The number of queued items waiting to run.\n */\n get queued() {\n return this.queue.length - this.pending;\n }\n /**\n * The number of items currently running.\n */\n get running() {\n return this.pending;\n }\n /**\n * Returns an async generator that makes it easy to iterate over the results\n * of jobs added to the queue.\n *\n * The generator will end when the queue becomes idle, that is there are no\n * jobs running and no jobs that have yet to run.\n *\n * If you need to keep the queue open indefinitely, consider using it-pushable\n * instead.\n */\n async *toGenerator(options) {\n options?.signal?.throwIfAborted();\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n const cleanup = (err) => {\n if (err != null) {\n this.abort();\n }\n else {\n this.clear();\n }\n stream.end(err);\n };\n const onQueueJobComplete = (evt) => {\n if (evt.detail != null) {\n stream.push(evt.detail);\n }\n };\n const onQueueError = (evt) => {\n cleanup(evt.detail);\n };\n const onQueueIdle = () => {\n cleanup();\n };\n // clear the queue and throw if the query is aborted\n const onSignalAbort = () => {\n cleanup(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('Queue aborted', 'ERR_QUEUE_ABORTED'));\n };\n // add listeners\n this.addEventListener('completed', onQueueJobComplete);\n this.addEventListener('error', onQueueError);\n this.addEventListener('idle', onQueueIdle);\n options?.signal?.addEventListener('abort', onSignalAbort);\n try {\n yield* stream;\n }\n finally {\n // remove listeners\n this.removeEventListener('completed', onQueueJobComplete);\n this.removeEventListener('error', onQueueError);\n this.removeEventListener('idle', onQueueIdle);\n options?.signal?.removeEventListener('abort', onSignalAbort);\n // empty the queue for when the user has broken out of a loop early\n cleanup();\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/queue/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/queue/job.js": +/*!**********************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/queue/job.js ***! + \**********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Job: () => (/* binding */ Job)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var race_signal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! race-signal */ \"./node_modules/race-signal/dist/src/index.js\");\n/* harmony import */ var _recipient_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./recipient.js */ \"./node_modules/@libp2p/utils/dist/src/queue/recipient.js\");\n\n\n\n/**\n * Returns a random string\n */\nfunction randomId() {\n return `${(parseInt(String(Math.random() * 1e9), 10)).toString()}${Date.now()}`;\n}\nclass Job {\n id;\n fn;\n options;\n priority;\n recipients;\n status;\n timeline;\n controller;\n constructor(fn, options, priority = 0) {\n this.id = randomId();\n this.status = 'queued';\n this.fn = fn;\n this.priority = priority;\n this.options = options;\n this.recipients = [];\n this.timeline = {\n created: Date.now()\n };\n this.controller = new AbortController();\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.setMaxListeners)(Infinity, this.controller.signal);\n this.onAbort = this.onAbort.bind(this);\n }\n abort(err) {\n this.controller.abort(err);\n }\n onAbort() {\n const allAborted = this.recipients.reduce((acc, curr) => {\n return acc && (curr.signal?.aborted === true);\n }, true);\n // if all recipients have aborted the job, actually abort the job\n if (allAborted) {\n this.controller.abort(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.AbortError());\n this.cleanup();\n }\n }\n async join(options = {}) {\n const recipient = new _recipient_js__WEBPACK_IMPORTED_MODULE_3__.JobRecipient((new Error('where')).stack, options.signal);\n this.recipients.push(recipient);\n options.signal?.addEventListener('abort', this.onAbort);\n return recipient.deferred.promise;\n }\n async run() {\n this.status = 'running';\n this.timeline.started = Date.now();\n try {\n this.controller.signal.throwIfAborted();\n const result = await (0,race_signal__WEBPACK_IMPORTED_MODULE_0__.raceSignal)(this.fn({\n ...(this.options ?? {}),\n signal: this.controller.signal\n }), this.controller.signal);\n this.recipients.forEach(recipient => {\n recipient.deferred.resolve(result);\n });\n this.status = 'complete';\n }\n catch (err) {\n this.recipients.forEach(recipient => {\n recipient.deferred.reject(err);\n });\n this.status = 'errored';\n }\n finally {\n this.timeline.finished = Date.now();\n this.cleanup();\n }\n }\n cleanup() {\n this.recipients.forEach(recipient => {\n recipient.cleanup();\n recipient.signal?.removeEventListener('abort', this.onAbort);\n });\n }\n}\n//# sourceMappingURL=job.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/queue/job.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/queue/recipient.js": +/*!****************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/queue/recipient.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ JobRecipient: () => (/* binding */ JobRecipient)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n\n\nclass JobRecipient {\n deferred;\n signal;\n where;\n constructor(where, signal) {\n this.signal = signal;\n this.deferred = (0,p_defer__WEBPACK_IMPORTED_MODULE_0__[\"default\"])();\n this.where = where;\n this.onAbort = this.onAbort.bind(this);\n this.signal?.addEventListener('abort', this.onAbort);\n }\n onAbort() {\n this.deferred.reject(this.signal?.reason ?? new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.AbortError());\n }\n cleanup() {\n this.signal?.removeEventListener('abort', this.onAbort);\n }\n}\n//# sourceMappingURL=recipient.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/queue/recipient.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/rate-limiter.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/rate-limiter.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimiter: () => (/* binding */ RateLimiter)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var delay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! delay */ \"./node_modules/delay/index.js\");\n\n\nclass RateLimiter {\n memoryStorage;\n points;\n duration;\n blockDuration;\n execEvenly;\n execEvenlyMinDelayMs;\n keyPrefix;\n constructor(opts = {}) {\n this.points = opts.points ?? 4;\n this.duration = opts.duration ?? 1;\n this.blockDuration = opts.blockDuration ?? 0;\n this.execEvenly = opts.execEvenly ?? false;\n this.execEvenlyMinDelayMs = opts.execEvenlyMinDelayMs ?? (this.duration * 1000 / this.points);\n this.keyPrefix = opts.keyPrefix ?? 'rlflx';\n this.memoryStorage = new MemoryStorage();\n }\n async consume(key, pointsToConsume = 1, options = {}) {\n const rlKey = this.getKey(key);\n const secDuration = this._getKeySecDuration(options);\n let res = this.memoryStorage.incrby(rlKey, pointsToConsume, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n if (res.consumedPoints > this.points) {\n // Block only first time when consumed more than points\n if (this.blockDuration > 0 && res.consumedPoints <= (this.points + pointsToConsume)) {\n // Block key\n res = this.memoryStorage.set(rlKey, res.consumedPoints, this.blockDuration);\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Rate limit exceeded', 'ERR_RATE_LIMIT_EXCEEDED', res);\n }\n else if (this.execEvenly && res.msBeforeNext > 0 && !res.isFirstInDuration) {\n // Execute evenly\n let delayMs = Math.ceil(res.msBeforeNext / (res.remainingPoints + 2));\n if (delayMs < this.execEvenlyMinDelayMs) {\n delayMs = res.consumedPoints * this.execEvenlyMinDelayMs;\n }\n await (0,delay__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(delayMs);\n }\n return res;\n }\n penalty(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n const secDuration = this._getKeySecDuration(options);\n const res = this.memoryStorage.incrby(rlKey, points, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n return res;\n }\n reward(key, points = 1, options = {}) {\n const rlKey = this.getKey(key);\n const secDuration = this._getKeySecDuration(options);\n const res = this.memoryStorage.incrby(rlKey, -points, secDuration);\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n return res;\n }\n /**\n * Block any key for secDuration seconds\n *\n * @param key\n * @param secDuration\n */\n block(key, secDuration) {\n const msDuration = secDuration * 1000;\n const initPoints = this.points + 1;\n this.memoryStorage.set(this.getKey(key), initPoints, secDuration);\n return {\n remainingPoints: 0,\n msBeforeNext: msDuration === 0 ? -1 : msDuration,\n consumedPoints: initPoints,\n isFirstInDuration: false\n };\n }\n set(key, points, secDuration = 0) {\n const msDuration = (secDuration >= 0 ? secDuration : this.duration) * 1000;\n this.memoryStorage.set(this.getKey(key), points, secDuration);\n return {\n remainingPoints: 0,\n msBeforeNext: msDuration === 0 ? -1 : msDuration,\n consumedPoints: points,\n isFirstInDuration: false\n };\n }\n get(key) {\n const res = this.memoryStorage.get(this.getKey(key));\n if (res != null) {\n res.remainingPoints = Math.max(this.points - res.consumedPoints, 0);\n }\n return res;\n }\n delete(key) {\n this.memoryStorage.delete(this.getKey(key));\n }\n _getKeySecDuration(options) {\n if (options?.customDuration != null && options.customDuration >= 0) {\n return options.customDuration;\n }\n return this.duration;\n }\n getKey(key) {\n return this.keyPrefix.length > 0 ? `${this.keyPrefix}:${key}` : key;\n }\n parseKey(rlKey) {\n return rlKey.substring(this.keyPrefix.length);\n }\n}\nclass MemoryStorage {\n storage;\n constructor() {\n this.storage = new Map();\n }\n incrby(key, value, durationSec) {\n const existing = this.storage.get(key);\n if (existing != null) {\n const msBeforeExpires = existing.expiresAt != null\n ? existing.expiresAt.getTime() - new Date().getTime()\n : -1;\n if (existing.expiresAt == null || msBeforeExpires > 0) {\n // Change value\n existing.value += value;\n return {\n remainingPoints: 0,\n msBeforeNext: msBeforeExpires,\n consumedPoints: existing.value,\n isFirstInDuration: false\n };\n }\n return this.set(key, value, durationSec);\n }\n return this.set(key, value, durationSec);\n }\n set(key, value, durationSec) {\n const durationMs = durationSec * 1000;\n const existing = this.storage.get(key);\n if (existing != null) {\n clearTimeout(existing.timeoutId);\n }\n const record = {\n value,\n expiresAt: durationMs > 0 ? new Date(Date.now() + durationMs) : undefined\n };\n this.storage.set(key, record);\n if (durationMs > 0) {\n record.timeoutId = setTimeout(() => {\n this.storage.delete(key);\n }, durationMs);\n if (record.timeoutId.unref != null) {\n record.timeoutId.unref();\n }\n }\n return {\n remainingPoints: 0,\n msBeforeNext: durationMs === 0 ? -1 : durationMs,\n consumedPoints: record.value,\n isFirstInDuration: true\n };\n }\n get(key) {\n const existing = this.storage.get(key);\n if (existing != null) {\n const msBeforeExpires = existing.expiresAt != null\n ? existing.expiresAt.getTime() - new Date().getTime()\n : -1;\n return {\n remainingPoints: 0,\n msBeforeNext: msBeforeExpires,\n consumedPoints: existing.value,\n isFirstInDuration: false\n };\n }\n }\n delete(key) {\n const record = this.storage.get(key);\n if (record != null) {\n if (record.timeoutId != null) {\n clearTimeout(record.timeoutId);\n }\n this.storage.delete(key);\n return true;\n }\n return false;\n }\n}\n//# sourceMappingURL=rate-limiter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/rate-limiter.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/dist/src/tracked-map.js": +/*!************************************************************!*\ + !*** ./node_modules/@libp2p/utils/dist/src/tracked-map.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ trackedMap: () => (/* binding */ trackedMap)\n/* harmony export */ });\nclass TrackedMap extends Map {\n metric;\n constructor(init) {\n super();\n const { name, metrics } = init;\n this.metric = metrics.registerMetric(name);\n this.updateComponentMetric();\n }\n set(key, value) {\n super.set(key, value);\n this.updateComponentMetric();\n return this;\n }\n delete(key) {\n const deleted = super.delete(key);\n this.updateComponentMetric();\n return deleted;\n }\n clear() {\n super.clear();\n this.updateComponentMetric();\n }\n updateComponentMetric() {\n this.metric.update(this.size);\n }\n}\nfunction trackedMap(config) {\n const { name, metrics } = config;\n let map;\n if (metrics != null) {\n map = new TrackedMap({ name, metrics });\n }\n else {\n map = new Map();\n }\n return map;\n}\n//# sourceMappingURL=tracked-map.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/tracked-map.js?"); /***/ }), @@ -3310,7 +4065,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CLOSE_TIMEOUT: () => (/* binding */ CLOSE_TIMEOUT),\n/* harmony export */ CODE_CIRCUIT: () => (/* binding */ CODE_CIRCUIT),\n/* harmony export */ CODE_P2P: () => (/* binding */ CODE_P2P),\n/* harmony export */ CODE_TCP: () => (/* binding */ CODE_TCP),\n/* harmony export */ CODE_WS: () => (/* binding */ CODE_WS),\n/* harmony export */ CODE_WSS: () => (/* binding */ CODE_WSS)\n/* harmony export */ });\n// p2p multi-address code\nconst CODE_P2P = 421;\nconst CODE_CIRCUIT = 290;\nconst CODE_TCP = 6;\nconst CODE_WS = 477;\nconst CODE_WSS = 478;\n// Time to wait for a connection to close gracefully before destroying it manually\nconst CLOSE_TIMEOUT = 2000;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/constants.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CLOSE_TIMEOUT: () => (/* binding */ CLOSE_TIMEOUT),\n/* harmony export */ CODE_CIRCUIT: () => (/* binding */ CODE_CIRCUIT),\n/* harmony export */ CODE_P2P: () => (/* binding */ CODE_P2P),\n/* harmony export */ CODE_TCP: () => (/* binding */ CODE_TCP),\n/* harmony export */ CODE_WS: () => (/* binding */ CODE_WS),\n/* harmony export */ CODE_WSS: () => (/* binding */ CODE_WSS)\n/* harmony export */ });\n// p2p multi-address code\nconst CODE_P2P = 421;\nconst CODE_CIRCUIT = 290;\nconst CODE_TCP = 6;\nconst CODE_WS = 477;\nconst CODE_WSS = 478;\n// Time to wait for a connection to close gracefully before destroying it manually\nconst CLOSE_TIMEOUT = 500;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/constants.js?"); /***/ }), @@ -3332,7 +4087,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ webSockets: () => (/* binding */ webSockets)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr-to-uri */ \"./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js\");\n/* harmony import */ var it_ws_client__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-ws/client */ \"./node_modules/it-ws/dist/src/client.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _filters_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filters.js */ \"./node_modules/@libp2p/websockets/dist/src/filters.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/@libp2p/websockets/dist/src/listener.browser.js\");\n/* harmony import */ var _socket_to_conn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./socket-to-conn.js */ \"./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:websockets');\nclass WebSockets {\n init;\n constructor(init) {\n this.init = init;\n }\n [Symbol.toStringTag] = '@libp2p/websockets';\n [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__.symbol] = true;\n async dial(ma, options) {\n log('dialing %s', ma);\n options = options ?? {};\n const socket = await this._connect(ma, options);\n const maConn = (0,_socket_to_conn_js__WEBPACK_IMPORTED_MODULE_8__.socketToMaConn)(socket, ma);\n log('new outbound connection %s', maConn.remoteAddr);\n const conn = await options.upgrader.upgradeOutbound(maConn);\n log('outbound connection %s upgraded', maConn.remoteAddr);\n return conn;\n }\n async _connect(ma, options) {\n if (options?.signal?.aborted === true) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.AbortError();\n }\n const cOpts = ma.toOptions();\n log('dialing %s:%s', cOpts.host, cOpts.port);\n const errorPromise = (0,p_defer__WEBPACK_IMPORTED_MODULE_9__[\"default\"])();\n const errfn = (err) => {\n log.error('connection error:', err);\n errorPromise.reject(err);\n };\n const rawSocket = (0,it_ws_client__WEBPACK_IMPORTED_MODULE_4__.connect)((0,_multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_3__.multiaddrToUri)(ma), this.init);\n if (rawSocket.socket.on != null) {\n rawSocket.socket.on('error', errfn);\n }\n else {\n rawSocket.socket.onerror = errfn;\n }\n if (options.signal == null) {\n await Promise.race([rawSocket.connected(), errorPromise.promise]);\n log('connected %s', ma);\n return rawSocket;\n }\n // Allow abort via signal during connect\n let onAbort;\n const abort = new Promise((resolve, reject) => {\n onAbort = () => {\n reject(new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.AbortError());\n rawSocket.close().catch(err => {\n log.error('error closing raw socket', err);\n });\n };\n // Already aborted?\n if (options?.signal?.aborted === true) {\n onAbort();\n return;\n }\n options?.signal?.addEventListener('abort', onAbort);\n });\n try {\n await Promise.race([abort, errorPromise.promise, rawSocket.connected()]);\n }\n finally {\n if (onAbort != null) {\n options?.signal?.removeEventListener('abort', onAbort);\n }\n }\n log('connected %s', ma);\n return rawSocket;\n }\n /**\n * Creates a Websockets listener. The provided `handler` function will be called\n * anytime a new incoming Connection has been successfully upgraded via\n * `upgrader.upgradeInbound`\n */\n createListener(options) {\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_7__.createListener)({ ...this.init, ...options });\n }\n /**\n * Takes a list of `Multiaddr`s and returns only valid Websockets addresses.\n * By default, in a browser environment only DNS+WSS multiaddr is accepted,\n * while in a Node.js environment DNS+{WS, WSS} multiaddrs are accepted.\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n if (this.init?.filter != null) {\n return this.init?.filter(multiaddrs);\n }\n // Browser\n if (wherearewe__WEBPACK_IMPORTED_MODULE_5__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_5__.isWebWorker) {\n return _filters_js__WEBPACK_IMPORTED_MODULE_6__.wss(multiaddrs);\n }\n return _filters_js__WEBPACK_IMPORTED_MODULE_6__.all(multiaddrs);\n }\n}\nfunction webSockets(init = {}) {\n return () => {\n return new WebSockets(init);\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ webSockets: () => (/* binding */ webSockets)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/transport/index.js\");\n/* harmony import */ var _multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr-to-uri */ \"./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js\");\n/* harmony import */ var it_ws_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-ws/client */ \"./node_modules/it-ws/dist/src/client.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _filters_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filters.js */ \"./node_modules/@libp2p/websockets/dist/src/filters.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/@libp2p/websockets/dist/src/listener.browser.js\");\n/* harmony import */ var _socket_to_conn_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./socket-to-conn.js */ \"./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js\");\n/**\n * @packageDocumentation\n *\n * A [libp2p transport](https://docs.libp2p.io/concepts/transports/overview/) based on [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API).\n *\n * @example\n *\n * ```TypeScript\n * import { createLibp2p } from 'libp2p'\n * import { webSockets } from '@libp2p/websockets'\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * const node = await createLibp2p({\n * transports: [\n * webSockets()\n * ]\n * //... other config\n * })\n * await node.start()\n *\n * const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ws')\n * await node.dial(ma)\n * ```\n *\n * ## Filters\n *\n * When run in a browser by default this module will only connect to secure web socket addresses.\n *\n * To change this you should pass a filter to the factory function.\n *\n * You can create your own address filters for this transports, or rely in the filters [provided](./src/filters.js).\n *\n * The available filters are:\n *\n * - `filters.all`\n * - Returns all TCP and DNS based addresses, both with `ws` or `wss`.\n * - `filters.dnsWss`\n * - Returns all DNS based addresses with `wss`.\n * - `filters.dnsWsOrWss`\n * - Returns all DNS based addresses, both with `ws` or `wss`.\n *\n * @example Allow dialing insecure WebSockets\n *\n * ```TypeScript\n * import { createLibp2p } from 'libp2p'\n * import { webSockets } from '@libp2p/websockets'\n * import filters from '@libp2p/websockets/filters'\n *\n * const node = await createLibp2p({\n * transports: [\n * webSockets({\n * // connect to all sockets, even insecure ones\n * filter: filters.all\n * })\n * ]\n * })\n * ```\n */\n\n\n\n\n\n\n\n\n\nclass WebSockets {\n log;\n init;\n logger;\n constructor(components, init) {\n this.log = components.logger.forComponent('libp2p:websockets');\n this.logger = components.logger;\n this.init = init;\n }\n [Symbol.toStringTag] = '@libp2p/websockets';\n [_libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.transportSymbol] = true;\n async dial(ma, options) {\n this.log('dialing %s', ma);\n options = options ?? {};\n const socket = await this._connect(ma, options);\n const maConn = (0,_socket_to_conn_js__WEBPACK_IMPORTED_MODULE_4__.socketToMaConn)(socket, ma, {\n logger: this.logger\n });\n this.log('new outbound connection %s', maConn.remoteAddr);\n const conn = await options.upgrader.upgradeOutbound(maConn);\n this.log('outbound connection %s upgraded', maConn.remoteAddr);\n return conn;\n }\n async _connect(ma, options) {\n if (options?.signal?.aborted === true) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.AbortError();\n }\n const cOpts = ma.toOptions();\n this.log('dialing %s:%s', cOpts.host, cOpts.port);\n const errorPromise = (0,p_defer__WEBPACK_IMPORTED_MODULE_6__[\"default\"])();\n const rawSocket = (0,it_ws_client__WEBPACK_IMPORTED_MODULE_1__.connect)((0,_multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_0__.multiaddrToUri)(ma), this.init);\n rawSocket.socket.addEventListener('error', () => {\n // the WebSocket.ErrorEvent type doesn't actually give us any useful\n // information about what happened\n // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event\n const err = new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.CodeError(`Could not connect to ${ma.toString()}`, 'ERR_CONNECTION_FAILED');\n this.log.error('connection error:', err);\n errorPromise.reject(err);\n });\n if (options.signal == null) {\n await Promise.race([rawSocket.connected(), errorPromise.promise]);\n this.log('connected %s', ma);\n return rawSocket;\n }\n // Allow abort via signal during connect\n let onAbort;\n const abort = new Promise((resolve, reject) => {\n onAbort = () => {\n reject(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.AbortError());\n rawSocket.close().catch(err => {\n this.log.error('error closing raw socket', err);\n });\n };\n // Already aborted?\n if (options?.signal?.aborted === true) {\n onAbort();\n return;\n }\n options?.signal?.addEventListener('abort', onAbort);\n });\n try {\n await Promise.race([abort, errorPromise.promise, rawSocket.connected()]);\n }\n finally {\n if (onAbort != null) {\n options?.signal?.removeEventListener('abort', onAbort);\n }\n }\n this.log('connected %s', ma);\n return rawSocket;\n }\n /**\n * Creates a Websockets listener. The provided `handler` function will be called\n * anytime a new incoming Connection has been successfully upgraded via\n * `upgrader.upgradeInbound`\n */\n createListener(options) {\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_7__.createListener)({\n logger: this.logger\n }, {\n ...this.init,\n ...options\n });\n }\n /**\n * Takes a list of `Multiaddr`s and returns only valid Websockets addresses.\n * By default, in a browser environment only DNS+WSS multiaddr is accepted,\n * while in a Node.js environment DNS+{WS, WSS} multiaddrs are accepted.\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n if (this.init?.filter != null) {\n return this.init?.filter(multiaddrs);\n }\n // Browser\n if (wherearewe__WEBPACK_IMPORTED_MODULE_2__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_2__.isWebWorker) {\n return _filters_js__WEBPACK_IMPORTED_MODULE_8__.wss(multiaddrs);\n }\n return _filters_js__WEBPACK_IMPORTED_MODULE_8__.all(multiaddrs);\n }\n}\nfunction webSockets(init = {}) {\n return (components) => {\n return new WebSockets(components, init);\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/index.js?"); /***/ }), @@ -3354,29 +4109,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ socketToMaConn: () => (/* binding */ socketToMaConn)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/websockets/dist/src/constants.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:websockets:socket');\n// Convert a stream into a MultiaddrConnection\n// https://github.com/libp2p/interface-transport#multiaddrconnection\nfunction socketToMaConn(stream, remoteAddr, options) {\n options = options ?? {};\n const maConn = {\n async sink(source) {\n if ((options?.signal) != null) {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_1__.abortableSource)(source, options.signal);\n }\n try {\n await stream.sink(source);\n }\n catch (err) {\n if (err.type !== 'aborted') {\n log.error(err);\n }\n }\n },\n source: (options.signal != null) ? (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_1__.abortableSource)(stream.source, options.signal) : stream.source,\n remoteAddr,\n timeline: { open: Date.now() },\n async close() {\n const start = Date.now();\n try {\n await (0,p_timeout__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(stream.close(), {\n milliseconds: _constants_js__WEBPACK_IMPORTED_MODULE_3__.CLOSE_TIMEOUT\n });\n }\n catch (err) {\n const { host, port } = maConn.remoteAddr.toOptions();\n log('timeout closing stream to %s:%s after %dms, destroying it manually', host, port, Date.now() - start);\n stream.destroy();\n }\n finally {\n maConn.timeline.close = Date.now();\n }\n }\n };\n stream.socket.addEventListener('close', () => {\n // In instances where `close` was not explicitly called,\n // such as an iterable stream ending, ensure we have set the close\n // timeline\n if (maConn.timeline.close == null) {\n maConn.timeline.close = Date.now();\n }\n }, { once: true });\n return maConn;\n}\n//# sourceMappingURL=socket-to-conn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/abort-error.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/abort-error.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/abort-error.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/index.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/index.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/node_modules/abortable-iterator/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ socketToMaConn: () => (/* binding */ socketToMaConn)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/websockets/dist/src/constants.js\");\n\n\n// Convert a stream into a MultiaddrConnection\n// https://github.com/libp2p/interface-transport#multiaddrconnection\nfunction socketToMaConn(stream, remoteAddr, options) {\n const log = options.logger.forComponent('libp2p:websockets:maconn');\n const maConn = {\n log,\n async sink(source) {\n try {\n await stream.sink((async function* () {\n for await (const buf of source) {\n if (buf instanceof Uint8Array) {\n yield buf;\n }\n else {\n yield buf.subarray();\n }\n }\n })());\n }\n catch (err) {\n if (err.type !== 'aborted') {\n log.error(err);\n }\n }\n },\n source: stream.source,\n remoteAddr,\n timeline: { open: Date.now() },\n async close(options = {}) {\n const start = Date.now();\n if (options.signal == null) {\n const signal = AbortSignal.timeout(_constants_js__WEBPACK_IMPORTED_MODULE_0__.CLOSE_TIMEOUT);\n options = {\n ...options,\n signal\n };\n }\n const listener = () => {\n const { host, port } = maConn.remoteAddr.toOptions();\n log('timeout closing stream to %s:%s after %dms, destroying it manually', host, port, Date.now() - start);\n this.abort(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Socket close timeout', 'ERR_SOCKET_CLOSE_TIMEOUT'));\n };\n options.signal?.addEventListener('abort', listener);\n try {\n await stream.close();\n }\n catch (err) {\n log.error('error closing WebSocket gracefully', err);\n this.abort(err);\n }\n finally {\n options.signal?.removeEventListener('abort', listener);\n maConn.timeline.close = Date.now();\n }\n },\n abort(err) {\n const { host, port } = maConn.remoteAddr.toOptions();\n log('timeout closing stream to %s:%s due to error', host, port, err);\n stream.destroy();\n maConn.timeline.close = Date.now();\n }\n };\n stream.socket.addEventListener('close', () => {\n // In instances where `close` was not explicitly called,\n // such as an iterable stream ending, ensure we have set the close\n // timeline\n if (maConn.timeline.close == null) {\n maConn.timeline.close = Date.now();\n }\n }, { once: true });\n return maConn;\n}\n//# sourceMappingURL=socket-to-conn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js?"); /***/ }), @@ -3420,7 +4153,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_QUERY_CONCURRENCY: () => (/* binding */ DEFAULT_QUERY_CONCURRENCY),\n/* harmony export */ dnsJsonOverHttps: () => (/* binding */ dnsJsonOverHttps)\n/* harmony export */ });\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-queue */ \"./node_modules/@multiformats/dns/node_modules/p-queue/dist/index.js\");\n/* harmony import */ var progress_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! progress-events */ \"./node_modules/progress-events/dist/src/index.js\");\n/* harmony import */ var _utils_get_types_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/get-types.js */ \"./node_modules/@multiformats/dns/dist/src/utils/get-types.js\");\n/* harmony import */ var _utils_to_dns_response_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/to-dns-response.js */ \"./node_modules/@multiformats/dns/dist/src/utils/to-dns-response.js\");\n/* eslint-env browser */\n\n\n\n\n/**\n * Browsers limit concurrent connections per host (~6), we don't want to exhaust\n * the limit so this value controls how many DNS queries can be in flight at\n * once.\n */\nconst DEFAULT_QUERY_CONCURRENCY = 4;\n/**\n * Uses the RFC 8427 'application/dns-json' content-type to resolve DNS queries.\n *\n * Supports and server that uses the same schema as Google's DNS over HTTPS\n * resolver.\n *\n * This resolver needs fewer dependencies than the regular DNS-over-HTTPS\n * resolver so can result in a smaller bundle size and consequently is preferred\n * for browser use.\n *\n * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/\n * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers\n * @see https://dnsprivacy.org/public_resolvers/\n * @see https://datatracker.ietf.org/doc/html/rfc8427\n */\nfunction dnsJsonOverHttps(url, init = {}) {\n const httpQueue = new p_queue__WEBPACK_IMPORTED_MODULE_3__[\"default\"]({\n concurrency: init.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY\n });\n return async (fqdn, options = {}) => {\n const searchParams = new URLSearchParams();\n searchParams.set('name', fqdn);\n (0,_utils_get_types_js__WEBPACK_IMPORTED_MODULE_1__.getTypes)(options.types).forEach(type => {\n searchParams.append('type', type.toString());\n });\n options.onProgress?.(new progress_events__WEBPACK_IMPORTED_MODULE_0__.CustomProgressEvent('dns:query', { detail: fqdn }));\n // query DNS-JSON over HTTPS server\n const response = await httpQueue.add(async () => {\n const res = await fetch(`${url}?${searchParams}`, {\n headers: {\n accept: 'application/dns-json'\n },\n signal: options?.signal\n });\n if (res.status !== 200) {\n throw new Error(`Unexpected HTTP status: ${res.status} - ${res.statusText}`);\n }\n const response = (0,_utils_to_dns_response_js__WEBPACK_IMPORTED_MODULE_2__.toDNSResponse)(await res.json());\n options.onProgress?.(new progress_events__WEBPACK_IMPORTED_MODULE_0__.CustomProgressEvent('dns:response', { detail: response }));\n return response;\n }, {\n signal: options.signal\n });\n if (response == null) {\n throw new Error('No DNS response received');\n }\n return response;\n };\n}\n//# sourceMappingURL=dns-json-over-https.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/dist/src/resolvers/dns-json-over-https.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_QUERY_CONCURRENCY: () => (/* binding */ DEFAULT_QUERY_CONCURRENCY),\n/* harmony export */ dnsJsonOverHttps: () => (/* binding */ dnsJsonOverHttps)\n/* harmony export */ });\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! p-queue */ \"./node_modules/p-queue/dist/index.js\");\n/* harmony import */ var progress_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! progress-events */ \"./node_modules/progress-events/dist/src/index.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@multiformats/dns/dist/src/index.js\");\n/* harmony import */ var _utils_get_types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/get-types.js */ \"./node_modules/@multiformats/dns/dist/src/utils/get-types.js\");\n/* harmony import */ var _utils_to_dns_response_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/to-dns-response.js */ \"./node_modules/@multiformats/dns/dist/src/utils/to-dns-response.js\");\n/* eslint-env browser */\n\n\n\n\n\n/**\n * Browsers limit concurrent connections per host (~6), we don't want to exhaust\n * the limit so this value controls how many DNS queries can be in flight at\n * once.\n */\nconst DEFAULT_QUERY_CONCURRENCY = 4;\n/**\n * Uses the RFC 8427 'application/dns-json' content-type to resolve DNS queries.\n *\n * Supports and server that uses the same schema as Google's DNS over HTTPS\n * resolver.\n *\n * This resolver needs fewer dependencies than the regular DNS-over-HTTPS\n * resolver so can result in a smaller bundle size and consequently is preferred\n * for browser use.\n *\n * @see https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/\n * @see https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers\n * @see https://dnsprivacy.org/public_resolvers/\n * @see https://datatracker.ietf.org/doc/html/rfc8427\n */\nfunction dnsJsonOverHttps(url, init = {}) {\n const httpQueue = new p_queue__WEBPACK_IMPORTED_MODULE_4__[\"default\"]({\n concurrency: init.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY\n });\n return async (fqdn, options = {}) => {\n const searchParams = new URLSearchParams();\n searchParams.set('name', fqdn);\n (0,_utils_get_types_js__WEBPACK_IMPORTED_MODULE_2__.getTypes)(options.types).forEach(type => {\n // We pass record type as a string to the server because cloudflare DNS bug. see https://github.com/ipfs/helia/issues/474\n searchParams.append('type', _index_js__WEBPACK_IMPORTED_MODULE_1__.RecordType[type]);\n });\n options.onProgress?.(new progress_events__WEBPACK_IMPORTED_MODULE_0__.CustomProgressEvent('dns:query', { detail: fqdn }));\n // query DNS-JSON over HTTPS server\n const response = await httpQueue.add(async () => {\n const res = await fetch(`${url}?${searchParams}`, {\n headers: {\n accept: 'application/dns-json'\n },\n signal: options?.signal\n });\n if (res.status !== 200) {\n throw new Error(`Unexpected HTTP status: ${res.status} - ${res.statusText}`);\n }\n const response = (0,_utils_to_dns_response_js__WEBPACK_IMPORTED_MODULE_3__.toDNSResponse)(await res.json());\n options.onProgress?.(new progress_events__WEBPACK_IMPORTED_MODULE_0__.CustomProgressEvent('dns:response', { detail: response }));\n return response;\n }, {\n signal: options.signal\n });\n if (response == null) {\n throw new Error('No DNS response received');\n }\n return response;\n };\n}\n//# sourceMappingURL=dns-json-over-https.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/dist/src/resolvers/dns-json-over-https.js?"); /***/ }), @@ -3457,369 +4190,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base10.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base10.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base16.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base16.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base2.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base2.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base256emoji.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base256emoji.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base32.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base32.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base36.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base36.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base58.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base58.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base64.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base64.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base8.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base8.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/identity.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/identity.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/interface.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/basics.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/basics.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/block/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/block/interface.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/block/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/cid.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/cid.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/interface.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/interface.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/json.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/json.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/raw.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/raw.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/hasher.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/hasher.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/identity.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/identity.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/interface.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/interface.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/sha2-browser.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/index.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/index.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/interface.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/interface.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/link/interface.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/link/interface.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/base-x.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/base-x.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/varint.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/varint.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/p-queue/dist/index.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/p-queue/dist/index.js ***! - \***************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PQueue)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./priority-queue.js */ \"./node_modules/@multiformats/dns/node_modules/p-queue/dist/priority-queue.js\");\n\n\n\n/**\nPromise queue with concurrency control.\n*/\nclass PQueue extends eventemitter3__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n #carryoverConcurrencyCount;\n #isIntervalIgnored;\n #intervalCount = 0;\n #intervalCap;\n #interval;\n #intervalEnd = 0;\n #intervalId;\n #timeoutId;\n #queue;\n #queueClass;\n #pending = 0;\n // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n #concurrency;\n #isPaused;\n #throwOnTimeout;\n /**\n Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.\n\n Applies to each future operation.\n */\n timeout;\n // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`\n constructor(options) {\n super();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = {\n carryoverConcurrencyCount: false,\n intervalCap: Number.POSITIVE_INFINITY,\n interval: 0,\n concurrency: Number.POSITIVE_INFINITY,\n autoStart: true,\n queueClass: _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n ...options,\n };\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${options.intervalCap?.toString() ?? ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${options.interval?.toString() ?? ''}\\` (${typeof options.interval})`);\n }\n this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;\n this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;\n this.#intervalCap = options.intervalCap;\n this.#interval = options.interval;\n this.#queue = new options.queueClass();\n this.#queueClass = options.queueClass;\n this.concurrency = options.concurrency;\n this.timeout = options.timeout;\n this.#throwOnTimeout = options.throwOnTimeout === true;\n this.#isPaused = options.autoStart === false;\n }\n get #doesIntervalAllowAnother() {\n return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;\n }\n get #doesConcurrentAllowAnother() {\n return this.#pending < this.#concurrency;\n }\n #next() {\n this.#pending--;\n this.#tryToStartAnother();\n this.emit('next');\n }\n #onResumeInterval() {\n this.#onInterval();\n this.#initializeIntervalIfNeeded();\n this.#timeoutId = undefined;\n }\n get #isIntervalPaused() {\n const now = Date.now();\n if (this.#intervalId === undefined) {\n const delay = this.#intervalEnd - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n this.#intervalCount = (this.#carryoverConcurrencyCount) ? this.#pending : 0;\n }\n else {\n // Act as the interval is pending\n if (this.#timeoutId === undefined) {\n this.#timeoutId = setTimeout(() => {\n this.#onResumeInterval();\n }, delay);\n }\n return true;\n }\n }\n return false;\n }\n #tryToStartAnother() {\n if (this.#queue.size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (this.#intervalId) {\n clearInterval(this.#intervalId);\n }\n this.#intervalId = undefined;\n this.emit('empty');\n if (this.#pending === 0) {\n this.emit('idle');\n }\n return false;\n }\n if (!this.#isPaused) {\n const canInitializeInterval = !this.#isIntervalPaused;\n if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {\n const job = this.#queue.dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n this.#initializeIntervalIfNeeded();\n }\n return true;\n }\n }\n return false;\n }\n #initializeIntervalIfNeeded() {\n if (this.#isIntervalIgnored || this.#intervalId !== undefined) {\n return;\n }\n this.#intervalId = setInterval(() => {\n this.#onInterval();\n }, this.#interval);\n this.#intervalEnd = Date.now() + this.#interval;\n }\n #onInterval() {\n if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {\n clearInterval(this.#intervalId);\n this.#intervalId = undefined;\n }\n this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;\n this.#processQueue();\n }\n /**\n Executes all queued functions until it reaches the limit.\n */\n #processQueue() {\n // eslint-disable-next-line no-empty\n while (this.#tryToStartAnother()) { }\n }\n get concurrency() {\n return this.#concurrency;\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n this.#concurrency = newConcurrency;\n this.#processQueue();\n }\n async #throwOnAbort(signal) {\n return new Promise((_resolve, reject) => {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n }, { once: true });\n });\n }\n async add(function_, options = {}) {\n options = {\n timeout: this.timeout,\n throwOnTimeout: this.#throwOnTimeout,\n ...options,\n };\n return new Promise((resolve, reject) => {\n this.#queue.enqueue(async () => {\n this.#pending++;\n this.#intervalCount++;\n try {\n options.signal?.throwIfAborted();\n let operation = function_({ signal: options.signal });\n if (options.timeout) {\n operation = (0,p_timeout__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(Promise.resolve(operation), { milliseconds: options.timeout });\n }\n if (options.signal) {\n operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);\n }\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n if (error instanceof p_timeout__WEBPACK_IMPORTED_MODULE_1__.TimeoutError && !options.throwOnTimeout) {\n resolve();\n return;\n }\n reject(error);\n this.emit('error', error);\n }\n finally {\n this.#next();\n }\n }, options);\n this.emit('add');\n this.#tryToStartAnother();\n });\n }\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!this.#isPaused) {\n return this;\n }\n this.#isPaused = false;\n this.#processQueue();\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n this.#isPaused = true;\n }\n /**\n Clear the queue.\n */\n clear() {\n this.#queue = new this.#queueClass();\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('empty');\n }\n /**\n @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.\n\n If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n */\n async onSizeLessThan(limit) {\n // Instantly resolve if the queue is empty.\n if (this.#queue.size < limit) {\n return;\n }\n await this.#onEvent('next', () => this.#queue.size < limit);\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (this.#pending === 0 && this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('idle');\n }\n async #onEvent(event, filter) {\n return new Promise(resolve => {\n const listener = () => {\n if (filter && !filter()) {\n return;\n }\n this.off(event, listener);\n resolve();\n };\n this.on(event, listener);\n });\n }\n /**\n Size of the queue, the number of queued items waiting to run.\n */\n get size() {\n return this.#queue.size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n return this.#queue.filter(options).length;\n }\n /**\n Number of running items (no longer in the queue).\n */\n get pending() {\n return this.#pending;\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return this.#isPaused;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/p-queue/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/p-queue/dist/lower-bound.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/p-queue/dist/lower-bound.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ lowerBound)\n/* harmony export */ });\n// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nfunction lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = Math.trunc(count / 2);\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/p-queue/dist/lower-bound.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/dns/node_modules/p-queue/dist/priority-queue.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@multiformats/dns/node_modules/p-queue/dist/priority-queue.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PriorityQueue)\n/* harmony export */ });\n/* harmony import */ var _lower_bound_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lower-bound.js */ \"./node_modules/@multiformats/dns/node_modules/p-queue/dist/lower-bound.js\");\n\nclass PriorityQueue {\n #queue = [];\n enqueue(run, options) {\n options = {\n priority: 0,\n ...options,\n };\n const element = {\n priority: options.priority,\n run,\n };\n if (this.size && this.#queue[this.size - 1].priority >= options.priority) {\n this.#queue.push(element);\n return;\n }\n const index = (0,_lower_bound_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/p-queue/dist/priority-queue.js?"); - -/***/ }), - /***/ "./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/alloc.js": /*!***********************************************************************************!*\ !*** ./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/alloc.js ***! @@ -3849,7 +4219,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/dns/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/util/bases.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/dns/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -3864,6 +4234,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Circuit: () => (/* binding */ Circuit),\n/* harmony export */ DNS: () => (/* binding */ DNS),\n/* harmony export */ DNS4: () => (/* binding */ DNS4),\n/* harmony export */ DNS6: () => (/* binding */ DNS6),\n/* harmony export */ DNSADDR: () => (/* binding */ DNSADDR),\n/* harmony export */ HTTP: () => (/* binding */ HTTP),\n/* harmony export */ HTTPS: () => (/* binding */ HTTPS),\n/* harmony export */ IP: () => (/* binding */ IP),\n/* harmony export */ IP4: () => (/* binding */ IP4),\n/* harmony export */ IP6: () => (/* binding */ IP6),\n/* harmony export */ IP_OR_DOMAIN: () => (/* binding */ IP_OR_DOMAIN),\n/* harmony export */ P2P: () => (/* binding */ P2P),\n/* harmony export */ QUIC: () => (/* binding */ QUIC),\n/* harmony export */ QUICV1: () => (/* binding */ QUICV1),\n/* harmony export */ TCP: () => (/* binding */ TCP),\n/* harmony export */ UDP: () => (/* binding */ UDP),\n/* harmony export */ WebRTC: () => (/* binding */ WebRTC),\n/* harmony export */ WebRTCDirect: () => (/* binding */ WebRTCDirect),\n/* harmony export */ WebSockets: () => (/* binding */ WebSockets),\n/* harmony export */ WebSocketsSecure: () => (/* binding */ WebSocketsSecure),\n/* harmony export */ WebTransport: () => (/* binding */ WebTransport)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/is-ip */ \"./node_modules/@chainsafe/is-ip/lib/is-ip.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base64 */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/**\n * @packageDocumentation\n *\n * This module exports various matchers that can be used to infer the type of a\n * passed multiaddr.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNS } from '@multiformats/multiaddr-matcher'\n *\n * const ma = multiaddr('/dnsaddr/example.org')\n *\n * DNS.matches(ma) // true - this is a multiaddr with a DNS address at the start\n * ```\n *\n * @example\n *\n * The default matching behaviour ignores any subsequent tuples in the multiaddr.\n * If you want stricter matching you can use `.exactMatch`:\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNS, Circuit } from '@multiformats/multiaddr-matcher'\n *\n * const ma = multiaddr('/dnsaddr/example.org/p2p/QmFoo/p2p-circuit/p2p/QmBar')\n *\n * DNS.exactMatch(ma) // false - this address has extra tuples after the DNS component\n * Circuit.matches(ma) // true\n * Circuit.exactMatch(ma) // true - the extra tuples are circuit relay related\n * ```\n */\n\n\n\n\n/**\n * Split a multiaddr into path components\n */\nconst toParts = (ma) => {\n return ma.toString().split('/').slice(1);\n};\nconst func = (fn) => {\n return {\n match: (vals) => {\n if (vals.length < 1) {\n return false;\n }\n if (fn(vals[0])) {\n return vals.slice(1);\n }\n return false;\n },\n pattern: 'fn'\n };\n};\nconst literal = (str) => {\n return {\n match: (vals) => func((val) => val === str).match(vals),\n pattern: str\n };\n};\nconst string = () => {\n return {\n match: (vals) => func((val) => typeof val === 'string').match(vals),\n pattern: '{string}'\n };\n};\nconst number = () => {\n return {\n match: (vals) => func((val) => !isNaN(parseInt(val))).match(vals),\n pattern: '{number}'\n };\n};\nconst peerId = () => {\n return {\n match: (vals) => {\n if (vals.length < 2) {\n return false;\n }\n if (vals[0] !== 'p2p' && vals[0] !== 'ipfs') {\n return false;\n }\n // Q is RSA, 1 is Ed25519 or Secp256k1\n if (vals[1].startsWith('Q') || vals[1].startsWith('1')) {\n try {\n multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.decode(`z${vals[1]}`);\n }\n catch (err) {\n return false;\n }\n }\n else {\n return false;\n }\n return vals.slice(2);\n },\n pattern: '/p2p/{peerid}'\n };\n};\nconst certhash = () => {\n return {\n match: (vals) => {\n if (vals.length < 2) {\n return false;\n }\n if (vals[0] !== 'certhash') {\n return false;\n }\n try {\n multiformats_bases_base64__WEBPACK_IMPORTED_MODULE_3__.base64url.decode(vals[1]);\n }\n catch {\n return false;\n }\n return vals.slice(2);\n },\n pattern: '/certhash/{certhash}'\n };\n};\nconst optional = (matcher) => {\n return {\n match: (vals) => {\n const result = matcher.match(vals);\n if (result === false) {\n return vals;\n }\n return result;\n },\n pattern: `optional(${matcher.pattern})`\n };\n};\nconst or = (...matchers) => {\n return {\n match: (vals) => {\n let matches;\n for (const matcher of matchers) {\n const result = matcher.match(vals);\n // no match\n if (result === false) {\n continue;\n }\n // choose greediest matcher\n if (matches == null || result.length < matches.length) {\n matches = result;\n }\n }\n if (matches == null) {\n return false;\n }\n return matches;\n },\n pattern: `or(${matchers.map(m => m.pattern).join(', ')})`\n };\n};\nconst and = (...matchers) => {\n return {\n match: (vals) => {\n for (const matcher of matchers) {\n // pass what's left of the array\n const result = matcher.match(vals);\n // no match\n if (result === false) {\n return false;\n }\n vals = result;\n }\n return vals;\n },\n pattern: `and(${matchers.map(m => m.pattern).join(', ')})`\n };\n};\nfunction fmt(...matchers) {\n function match(ma) {\n let parts = toParts(ma);\n for (const matcher of matchers) {\n const result = matcher.match(parts);\n if (result === false) {\n return false;\n }\n parts = result;\n }\n return parts;\n }\n function matches(ma) {\n const result = match(ma);\n return result !== false;\n }\n function exactMatch(ma) {\n const result = match(ma);\n if (result === false) {\n return false;\n }\n return result.length === 0;\n }\n return {\n matches,\n exactMatch\n };\n}\n/**\n * DNS matchers\n */\nconst _DNS4 = and(literal('dns4'), string());\nconst _DNS6 = and(literal('dns6'), string());\nconst _DNSADDR = and(literal('dnsaddr'), string());\nconst _DNS = and(literal('dns'), string());\n/**\n * Matches dns4 addresses.\n *\n * Use {@link DNS DNS} instead to match any type of DNS address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNS4 } from '@multiformats/multiaddr-matcher'\n *\n * DNS4.matches(multiaddr('/dns4/example.org')) // true\n * ```\n */\nconst DNS4 = fmt(_DNS4);\n/**\n * Matches dns6 addresses.\n *\n * Use {@link DNS DNS} instead to match any type of DNS address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNS6 } from '@multiformats/multiaddr-matcher'\n *\n * DNS6.matches(multiaddr('/dns6/example.org')) // true\n * ```\n */\nconst DNS6 = fmt(_DNS6);\n/**\n * Matches dnsaddr addresses.\n *\n * Use {@link DNS DNS} instead to match any type of DNS address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNSADDR } from '@multiformats/multiaddr-matcher'\n *\n * DNSADDR.matches(multiaddr('/dnsaddr/example.org')) // true\n * ```\n */\nconst DNSADDR = fmt(_DNSADDR);\n/**\n * Matches any dns address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { DNS } from '@multiformats/multiaddr-matcher'\n *\n * DNS.matches(multiaddr('/dnsaddr/example.org')) // true\n * DNS.matches(multiaddr('/dns4/example.org')) // true\n * DNS.matches(multiaddr('/dns6/example.org')) // true\n * ```\n */\nconst DNS = fmt(or(_DNS, _DNSADDR, _DNS4, _DNS6));\nconst _IP4 = and(literal('ip4'), func(_chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4));\nconst _IP6 = and(literal('ip6'), func(_chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6));\nconst _IP = or(_IP4, _IP6);\nconst _IP_OR_DOMAIN = or(_IP, _DNS, _DNS4, _DNS6, _DNSADDR);\n/**\n * A matcher for addresses that start with IP or DNS tuples.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher'\n *\n * IP_OR_DOMAIN.matches(multiaddr('/ip4/123.123.123.123/p2p/QmFoo')) // true\n * IP_OR_DOMAIN.matches(multiaddr('/dns/example.com/p2p/QmFoo')) // true\n * IP_OR_DOMAIN.matches(multiaddr('/p2p/QmFoo')) // false\n * ```\n */\nconst IP_OR_DOMAIN = fmt(_IP_OR_DOMAIN);\n/**\n * Matches ip4 addresses.\n *\n * Use {@link IP IP} instead to match any ip4/ip6 address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { IP4 } from '@multiformats/multiaddr-matcher'\n *\n * const ma = multiaddr('/ip4/123.123.123.123')\n *\n * IP4.matches(ma) // true\n * ```\n */\nconst IP4 = fmt(_IP4);\n/**\n * Matches ip6 addresses.\n *\n * Use {@link IP IP} instead to match any ip4/ip6 address.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { IP6 } from '@multiformats/multiaddr-matcher'\n *\n * const ma = multiaddr('/ip6/fe80::1cc1:a3b8:322f:cf22')\n *\n * IP6.matches(ma) // true\n * ```\n */\nconst IP6 = fmt(_IP6);\n/**\n * Matches ip4 or ip6 addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { IP } from '@multiformats/multiaddr-matcher'\n *\n * IP.matches(multiaddr('/ip4/123.123.123.123')) // true\n * IP.matches(multiaddr('/ip6/fe80::1cc1:a3b8:322f:cf22')) // true\n * ```\n */\nconst IP = fmt(_IP);\nconst _TCP = and(_IP_OR_DOMAIN, literal('tcp'), number());\nconst _UDP = and(_IP_OR_DOMAIN, literal('udp'), number());\nconst TCP_OR_UDP = or(_TCP, _UDP);\n/**\n * Matches TCP addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { TCP } from '@multiformats/multiaddr-matcher'\n *\n * TCP.matches(multiaddr('/ip4/123.123.123.123/tcp/1234')) // true\n * ```\n */\nconst TCP = fmt(_TCP);\n/**\n * Matches UDP addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { UDP } from '@multiformats/multiaddr-matcher'\n *\n * UDP.matches(multiaddr('/ip4/123.123.123.123/udp/1234')) // true\n * ```\n */\nconst UDP = fmt(_UDP);\nconst _QUIC = and(_UDP, literal('quic'));\nconst _QUICV1 = and(_UDP, literal('quic-v1'));\nconst QUIC_V0_OR_V1 = or(_QUIC, _QUICV1);\n/**\n * Matches QUIC addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { QUIC } from '@multiformats/multiaddr-matcher'\n *\n * QUIC.matches(multiaddr('/ip4/123.123.123.123/udp/1234/quic')) // true\n * ```\n */\nconst QUIC = fmt(_QUIC);\n/**\n * Matches QUICv1 addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { QUICV1 } from '@multiformats/multiaddr-matcher'\n *\n * QUICV1.matches(multiaddr('/ip4/123.123.123.123/udp/1234/quic-v1')) // true\n * ```\n */\nconst QUICV1 = fmt(_QUICV1);\nconst _WEB = or(_IP_OR_DOMAIN, _TCP, _UDP, _QUIC, _QUICV1);\nconst _WebSockets = or(and(_WEB, literal('ws'), optional(peerId())));\n/**\n * Matches WebSocket addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { WebSockets } from '@multiformats/multiaddr-matcher'\n *\n * WebSockets.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/ws')) // true\n * ```\n */\nconst WebSockets = fmt(_WebSockets);\nconst _WebSocketsSecure = or(and(_WEB, literal('wss'), optional(peerId())), and(_WEB, literal('tls'), literal('ws'), optional(peerId())));\n/**\n * Matches secure WebSocket addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { WebSocketsSecure } from '@multiformats/multiaddr-matcher'\n *\n * WebSocketsSecure.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/wss')) // true\n * ```\n */\nconst WebSocketsSecure = fmt(_WebSocketsSecure);\nconst _WebRTCDirect = and(TCP_OR_UDP, literal('webrtc-direct'), certhash(), optional(certhash()), optional(peerId()));\n/**\n * Matches WebRTC-direct addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { WebRTCDirect } from '@multiformats/multiaddr-matcher'\n *\n * WebRTCDirect.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/p2p/QmFoo/webrtc-direct/certhash/u....')) // true\n * ```\n */\nconst WebRTCDirect = fmt(_WebRTCDirect);\nconst _WebTransport = and(_QUICV1, literal('webtransport'), certhash(), certhash(), optional(peerId()));\n/**\n * Matches WebTransport addresses.\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { WebRTCDirect } from '@multiformats/multiaddr-matcher'\n *\n * WebRTCDirect.matches(multiaddr('/ip4/123.123.123.123/udp/1234/quic-v1/webtransport/certhash/u..../certhash/u..../p2p/QmFoo')) // true\n * ```\n */\nconst WebTransport = fmt(_WebTransport);\nconst _P2P = or(_WebSockets, _WebSocketsSecure, and(_TCP, optional(peerId())), and(QUIC_V0_OR_V1, optional(peerId())), and(_IP_OR_DOMAIN, optional(peerId())), _WebRTCDirect, _WebTransport, peerId());\n/**\n * Matches peer addresses\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { P2P } from '@multiformats/multiaddr-matcher'\n *\n * P2P.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/p2p/QmFoo')) // true\n * ```\n */\nconst P2P = fmt(_P2P);\nconst _Circuit = and(_P2P, literal('p2p-circuit'), peerId());\n/**\n * Matches circuit relay addresses\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { Circuit } from '@multiformats/multiaddr-matcher'\n *\n * Circuit.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/p2p/QmRelay/p2p-circuit/p2p/QmTarget')) // true\n * ```\n */\nconst Circuit = fmt(_Circuit);\nconst _WebRTC = or(and(_P2P, literal('p2p-circuit'), literal('webrtc'), peerId()), and(_P2P, literal('webrtc'), optional(peerId())), literal('webrtc'));\n/**\n * Matches WebRTC addresses\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { WebRTC } from '@multiformats/multiaddr-matcher'\n *\n * WebRTC.matches(multiaddr('/ip4/123.123.123.123/tcp/1234/p2p/QmRelay/p2p-circuit/webrtc/p2p/QmTarget')) // true\n * ```\n */\nconst WebRTC = fmt(_WebRTC);\nconst _HTTP = or(and(_IP_OR_DOMAIN, literal('tcp'), number(), literal('http'), optional(peerId())), and(_IP_OR_DOMAIN, literal('http'), optional(peerId())));\n/**\n * Matches HTTP addresses\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { HTTP } from '@multiformats/multiaddr-matcher'\n *\n * HTTP.matches(multiaddr('/dns/example.org/http')) // true\n * ```\n */\nconst HTTP = fmt(_HTTP);\nconst _HTTPS = or(and(_IP_OR_DOMAIN, literal('tcp'), or(and(literal('443'), literal('http')), and(number(), literal('https'))), optional(peerId())), and(_IP_OR_DOMAIN, literal('tls'), literal('http'), optional(peerId())), and(_IP_OR_DOMAIN, literal('https'), optional(peerId())));\n/**\n * Matches HTTPS addresses\n *\n * @example\n *\n * ```ts\n * import { multiaddr } from '@multiformats/multiaddr'\n * import { HTTP } from '@multiformats/multiaddr-matcher'\n *\n * HTTP.matches(multiaddr('/dns/example.org/tls/http')) // true\n * ```\n */\nconst HTTPS = fmt(_HTTPS);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js": /*!***********************************************************************!*\ !*** ./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js ***! @@ -3871,7 +4252,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrToUri: () => (/* binding */ multiaddrToUri)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * This module allows easy conversion of Multiaddrs to URLs.\n *\n * @example Converting multiaddrs to URLs\n *\n * ```js\n * import { multiaddrToUri } from '@multiformats/multiaddr-to-uri'\n *\n * console.log(multiaddrToUri('/dnsaddr/protocol.ai/https'))\n * // -> https://protocol.ai\n *\n * console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080'))\n * // -> http://127.0.0.1:8080\n *\n * console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080', { assumeHttp: false }))\n * // -> tcp://127.0.0.1:8080\n * ```\n *\n * Note:\n *\n * - When `/tcp` is the last (terminating) protocol HTTP is assumed by default (implicit `assumeHttp: true`)\n * - this means produced URIs will start with `http://` instead of `tcp://`\n * - passing `{ assumeHttp: false }` disables this behavior\n * - Might be lossy - e.g. a DNSv6 multiaddr\n * - Can throw if the passed multiaddr:\n * - is not a valid multiaddr\n * - is not supported as a URI e.g. circuit\n */\n\nfunction extractSNI(ma) {\n let sniProtoCode;\n try {\n sniProtoCode = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('sni').code;\n }\n catch (e) {\n // No SNI protocol in multiaddr\n return null;\n }\n for (const [proto, value] of ma) {\n if (proto === sniProtoCode && value !== undefined) {\n return value;\n }\n }\n return null;\n}\nfunction hasTLS(ma) {\n return ma.some(([proto, _]) => proto === (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('tls').code);\n}\nfunction interpretNext(headProtoCode, headProtoVal, restMa) {\n const interpreter = interpreters[(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(headProtoCode).name];\n if (interpreter === undefined) {\n throw new Error(`Can't interpret protocol ${(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(headProtoCode).name}`);\n }\n const restVal = interpreter(headProtoVal, restMa);\n if (headProtoCode === (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('ip6').code) {\n return `[${restVal}]`;\n }\n return restVal;\n}\nconst interpreters = {\n ip4: (value, restMa) => value,\n ip6: (value, restMa) => {\n if (restMa.length === 0) {\n return value;\n }\n return `[${value}]`;\n },\n tcp: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `tcp://${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}:${value}`;\n },\n udp: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `udp://${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}:${value}`;\n },\n dnsaddr: (value, restMa) => value,\n dns4: (value, restMa) => value,\n dns6: (value, restMa) => value,\n dns: (value, restMa) => value,\n ipfs: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/ipfs/${value}`;\n },\n p2p: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p/${value}`;\n },\n http: (value, restMa) => {\n const maHasTLS = hasTLS(restMa);\n const sni = extractSNI(restMa);\n if (maHasTLS && sni !== null) {\n return `https://${sni}`;\n }\n const protocol = maHasTLS ? 'https://' : 'http://';\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `${protocol}${baseVal}`;\n },\n tls: (value, restMa) => {\n // Noop, the parent context knows that it's tls. We don't need to do\n // anything here\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n },\n sni: (value, restMa) => {\n // Noop, the parent context uses the sni information, we don't need to do\n // anything here\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n },\n https: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `https://${baseVal}`;\n },\n ws: (value, restMa) => {\n const maHasTLS = hasTLS(restMa);\n const sni = extractSNI(restMa);\n if (maHasTLS && sni !== null) {\n return `wss://${sni}`;\n }\n const protocol = maHasTLS ? 'wss://' : 'ws://';\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `${protocol}${baseVal}`;\n },\n wss: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `wss://${baseVal}`;\n },\n 'p2p-websocket-star': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-websocket-star`;\n },\n 'p2p-webrtc-star': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-webrtc-star`;\n },\n 'p2p-webrtc-direct': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-webrtc-direct`;\n }\n};\nfunction multiaddrToUri(input, opts) {\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(input);\n const parts = ma.stringTuples();\n const head = parts.pop();\n if (head === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n const protocol = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(head[0]);\n const interpreter = interpreters[protocol.name];\n if (interpreter == null) {\n throw new Error(`No interpreter found for ${protocol.name}`);\n }\n let uri = interpreter(head[1] ?? '', parts);\n if (opts?.assumeHttp !== false && head[0] === (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('tcp').code) {\n // If rightmost proto is tcp, we assume http here\n uri = uri.replace('tcp://', 'http://');\n if (head[1] === '443' || head[1] === '80') {\n if (head[1] === '443') {\n uri = uri.replace('http://', 'https://');\n }\n // Drop the port\n uri = uri.substring(0, uri.lastIndexOf(':'));\n }\n }\n return uri;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrToUri: () => (/* binding */ multiaddrToUri)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * This module allows easy conversion of Multiaddrs to string URIs.\n *\n * @example Converting multiaddrs to string URIs\n *\n * ```js\n * import { multiaddrToUri } from '@multiformats/multiaddr-to-uri'\n *\n * console.log(multiaddrToUri('/dnsaddr/protocol.ai/https'))\n * // -> https://protocol.ai\n *\n * console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080'))\n * // -> http://127.0.0.1:8080\n *\n * console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080', { assumeHttp: false }))\n * // -> tcp://127.0.0.1:8080\n * ```\n *\n * Note:\n *\n * - When `/tcp` is the last (terminating) protocol HTTP is assumed by default (implicit `assumeHttp: true`)\n * - this means produced URIs will start with `http://` instead of `tcp://`\n * - passing `{ assumeHttp: false }` disables this behavior\n * - Might be lossy - e.g. a DNSv6 multiaddr\n * - Can throw if the passed multiaddr:\n * - is not a valid multiaddr\n * - is not supported as a URI e.g. circuit\n */\n\nconst ASSUME_HTTP_CODES = [\n (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('tcp').code,\n (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('dns').code,\n (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('dnsaddr').code,\n (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('dns4').code,\n (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('dns6').code\n];\nfunction extractSNI(ma) {\n let sniProtoCode;\n try {\n sniProtoCode = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('sni').code;\n }\n catch (e) {\n // No SNI protocol in multiaddr\n return null;\n }\n for (const [proto, value] of ma) {\n if (proto === sniProtoCode && value !== undefined) {\n return value;\n }\n }\n return null;\n}\nfunction hasTLS(ma) {\n return ma.some(([proto, _]) => proto === (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('tls').code);\n}\nfunction interpretNext(headProtoCode, headProtoVal, restMa) {\n const interpreter = interpreters[(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(headProtoCode).name];\n if (interpreter === undefined) {\n throw new Error(`Can't interpret protocol ${(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(headProtoCode).name}`);\n }\n const restVal = interpreter(headProtoVal, restMa);\n if (headProtoCode === (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)('ip6').code) {\n return `[${restVal}]`;\n }\n return restVal;\n}\nconst interpreters = {\n ip4: (value, restMa) => value,\n ip6: (value, restMa) => {\n if (restMa.length === 0) {\n return value;\n }\n return `[${value}]`;\n },\n tcp: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `tcp://${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}:${value}`;\n },\n udp: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `udp://${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}:${value}`;\n },\n dnsaddr: (value, restMa) => value,\n dns4: (value, restMa) => value,\n dns6: (value, restMa) => value,\n dns: (value, restMa) => value,\n ipfs: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/ipfs/${value}`;\n },\n p2p: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p/${value}`;\n },\n http: (value, restMa) => {\n const maHasTLS = hasTLS(restMa);\n const sni = extractSNI(restMa);\n if (maHasTLS && sni !== null) {\n return `https://${sni}`;\n }\n const protocol = maHasTLS ? 'https://' : 'http://';\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `${protocol}${baseVal}`;\n },\n tls: (value, restMa) => {\n // Noop, the parent context knows that it's tls. We don't need to do\n // anything here\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n },\n sni: (value, restMa) => {\n // Noop, the parent context uses the sni information, we don't need to do\n // anything here\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n },\n https: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `https://${baseVal}`;\n },\n ws: (value, restMa) => {\n const maHasTLS = hasTLS(restMa);\n const sni = extractSNI(restMa);\n if (maHasTLS && sni !== null) {\n return `wss://${sni}`;\n }\n const protocol = maHasTLS ? 'wss://' : 'ws://';\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `${protocol}${baseVal}`;\n },\n wss: (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n let baseVal = interpretNext(tailProto[0], tailProto[1] ?? '', restMa);\n // We are reinterpreting the base as http, so we need to remove the tcp:// if it's there\n baseVal = baseVal.replace('tcp://', '');\n return `wss://${baseVal}`;\n },\n 'p2p-websocket-star': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-websocket-star`;\n },\n 'p2p-webrtc-star': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-webrtc-star`;\n },\n 'p2p-webrtc-direct': (value, restMa) => {\n const tailProto = restMa.pop();\n if (tailProto === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n return `${interpretNext(tailProto[0], tailProto[1] ?? '', restMa)}/p2p-webrtc-direct`;\n }\n};\nfunction multiaddrToUri(input, opts) {\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(input);\n const parts = ma.stringTuples();\n const head = parts.pop();\n if (head === undefined) {\n throw new Error('Unexpected end of multiaddr');\n }\n const protocol = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.protocols)(head[0]);\n const interpreter = interpreters[protocol.name];\n if (interpreter == null) {\n throw new Error(`No interpreter found for ${protocol.name}`);\n }\n let uri = interpreter(head[1] ?? '', parts);\n if (opts?.assumeHttp !== false && ASSUME_HTTP_CODES.includes(head[0])) {\n // strip any declared protocol\n uri = uri.replace(/^.*:\\/\\//, '');\n if (head[1] === '443') {\n uri = `https://${uri}`;\n }\n else {\n uri = `http://${uri}`;\n }\n }\n if (uri.startsWith('http://') || uri.startsWith('https://')) {\n // this will strip default ports while keeping paths intact\n uri = new URL(uri).toString();\n // strip trailing slash, e.g. http://127.0.0.1/ -> http://127.0.0.1\n if (uri.endsWith('/')) {\n uri = uri.substring(0, uri.length - 1);\n }\n }\n return uri;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js?"); /***/ }), @@ -3882,7 +4263,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParseError: () => (/* binding */ ParseError),\n/* harmony export */ bytesToMultiaddrParts: () => (/* binding */ bytesToMultiaddrParts),\n/* harmony export */ bytesToTuples: () => (/* binding */ bytesToTuples),\n/* harmony export */ cleanPath: () => (/* binding */ cleanPath),\n/* harmony export */ stringToMultiaddrParts: () => (/* binding */ stringToMultiaddrParts),\n/* harmony export */ tuplesToBytes: () => (/* binding */ tuplesToBytes)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n\n\n\n\n\nfunction stringToMultiaddrParts(str) {\n str = cleanPath(str);\n const tuples = [];\n const stringTuples = [];\n let path = null;\n const parts = str.split('/').slice(1);\n if (parts.length === 1 && parts[0] === '') {\n return {\n bytes: new Uint8Array(),\n string: '/',\n tuples: [],\n stringTuples: [],\n path: null\n };\n }\n for (let p = 0; p < parts.length; p++) {\n const part = parts[p];\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([proto.code]);\n stringTuples.push([proto.code]);\n // eslint-disable-next-line no-continue\n continue;\n }\n p++; // advance addr part\n if (p >= parts.length) {\n throw ParseError('invalid address: ' + str);\n }\n // if it's a path proto, take the rest\n if (proto.path === true) {\n // should we need to check each path part to see if it's a proto?\n // This would allow for other protocols to be added after a unix path,\n // however it would have issues if the path had a protocol name in the path\n path = cleanPath(parts.slice(p).join('/'));\n tuples.push([proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, path)]);\n stringTuples.push([proto.code, path]);\n break;\n }\n const bytes = (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, parts[p]);\n tuples.push([proto.code, bytes]);\n stringTuples.push([proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(proto.code, bytes)]);\n }\n return {\n string: stringTuplesToString(stringTuples),\n bytes: tuplesToBytes(tuples),\n tuples,\n stringTuples,\n path\n };\n}\nfunction bytesToMultiaddrParts(bytes) {\n const tuples = [];\n const stringTuples = [];\n let path = null;\n let i = 0;\n while (i < bytes.length) {\n const code = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(bytes, i);\n const n = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(code);\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(code);\n const size = sizeForAddr(p, bytes.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n stringTuples.push([code]);\n i += n;\n // eslint-disable-next-line no-continue\n continue;\n }\n const addr = bytes.slice(i + n, i + n + size);\n i += (size + n);\n if (i > bytes.length) { // did not end _exactly_ at buffer.length\n throw ParseError('Invalid address Uint8Array: ' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bytes, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n const stringAddr = (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(code, addr);\n stringTuples.push([code, stringAddr]);\n if (p.path === true) {\n // should we need to check each path part to see if it's a proto?\n // This would allow for other protocols to be added after a unix path,\n // however it would have issues if the path had a protocol name in the path\n path = stringAddr;\n break;\n }\n }\n return {\n bytes: Uint8Array.from(bytes),\n string: stringTuplesToString(stringTuples),\n tuples,\n stringTuples,\n path\n };\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n parts.push(proto.name);\n if (tup.length > 1 && tup[1] != null) {\n parts.push(tup[1]);\n }\n return null;\n });\n return cleanPath(parts.join('/'));\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)(tuples.map((tup) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n let buf = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([buf, tup[1]]); // add address buffer\n }\n return buf;\n }));\n}\n/**\n * For the passed address, return the serialized size\n */\nfunction sizeForAddr(p, addr) {\n if (p.size > 0) {\n return p.size / 8;\n }\n else if (p.size === 0) {\n return 0;\n }\n else {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(addr instanceof Uint8Array ? addr : Uint8Array.from(addr));\n return size + uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(size);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(buf, i);\n const n = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(code);\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(code);\n const size = sizeForAddr(p, buf.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n i += n;\n // eslint-disable-next-line no-continue\n continue;\n }\n const addr = buf.slice(i + n, i + n + size);\n i += (size + n);\n if (i > buf.length) { // did not end _exactly_ at buffer.length\n throw ParseError('Invalid address Uint8Array: ' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\nfunction cleanPath(str) {\n return '/' + str.trim().split('/').filter((a) => a).join('/');\n}\nfunction ParseError(str) {\n return new Error('Error parsing address: ' + str);\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/codec.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParseError: () => (/* binding */ ParseError),\n/* harmony export */ bytesToMultiaddrParts: () => (/* binding */ bytesToMultiaddrParts),\n/* harmony export */ bytesToTuples: () => (/* binding */ bytesToTuples),\n/* harmony export */ cleanPath: () => (/* binding */ cleanPath),\n/* harmony export */ stringToMultiaddrParts: () => (/* binding */ stringToMultiaddrParts),\n/* harmony export */ tuplesToBytes: () => (/* binding */ tuplesToBytes)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n\n\n\n\n\nfunction stringToMultiaddrParts(str) {\n str = cleanPath(str);\n const tuples = [];\n const stringTuples = [];\n let path = null;\n const parts = str.split('/').slice(1);\n if (parts.length === 1 && parts[0] === '') {\n return {\n bytes: new Uint8Array(),\n string: '/',\n tuples: [],\n stringTuples: [],\n path: null\n };\n }\n for (let p = 0; p < parts.length; p++) {\n const part = parts[p];\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([proto.code]);\n stringTuples.push([proto.code]);\n // eslint-disable-next-line no-continue\n continue;\n }\n p++; // advance addr part\n if (p >= parts.length) {\n throw ParseError('invalid address: ' + str);\n }\n // if it's a path proto, take the rest\n if (proto.path === true) {\n // should we need to check each path part to see if it's a proto?\n // This would allow for other protocols to be added after a unix path,\n // however it would have issues if the path had a protocol name in the path\n path = cleanPath(parts.slice(p).join('/'));\n tuples.push([proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, path)]);\n stringTuples.push([proto.code, path]);\n break;\n }\n const bytes = (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, parts[p]);\n tuples.push([proto.code, bytes]);\n stringTuples.push([proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(proto.code, bytes)]);\n }\n return {\n string: stringTuplesToString(stringTuples),\n bytes: tuplesToBytes(tuples),\n tuples,\n stringTuples,\n path\n };\n}\nfunction bytesToMultiaddrParts(bytes) {\n const tuples = [];\n const stringTuples = [];\n let path = null;\n let i = 0;\n while (i < bytes.length) {\n const code = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(bytes, i);\n const n = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(code);\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(code);\n const size = sizeForAddr(p, bytes.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n stringTuples.push([code]);\n i += n;\n // eslint-disable-next-line no-continue\n continue;\n }\n const addr = bytes.slice(i + n, i + n + size);\n i += (size + n);\n if (i > bytes.length) { // did not end _exactly_ at buffer.length\n throw ParseError('Invalid address Uint8Array: ' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(bytes, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n const stringAddr = (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(code, addr);\n stringTuples.push([code, stringAddr]);\n if (p.path === true) {\n // should we need to check each path part to see if it's a proto?\n // This would allow for other protocols to be added after a unix path,\n // however it would have issues if the path had a protocol name in the path\n path = stringAddr;\n break;\n }\n }\n return {\n bytes: Uint8Array.from(bytes),\n string: stringTuplesToString(stringTuples),\n tuples,\n stringTuples,\n path\n };\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n parts.push(proto.name);\n if (tup.length > 1 && tup[1] != null) {\n parts.push(tup[1]);\n }\n return null;\n });\n return cleanPath(parts.join('/'));\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)(tuples.map((tup) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n let buf = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([buf, tup[1]]); // add address buffer\n }\n return buf;\n }));\n}\n/**\n * For the passed address, return the serialized size\n */\nfunction sizeForAddr(p, addr) {\n if (p.size > 0) {\n return p.size / 8;\n }\n else if (p.size === 0) {\n return 0;\n }\n else {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(addr instanceof Uint8Array ? addr : Uint8Array.from(addr));\n return size + uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(size);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decode(buf, i);\n const n = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(code);\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(code);\n const size = sizeForAddr(p, buf.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n i += n;\n // eslint-disable-next-line no-continue\n continue;\n }\n const addr = buf.slice(i + n, i + n + size);\n i += (size + n);\n if (i > buf.length) { // did not end _exactly_ at buffer.length\n throw ParseError('Invalid address Uint8Array: ' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\nfunction cleanPath(str) {\n return '/' + str.trim().split('/').filter((a) => a).join('/');\n}\nfunction ParseError(str) {\n return new Error('Error parsing address: ' + str);\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/codec.js?"); /***/ }), @@ -3893,7 +4274,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ convert: () => (/* binding */ convert),\n/* harmony export */ convertToBytes: () => (/* binding */ convertToBytes),\n/* harmony export */ convertToIpNet: () => (/* binding */ convertToIpNet),\n/* harmony export */ convertToString: () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\n\nconst ip4Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ipcidr');\nfunction convert(proto, a) {\n if (a instanceof Uint8Array) {\n return convertToString(proto, a);\n }\n else {\n return convertToBytes(proto, a);\n }\n}\n/**\n * Convert [code,Uint8Array] to string\n */\nfunction convertToString(proto, buf) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n case 41: // ipv6\n return bytes2ip(buf);\n case 42: // ipv6zone\n return bytes2str(buf);\n case 6: // tcp\n case 273: // udp\n case 33: // dccp\n case 132: // sctp\n return bytes2port(buf).toString();\n case 53: // dns\n case 54: // dns4\n case 55: // dns6\n case 56: // dnsaddr\n case 400: // unix\n case 449: // sni\n case 777: // memory\n return bytes2str(buf);\n case 421: // ipfs\n return bytes2mh(buf);\n case 444: // onion\n return bytes2onion(buf);\n case 445: // onion3\n return bytes2onion(buf);\n case 466: // certhash\n return bytes2mb(buf);\n default:\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n return ip2bytes(str);\n case 41: // ipv6\n return ip2bytes(str);\n case 42: // ipv6zone\n return str2bytes(str);\n case 6: // tcp\n case 273: // udp\n case 33: // dccp\n case 132: // sctp\n return port2bytes(parseInt(str, 10));\n case 53: // dns\n case 54: // dns4\n case 55: // dns6\n case 56: // dnsaddr\n case 400: // unix\n case 449: // sni\n case 777: // memory\n return str2bytes(str);\n case 421: // ipfs\n return mh2bytes(str);\n case 444: // onion\n return onion2bytes(str);\n case 445: // onion3\n return onion32bytes(str);\n case 466: // certhash\n return mb2bytes(str);\n default:\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nfunction convertToIpNet(multiaddr) {\n let mask;\n let addr;\n multiaddr.stringTuples().forEach(([code, value]) => {\n if (code === ip4Protocol.code || code === ip6Protocol.code) {\n addr = value;\n }\n if (code === ipcidrProtocol.code) {\n mask = value;\n }\n });\n if (mask == null || addr == null) {\n throw new Error('Invalid multiaddr');\n }\n return new _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_0__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_3__.bases).map((c) => c.decoder);\nconst anybaseDecoder = (function () {\n let acc = decoders[0].or(decoders[1]);\n decoders.slice(2).forEach((d) => (acc = acc.or(d)));\n return acc;\n})();\nfunction ip2bytes(ipString) {\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_10__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_10__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_10__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_10__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return ipString;\n}\nfunction port2bytes(port) {\n const buf = new ArrayBuffer(2);\n const view = new DataView(buf);\n view.setUint16(0, port);\n return new Uint8Array(buf);\n}\nfunction bytes2port(buf) {\n const view = new DataView(buf.buffer);\n return view.getUint16(buf.byteOffset);\n}\nfunction str2bytes(str) {\n const buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(str);\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n buf = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(buf);\n}\nfunction mh2bytes(hash) {\n let mh;\n if (hash[0] === 'Q' || hash[0] === '1') {\n mh = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_4__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n const hash = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n const address = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(address, 'base58btc');\n}\nfunction onion2bytes(str) {\n const addr = str.split(':');\n if (addr.length !== 2) {\n throw new Error(`failed to parse onion addr: [\"'${addr.join('\", \"')}'\"]' does not contain a port number`);\n }\n if (addr[0].length !== 16) {\n throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion address.`);\n }\n // onion addresses do not include the multibase prefix, add it before decoding\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.decode('b' + addr[0]);\n // onion port number\n const port = parseInt(addr[1], 10);\n if (port < 1 || port > 65536) {\n throw new Error('Port number is not in range(1, 65536)');\n }\n const portBuf = port2bytes(port);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([buf, portBuf], buf.length + portBuf.length);\n}\nfunction onion32bytes(str) {\n const addr = str.split(':');\n if (addr.length !== 2) {\n throw new Error(`failed to parse onion addr: [\"'${addr.join('\", \"')}'\"]' does not contain a port number`);\n }\n if (addr[0].length !== 56) {\n throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion3 address.`);\n }\n // onion addresses do not include the multibase prefix, add it before decoding\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.decode(`b${addr[0]}`);\n // onion port number\n const port = parseInt(addr[1], 10);\n if (port < 1 || port > 65536) {\n throw new Error('Port number is not in range(1, 65536)');\n }\n const portBuf = port2bytes(port);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([buf, portBuf], buf.length + portBuf.length);\n}\nfunction bytes2onion(buf) {\n const addrBytes = buf.slice(0, buf.length - 2);\n const portBytes = buf.slice(buf.length - 2);\n const addr = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(addrBytes, 'base32');\n const port = bytes2port(portBytes);\n return `${addr}:${port}`;\n}\n//# sourceMappingURL=convert.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/convert.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ convert: () => (/* binding */ convert),\n/* harmony export */ convertToBytes: () => (/* binding */ convertToBytes),\n/* harmony export */ convertToIpNet: () => (/* binding */ convertToIpNet),\n/* harmony export */ convertToString: () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\n\nconst ip4Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)('ipcidr');\nfunction convert(proto, a) {\n if (a instanceof Uint8Array) {\n return convertToString(proto, a);\n }\n else {\n return convertToBytes(proto, a);\n }\n}\n/**\n * Convert [code,Uint8Array] to string\n */\nfunction convertToString(proto, buf) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n case 41: // ipv6\n return bytes2ip(buf);\n case 42: // ipv6zone\n return bytes2str(buf);\n case 6: // tcp\n case 273: // udp\n case 33: // dccp\n case 132: // sctp\n return bytes2port(buf).toString();\n case 53: // dns\n case 54: // dns4\n case 55: // dns6\n case 56: // dnsaddr\n case 400: // unix\n case 449: // sni\n case 777: // memory\n return bytes2str(buf);\n case 421: // ipfs\n return bytes2mh(buf);\n case 444: // onion\n return bytes2onion(buf);\n case 445: // onion3\n return bytes2onion(buf);\n case 466: // certhash\n return bytes2mb(buf);\n default:\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_11__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n return ip2bytes(str);\n case 41: // ipv6\n return ip2bytes(str);\n case 42: // ipv6zone\n return str2bytes(str);\n case 6: // tcp\n case 273: // udp\n case 33: // dccp\n case 132: // sctp\n return port2bytes(parseInt(str, 10));\n case 53: // dns\n case 54: // dns4\n case 55: // dns6\n case 56: // dnsaddr\n case 400: // unix\n case 449: // sni\n case 777: // memory\n return str2bytes(str);\n case 421: // ipfs\n return mh2bytes(str);\n case 444: // onion\n return onion2bytes(str);\n case 445: // onion3\n return onion32bytes(str);\n case 466: // certhash\n return mb2bytes(str);\n default:\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nfunction convertToIpNet(multiaddr) {\n let mask;\n let addr;\n multiaddr.stringTuples().forEach(([code, value]) => {\n if (code === ip4Protocol.code || code === ip6Protocol.code) {\n addr = value;\n }\n if (code === ipcidrProtocol.code) {\n mask = value;\n }\n });\n if (mask == null || addr == null) {\n throw new Error('Invalid multiaddr');\n }\n return new _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_0__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_3__.bases).map((c) => c.decoder);\nconst anybaseDecoder = (function () {\n let acc = decoders[0].or(decoders[1]);\n decoders.slice(2).forEach((d) => (acc = acc.or(d)));\n return acc;\n})();\nfunction ip2bytes(ipString) {\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_10__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_10__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_10__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_10__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return ipString;\n}\nfunction port2bytes(port) {\n const buf = new ArrayBuffer(2);\n const view = new DataView(buf);\n view.setUint16(0, port);\n return new Uint8Array(buf);\n}\nfunction bytes2port(buf) {\n const view = new DataView(buf.buffer);\n return view.getUint16(buf.byteOffset);\n}\nfunction str2bytes(str) {\n const buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_8__.fromString)(str);\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n buf = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(buf);\n}\nfunction mh2bytes(hash) {\n let mh;\n if (hash[0] === 'Q' || hash[0] === '1') {\n mh = multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_5__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_4__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n const hash = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = uint8_varint__WEBPACK_IMPORTED_MODULE_6__.decode(buf);\n const address = buf.slice(uint8_varint__WEBPACK_IMPORTED_MODULE_6__.encodingLength(size));\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(address, 'base58btc');\n}\nfunction onion2bytes(str) {\n const addr = str.split(':');\n if (addr.length !== 2) {\n throw new Error(`failed to parse onion addr: [\"'${addr.join('\", \"')}'\"]' does not contain a port number`);\n }\n if (addr[0].length !== 16) {\n throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion address.`);\n }\n // onion addresses do not include the multibase prefix, add it before decoding\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.decode('b' + addr[0]);\n // onion port number\n const port = parseInt(addr[1], 10);\n if (port < 1 || port > 65536) {\n throw new Error('Port number is not in range(1, 65536)');\n }\n const portBuf = port2bytes(port);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([buf, portBuf], buf.length + portBuf.length);\n}\nfunction onion32bytes(str) {\n const addr = str.split(':');\n if (addr.length !== 2) {\n throw new Error(`failed to parse onion addr: [\"'${addr.join('\", \"')}'\"]' does not contain a port number`);\n }\n if (addr[0].length !== 56) {\n throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion3 address.`);\n }\n // onion addresses do not include the multibase prefix, add it before decoding\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_1__.base32.decode(`b${addr[0]}`);\n // onion port number\n const port = parseInt(addr[1], 10);\n if (port < 1 || port > 65536) {\n throw new Error('Port number is not in range(1, 65536)');\n }\n const portBuf = port2bytes(port);\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_7__.concat)([buf, portBuf], buf.length + portBuf.length);\n}\nfunction bytes2onion(buf) {\n const addrBytes = buf.slice(0, buf.length - 2);\n const portBytes = buf.slice(buf.length - 2);\n const addr = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(addrBytes, 'base32');\n const port = bytes2port(portBytes);\n return `${addr}:${port}`;\n}\n//# sourceMappingURL=convert.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/convert.js?"); /***/ }), @@ -3937,7 +4318,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Multiaddr: () => (/* binding */ Multiaddr),\n/* harmony export */ symbol: () => (/* binding */ symbol)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * An implementation of a Multiaddr in JavaScript\n *\n * @example\n *\n * ```js\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * const ma = multiaddr('/ip4/127.0.0.1/tcp/1234')\n * ```\n */\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dnsaddr').code\n];\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass Multiaddr {\n bytes;\n #string;\n #tuples;\n #stringTuples;\n #path;\n [symbol] = true;\n constructor(addr) {\n // default\n if (addr == null) {\n addr = '';\n }\n let parts;\n if (addr instanceof Uint8Array) {\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.bytesToMultiaddrParts)(addr);\n }\n else if (typeof addr === 'string') {\n if (addr.length > 0 && addr.charAt(0) !== '/') {\n throw new Error(`multiaddr \"${addr}\" must start with a \"/\"`);\n }\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.stringToMultiaddrParts)(addr);\n }\n else if ((0,_index_js__WEBPACK_IMPORTED_MODULE_6__.isMultiaddr)(addr)) { // Multiaddr\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.bytesToMultiaddrParts)(addr.bytes);\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n this.bytes = parts.bytes;\n this.#string = parts.string;\n this.#tuples = parts.tuples;\n this.#stringTuples = parts.stringTuples;\n this.#path = parts.path;\n }\n toString() {\n return this.#string;\n }\n toJSON() {\n return this.toString();\n }\n toOptions() {\n let family;\n let transport;\n let host;\n let port;\n let zone = '';\n const tcp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip6zone');\n for (const [code, value] of this.stringTuples()) {\n if (code === ip6zone.code) {\n zone = `%${value ?? ''}`;\n }\n // default to https when protocol & port are omitted from DNS addrs\n if (DNS_CODES.includes(code)) {\n transport = tcp.name;\n port = 443;\n host = `${value ?? ''}${zone}`;\n family = code === dns6.code ? 6 : 4;\n }\n if (code === tcp.code || code === udp.code) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name;\n port = parseInt(value ?? '');\n }\n if (code === ip4.code || code === ip6.code) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name;\n host = `${value ?? ''}${zone}`;\n family = code === ip6.code ? 6 : 4;\n }\n }\n if (family == null || transport == null || host == null || port == null) {\n throw new Error('multiaddr must have a valid format: \"/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}\".');\n }\n const opts = {\n family,\n host,\n transport,\n port\n };\n return opts;\n }\n protos() {\n return this.#tuples.map(([code]) => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code)));\n }\n protoCodes() {\n return this.#tuples.map(([code]) => code);\n }\n protoNames() {\n return this.#tuples.map(([code]) => (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name);\n }\n tuples() {\n return this.#tuples;\n }\n stringTuples() {\n return this.#stringTuples;\n }\n encapsulate(addr) {\n addr = new Multiaddr(addr);\n return new Multiaddr(this.toString() + addr.toString());\n }\n decapsulate(addr) {\n const addrString = addr.toString();\n const s = this.toString();\n const i = s.lastIndexOf(addrString);\n if (i < 0) {\n throw new Error(`Address ${this.toString()} does not contain subaddress: ${addr.toString()}`);\n }\n return new Multiaddr(s.slice(0, i));\n }\n decapsulateCode(code) {\n const tuples = this.tuples();\n for (let i = tuples.length - 1; i >= 0; i--) {\n if (tuples[i][0] === code) {\n return new Multiaddr((0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.tuplesToBytes)(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n let tuples = [];\n this.stringTuples().forEach(([code, name]) => {\n if (code === _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.names.p2p.code) {\n tuples.push([code, name]);\n }\n // if this is a p2p-circuit address, return the target peer id if present\n // not the peer id of the relay\n if (code === _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.names['p2p-circuit'].code) {\n tuples = [];\n }\n });\n // Get the last ipfs tuple ['p2p', 'peerid string']\n const tuple = tuples.pop();\n if (tuple?.[1] != null) {\n const peerIdStr = tuple[1];\n // peer id is base58btc encoded string but not multibase encoded so add the `z`\n // prefix so we can validate that it is correctly encoded\n if (peerIdStr[0] === 'Q' || peerIdStr[0] === '1') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_1__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n return this.#path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, addr.bytes);\n }\n async resolve(options) {\n const resolvableProto = this.protos().find((p) => p.resolvable);\n // Multiaddr is not resolvable?\n if (resolvableProto == null) {\n return [this];\n }\n const resolver = _index_js__WEBPACK_IMPORTED_MODULE_6__.resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError(`no available resolver for ${resolvableProto.name}`, 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const result = await resolver(this, options);\n return result.map(str => (0,_index_js__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(str));\n }\n nodeAddress() {\n const options = this.toOptions();\n if (options.transport !== 'tcp' && options.transport !== 'udp') {\n throw new Error(`multiaddr must have a valid format - no protocol with name: \"${options.transport}\". Must have a valid transport protocol: \"{tcp, udp}\"`);\n }\n return {\n family: options.family,\n address: options.host,\n port: options.port\n };\n }\n isThinWaistAddress(addr) {\n const protos = (addr ?? this).protos();\n if (protos.length !== 2) {\n return false;\n }\n if (protos[0].code !== 4 && protos[0].code !== 41) {\n return false;\n }\n if (protos[1].code !== 6 && protos[1].code !== 273) {\n return false;\n }\n return true;\n }\n /**\n * Returns Multiaddr as a human-readable string\n * https://nodejs.org/api/util.html#utilinspectcustom\n *\n * @example\n * ```js\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * console.info(multiaddr('/ip4/127.0.0.1/tcp/4001'))\n * // 'Multiaddr(/ip4/127.0.0.1/tcp/4001)'\n * ```\n */\n [inspect]() {\n return `Multiaddr(${this.#string})`;\n }\n}\n//# sourceMappingURL=multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/multiaddr.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Multiaddr: () => (/* binding */ Multiaddr),\n/* harmony export */ symbol: () => (/* binding */ symbol)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * An implementation of a Multiaddr in JavaScript\n *\n * @example\n *\n * ```js\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * const ma = multiaddr('/ip4/127.0.0.1/tcp/1234')\n * ```\n */\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dnsaddr').code\n];\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass Multiaddr {\n bytes;\n #string;\n #tuples;\n #stringTuples;\n #path;\n [symbol] = true;\n constructor(addr) {\n // default\n if (addr == null) {\n addr = '';\n }\n let parts;\n if (addr instanceof Uint8Array) {\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.bytesToMultiaddrParts)(addr);\n }\n else if (typeof addr === 'string') {\n if (addr.length > 0 && addr.charAt(0) !== '/') {\n throw new Error(`multiaddr \"${addr}\" must start with a \"/\"`);\n }\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.stringToMultiaddrParts)(addr);\n }\n else if ((0,_index_js__WEBPACK_IMPORTED_MODULE_6__.isMultiaddr)(addr)) { // Multiaddr\n parts = (0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.bytesToMultiaddrParts)(addr.bytes);\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n this.bytes = parts.bytes;\n this.#string = parts.string;\n this.#tuples = parts.tuples;\n this.#stringTuples = parts.stringTuples;\n this.#path = parts.path;\n }\n toString() {\n return this.#string;\n }\n toJSON() {\n return this.toString();\n }\n toOptions() {\n let family;\n let transport;\n let host;\n let port;\n let zone = '';\n const tcp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)('ip6zone');\n for (const [code, value] of this.stringTuples()) {\n if (code === ip6zone.code) {\n zone = `%${value ?? ''}`;\n }\n // default to https when protocol & port are omitted from DNS addrs\n if (DNS_CODES.includes(code)) {\n transport = tcp.name;\n port = 443;\n host = `${value ?? ''}${zone}`;\n family = code === dns6.code ? 6 : 4;\n }\n if (code === tcp.code || code === udp.code) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name;\n port = parseInt(value ?? '');\n }\n if (code === ip4.code || code === ip6.code) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name;\n host = `${value ?? ''}${zone}`;\n family = code === ip6.code ? 6 : 4;\n }\n }\n if (family == null || transport == null || host == null || port == null) {\n throw new Error('multiaddr must have a valid format: \"/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}\".');\n }\n const opts = {\n family,\n host,\n transport,\n port\n };\n return opts;\n }\n protos() {\n return this.#tuples.map(([code]) => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code)));\n }\n protoCodes() {\n return this.#tuples.map(([code]) => code);\n }\n protoNames() {\n return this.#tuples.map(([code]) => (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.getProtocol)(code).name);\n }\n tuples() {\n return this.#tuples;\n }\n stringTuples() {\n return this.#stringTuples;\n }\n encapsulate(addr) {\n addr = new Multiaddr(addr);\n return new Multiaddr(this.toString() + addr.toString());\n }\n decapsulate(addr) {\n const addrString = addr.toString();\n const s = this.toString();\n const i = s.lastIndexOf(addrString);\n if (i < 0) {\n throw new Error(`Address ${this.toString()} does not contain subaddress: ${addr.toString()}`);\n }\n return new Multiaddr(s.slice(0, i));\n }\n decapsulateCode(code) {\n const tuples = this.tuples();\n for (let i = tuples.length - 1; i >= 0; i--) {\n if (tuples[i][0] === code) {\n return new Multiaddr((0,_codec_js__WEBPACK_IMPORTED_MODULE_4__.tuplesToBytes)(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n let tuples = [];\n this.stringTuples().forEach(([code, name]) => {\n if (code === _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.names.p2p.code) {\n tuples.push([code, name]);\n }\n // if this is a p2p-circuit address, return the target peer id if present\n // not the peer id of the relay\n if (code === _protocols_table_js__WEBPACK_IMPORTED_MODULE_5__.names['p2p-circuit'].code) {\n tuples = [];\n }\n });\n // Get the last ipfs tuple ['p2p', 'peerid string']\n const tuple = tuples.pop();\n if (tuple?.[1] != null) {\n const peerIdStr = tuple[1];\n // peer id is base58btc encoded string but not multibase encoded so add the `z`\n // prefix so we can validate that it is correctly encoded\n if (peerIdStr[0] === 'Q' || peerIdStr[0] === '1') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_0__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_3__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_1__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n return this.#path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.bytes, addr.bytes);\n }\n async resolve(options) {\n const resolvableProto = this.protos().find((p) => p.resolvable);\n // Multiaddr is not resolvable?\n if (resolvableProto == null) {\n return [this];\n }\n const resolver = _index_js__WEBPACK_IMPORTED_MODULE_6__.resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_7__.CodeError(`no available resolver for ${resolvableProto.name}`, 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const result = await resolver(this, options);\n return result.map(str => (0,_index_js__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(str));\n }\n nodeAddress() {\n const options = this.toOptions();\n if (options.transport !== 'tcp' && options.transport !== 'udp') {\n throw new Error(`multiaddr must have a valid format - no protocol with name: \"${options.transport}\". Must have a valid transport protocol: \"{tcp, udp}\"`);\n }\n return {\n family: options.family,\n address: options.host,\n port: options.port\n };\n }\n isThinWaistAddress(addr) {\n const protos = (addr ?? this).protos();\n if (protos.length !== 2) {\n return false;\n }\n if (protos[0].code !== 4 && protos[0].code !== 41) {\n return false;\n }\n if (protos[1].code !== 6 && protos[1].code !== 273) {\n return false;\n }\n return true;\n }\n /**\n * Returns Multiaddr as a human-readable string\n * https://nodejs.org/api/util.html#utilinspectcustom\n *\n * @example\n * ```js\n * import { multiaddr } from '@multiformats/multiaddr'\n *\n * console.info(multiaddr('/ip4/127.0.0.1/tcp/4001'))\n * // 'Multiaddr(/ip4/127.0.0.1/tcp/4001)'\n * ```\n */\n [inspect]() {\n return `Multiaddr(${this.#string})`;\n }\n}\n//# sourceMappingURL=multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/multiaddr.js?"); /***/ }), @@ -3974,347 +4355,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js ***! - \*******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/interface.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/interface.js ***! - \****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/block/interface.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/block/interface.js ***! - \****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/block/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/interface.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/interface.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js ***! - \****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/interface.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/interface.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! - \********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/index.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/interface.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/base-x.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/base-x.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/varint.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/varint.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/uint8-varint/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/uint8-varint/dist/src/index.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ decodeUint8Array: () => (/* binding */ decodeUint8Array),\n/* harmony export */ decodeUint8ArrayList: () => (/* binding */ decodeUint8ArrayList),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ encodeUint8Array: () => (/* binding */ encodeUint8Array),\n/* harmony export */ encodeUint8ArrayList: () => (/* binding */ encodeUint8ArrayList),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable no-fallthrough */\n\nconst N1 = Math.pow(2, 7);\nconst N2 = Math.pow(2, 14);\nconst N3 = Math.pow(2, 21);\nconst N4 = Math.pow(2, 28);\nconst N5 = Math.pow(2, 35);\nconst N6 = Math.pow(2, 42);\nconst N7 = Math.pow(2, 49);\n/** Most significant bit of a byte */\nconst MSB = 0x80;\n/** Rest of the bits in a byte */\nconst REST = 0x7f;\nfunction encodingLength(value) {\n if (value < N1) {\n return 1;\n }\n if (value < N2) {\n return 2;\n }\n if (value < N3) {\n return 3;\n }\n if (value < N4) {\n return 4;\n }\n if (value < N5) {\n return 5;\n }\n if (value < N6) {\n return 6;\n }\n if (value < N7) {\n return 7;\n }\n if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {\n throw new RangeError('Could not encode varint');\n }\n return 8;\n}\nfunction encodeUint8Array(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 7: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 6: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 5: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 4: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 3: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 2: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 1: {\n buf[offset++] = (value & 0xFF);\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction encodeUint8ArrayList(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 7: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 6: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 5: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 4: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 3: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 2: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 1: {\n buf.set(offset++, (value & 0xFF));\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction decodeUint8Array(buf, offset) {\n let b = buf[offset];\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 1];\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 2];\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 3];\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 4];\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 5];\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 6];\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 7];\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction decodeUint8ArrayList(buf, offset) {\n let b = buf.get(offset);\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 1);\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 2);\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 3);\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 4);\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 5);\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 6);\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 7);\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction encode(value, buf, offset = 0) {\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(encodingLength(value));\n }\n if (buf instanceof Uint8Array) {\n return encodeUint8Array(value, buf, offset);\n }\n else {\n return encodeUint8ArrayList(value, buf, offset);\n }\n}\nfunction decode(buf, offset = 0) {\n if (buf instanceof Uint8Array) {\n return decodeUint8Array(buf, offset);\n }\n else {\n return decodeUint8ArrayList(buf, offset);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/uint8-varint/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/alloc.js": /*!*****************************************************************************************!*\ !*** ./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/alloc.js ***! @@ -4388,7 +4428,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/util/bases.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@noble/ciphers/esm/_arx.js": +/*!*************************************************!*\ + !*** ./node_modules/@noble/ciphers/esm/_arx.js ***! + \*************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createCipher: () => (/* binding */ createCipher),\n/* harmony export */ rotl: () => (/* binding */ rotl)\n/* harmony export */ });\n/* harmony import */ var _assert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_assert.js */ \"./node_modules/@noble/ciphers/esm/_assert.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n// Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers.\n\n\n/*\nRFC8439 requires multi-step cipher stream, where\nauthKey starts with counter: 0, actual msg with counter: 1.\n\nFor this, we need a way to re-use nonce / counter:\n\n const counter = new Uint8Array(4);\n chacha(..., counter, ...); // counter is now 1\n chacha(..., counter, ...); // counter is now 2\n\nThis is complicated:\n\n- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB\n- Original papers don't allow mutating counters\n- Counter overflow is undefined [^1]\n- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it\n- Caveat: Cannot be re-used through all cases:\n- * chacha has (counter | nonce)\n- * xchacha has (nonce16 | counter | nonce16)\n- Idea B: separate nonce / counter and provide separate API for counter re-use\n- Caveat: there are different counter sizes depending on an algorithm.\n- salsa & chacha also differ in structures of key & sigma:\n salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3]\n chacha: s(4) | k(8) | ctr(1) | nonce(3)\n chacha20orig: s(4) | k(8) | ctr(2) | nonce(2)\n- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)`\n- Caveat: we can't re-use counter array\n\nxchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal\n(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce).\n\n[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/\n[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2\n*/\nconst sigma16 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)('expand 16-byte k');\nconst sigma32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)('expand 32-byte k');\nconst sigma16_32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(sigma16);\nconst sigma32_32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(sigma32);\nfunction rotl(a, b) {\n return (a << b) | (a >>> (32 - b));\n}\n// Is byte array aligned to 4 byte offset (u32)?\nfunction isAligned32(b) {\n return b.byteOffset % 4 === 0;\n}\n// Salsa and Chacha block length is always 512-bit\nconst BLOCK_LEN = 64;\nconst BLOCK_LEN32 = 16;\n// new Uint32Array([2**32]) // => Uint32Array(1) [ 0 ]\n// new Uint32Array([2**32-1]) // => Uint32Array(1) [ 4294967295 ]\nconst MAX_COUNTER = 2 ** 32 - 1;\nconst U32_EMPTY = new Uint32Array();\nfunction runCipher(core, sigma, key, nonce, data, output, counter, rounds) {\n const len = data.length;\n const block = new Uint8Array(BLOCK_LEN);\n const b32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(block);\n // Make sure that buffers aligned to 4 bytes\n const isAligned = isAligned32(data) && isAligned32(output);\n const d32 = isAligned ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(data) : U32_EMPTY;\n const o32 = isAligned ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(output) : U32_EMPTY;\n for (let pos = 0; pos < len; counter++) {\n core(sigma, key, nonce, b32, counter, rounds);\n if (counter >= MAX_COUNTER)\n throw new Error('arx: counter overflow');\n const take = Math.min(BLOCK_LEN, len - pos);\n // aligned to 4 bytes\n if (isAligned && take === BLOCK_LEN) {\n const pos32 = pos / 4;\n if (pos % 4 !== 0)\n throw new Error('arx: invalid block position');\n for (let j = 0, posj; j < BLOCK_LEN32; j++) {\n posj = pos32 + j;\n o32[posj] = d32[posj] ^ b32[j];\n }\n pos += BLOCK_LEN;\n continue;\n }\n for (let j = 0, posj; j < take; j++) {\n posj = pos + j;\n output[posj] = data[posj] ^ block[j];\n }\n pos += take;\n }\n}\nfunction createCipher(core, opts) {\n const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.checkOpts)({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts);\n if (typeof core !== 'function')\n throw new Error('core must be a function');\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(counterLength);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(rounds);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bool)(counterRight);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bool)(allowShortKeys);\n return (key, nonce, data, output, counter = 0) => {\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bytes)(key);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bytes)(nonce);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bytes)(data);\n const len = data.length;\n if (!output)\n output = new Uint8Array(len);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.bytes)(output);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(counter);\n if (counter < 0 || counter >= MAX_COUNTER)\n throw new Error('arx: counter overflow');\n if (output.length < len)\n throw new Error(`arx: output (${output.length}) is shorter than data (${len})`);\n const toClean = [];\n // Key & sigma\n // key=16 -> sigma16, k=key|key\n // key=32 -> sigma32, k=key\n let l = key.length, k, sigma;\n if (l === 32) {\n k = key.slice();\n toClean.push(k);\n sigma = sigma32_32;\n }\n else if (l === 16 && allowShortKeys) {\n k = new Uint8Array(32);\n k.set(key);\n k.set(key, 16);\n sigma = sigma16_32;\n toClean.push(k);\n }\n else {\n throw new Error(`arx: invalid 32-byte key, got length=${l}`);\n }\n // Nonce\n // salsa20: 8 (8-byte counter)\n // chacha20orig: 8 (8-byte counter)\n // chacha20: 12 (4-byte counter)\n // xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce)\n // xchacha20: 24 (16 -> hchacha, 8 -> old nonce)\n // Align nonce to 4 bytes\n if (!isAligned32(nonce)) {\n nonce = nonce.slice();\n toClean.push(nonce);\n }\n const k32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(k);\n // hsalsa & hchacha: handle extended nonce\n if (extendNonceFn) {\n if (nonce.length !== 24)\n throw new Error(`arx: extended nonce must be 24 bytes`);\n extendNonceFn(sigma, k32, (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(nonce.subarray(0, 16)), k32);\n nonce = nonce.subarray(16);\n }\n // Handle nonce counter\n const nonceNcLen = 16 - counterLength;\n if (nonceNcLen !== nonce.length)\n throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);\n // Pad counter when nonce is 64 bit\n if (nonceNcLen !== 12) {\n const nc = new Uint8Array(12);\n nc.set(nonce, counterRight ? 0 : 12 - nonce.length);\n nonce = nc;\n toClean.push(nonce);\n }\n const n32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(nonce);\n runCipher(core, sigma, k32, n32, data, output, counter, rounds);\n while (toClean.length > 0)\n toClean.pop().fill(0);\n return output;\n };\n}\n//# sourceMappingURL=_arx.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_arx.js?"); /***/ }), @@ -4399,7 +4450,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bool: () => (/* binding */ bool),\n/* harmony export */ bytes: () => (/* binding */ bytes),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ exists: () => (/* binding */ exists),\n/* harmony export */ hash: () => (/* binding */ hash),\n/* harmony export */ number: () => (/* binding */ number),\n/* harmony export */ output: () => (/* binding */ output)\n/* harmony export */ });\nfunction number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`Wrong positive integer: ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`Expected boolean, not ${b}`);\n}\nfunction bytes(b, ...lengths) {\n if (!(b instanceof Uint8Array))\n throw new Error('Expected Uint8Array');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(hash) {\n if (typeof hash !== 'function' || typeof hash.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(hash.outputLen);\n number(hash.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nconst assert = { number, bool, bytes, hash, exists, output };\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (assert);\n//# sourceMappingURL=_assert.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_assert.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bool: () => (/* binding */ bool),\n/* harmony export */ bytes: () => (/* binding */ bytes),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ exists: () => (/* binding */ exists),\n/* harmony export */ hash: () => (/* binding */ hash),\n/* harmony export */ number: () => (/* binding */ number),\n/* harmony export */ output: () => (/* binding */ output)\n/* harmony export */ });\nfunction number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`wrong positive integer: ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`boolean expected, not ${b}`);\n}\n// TODO: merge with utils\nfunction isBytes(a) {\n return (a != null &&\n typeof a === 'object' &&\n (a instanceof Uint8Array || a.constructor.name === 'Uint8Array'));\n}\nfunction bytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(hash) {\n if (typeof hash !== 'function' || typeof hash.create !== 'function')\n throw new Error('hash must be wrapped by utils.wrapConstructor');\n number(hash.outputLen);\n number(hash.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nconst assert = { number, bool, bytes, hash, exists, output };\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (assert);\n//# sourceMappingURL=_assert.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_assert.js?"); /***/ }), @@ -4410,18 +4461,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ poly1305: () => (/* binding */ poly1305),\n/* harmony export */ wrapConstructorWithKey: () => (/* binding */ wrapConstructorWithKey)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n/* harmony import */ var _assert_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_assert.js */ \"./node_modules/@noble/ciphers/esm/_assert.js\");\n\n\n// Poly1305 is a fast and parallel secret-key message-authentication code.\n// https://cr.yp.to/mac.html, https://cr.yp.to/mac/poly1305-20050329.pdf\n// https://datatracker.ietf.org/doc/html/rfc8439\n// Based on Public Domain poly1305-donna https://github.com/floodyberry/poly1305-donna\nconst u8to16 = (a, i) => (a[i++] & 0xff) | ((a[i++] & 0xff) << 8);\nclass Poly1305 {\n constructor(key) {\n this.blockLen = 16;\n this.outputLen = 16;\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.pos = 0;\n this.finished = false;\n key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toBytes)(key);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(key, 32);\n const t0 = u8to16(key, 0);\n const t1 = u8to16(key, 2);\n const t2 = u8to16(key, 4);\n const t3 = u8to16(key, 6);\n const t4 = u8to16(key, 8);\n const t5 = u8to16(key, 10);\n const t6 = u8to16(key, 12);\n const t7 = u8to16(key, 14);\n // https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47\n this.r[0] = t0 & 0x1fff;\n this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = (t4 >>> 1) & 0x1ffe;\n this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = (t7 >>> 5) & 0x007f;\n for (let i = 0; i < 8; i++)\n this.pad[i] = u8to16(key, 16 + 2 * i);\n }\n process(data, offset, isLast = false) {\n const hibit = isLast ? 0 : 1 << 11;\n const { h, r } = this;\n const r0 = r[0];\n const r1 = r[1];\n const r2 = r[2];\n const r3 = r[3];\n const r4 = r[4];\n const r5 = r[5];\n const r6 = r[6];\n const r7 = r[7];\n const r8 = r[8];\n const r9 = r[9];\n const t0 = u8to16(data, offset + 0);\n const t1 = u8to16(data, offset + 2);\n const t2 = u8to16(data, offset + 4);\n const t3 = u8to16(data, offset + 6);\n const t4 = u8to16(data, offset + 8);\n const t5 = u8to16(data, offset + 10);\n const t6 = u8to16(data, offset + 12);\n const t7 = u8to16(data, offset + 14);\n let h0 = h[0] + (t0 & 0x1fff);\n let h1 = h[1] + (((t0 >>> 13) | (t1 << 3)) & 0x1fff);\n let h2 = h[2] + (((t1 >>> 10) | (t2 << 6)) & 0x1fff);\n let h3 = h[3] + (((t2 >>> 7) | (t3 << 9)) & 0x1fff);\n let h4 = h[4] + (((t3 >>> 4) | (t4 << 12)) & 0x1fff);\n let h5 = h[5] + ((t4 >>> 1) & 0x1fff);\n let h6 = h[6] + (((t4 >>> 14) | (t5 << 2)) & 0x1fff);\n let h7 = h[7] + (((t5 >>> 11) | (t6 << 5)) & 0x1fff);\n let h8 = h[8] + (((t6 >>> 8) | (t7 << 8)) & 0x1fff);\n let h9 = h[9] + ((t7 >>> 5) | hibit);\n let c = 0;\n let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6);\n c = d0 >>> 13;\n d0 &= 0x1fff;\n d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1);\n c += d0 >>> 13;\n d0 &= 0x1fff;\n let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7);\n c = d1 >>> 13;\n d1 &= 0x1fff;\n d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2);\n c += d1 >>> 13;\n d1 &= 0x1fff;\n let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8);\n c = d2 >>> 13;\n d2 &= 0x1fff;\n d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3);\n c += d2 >>> 13;\n d2 &= 0x1fff;\n let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9);\n c = d3 >>> 13;\n d3 &= 0x1fff;\n d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4);\n c += d3 >>> 13;\n d3 &= 0x1fff;\n let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;\n c = d4 >>> 13;\n d4 &= 0x1fff;\n d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5);\n c += d4 >>> 13;\n d4 &= 0x1fff;\n let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1;\n c = d5 >>> 13;\n d5 &= 0x1fff;\n d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6);\n c += d5 >>> 13;\n d5 &= 0x1fff;\n let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2;\n c = d6 >>> 13;\n d6 &= 0x1fff;\n d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7);\n c += d6 >>> 13;\n d6 &= 0x1fff;\n let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3;\n c = d7 >>> 13;\n d7 &= 0x1fff;\n d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8);\n c += d7 >>> 13;\n d7 &= 0x1fff;\n let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4;\n c = d8 >>> 13;\n d8 &= 0x1fff;\n d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9);\n c += d8 >>> 13;\n d8 &= 0x1fff;\n let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5;\n c = d9 >>> 13;\n d9 &= 0x1fff;\n d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0;\n c += d9 >>> 13;\n d9 &= 0x1fff;\n c = ((c << 2) + c) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = c >>> 13;\n d1 += c;\n h[0] = d0;\n h[1] = d1;\n h[2] = d2;\n h[3] = d3;\n h[4] = d4;\n h[5] = d5;\n h[6] = d6;\n h[7] = d7;\n h[8] = d8;\n h[9] = d9;\n }\n finalize() {\n const { h, pad } = this;\n const g = new Uint16Array(10);\n let c = h[1] >>> 13;\n h[1] &= 0x1fff;\n for (let i = 2; i < 10; i++) {\n h[i] += c;\n c = h[i] >>> 13;\n h[i] &= 0x1fff;\n }\n h[0] += c * 5;\n c = h[0] >>> 13;\n h[0] &= 0x1fff;\n h[1] += c;\n c = h[1] >>> 13;\n h[1] &= 0x1fff;\n h[2] += c;\n g[0] = h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (let i = 1; i < 10; i++) {\n g[i] = h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= 1 << 13;\n let mask = (c ^ 1) - 1;\n for (let i = 0; i < 10; i++)\n g[i] &= mask;\n mask = ~mask;\n for (let i = 0; i < 10; i++)\n h[i] = (h[i] & mask) | g[i];\n h[0] = (h[0] | (h[1] << 13)) & 0xffff;\n h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff;\n h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff;\n h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff;\n h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff;\n h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff;\n h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff;\n h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff;\n let f = h[0] + pad[0];\n h[0] = f & 0xffff;\n for (let i = 1; i < 8; i++) {\n f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0;\n h[i] = f & 0xffff;\n }\n }\n update(data) {\n _assert_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].exists(this);\n const { buffer, blockLen } = this;\n data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toBytes)(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input\n if (take === blockLen) {\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(data, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(buffer, 0, false);\n this.pos = 0;\n }\n }\n return this;\n }\n destroy() {\n this.h.fill(0);\n this.r.fill(0);\n this.buffer.fill(0);\n this.pad.fill(0);\n }\n digestInto(out) {\n _assert_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].exists(this);\n _assert_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].output(out, this);\n this.finished = true;\n const { buffer, h } = this;\n let { pos } = this;\n if (pos) {\n buffer[pos++] = 1;\n // buffer.subarray(pos).fill(0);\n for (; pos < 16; pos++)\n buffer[pos] = 0;\n this.process(buffer, 0, true);\n }\n this.finalize();\n let opos = 0;\n for (let i = 0; i < 8; i++) {\n out[opos++] = h[i] >>> 0;\n out[opos++] = h[i] >>> 8;\n }\n return out;\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n}\nfunction wrapConstructorWithKey(hashCons) {\n const hashC = (msg, key) => hashCons(key).update((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.toBytes)(msg)).digest();\n const tmp = hashCons(new Uint8Array(32));\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (key) => hashCons(key);\n return hashC;\n}\nconst poly1305 = wrapConstructorWithKey((key) => new Poly1305(key));\n//# sourceMappingURL=_poly1305.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_poly1305.js?"); - -/***/ }), - -/***/ "./node_modules/@noble/ciphers/esm/_salsa.js": -/*!***************************************************!*\ - !*** ./node_modules/@noble/ciphers/esm/_salsa.js ***! - \***************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ salsaBasic: () => (/* binding */ salsaBasic)\n/* harmony export */ });\n/* harmony import */ var _assert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_assert.js */ \"./node_modules/@noble/ciphers/esm/_assert.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n// Basic utils for salsa-like ciphers\n// Check out _micro.ts for descriptive documentation.\n\n\n/*\nRFC8439 requires multi-step cipher stream, where\nauthKey starts with counter: 0, actual msg with counter: 1.\n\nFor this, we need a way to re-use nonce / counter:\n\n const counter = new Uint8Array(4);\n chacha(..., counter, ...); // counter is now 1\n chacha(..., counter, ...); // counter is now 2\n\nThis is complicated:\n\n- Original papers don't allow mutating counters\n- Counter overflow is undefined: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/\n- 3rd-party library stablelib implementation uses an approach where you can provide\n nonce and counter instead of just nonce - and it will re-use it\n- We could have did something similar, but ChaCha has different counter position\n (counter | nonce), which is not composable with XChaCha, because full counter\n is (nonce16 | counter | nonce16). Stablelib doesn't support in-place counter for XChaCha.\n- We could separate nonce & counter and provide separate API for counter re-use, but\n there are different counter sizes depending on an algorithm.\n- Salsa & ChaCha also differ in structures of key / sigma:\n\n salsa: c0 | k(4) | c1 | nonce(2) | ctr(2) | c2 | k(4) | c4\n chacha: c(4) | k(8) | ctr(1) | nonce(3)\n chachaDJB: c(4) | k(8) | ctr(2) | nonce(2)\n- Creating function such as `setSalsaState(key, nonce, sigma, data)` won't work,\n because we can't re-use counter array\n- 32-bit nonce is `2 ** 32 * 64` = 256GB with 32-bit counter\n- JS does not allow UintArrays bigger than 4GB, so supporting 64-bit counters doesn't matter\n\nStructure is as following:\n\nkey=16 -> sigma16, k=key|key\nkey=32 -> sigma32, k=key\n\nnonces:\nsalsa20: 8 (8-byte counter)\nchacha20djb: 8 (8-byte counter)\nchacha20tls: 12 (4-byte counter)\nxsalsa: 24 (16 -> hsalsa, 8 -> old nonce)\nxchacha: 24 (16 -> hchacha, 8 -> old nonce)\n\nhttps://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2\nUse the subkey and remaining 8 byte nonce with ChaCha20 as normal\n(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce).\n*/\nconst sigma16 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)('expand 16-byte k');\nconst sigma32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)('expand 32-byte k');\nconst sigma16_32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(sigma16);\nconst sigma32_32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(sigma32);\n// Is byte array aligned to 4 byte offset (u32)?\nconst isAligned32 = (b) => !(b.byteOffset % 4);\nconst salsaBasic = (opts) => {\n const { core, rounds, counterRight, counterLen, allow128bitKeys, extendNonceFn, blockLen } = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.checkOpts)({ rounds: 20, counterRight: false, counterLen: 8, allow128bitKeys: true, blockLen: 64 }, opts);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].number(counterLen);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].number(rounds);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].number(blockLen);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bool(counterRight);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bool(allow128bitKeys);\n const blockLen32 = blockLen / 4;\n if (blockLen % 4 !== 0)\n throw new Error('Salsa/ChaCha: blockLen should be aligned to 4 bytes');\n return (key, nonce, data, output, counter = 0) => {\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bytes(key);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bytes(nonce);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bytes(data);\n if (!output)\n output = new Uint8Array(data.length);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bytes(output);\n _assert_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].number(counter);\n // > new Uint32Array([2**32])\n // Uint32Array(1) [ 0 ]\n // > new Uint32Array([2**32-1])\n // Uint32Array(1) [ 4294967295 ]\n if (counter < 0 || counter >= 2 ** 32 - 1)\n throw new Error('Salsa/ChaCha: counter overflow');\n if (output.length < data.length) {\n throw new Error(`Salsa/ChaCha: output (${output.length}) is shorter than data (${data.length})`);\n }\n const toClean = [];\n let k, sigma;\n // Handle 128 byte keys\n if (key.length === 32) {\n k = key;\n sigma = sigma32_32;\n }\n else if (key.length === 16 && allow128bitKeys) {\n k = new Uint8Array(32);\n k.set(key);\n k.set(key, 16);\n sigma = sigma16_32;\n toClean.push(k);\n }\n else\n throw new Error(`Salsa/ChaCha: wrong key length=${key.length}, expected`);\n // Handle extended nonce (HChaCha/HSalsa)\n if (extendNonceFn) {\n if (nonce.length <= 16)\n throw new Error(`Salsa/ChaCha: extended nonce should be bigger than 16 bytes`);\n k = extendNonceFn(sigma, k, nonce.subarray(0, 16), new Uint8Array(32));\n toClean.push(k);\n nonce = nonce.subarray(16);\n }\n // Handle nonce counter\n const nonceLen = 16 - counterLen;\n if (nonce.length !== nonceLen)\n throw new Error(`Salsa/ChaCha: nonce should be ${nonceLen} or 16 bytes`);\n // Pad counter when nonce is 64 bit\n if (nonceLen !== 12) {\n const nc = new Uint8Array(12);\n nc.set(nonce, counterRight ? 0 : 12 - nonce.length);\n toClean.push((nonce = nc));\n }\n // Counter positions\n const block = new Uint8Array(blockLen);\n // Cast to Uint32Array for speed\n const b32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(block);\n const k32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(k);\n const n32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(nonce);\n // Make sure that buffers aligned to 4 bytes\n const d32 = isAligned32(data) && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(data);\n const o32 = isAligned32(output) && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.u32)(output);\n toClean.push(b32);\n const len = data.length;\n for (let pos = 0, ctr = counter; pos < len; ctr++) {\n core(sigma, k32, n32, b32, ctr, rounds);\n if (ctr >= 2 ** 32 - 1)\n throw new Error('Salsa/ChaCha: counter overflow');\n const take = Math.min(blockLen, len - pos);\n // full block && aligned to 4 bytes\n if (take === blockLen && o32 && d32) {\n const pos32 = pos / 4;\n if (pos % 4 !== 0)\n throw new Error('Salsa/ChaCha: wrong block position');\n for (let j = 0; j < blockLen32; j++)\n o32[pos32 + j] = d32[pos32 + j] ^ b32[j];\n pos += blockLen;\n continue;\n }\n for (let j = 0; j < take; j++)\n output[pos + j] = data[pos + j] ^ block[j];\n pos += take;\n }\n for (let i = 0; i < toClean.length; i++)\n toClean[i].fill(0);\n return output;\n };\n};\n//# sourceMappingURL=_salsa.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_salsa.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ poly1305: () => (/* binding */ poly1305),\n/* harmony export */ wrapConstructorWithKey: () => (/* binding */ wrapConstructorWithKey)\n/* harmony export */ });\n/* harmony import */ var _assert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_assert.js */ \"./node_modules/@noble/ciphers/esm/_assert.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n\n\n// Poly1305 is a fast and parallel secret-key message-authentication code.\n// https://cr.yp.to/mac.html, https://cr.yp.to/mac/poly1305-20050329.pdf\n// https://datatracker.ietf.org/doc/html/rfc8439\n// Based on Public Domain poly1305-donna https://github.com/floodyberry/poly1305-donna\nconst u8to16 = (a, i) => (a[i++] & 0xff) | ((a[i++] & 0xff) << 8);\nclass Poly1305 {\n constructor(key) {\n this.blockLen = 16;\n this.outputLen = 16;\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.pos = 0;\n this.finished = false;\n key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.toBytes)(key);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)(key, 32);\n const t0 = u8to16(key, 0);\n const t1 = u8to16(key, 2);\n const t2 = u8to16(key, 4);\n const t3 = u8to16(key, 6);\n const t4 = u8to16(key, 8);\n const t5 = u8to16(key, 10);\n const t6 = u8to16(key, 12);\n const t7 = u8to16(key, 14);\n // https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47\n this.r[0] = t0 & 0x1fff;\n this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = (t4 >>> 1) & 0x1ffe;\n this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = (t7 >>> 5) & 0x007f;\n for (let i = 0; i < 8; i++)\n this.pad[i] = u8to16(key, 16 + 2 * i);\n }\n process(data, offset, isLast = false) {\n const hibit = isLast ? 0 : 1 << 11;\n const { h, r } = this;\n const r0 = r[0];\n const r1 = r[1];\n const r2 = r[2];\n const r3 = r[3];\n const r4 = r[4];\n const r5 = r[5];\n const r6 = r[6];\n const r7 = r[7];\n const r8 = r[8];\n const r9 = r[9];\n const t0 = u8to16(data, offset + 0);\n const t1 = u8to16(data, offset + 2);\n const t2 = u8to16(data, offset + 4);\n const t3 = u8to16(data, offset + 6);\n const t4 = u8to16(data, offset + 8);\n const t5 = u8to16(data, offset + 10);\n const t6 = u8to16(data, offset + 12);\n const t7 = u8to16(data, offset + 14);\n let h0 = h[0] + (t0 & 0x1fff);\n let h1 = h[1] + (((t0 >>> 13) | (t1 << 3)) & 0x1fff);\n let h2 = h[2] + (((t1 >>> 10) | (t2 << 6)) & 0x1fff);\n let h3 = h[3] + (((t2 >>> 7) | (t3 << 9)) & 0x1fff);\n let h4 = h[4] + (((t3 >>> 4) | (t4 << 12)) & 0x1fff);\n let h5 = h[5] + ((t4 >>> 1) & 0x1fff);\n let h6 = h[6] + (((t4 >>> 14) | (t5 << 2)) & 0x1fff);\n let h7 = h[7] + (((t5 >>> 11) | (t6 << 5)) & 0x1fff);\n let h8 = h[8] + (((t6 >>> 8) | (t7 << 8)) & 0x1fff);\n let h9 = h[9] + ((t7 >>> 5) | hibit);\n let c = 0;\n let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6);\n c = d0 >>> 13;\n d0 &= 0x1fff;\n d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1);\n c += d0 >>> 13;\n d0 &= 0x1fff;\n let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7);\n c = d1 >>> 13;\n d1 &= 0x1fff;\n d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2);\n c += d1 >>> 13;\n d1 &= 0x1fff;\n let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8);\n c = d2 >>> 13;\n d2 &= 0x1fff;\n d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3);\n c += d2 >>> 13;\n d2 &= 0x1fff;\n let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9);\n c = d3 >>> 13;\n d3 &= 0x1fff;\n d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4);\n c += d3 >>> 13;\n d3 &= 0x1fff;\n let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;\n c = d4 >>> 13;\n d4 &= 0x1fff;\n d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5);\n c += d4 >>> 13;\n d4 &= 0x1fff;\n let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1;\n c = d5 >>> 13;\n d5 &= 0x1fff;\n d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6);\n c += d5 >>> 13;\n d5 &= 0x1fff;\n let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2;\n c = d6 >>> 13;\n d6 &= 0x1fff;\n d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7);\n c += d6 >>> 13;\n d6 &= 0x1fff;\n let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3;\n c = d7 >>> 13;\n d7 &= 0x1fff;\n d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8);\n c += d7 >>> 13;\n d7 &= 0x1fff;\n let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4;\n c = d8 >>> 13;\n d8 &= 0x1fff;\n d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9);\n c += d8 >>> 13;\n d8 &= 0x1fff;\n let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5;\n c = d9 >>> 13;\n d9 &= 0x1fff;\n d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0;\n c += d9 >>> 13;\n d9 &= 0x1fff;\n c = ((c << 2) + c) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = c >>> 13;\n d1 += c;\n h[0] = d0;\n h[1] = d1;\n h[2] = d2;\n h[3] = d3;\n h[4] = d4;\n h[5] = d5;\n h[6] = d6;\n h[7] = d7;\n h[8] = d8;\n h[9] = d9;\n }\n finalize() {\n const { h, pad } = this;\n const g = new Uint16Array(10);\n let c = h[1] >>> 13;\n h[1] &= 0x1fff;\n for (let i = 2; i < 10; i++) {\n h[i] += c;\n c = h[i] >>> 13;\n h[i] &= 0x1fff;\n }\n h[0] += c * 5;\n c = h[0] >>> 13;\n h[0] &= 0x1fff;\n h[1] += c;\n c = h[1] >>> 13;\n h[1] &= 0x1fff;\n h[2] += c;\n g[0] = h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (let i = 1; i < 10; i++) {\n g[i] = h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= 1 << 13;\n let mask = (c ^ 1) - 1;\n for (let i = 0; i < 10; i++)\n g[i] &= mask;\n mask = ~mask;\n for (let i = 0; i < 10; i++)\n h[i] = (h[i] & mask) | g[i];\n h[0] = (h[0] | (h[1] << 13)) & 0xffff;\n h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff;\n h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff;\n h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff;\n h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff;\n h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff;\n h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff;\n h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff;\n let f = h[0] + pad[0];\n h[0] = f & 0xffff;\n for (let i = 1; i < 8; i++) {\n f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0;\n h[i] = f & 0xffff;\n }\n }\n update(data) {\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.exists)(this);\n const { buffer, blockLen } = this;\n data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.toBytes)(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input\n if (take === blockLen) {\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(data, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(buffer, 0, false);\n this.pos = 0;\n }\n }\n return this;\n }\n destroy() {\n this.h.fill(0);\n this.r.fill(0);\n this.buffer.fill(0);\n this.pad.fill(0);\n }\n digestInto(out) {\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.exists)(this);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.output)(out, this);\n this.finished = true;\n const { buffer, h } = this;\n let { pos } = this;\n if (pos) {\n buffer[pos++] = 1;\n // buffer.subarray(pos).fill(0);\n for (; pos < 16; pos++)\n buffer[pos] = 0;\n this.process(buffer, 0, true);\n }\n this.finalize();\n let opos = 0;\n for (let i = 0; i < 8; i++) {\n out[opos++] = h[i] >>> 0;\n out[opos++] = h[i] >>> 8;\n }\n return out;\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n}\nfunction wrapConstructorWithKey(hashCons) {\n const hashC = (msg, key) => hashCons(key).update((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.toBytes)(msg)).digest();\n const tmp = hashCons(new Uint8Array(32));\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (key) => hashCons(key);\n return hashC;\n}\nconst poly1305 = wrapConstructorWithKey((key) => new Poly1305(key));\n//# sourceMappingURL=_poly1305.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/_poly1305.js?"); /***/ }), @@ -4432,7 +4472,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _poly1305_aead: () => (/* binding */ _poly1305_aead),\n/* harmony export */ chacha12: () => (/* binding */ chacha12),\n/* harmony export */ chacha20: () => (/* binding */ chacha20),\n/* harmony export */ chacha20_poly1305: () => (/* binding */ chacha20_poly1305),\n/* harmony export */ chacha20orig: () => (/* binding */ chacha20orig),\n/* harmony export */ chacha8: () => (/* binding */ chacha8),\n/* harmony export */ hchacha: () => (/* binding */ hchacha),\n/* harmony export */ xchacha20: () => (/* binding */ xchacha20),\n/* harmony export */ xchacha20_poly1305: () => (/* binding */ xchacha20_poly1305)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n/* harmony import */ var _poly1305_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_poly1305.js */ \"./node_modules/@noble/ciphers/esm/_poly1305.js\");\n/* harmony import */ var _salsa_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_salsa.js */ \"./node_modules/@noble/ciphers/esm/_salsa.js\");\n\n\n\n// ChaCha20 stream cipher was released in 2008. ChaCha aims to increase\n// the diffusion per round, but had slightly less cryptanalysis.\n// https://cr.yp.to/chacha.html, http://cr.yp.to/chacha/chacha-20080128.pdf\n// Left rotate for uint32\nconst rotl = (a, b) => (a << b) | (a >>> (32 - b));\n/**\n * ChaCha core function.\n */\n// prettier-ignore\nfunction chachaCore(c, k, n, out, cnt, rounds = 20) {\n let y00 = c[0], y01 = c[1], y02 = c[2], y03 = c[3]; // \"expa\" \"nd 3\" \"2-by\" \"te k\"\n let y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3]; // Key Key Key Key\n let y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7]; // Key Key Key Key\n let y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter\tNonce Nonce\n // Save state to temporary variables\n let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15;\n // Main loop\n for (let i = 0; i < rounds; i += 2) {\n x00 = (x00 + x04) | 0;\n x12 = rotl(x12 ^ x00, 16);\n x08 = (x08 + x12) | 0;\n x04 = rotl(x04 ^ x08, 12);\n x00 = (x00 + x04) | 0;\n x12 = rotl(x12 ^ x00, 8);\n x08 = (x08 + x12) | 0;\n x04 = rotl(x04 ^ x08, 7);\n x01 = (x01 + x05) | 0;\n x13 = rotl(x13 ^ x01, 16);\n x09 = (x09 + x13) | 0;\n x05 = rotl(x05 ^ x09, 12);\n x01 = (x01 + x05) | 0;\n x13 = rotl(x13 ^ x01, 8);\n x09 = (x09 + x13) | 0;\n x05 = rotl(x05 ^ x09, 7);\n x02 = (x02 + x06) | 0;\n x14 = rotl(x14 ^ x02, 16);\n x10 = (x10 + x14) | 0;\n x06 = rotl(x06 ^ x10, 12);\n x02 = (x02 + x06) | 0;\n x14 = rotl(x14 ^ x02, 8);\n x10 = (x10 + x14) | 0;\n x06 = rotl(x06 ^ x10, 7);\n x03 = (x03 + x07) | 0;\n x15 = rotl(x15 ^ x03, 16);\n x11 = (x11 + x15) | 0;\n x07 = rotl(x07 ^ x11, 12);\n x03 = (x03 + x07) | 0;\n x15 = rotl(x15 ^ x03, 8);\n x11 = (x11 + x15) | 0;\n x07 = rotl(x07 ^ x11, 7);\n x00 = (x00 + x05) | 0;\n x15 = rotl(x15 ^ x00, 16);\n x10 = (x10 + x15) | 0;\n x05 = rotl(x05 ^ x10, 12);\n x00 = (x00 + x05) | 0;\n x15 = rotl(x15 ^ x00, 8);\n x10 = (x10 + x15) | 0;\n x05 = rotl(x05 ^ x10, 7);\n x01 = (x01 + x06) | 0;\n x12 = rotl(x12 ^ x01, 16);\n x11 = (x11 + x12) | 0;\n x06 = rotl(x06 ^ x11, 12);\n x01 = (x01 + x06) | 0;\n x12 = rotl(x12 ^ x01, 8);\n x11 = (x11 + x12) | 0;\n x06 = rotl(x06 ^ x11, 7);\n x02 = (x02 + x07) | 0;\n x13 = rotl(x13 ^ x02, 16);\n x08 = (x08 + x13) | 0;\n x07 = rotl(x07 ^ x08, 12);\n x02 = (x02 + x07) | 0;\n x13 = rotl(x13 ^ x02, 8);\n x08 = (x08 + x13) | 0;\n x07 = rotl(x07 ^ x08, 7);\n x03 = (x03 + x04) | 0;\n x14 = rotl(x14 ^ x03, 16);\n x09 = (x09 + x14) | 0;\n x04 = rotl(x04 ^ x09, 12);\n x03 = (x03 + x04) | 0;\n x14 = rotl(x14 ^ x03, 8);\n x09 = (x09 + x14) | 0;\n x04 = rotl(x04 ^ x09, 7);\n }\n // Write output\n let oi = 0;\n out[oi++] = (y00 + x00) | 0;\n out[oi++] = (y01 + x01) | 0;\n out[oi++] = (y02 + x02) | 0;\n out[oi++] = (y03 + x03) | 0;\n out[oi++] = (y04 + x04) | 0;\n out[oi++] = (y05 + x05) | 0;\n out[oi++] = (y06 + x06) | 0;\n out[oi++] = (y07 + x07) | 0;\n out[oi++] = (y08 + x08) | 0;\n out[oi++] = (y09 + x09) | 0;\n out[oi++] = (y10 + x10) | 0;\n out[oi++] = (y11 + x11) | 0;\n out[oi++] = (y12 + x12) | 0;\n out[oi++] = (y13 + x13) | 0;\n out[oi++] = (y14 + x14) | 0;\n out[oi++] = (y15 + x15) | 0;\n}\n/**\n * hchacha helper method, used primarily in xchacha, to hash\n * key and nonce into key' and nonce'.\n * Same as chachaCore, but there doesn't seem to be a way to move the block\n * out without 25% performance hit.\n */\n// prettier-ignore\nfunction hchacha(c, key, src, out) {\n const k32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.u32)(key);\n const i32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.u32)(src);\n const o32 = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.u32)(out);\n let x00 = c[0], x01 = c[1], x02 = c[2], x03 = c[3];\n let x04 = k32[0], x05 = k32[1], x06 = k32[2], x07 = k32[3];\n let x08 = k32[4], x09 = k32[5], x10 = k32[6], x11 = k32[7];\n let x12 = i32[0], x13 = i32[1], x14 = i32[2], x15 = i32[3];\n for (let i = 0; i < 20; i += 2) {\n x00 = (x00 + x04) | 0;\n x12 = rotl(x12 ^ x00, 16);\n x08 = (x08 + x12) | 0;\n x04 = rotl(x04 ^ x08, 12);\n x00 = (x00 + x04) | 0;\n x12 = rotl(x12 ^ x00, 8);\n x08 = (x08 + x12) | 0;\n x04 = rotl(x04 ^ x08, 7);\n x01 = (x01 + x05) | 0;\n x13 = rotl(x13 ^ x01, 16);\n x09 = (x09 + x13) | 0;\n x05 = rotl(x05 ^ x09, 12);\n x01 = (x01 + x05) | 0;\n x13 = rotl(x13 ^ x01, 8);\n x09 = (x09 + x13) | 0;\n x05 = rotl(x05 ^ x09, 7);\n x02 = (x02 + x06) | 0;\n x14 = rotl(x14 ^ x02, 16);\n x10 = (x10 + x14) | 0;\n x06 = rotl(x06 ^ x10, 12);\n x02 = (x02 + x06) | 0;\n x14 = rotl(x14 ^ x02, 8);\n x10 = (x10 + x14) | 0;\n x06 = rotl(x06 ^ x10, 7);\n x03 = (x03 + x07) | 0;\n x15 = rotl(x15 ^ x03, 16);\n x11 = (x11 + x15) | 0;\n x07 = rotl(x07 ^ x11, 12);\n x03 = (x03 + x07) | 0;\n x15 = rotl(x15 ^ x03, 8);\n x11 = (x11 + x15) | 0;\n x07 = rotl(x07 ^ x11, 7);\n x00 = (x00 + x05) | 0;\n x15 = rotl(x15 ^ x00, 16);\n x10 = (x10 + x15) | 0;\n x05 = rotl(x05 ^ x10, 12);\n x00 = (x00 + x05) | 0;\n x15 = rotl(x15 ^ x00, 8);\n x10 = (x10 + x15) | 0;\n x05 = rotl(x05 ^ x10, 7);\n x01 = (x01 + x06) | 0;\n x12 = rotl(x12 ^ x01, 16);\n x11 = (x11 + x12) | 0;\n x06 = rotl(x06 ^ x11, 12);\n x01 = (x01 + x06) | 0;\n x12 = rotl(x12 ^ x01, 8);\n x11 = (x11 + x12) | 0;\n x06 = rotl(x06 ^ x11, 7);\n x02 = (x02 + x07) | 0;\n x13 = rotl(x13 ^ x02, 16);\n x08 = (x08 + x13) | 0;\n x07 = rotl(x07 ^ x08, 12);\n x02 = (x02 + x07) | 0;\n x13 = rotl(x13 ^ x02, 8);\n x08 = (x08 + x13) | 0;\n x07 = rotl(x07 ^ x08, 7);\n x03 = (x03 + x04) | 0;\n x14 = rotl(x14 ^ x03, 16);\n x09 = (x09 + x14) | 0;\n x04 = rotl(x04 ^ x09, 12);\n x03 = (x03 + x04) | 0;\n x14 = rotl(x14 ^ x03, 8);\n x09 = (x09 + x14) | 0;\n x04 = rotl(x04 ^ x09, 7);\n }\n o32[0] = x00;\n o32[1] = x01;\n o32[2] = x02;\n o32[3] = x03;\n o32[4] = x12;\n o32[5] = x13;\n o32[6] = x14;\n o32[7] = x15;\n return out;\n}\n/**\n * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter.\n */\nconst chacha20orig = (0,_salsa_js__WEBPACK_IMPORTED_MODULE_2__.salsaBasic)({ core: chachaCore, counterRight: false, counterLen: 8 });\n/**\n * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter.\n * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance.\n */\nconst chacha20 = (0,_salsa_js__WEBPACK_IMPORTED_MODULE_2__.salsaBasic)({\n core: chachaCore,\n counterRight: false,\n counterLen: 4,\n allow128bitKeys: false,\n});\n/**\n * XChaCha eXtended-nonce ChaCha. 24-byte nonce.\n * With 24-byte nonce, it's safe to use fill it with random (CSPRNG).\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha\n */\nconst xchacha20 = (0,_salsa_js__WEBPACK_IMPORTED_MODULE_2__.salsaBasic)({\n core: chachaCore,\n counterRight: false,\n counterLen: 8,\n extendNonceFn: hchacha,\n allow128bitKeys: false,\n});\n/**\n * Reduced 8-round chacha, described in original paper.\n */\nconst chacha8 = (0,_salsa_js__WEBPACK_IMPORTED_MODULE_2__.salsaBasic)({\n core: chachaCore,\n counterRight: false,\n counterLen: 4,\n rounds: 8,\n});\n/**\n * Reduced 12-round chacha, described in original paper.\n */\nconst chacha12 = (0,_salsa_js__WEBPACK_IMPORTED_MODULE_2__.salsaBasic)({\n core: chachaCore,\n counterRight: false,\n counterLen: 4,\n rounds: 12,\n});\nconst ZERO = new Uint8Array(16);\n// Pad to digest size with zeros\nconst updatePadded = (h, msg) => {\n h.update(msg);\n const left = msg.length % 16;\n if (left)\n h.update(ZERO.subarray(left));\n};\nconst computeTag = (fn, key, nonce, data, AAD) => {\n const authKey = fn(key, nonce, new Uint8Array(32));\n const h = _poly1305_js__WEBPACK_IMPORTED_MODULE_1__.poly1305.create(authKey);\n if (AAD)\n updatePadded(h, AAD);\n updatePadded(h, data);\n const num = new Uint8Array(16);\n const view = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createView)(num);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.setBigUint64)(view, 0, BigInt(AAD ? AAD.length : 0), true);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.setBigUint64)(view, 8, BigInt(data.length), true);\n h.update(num);\n const res = h.digest();\n authKey.fill(0);\n return res;\n};\n/**\n * AEAD algorithm from RFC 8439.\n * Salsa20 and chacha (RFC 8439) use poly1305 differently.\n * We could have composed them similar to:\n * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250\n * But it's hard because of authKey:\n * In salsa20, authKey changes position in salsa stream.\n * In chacha, authKey can't be computed inside computeTag, it modifies the counter.\n */\nconst _poly1305_aead = (fn) => (key, nonce, AAD) => {\n const tagLength = 16;\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(key, 32);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(nonce);\n return {\n tagLength,\n encrypt: (plaintext) => {\n const res = new Uint8Array(plaintext.length + tagLength);\n fn(key, nonce, plaintext, res, 1);\n const tag = computeTag(fn, key, nonce, res.subarray(0, -tagLength), AAD);\n res.set(tag, plaintext.length); // append tag\n return res;\n },\n decrypt: (ciphertext) => {\n if (ciphertext.length < tagLength)\n throw new Error(`Encrypted data should be at least ${tagLength}`);\n const realTag = ciphertext.subarray(-tagLength);\n const data = ciphertext.subarray(0, -tagLength);\n const tag = computeTag(fn, key, nonce, data, AAD);\n if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.equalBytes)(realTag, tag))\n throw new Error('Wrong tag');\n return fn(key, nonce, data, undefined, 1);\n },\n };\n};\n/**\n * ChaCha20-Poly1305 from RFC 8439.\n * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance.\n */\nconst chacha20_poly1305 = _poly1305_aead(chacha20);\n/**\n * XChaCha20-Poly1305 extended-nonce chacha.\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha\n * With 24-byte nonce, it's safe to use fill it with random (CSPRNG).\n */\nconst xchacha20_poly1305 = _poly1305_aead(xchacha20);\n//# sourceMappingURL=chacha.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/chacha.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _poly1305_aead: () => (/* binding */ _poly1305_aead),\n/* harmony export */ chacha12: () => (/* binding */ chacha12),\n/* harmony export */ chacha20: () => (/* binding */ chacha20),\n/* harmony export */ chacha20orig: () => (/* binding */ chacha20orig),\n/* harmony export */ chacha20poly1305: () => (/* binding */ chacha20poly1305),\n/* harmony export */ chacha8: () => (/* binding */ chacha8),\n/* harmony export */ hchacha: () => (/* binding */ hchacha),\n/* harmony export */ xchacha20: () => (/* binding */ xchacha20),\n/* harmony export */ xchacha20poly1305: () => (/* binding */ xchacha20poly1305)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/ciphers/esm/utils.js\");\n/* harmony import */ var _poly1305_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_poly1305.js */ \"./node_modules/@noble/ciphers/esm/_poly1305.js\");\n/* harmony import */ var _arx_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_arx.js */ \"./node_modules/@noble/ciphers/esm/_arx.js\");\n\n\n\n// ChaCha20 stream cipher was released in 2008. ChaCha aims to increase\n// the diffusion per round, but had slightly less cryptanalysis.\n// https://cr.yp.to/chacha.html, http://cr.yp.to/chacha/chacha-20080128.pdf\n/**\n * ChaCha core function.\n */\n// prettier-ignore\nfunction chachaCore(s, k, n, out, cnt, rounds = 20) {\n let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], // \"expa\" \"nd 3\" \"2-by\" \"te k\"\n y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key\n y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key\n y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter\tNonce Nonce\n // Save state to temporary variables\n let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15;\n for (let r = 0; r < rounds; r += 2) {\n x00 = (x00 + x04) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x00, 16);\n x08 = (x08 + x12) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x08, 12);\n x00 = (x00 + x04) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x00, 8);\n x08 = (x08 + x12) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x08, 7);\n x01 = (x01 + x05) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x01, 16);\n x09 = (x09 + x13) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x09, 12);\n x01 = (x01 + x05) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x01, 8);\n x09 = (x09 + x13) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x09, 7);\n x02 = (x02 + x06) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x02, 16);\n x10 = (x10 + x14) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x10, 12);\n x02 = (x02 + x06) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x02, 8);\n x10 = (x10 + x14) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x10, 7);\n x03 = (x03 + x07) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x03, 16);\n x11 = (x11 + x15) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x11, 12);\n x03 = (x03 + x07) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x03, 8);\n x11 = (x11 + x15) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x11, 7);\n x00 = (x00 + x05) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x00, 16);\n x10 = (x10 + x15) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x10, 12);\n x00 = (x00 + x05) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x00, 8);\n x10 = (x10 + x15) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x10, 7);\n x01 = (x01 + x06) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x01, 16);\n x11 = (x11 + x12) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x11, 12);\n x01 = (x01 + x06) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x01, 8);\n x11 = (x11 + x12) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x11, 7);\n x02 = (x02 + x07) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x02, 16);\n x08 = (x08 + x13) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x08, 12);\n x02 = (x02 + x07) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x02, 8);\n x08 = (x08 + x13) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x08, 7);\n x03 = (x03 + x04) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x03, 16);\n x09 = (x09 + x14) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x09, 12);\n x03 = (x03 + x04) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x03, 8);\n x09 = (x09 + x14) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x09, 7);\n }\n // Write output\n let oi = 0;\n out[oi++] = (y00 + x00) | 0;\n out[oi++] = (y01 + x01) | 0;\n out[oi++] = (y02 + x02) | 0;\n out[oi++] = (y03 + x03) | 0;\n out[oi++] = (y04 + x04) | 0;\n out[oi++] = (y05 + x05) | 0;\n out[oi++] = (y06 + x06) | 0;\n out[oi++] = (y07 + x07) | 0;\n out[oi++] = (y08 + x08) | 0;\n out[oi++] = (y09 + x09) | 0;\n out[oi++] = (y10 + x10) | 0;\n out[oi++] = (y11 + x11) | 0;\n out[oi++] = (y12 + x12) | 0;\n out[oi++] = (y13 + x13) | 0;\n out[oi++] = (y14 + x14) | 0;\n out[oi++] = (y15 + x15) | 0;\n}\n/**\n * hchacha helper method, used primarily in xchacha, to hash\n * key and nonce into key' and nonce'.\n * Same as chachaCore, but there doesn't seem to be a way to move the block\n * out without 25% performance hit.\n */\n// prettier-ignore\nfunction hchacha(s, k, i, o32) {\n let x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3];\n for (let r = 0; r < 20; r += 2) {\n x00 = (x00 + x04) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x00, 16);\n x08 = (x08 + x12) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x08, 12);\n x00 = (x00 + x04) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x00, 8);\n x08 = (x08 + x12) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x08, 7);\n x01 = (x01 + x05) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x01, 16);\n x09 = (x09 + x13) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x09, 12);\n x01 = (x01 + x05) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x01, 8);\n x09 = (x09 + x13) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x09, 7);\n x02 = (x02 + x06) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x02, 16);\n x10 = (x10 + x14) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x10, 12);\n x02 = (x02 + x06) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x02, 8);\n x10 = (x10 + x14) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x10, 7);\n x03 = (x03 + x07) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x03, 16);\n x11 = (x11 + x15) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x11, 12);\n x03 = (x03 + x07) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x03, 8);\n x11 = (x11 + x15) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x11, 7);\n x00 = (x00 + x05) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x00, 16);\n x10 = (x10 + x15) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x10, 12);\n x00 = (x00 + x05) | 0;\n x15 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x15 ^ x00, 8);\n x10 = (x10 + x15) | 0;\n x05 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x05 ^ x10, 7);\n x01 = (x01 + x06) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x01, 16);\n x11 = (x11 + x12) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x11, 12);\n x01 = (x01 + x06) | 0;\n x12 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x12 ^ x01, 8);\n x11 = (x11 + x12) | 0;\n x06 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x06 ^ x11, 7);\n x02 = (x02 + x07) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x02, 16);\n x08 = (x08 + x13) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x08, 12);\n x02 = (x02 + x07) | 0;\n x13 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x13 ^ x02, 8);\n x08 = (x08 + x13) | 0;\n x07 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x07 ^ x08, 7);\n x03 = (x03 + x04) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x03, 16);\n x09 = (x09 + x14) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x09, 12);\n x03 = (x03 + x04) | 0;\n x14 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x14 ^ x03, 8);\n x09 = (x09 + x14) | 0;\n x04 = (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.rotl)(x04 ^ x09, 7);\n }\n let oi = 0;\n o32[oi++] = x00;\n o32[oi++] = x01;\n o32[oi++] = x02;\n o32[oi++] = x03;\n o32[oi++] = x12;\n o32[oi++] = x13;\n o32[oi++] = x14;\n o32[oi++] = x15;\n}\n/**\n * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter.\n */\nconst chacha20orig = /* @__PURE__ */ (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.createCipher)(chachaCore, {\n counterRight: false,\n counterLength: 8,\n allowShortKeys: true,\n});\n/**\n * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter.\n * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance.\n */\nconst chacha20 = /* @__PURE__ */ (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.createCipher)(chachaCore, {\n counterRight: false,\n counterLength: 4,\n allowShortKeys: false,\n});\n/**\n * XChaCha eXtended-nonce ChaCha. 24-byte nonce.\n * With 24-byte nonce, it's safe to use fill it with random (CSPRNG).\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha\n */\nconst xchacha20 = /* @__PURE__ */ (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.createCipher)(chachaCore, {\n counterRight: false,\n counterLength: 8,\n extendNonceFn: hchacha,\n allowShortKeys: false,\n});\n/**\n * Reduced 8-round chacha, described in original paper.\n */\nconst chacha8 = /* @__PURE__ */ (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.createCipher)(chachaCore, {\n counterRight: false,\n counterLength: 4,\n rounds: 8,\n});\n/**\n * Reduced 12-round chacha, described in original paper.\n */\nconst chacha12 = /* @__PURE__ */ (0,_arx_js__WEBPACK_IMPORTED_MODULE_2__.createCipher)(chachaCore, {\n counterRight: false,\n counterLength: 4,\n rounds: 12,\n});\nconst ZEROS16 = /* @__PURE__ */ new Uint8Array(16);\n// Pad to digest size with zeros\nconst updatePadded = (h, msg) => {\n h.update(msg);\n const left = msg.length % 16;\n if (left)\n h.update(ZEROS16.subarray(left));\n};\nconst ZEROS32 = /* @__PURE__ */ new Uint8Array(32);\nfunction computeTag(fn, key, nonce, data, AAD) {\n const authKey = fn(key, nonce, ZEROS32);\n const h = _poly1305_js__WEBPACK_IMPORTED_MODULE_1__.poly1305.create(authKey);\n if (AAD)\n updatePadded(h, AAD);\n updatePadded(h, data);\n const num = new Uint8Array(16);\n const view = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.createView)(num);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.setBigUint64)(view, 0, BigInt(AAD ? AAD.length : 0), true);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.setBigUint64)(view, 8, BigInt(data.length), true);\n h.update(num);\n const res = h.digest();\n authKey.fill(0);\n return res;\n}\n/**\n * AEAD algorithm from RFC 8439.\n * Salsa20 and chacha (RFC 8439) use poly1305 differently.\n * We could have composed them similar to:\n * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250\n * But it's hard because of authKey:\n * In salsa20, authKey changes position in salsa stream.\n * In chacha, authKey can't be computed inside computeTag, it modifies the counter.\n */\nconst _poly1305_aead = (xorStream) => (key, nonce, AAD) => {\n const tagLength = 16;\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(key, 32);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(nonce);\n return {\n encrypt: (plaintext, output) => {\n const plength = plaintext.length;\n const clength = plength + tagLength;\n if (output) {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(output, clength);\n }\n else {\n output = new Uint8Array(clength);\n }\n xorStream(key, nonce, plaintext, output, 1);\n const tag = computeTag(xorStream, key, nonce, output.subarray(0, -tagLength), AAD);\n output.set(tag, plength); // append tag\n return output;\n },\n decrypt: (ciphertext, output) => {\n const clength = ciphertext.length;\n const plength = clength - tagLength;\n if (clength < tagLength)\n throw new Error(`encrypted data must be at least ${tagLength} bytes`);\n if (output) {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureBytes)(output, plength);\n }\n else {\n output = new Uint8Array(plength);\n }\n const data = ciphertext.subarray(0, -tagLength);\n const passedTag = ciphertext.subarray(-tagLength);\n const tag = computeTag(xorStream, key, nonce, data, AAD);\n if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.equalBytes)(passedTag, tag))\n throw new Error('invalid tag');\n xorStream(key, nonce, data, output, 1);\n return output;\n },\n };\n};\n/**\n * ChaCha20-Poly1305 from RFC 8439.\n * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance.\n */\nconst chacha20poly1305 = /* @__PURE__ */ (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.wrapCipher)({ blockSize: 64, nonceLength: 12, tagLength: 16 }, _poly1305_aead(chacha20));\n/**\n * XChaCha20-Poly1305 extended-nonce chacha.\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha\n * With 24-byte nonce, it's safe to use fill it with random (CSPRNG).\n */\nconst xchacha20poly1305 = /* @__PURE__ */ (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.wrapCipher)({ blockSize: 64, nonceLength: 24, tagLength: 16 }, _poly1305_aead(xchacha20));\n//# sourceMappingURL=chacha.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/chacha.js?"); /***/ }), @@ -4443,7 +4483,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hash: () => (/* binding */ Hash),\n/* harmony export */ asyncLoop: () => (/* binding */ asyncLoop),\n/* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),\n/* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),\n/* harmony export */ checkOpts: () => (/* binding */ checkOpts),\n/* harmony export */ concatBytes: () => (/* binding */ concatBytes),\n/* harmony export */ createView: () => (/* binding */ createView),\n/* harmony export */ ensureBytes: () => (/* binding */ ensureBytes),\n/* harmony export */ equalBytes: () => (/* binding */ equalBytes),\n/* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),\n/* harmony export */ isLE: () => (/* binding */ isLE),\n/* harmony export */ nextTick: () => (/* binding */ nextTick),\n/* harmony export */ setBigUint64: () => (/* binding */ setBigUint64),\n/* harmony export */ toBytes: () => (/* binding */ toBytes),\n/* harmony export */ u16: () => (/* binding */ u16),\n/* harmony export */ u32: () => (/* binding */ u32),\n/* harmony export */ u8: () => (/* binding */ u8),\n/* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes)\n/* harmony export */ });\n/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */\nconst u8a = (a) => a instanceof Uint8Array;\n// Cast array to different type\nconst u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nconst u16 = (arr) => new Uint16Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 2));\nconst u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nconst createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// big-endian hardware is rare. Just in case someone still decides to run ciphers:\n// early-throw an error because we don't support BE yet.\nconst isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\nif (!isLE)\n throw new Error('Non little-endian hardware is not supported');\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nfunction bytesToHex(bytes) {\n if (!u8a(bytes))\n throw new Error('Uint8Array expected');\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const len = hex.length;\n if (len % 2)\n throw new Error('padded hex string expected, got unpadded hex of length ' + len);\n const array = new Uint8Array(len / 2);\n for (let i = 0; i < array.length; i++) {\n const j = i * 2;\n const hexByte = hex.slice(j, j + 2);\n const byte = Number.parseInt(hexByte, 16);\n if (Number.isNaN(byte) || byte < 0)\n throw new Error('Invalid byte sequence');\n array[i] = byte;\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nconst nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nasync function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\nfunction bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n if (!u8a(data))\n throw new Error(`expected Uint8Array, got ${typeof data}`);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nfunction concatBytes(...arrays) {\n const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));\n let pad = 0; // walk through each item, ensure they have proper type\n arrays.forEach((a) => {\n if (!u8a(a))\n throw new Error('Uint8Array expected');\n r.set(a, pad);\n pad += a.length;\n });\n return r;\n}\n// Check if object doens't have custom constructor (like Uint8Array/Array)\nconst isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;\nfunction checkOpts(defaults, opts) {\n if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nfunction ensureBytes(b, len) {\n if (!(b instanceof Uint8Array))\n throw new Error('Uint8Array expected');\n if (typeof len === 'number')\n if (b.length !== len)\n throw new Error(`Uint8Array length ${len} expected`);\n}\n// Constant-time equality\nfunction equalBytes(a, b) {\n // Should not happen\n if (a.length !== b.length)\n throw new Error('equalBytes: Different size of Uint8Arrays');\n let isSame = true;\n for (let i = 0; i < a.length; i++)\n isSame && (isSame = a[i] === b[i]); // Lets hope JIT won't optimize away.\n return isSame;\n}\n// For runtime check if class implements interface\nclass Hash {\n}\n// Polyfill for Safari 14\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/utils.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hash: () => (/* binding */ Hash),\n/* harmony export */ asyncLoop: () => (/* binding */ asyncLoop),\n/* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),\n/* harmony export */ bytesToNumberBE: () => (/* binding */ bytesToNumberBE),\n/* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),\n/* harmony export */ checkOpts: () => (/* binding */ checkOpts),\n/* harmony export */ concatBytes: () => (/* binding */ concatBytes),\n/* harmony export */ createView: () => (/* binding */ createView),\n/* harmony export */ ensureBytes: () => (/* binding */ ensureBytes),\n/* harmony export */ equalBytes: () => (/* binding */ equalBytes),\n/* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),\n/* harmony export */ hexToNumber: () => (/* binding */ hexToNumber),\n/* harmony export */ isLE: () => (/* binding */ isLE),\n/* harmony export */ nextTick: () => (/* binding */ nextTick),\n/* harmony export */ numberToBytesBE: () => (/* binding */ numberToBytesBE),\n/* harmony export */ setBigUint64: () => (/* binding */ setBigUint64),\n/* harmony export */ toBytes: () => (/* binding */ toBytes),\n/* harmony export */ u16: () => (/* binding */ u16),\n/* harmony export */ u32: () => (/* binding */ u32),\n/* harmony export */ u64Lengths: () => (/* binding */ u64Lengths),\n/* harmony export */ u8: () => (/* binding */ u8),\n/* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes),\n/* harmony export */ wrapCipher: () => (/* binding */ wrapCipher)\n/* harmony export */ });\n/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */\n// Cast array to different type\nconst u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nconst u16 = (arr) => new Uint16Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 2));\nconst u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\nfunction isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\n// Cast array to view\nconst createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// big-endian hardware is rare. Just in case someone still decides to run ciphers:\n// early-throw an error because we don't support BE yet.\nconst isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\nif (!isLE)\n throw new Error('Non little-endian hardware is not supported');\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nfunction bytesToHex(bytes) {\n if (!isBytes(bytes))\n throw new Error('Uint8Array expected');\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };\nfunction asciiToBase16(char) {\n if (char >= asciis._0 && char <= asciis._9)\n return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F)\n return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f)\n return char - (asciis._a - 10);\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\nfunction hexToNumber(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n // Big Endian\n return BigInt(hex === '' ? '0' : `0x${hex}`);\n}\n// BE: Big Endian, LE: Little Endian\nfunction bytesToNumberBE(bytes) {\n return hexToNumber(bytesToHex(bytes));\n}\nfunction numberToBytesBE(n, len) {\n return hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nconst nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nasync function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\nfunction bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n else if (isBytes(data))\n data = data.slice();\n else\n throw new Error(`expected Uint8Array, got ${typeof data}`);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nfunction concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n if (!isBytes(a))\n throw new Error('Uint8Array expected');\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// Check if object doens't have custom constructor (like Uint8Array/Array)\nconst isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;\nfunction checkOpts(defaults, opts) {\n if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))\n throw new Error('options must be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nfunction ensureBytes(b, len) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (typeof len === 'number')\n if (b.length !== len)\n throw new Error(`Uint8Array length ${len} expected`);\n}\n// Compares 2 u8a-s in kinda constant time\nfunction equalBytes(a, b) {\n if (a.length !== b.length)\n return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++)\n diff |= a[i] ^ b[i];\n return diff === 0;\n}\n// For runtime check if class implements interface\nclass Hash {\n}\nconst wrapCipher = (params, c) => {\n Object.assign(c, params);\n return c;\n};\n// Polyfill for Safari 14\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\nfunction u64Lengths(ciphertext, AAD) {\n const num = new Uint8Array(16);\n const view = createView(num);\n setBigUint64(view, 0, BigInt(AAD ? AAD.length : 0), true);\n setBigUint64(view, 8, BigInt(ciphertext.length), true);\n return num;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ciphers/esm/utils.js?"); + +/***/ }), + +/***/ "./node_modules/@noble/curves/esm/_shortw_utils.js": +/*!*********************************************************!*\ + !*** ./node_modules/@noble/curves/esm/_shortw_utils.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createCurve: () => (/* binding */ createCurve),\n/* harmony export */ getHash: () => (/* binding */ getHash)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_hmac__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/hashes/hmac */ \"./node_modules/@noble/hashes/esm/hmac.js\");\n/* harmony import */ var _noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/utils */ \"./node_modules/@noble/hashes/esm/utils.js\");\n/* harmony import */ var _abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstract/weierstrass.js */ \"./node_modules/@noble/curves/esm/abstract/weierstrass.js\");\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n\n\n// connects noble-curves to noble-hashes\nfunction getHash(hash) {\n return {\n hash,\n hmac: (key, ...msgs) => (0,_noble_hashes_hmac__WEBPACK_IMPORTED_MODULE_0__.hmac)(hash, key, (0,_noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__.concatBytes)(...msgs)),\n randomBytes: _noble_hashes_utils__WEBPACK_IMPORTED_MODULE_1__.randomBytes,\n };\n}\nfunction createCurve(curveDef, defHash) {\n const create = (hash) => (0,_abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_2__.weierstrass)({ ...curveDef, ...getHash(hash) });\n return Object.freeze({ ...create(defHash), create });\n}\n//# sourceMappingURL=_shortw_utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/curves/esm/_shortw_utils.js?"); /***/ }), @@ -4513,6 +4564,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@noble/curves/esm/abstract/weierstrass.js": +/*!****************************************************************!*\ + !*** ./node_modules/@noble/curves/esm/abstract/weierstrass.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DER: () => (/* binding */ DER),\n/* harmony export */ SWUFpSqrtRatio: () => (/* binding */ SWUFpSqrtRatio),\n/* harmony export */ mapToCurveSimpleSWU: () => (/* binding */ mapToCurveSimpleSWU),\n/* harmony export */ weierstrass: () => (/* binding */ weierstrass),\n/* harmony export */ weierstrassPoints: () => (/* binding */ weierstrassPoints)\n/* harmony export */ });\n/* harmony import */ var _modular_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modular.js */ \"./node_modules/@noble/curves/esm/abstract/modular.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/curves/esm/abstract/utils.js\");\n/* harmony import */ var _curve_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./curve.js */ \"./node_modules/@noble/curves/esm/abstract/curve.js\");\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// Short Weierstrass curve. The formula is: y² = x³ + ax + b\n\n\n\n\nfunction validatePointOpts(curve) {\n const opts = (0,_curve_js__WEBPACK_IMPORTED_MODULE_0__.validateBasic)(curve);\n _utils_js__WEBPACK_IMPORTED_MODULE_1__.validateObject(opts, {\n a: 'field',\n b: 'field',\n }, {\n allowedPrivateKeyLengths: 'array',\n wrapPrivateKey: 'boolean',\n isTorsionFree: 'function',\n clearCofactor: 'function',\n allowInfinityPoint: 'boolean',\n fromBytes: 'function',\n toBytes: 'function',\n });\n const { endo, Fp, a } = opts;\n if (endo) {\n if (!Fp.eql(a, Fp.ZERO)) {\n throw new Error('Endomorphism can only be defined for Koblitz curves that have a=0');\n }\n if (typeof endo !== 'object' ||\n typeof endo.beta !== 'bigint' ||\n typeof endo.splitScalar !== 'function') {\n throw new Error('Expected endomorphism with beta: bigint and splitScalar: function');\n }\n }\n return Object.freeze({ ...opts });\n}\n// ASN.1 DER encoding utilities\nconst { bytesToNumberBE: b2n, hexToBytes: h2b } = _utils_js__WEBPACK_IMPORTED_MODULE_1__;\nconst DER = {\n // asn.1 DER encoding utils\n Err: class DERErr extends Error {\n constructor(m = '') {\n super(m);\n }\n },\n _parseInt(data) {\n const { Err: E } = DER;\n if (data.length < 2 || data[0] !== 0x02)\n throw new E('Invalid signature integer tag');\n const len = data[1];\n const res = data.subarray(2, len + 2);\n if (!len || res.length !== len)\n throw new E('Invalid signature integer: wrong length');\n // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,\n // since we always use positive integers here. It must always be empty:\n // - add zero byte if exists\n // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)\n if (res[0] & 0b10000000)\n throw new E('Invalid signature integer: negative');\n if (res[0] === 0x00 && !(res[1] & 0b10000000))\n throw new E('Invalid signature integer: unnecessary leading zero');\n return { d: b2n(res), l: data.subarray(len + 2) }; // d is data, l is left\n },\n toSig(hex) {\n // parse DER signature\n const { Err: E } = DER;\n const data = typeof hex === 'string' ? h2b(hex) : hex;\n _utils_js__WEBPACK_IMPORTED_MODULE_1__.abytes(data);\n let l = data.length;\n if (l < 2 || data[0] != 0x30)\n throw new E('Invalid signature tag');\n if (data[1] !== l - 2)\n throw new E('Invalid signature: incorrect length');\n const { d: r, l: sBytes } = DER._parseInt(data.subarray(2));\n const { d: s, l: rBytesLeft } = DER._parseInt(sBytes);\n if (rBytesLeft.length)\n throw new E('Invalid signature: left bytes after parsing');\n return { r, s };\n },\n hexFromSig(sig) {\n // Add leading zero if first byte has negative bit enabled. More details in '_parseInt'\n const slice = (s) => (Number.parseInt(s[0], 16) & 0b1000 ? '00' + s : s);\n const h = (num) => {\n const hex = num.toString(16);\n return hex.length & 1 ? `0${hex}` : hex;\n };\n const s = slice(h(sig.s));\n const r = slice(h(sig.r));\n const shl = s.length / 2;\n const rhl = r.length / 2;\n const sl = h(shl);\n const rl = h(rhl);\n return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`;\n },\n};\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4);\nfunction weierstrassPoints(opts) {\n const CURVE = validatePointOpts(opts);\n const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ\n const toBytes = CURVE.toBytes ||\n ((_c, point, _isCompressed) => {\n const a = point.toAffine();\n return _utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));\n });\n const fromBytes = CURVE.fromBytes ||\n ((bytes) => {\n // const head = bytes[0];\n const tail = bytes.subarray(1);\n // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported');\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n });\n /**\n * y² = x³ + ax + b: Short weierstrass curve formula\n * @returns y²\n */\n function weierstrassEquation(x) {\n const { a, b } = CURVE;\n const x2 = Fp.sqr(x); // x * x\n const x3 = Fp.mul(x2, x); // x2 * x\n return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b\n }\n // Validate whether the passed curve params are valid.\n // We check if curve equation works for generator point.\n // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381.\n // ProjectivePoint class has not been initialized yet.\n if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))\n throw new Error('bad generator point: equation left != right');\n // Valid group elements reside in range 1..n-1\n function isWithinCurveOrder(num) {\n return typeof num === 'bigint' && _0n < num && num < CURVE.n;\n }\n function assertGE(num) {\n if (!isWithinCurveOrder(num))\n throw new Error('Expected valid bigint: 0 < bigint < curve.n');\n }\n // Validates if priv key is valid and converts it to bigint.\n // Supports options allowedPrivateKeyLengths and wrapPrivateKey.\n function normPrivateKeyToScalar(key) {\n const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;\n if (lengths && typeof key !== 'bigint') {\n if (_utils_js__WEBPACK_IMPORTED_MODULE_1__.isBytes(key))\n key = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToHex(key);\n // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes\n if (typeof key !== 'string' || !lengths.includes(key.length))\n throw new Error('Invalid key');\n key = key.padStart(nByteLength * 2, '0');\n }\n let num;\n try {\n num =\n typeof key === 'bigint'\n ? key\n : _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberBE((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('private key', key, nByteLength));\n }\n catch (error) {\n throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);\n }\n if (wrapPrivateKey)\n num = _modular_js__WEBPACK_IMPORTED_MODULE_2__.mod(num, n); // disabled by default, enabled for BLS\n assertGE(num); // num in range [1..N-1]\n return num;\n }\n const pointPrecomputes = new Map();\n function assertPrjPoint(other) {\n if (!(other instanceof Point))\n throw new Error('ProjectivePoint expected');\n }\n /**\n * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z)\n * Default Point works in 2d / affine coordinates: (x, y)\n * We're doing calculations in projective, because its operations don't require costly inversion.\n */\n class Point {\n constructor(px, py, pz) {\n this.px = px;\n this.py = py;\n this.pz = pz;\n if (px == null || !Fp.isValid(px))\n throw new Error('x required');\n if (py == null || !Fp.isValid(py))\n throw new Error('y required');\n if (pz == null || !Fp.isValid(pz))\n throw new Error('z required');\n }\n // Does not validate if the point is on-curve.\n // Use fromHex instead, or call assertValidity() later.\n static fromAffine(p) {\n const { x, y } = p || {};\n if (!p || !Fp.isValid(x) || !Fp.isValid(y))\n throw new Error('invalid affine point');\n if (p instanceof Point)\n throw new Error('projective point not allowed');\n const is0 = (i) => Fp.eql(i, Fp.ZERO);\n // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0)\n if (is0(x) && is0(y))\n return Point.ZERO;\n return new Point(x, y, Fp.ONE);\n }\n get x() {\n return this.toAffine().x;\n }\n get y() {\n return this.toAffine().y;\n }\n /**\n * Takes a bunch of Projective Points but executes only one\n * inversion on all of them. Inversion is very slow operation,\n * so this improves performance massively.\n * Optimization: converts a list of projective points to a list of identical points with Z=1.\n */\n static normalizeZ(points) {\n const toInv = Fp.invertBatch(points.map((p) => p.pz));\n return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n /**\n * Converts hash string or Uint8Array to Point.\n * @param hex short/long ECDSA hex\n */\n static fromHex(hex) {\n const P = Point.fromAffine(fromBytes((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('pointHex', hex)));\n P.assertValidity();\n return P;\n }\n // Multiplies generator point by privateKey.\n static fromPrivateKey(privateKey) {\n return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));\n }\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize) {\n this._WINDOW_SIZE = windowSize;\n pointPrecomputes.delete(this);\n }\n // A point on curve is valid if it conforms to equation.\n assertValidity() {\n if (this.is0()) {\n // (0, 1, 0) aka ZERO is invalid in most contexts.\n // In BLS, ZERO can be serialized, so we allow it.\n // (0, 0, 0) is wrong representation of ZERO and is always invalid.\n if (CURVE.allowInfinityPoint && !Fp.is0(this.py))\n return;\n throw new Error('bad point: ZERO');\n }\n // Some 3rd-party test vectors require different wording between here & `fromCompressedHex`\n const { x, y } = this.toAffine();\n // Check if x, y are valid field elements\n if (!Fp.isValid(x) || !Fp.isValid(y))\n throw new Error('bad point: x or y not FE');\n const left = Fp.sqr(y); // y²\n const right = weierstrassEquation(x); // x³ + ax + b\n if (!Fp.eql(left, right))\n throw new Error('bad point: equation left != right');\n if (!this.isTorsionFree())\n throw new Error('bad point: not in prime-order subgroup');\n }\n hasEvenY() {\n const { y } = this.toAffine();\n if (Fp.isOdd)\n return !Fp.isOdd(y);\n throw new Error(\"Field doesn't support isOdd\");\n }\n /**\n * Compare one point to another.\n */\n equals(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));\n const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));\n return U1 && U2;\n }\n /**\n * Flips point to one corresponding to (x, -y) in Affine coordinates.\n */\n negate() {\n return new Point(this.px, Fp.neg(this.py), this.pz);\n }\n // Renes-Costello-Batina exception-free doubling formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 3\n // Cost: 8M + 3S + 3*a + 2*b3 + 15add.\n double() {\n const { a, b } = CURVE;\n const b3 = Fp.mul(b, _3n);\n const { px: X1, py: Y1, pz: Z1 } = this;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n let t0 = Fp.mul(X1, X1); // step 1\n let t1 = Fp.mul(Y1, Y1);\n let t2 = Fp.mul(Z1, Z1);\n let t3 = Fp.mul(X1, Y1);\n t3 = Fp.add(t3, t3); // step 5\n Z3 = Fp.mul(X1, Z1);\n Z3 = Fp.add(Z3, Z3);\n X3 = Fp.mul(a, Z3);\n Y3 = Fp.mul(b3, t2);\n Y3 = Fp.add(X3, Y3); // step 10\n X3 = Fp.sub(t1, Y3);\n Y3 = Fp.add(t1, Y3);\n Y3 = Fp.mul(X3, Y3);\n X3 = Fp.mul(t3, X3);\n Z3 = Fp.mul(b3, Z3); // step 15\n t2 = Fp.mul(a, t2);\n t3 = Fp.sub(t0, t2);\n t3 = Fp.mul(a, t3);\n t3 = Fp.add(t3, Z3);\n Z3 = Fp.add(t0, t0); // step 20\n t0 = Fp.add(Z3, t0);\n t0 = Fp.add(t0, t2);\n t0 = Fp.mul(t0, t3);\n Y3 = Fp.add(Y3, t0);\n t2 = Fp.mul(Y1, Z1); // step 25\n t2 = Fp.add(t2, t2);\n t0 = Fp.mul(t2, t3);\n X3 = Fp.sub(X3, t0);\n Z3 = Fp.mul(t2, t1);\n Z3 = Fp.add(Z3, Z3); // step 30\n Z3 = Fp.add(Z3, Z3);\n return new Point(X3, Y3, Z3);\n }\n // Renes-Costello-Batina exception-free addition formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 1\n // Cost: 12M + 0S + 3*a + 3*b3 + 23add.\n add(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n const a = CURVE.a;\n const b3 = Fp.mul(CURVE.b, _3n);\n let t0 = Fp.mul(X1, X2); // step 1\n let t1 = Fp.mul(Y1, Y2);\n let t2 = Fp.mul(Z1, Z2);\n let t3 = Fp.add(X1, Y1);\n let t4 = Fp.add(X2, Y2); // step 5\n t3 = Fp.mul(t3, t4);\n t4 = Fp.add(t0, t1);\n t3 = Fp.sub(t3, t4);\n t4 = Fp.add(X1, Z1);\n let t5 = Fp.add(X2, Z2); // step 10\n t4 = Fp.mul(t4, t5);\n t5 = Fp.add(t0, t2);\n t4 = Fp.sub(t4, t5);\n t5 = Fp.add(Y1, Z1);\n X3 = Fp.add(Y2, Z2); // step 15\n t5 = Fp.mul(t5, X3);\n X3 = Fp.add(t1, t2);\n t5 = Fp.sub(t5, X3);\n Z3 = Fp.mul(a, t4);\n X3 = Fp.mul(b3, t2); // step 20\n Z3 = Fp.add(X3, Z3);\n X3 = Fp.sub(t1, Z3);\n Z3 = Fp.add(t1, Z3);\n Y3 = Fp.mul(X3, Z3);\n t1 = Fp.add(t0, t0); // step 25\n t1 = Fp.add(t1, t0);\n t2 = Fp.mul(a, t2);\n t4 = Fp.mul(b3, t4);\n t1 = Fp.add(t1, t2);\n t2 = Fp.sub(t0, t2); // step 30\n t2 = Fp.mul(a, t2);\n t4 = Fp.add(t4, t2);\n t0 = Fp.mul(t1, t4);\n Y3 = Fp.add(Y3, t0);\n t0 = Fp.mul(t5, t4); // step 35\n X3 = Fp.mul(t3, X3);\n X3 = Fp.sub(X3, t0);\n t0 = Fp.mul(t3, t1);\n Z3 = Fp.mul(t5, Z3);\n Z3 = Fp.add(Z3, t0); // step 40\n return new Point(X3, Y3, Z3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n is0() {\n return this.equals(Point.ZERO);\n }\n wNAF(n) {\n return wnaf.wNAFCached(this, pointPrecomputes, n, (comp) => {\n const toInv = Fp.invertBatch(comp.map((p) => p.pz));\n return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n });\n }\n /**\n * Non-constant-time multiplication. Uses double-and-add algorithm.\n * It's faster, but should only be used when you don't care about\n * an exposed private key e.g. sig verification, which works over *public* keys.\n */\n multiplyUnsafe(n) {\n const I = Point.ZERO;\n if (n === _0n)\n return I;\n assertGE(n); // Will throw on 0\n if (n === _1n)\n return this;\n const { endo } = CURVE;\n if (!endo)\n return wnaf.unsafeLadder(this, n);\n // Apply endomorphism\n let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);\n let k1p = I;\n let k2p = I;\n let d = this;\n while (k1 > _0n || k2 > _0n) {\n if (k1 & _1n)\n k1p = k1p.add(d);\n if (k2 & _1n)\n k2p = k2p.add(d);\n d = d.double();\n k1 >>= _1n;\n k2 >>= _1n;\n }\n if (k1neg)\n k1p = k1p.negate();\n if (k2neg)\n k2p = k2p.negate();\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n return k1p.add(k2p);\n }\n /**\n * Constant time multiplication.\n * Uses wNAF method. Windowed method may be 10% faster,\n * but takes 2x longer to generate and consumes 2x memory.\n * Uses precomputes when available.\n * Uses endomorphism for Koblitz curves.\n * @param scalar by which the point would be multiplied\n * @returns New point\n */\n multiply(scalar) {\n assertGE(scalar);\n let n = scalar;\n let point, fake; // Fake point is used to const-time mult\n const { endo } = CURVE;\n if (endo) {\n const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);\n let { p: k1p, f: f1p } = this.wNAF(k1);\n let { p: k2p, f: f2p } = this.wNAF(k2);\n k1p = wnaf.constTimeNegate(k1neg, k1p);\n k2p = wnaf.constTimeNegate(k2neg, k2p);\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n point = k1p.add(k2p);\n fake = f1p.add(f2p);\n }\n else {\n const { p, f } = this.wNAF(n);\n point = p;\n fake = f;\n }\n // Normalize `z` for both points, but return only real one\n return Point.normalizeZ([point, fake])[0];\n }\n /**\n * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.\n * Not using Strauss-Shamir trick: precomputation tables are faster.\n * The trick could be useful if both P and Q are not G (not in our case).\n * @returns non-zero affine point\n */\n multiplyAndAddUnsafe(Q, a, b) {\n const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes\n const mul = (P, a // Select faster multiply() method\n ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a));\n const sum = mul(this, a).add(mul(Q, b));\n return sum.is0() ? undefined : sum;\n }\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n toAffine(iz) {\n const { px: x, py: y, pz: z } = this;\n const is0 = this.is0();\n // If invZ was 0, we return zero point. However we still want to execute\n // all operations, so we replace invZ with a random number, 1.\n if (iz == null)\n iz = is0 ? Fp.ONE : Fp.inv(z);\n const ax = Fp.mul(x, iz);\n const ay = Fp.mul(y, iz);\n const zz = Fp.mul(z, iz);\n if (is0)\n return { x: Fp.ZERO, y: Fp.ZERO };\n if (!Fp.eql(zz, Fp.ONE))\n throw new Error('invZ was invalid');\n return { x: ax, y: ay };\n }\n isTorsionFree() {\n const { h: cofactor, isTorsionFree } = CURVE;\n if (cofactor === _1n)\n return true; // No subgroups, always torsion-free\n if (isTorsionFree)\n return isTorsionFree(Point, this);\n throw new Error('isTorsionFree() has not been declared for the elliptic curve');\n }\n clearCofactor() {\n const { h: cofactor, clearCofactor } = CURVE;\n if (cofactor === _1n)\n return this; // Fast-path\n if (clearCofactor)\n return clearCofactor(Point, this);\n return this.multiplyUnsafe(CURVE.h);\n }\n toRawBytes(isCompressed = true) {\n this.assertValidity();\n return toBytes(Point, this, isCompressed);\n }\n toHex(isCompressed = true) {\n return _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToHex(this.toRawBytes(isCompressed));\n }\n }\n Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);\n Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);\n const _bits = CURVE.nBitLength;\n const wnaf = (0,_curve_js__WEBPACK_IMPORTED_MODULE_0__.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);\n // Validate if generator point is on curve\n return {\n CURVE,\n ProjectivePoint: Point,\n normPrivateKeyToScalar,\n weierstrassEquation,\n isWithinCurveOrder,\n };\n}\nfunction validateOpts(curve) {\n const opts = (0,_curve_js__WEBPACK_IMPORTED_MODULE_0__.validateBasic)(curve);\n _utils_js__WEBPACK_IMPORTED_MODULE_1__.validateObject(opts, {\n hash: 'hash',\n hmac: 'function',\n randomBytes: 'function',\n }, {\n bits2int: 'function',\n bits2int_modN: 'function',\n lowS: 'boolean',\n });\n return Object.freeze({ lowS: true, ...opts });\n}\nfunction weierstrass(curveDef) {\n const CURVE = validateOpts(curveDef);\n const { Fp, n: CURVE_ORDER } = CURVE;\n const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32\n const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32\n function isValidFieldElement(num) {\n return _0n < num && num < Fp.ORDER; // 0 is banned since it's not invertible FE\n }\n function modN(a) {\n return _modular_js__WEBPACK_IMPORTED_MODULE_2__.mod(a, CURVE_ORDER);\n }\n function invN(a) {\n return _modular_js__WEBPACK_IMPORTED_MODULE_2__.invert(a, CURVE_ORDER);\n }\n const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder, } = weierstrassPoints({\n ...CURVE,\n toBytes(_c, point, isCompressed) {\n const a = point.toAffine();\n const x = Fp.toBytes(a.x);\n const cat = _utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes;\n if (isCompressed) {\n return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x);\n }\n else {\n return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y));\n }\n },\n fromBytes(bytes) {\n const len = bytes.length;\n const head = bytes[0];\n const tail = bytes.subarray(1);\n // this.assertValidity() is done inside of fromHex\n if (len === compressedLen && (head === 0x02 || head === 0x03)) {\n const x = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberBE(tail);\n if (!isValidFieldElement(x))\n throw new Error('Point is not on curve');\n const y2 = weierstrassEquation(x); // y² = x³ + ax + b\n let y;\n try {\n y = Fp.sqrt(y2); // y = y² ^ (p+1)/4\n }\n catch (sqrtError) {\n const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';\n throw new Error('Point is not on curve' + suffix);\n }\n const isYOdd = (y & _1n) === _1n;\n // ECDSA\n const isHeadOdd = (head & 1) === 1;\n if (isHeadOdd !== isYOdd)\n y = Fp.neg(y);\n return { x, y };\n }\n else if (len === uncompressedLen && head === 0x04) {\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n }\n else {\n throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`);\n }\n },\n });\n const numToNByteStr = (num) => _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToHex(_utils_js__WEBPACK_IMPORTED_MODULE_1__.numberToBytesBE(num, CURVE.nByteLength));\n function isBiggerThanHalfOrder(number) {\n const HALF = CURVE_ORDER >> _1n;\n return number > HALF;\n }\n function normalizeS(s) {\n return isBiggerThanHalfOrder(s) ? modN(-s) : s;\n }\n // slice bytes num\n const slcNum = (b, from, to) => _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberBE(b.slice(from, to));\n /**\n * ECDSA signature with its (r, s) properties. Supports DER & compact representations.\n */\n class Signature {\n constructor(r, s, recovery) {\n this.r = r;\n this.s = s;\n this.recovery = recovery;\n this.assertValidity();\n }\n // pair (bytes of r, bytes of s)\n static fromCompact(hex) {\n const l = CURVE.nByteLength;\n hex = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('compactSignature', hex, l * 2);\n return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));\n }\n // DER encoded ECDSA signature\n // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script\n static fromDER(hex) {\n const { r, s } = DER.toSig((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('DER', hex));\n return new Signature(r, s);\n }\n assertValidity() {\n // can use assertGE here\n if (!isWithinCurveOrder(this.r))\n throw new Error('r must be 0 < r < CURVE.n');\n if (!isWithinCurveOrder(this.s))\n throw new Error('s must be 0 < s < CURVE.n');\n }\n addRecoveryBit(recovery) {\n return new Signature(this.r, this.s, recovery);\n }\n recoverPublicKey(msgHash) {\n const { r, s, recovery: rec } = this;\n const h = bits2int_modN((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('msgHash', msgHash)); // Truncate hash\n if (rec == null || ![0, 1, 2, 3].includes(rec))\n throw new Error('recovery id invalid');\n const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;\n if (radj >= Fp.ORDER)\n throw new Error('recovery id 2 or 3 invalid');\n const prefix = (rec & 1) === 0 ? '02' : '03';\n const R = Point.fromHex(prefix + numToNByteStr(radj));\n const ir = invN(radj); // r^-1\n const u1 = modN(-h * ir); // -hr^-1\n const u2 = modN(s * ir); // sr^-1\n const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1)\n if (!Q)\n throw new Error('point at infinify'); // unsafe is fine: no priv data leaked\n Q.assertValidity();\n return Q;\n }\n // Signatures should be low-s, to prevent malleability.\n hasHighS() {\n return isBiggerThanHalfOrder(this.s);\n }\n normalizeS() {\n return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;\n }\n // DER-encoded\n toDERRawBytes() {\n return _utils_js__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(this.toDERHex());\n }\n toDERHex() {\n return DER.hexFromSig({ r: this.r, s: this.s });\n }\n // padded bytes of r, then padded bytes of s\n toCompactRawBytes() {\n return _utils_js__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(this.toCompactHex());\n }\n toCompactHex() {\n return numToNByteStr(this.r) + numToNByteStr(this.s);\n }\n }\n const utils = {\n isValidPrivateKey(privateKey) {\n try {\n normPrivateKeyToScalar(privateKey);\n return true;\n }\n catch (error) {\n return false;\n }\n },\n normPrivateKeyToScalar: normPrivateKeyToScalar,\n /**\n * Produces cryptographically secure private key from random of size\n * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.\n */\n randomPrivateKey: () => {\n const length = _modular_js__WEBPACK_IMPORTED_MODULE_2__.getMinHashLength(CURVE.n);\n return _modular_js__WEBPACK_IMPORTED_MODULE_2__.mapHashToField(CURVE.randomBytes(length), CURVE.n);\n },\n /**\n * Creates precompute table for an arbitrary EC point. Makes point \"cached\".\n * Allows to massively speed-up `point.multiply(scalar)`.\n * @returns cached point\n * @example\n * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));\n * fast.multiply(privKey); // much faster ECDH now\n */\n precompute(windowSize = 8, point = Point.BASE) {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here\n return point;\n },\n };\n /**\n * Computes public key for a private key. Checks for validity of the private key.\n * @param privateKey private key\n * @param isCompressed whether to return compact (default), or full key\n * @returns Public key, full when isCompressed=false; short when isCompressed=true\n */\n function getPublicKey(privateKey, isCompressed = true) {\n return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);\n }\n /**\n * Quick and dirty check for item being public key. Does not validate hex, or being on-curve.\n */\n function isProbPub(item) {\n const arr = _utils_js__WEBPACK_IMPORTED_MODULE_1__.isBytes(item);\n const str = typeof item === 'string';\n const len = (arr || str) && item.length;\n if (arr)\n return len === compressedLen || len === uncompressedLen;\n if (str)\n return len === 2 * compressedLen || len === 2 * uncompressedLen;\n if (item instanceof Point)\n return true;\n return false;\n }\n /**\n * ECDH (Elliptic Curve Diffie Hellman).\n * Computes shared public key from private key and public key.\n * Checks: 1) private key validity 2) shared key is on-curve.\n * Does NOT hash the result.\n * @param privateA private key\n * @param publicB different public key\n * @param isCompressed whether to return compact (default), or full key\n * @returns shared public key\n */\n function getSharedSecret(privateA, publicB, isCompressed = true) {\n if (isProbPub(privateA))\n throw new Error('first arg must be private key');\n if (!isProbPub(publicB))\n throw new Error('second arg must be public key');\n const b = Point.fromHex(publicB); // check for being on-curve\n return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);\n }\n // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets.\n // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int.\n // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same.\n // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors\n const bits2int = CURVE.bits2int ||\n function (bytes) {\n // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m)\n // for some cases, since bytes.length * 8 is not actual bitLength.\n const num = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberBE(bytes); // check for == u8 done here\n const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits\n return delta > 0 ? num >> BigInt(delta) : num;\n };\n const bits2int_modN = CURVE.bits2int_modN ||\n function (bytes) {\n return modN(bits2int(bytes)); // can't use bytesToNumberBE here\n };\n // NOTE: pads output with zero as per spec\n const ORDER_MASK = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bitMask(CURVE.nBitLength);\n /**\n * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`.\n */\n function int2octets(num) {\n if (typeof num !== 'bigint')\n throw new Error('bigint expected');\n if (!(_0n <= num && num < ORDER_MASK))\n throw new Error(`bigint expected < 2^${CURVE.nBitLength}`);\n // works with order, can have different size than numToField!\n return _utils_js__WEBPACK_IMPORTED_MODULE_1__.numberToBytesBE(num, CURVE.nByteLength);\n }\n // Steps A, D of RFC6979 3.2\n // Creates RFC6979 seed; converts msg/privKey to numbers.\n // Used only in sign, not in verify.\n // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order, this will be wrong at least for P521.\n // Also it can be bigger for P224 + SHA256\n function prepSig(msgHash, privateKey, opts = defaultSigOpts) {\n if (['recovered', 'canonical'].some((k) => k in opts))\n throw new Error('sign() legacy options not supported');\n const { hash, randomBytes } = CURVE;\n let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default\n if (lowS == null)\n lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash\n msgHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('msgHash', msgHash);\n if (prehash)\n msgHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('prehashed msgHash', hash(msgHash));\n // We can't later call bits2octets, since nested bits2int is broken for curves\n // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call.\n // const bits2octets = (bits) => int2octets(bits2int_modN(bits))\n const h1int = bits2int_modN(msgHash);\n const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint\n const seedArgs = [int2octets(d), int2octets(h1int)];\n // extraEntropy. RFC6979 3.6: additional k' (optional).\n if (ent != null && ent !== false) {\n // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')\n const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is\n seedArgs.push((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('extraEntropy', e)); // check for being bytes\n }\n const seed = _utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes(...seedArgs); // Step D of RFC6979 3.2\n const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!\n // Converts signature params into point w r/s, checks result for validity.\n function k2sig(kBytes) {\n // RFC 6979 Section 3.2, step 3: k = bits2int(T)\n const k = bits2int(kBytes); // Cannot use fields methods, since it is group element\n if (!isWithinCurveOrder(k))\n return; // Important: all mod() calls here must be done over N\n const ik = invN(k); // k^-1 mod n\n const q = Point.BASE.multiply(k).toAffine(); // q = Gk\n const r = modN(q.x); // r = q.x mod n\n if (r === _0n)\n return;\n // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to\n // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it:\n // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT\n const s = modN(ik * modN(m + r * d)); // Not using blinding here\n if (s === _0n)\n return;\n let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n)\n let normS = s;\n if (lowS && isBiggerThanHalfOrder(s)) {\n normS = normalizeS(s); // if lowS was passed, ensure s is always\n recovery ^= 1; // // in the bottom half of N\n }\n return new Signature(r, normS, recovery); // use normS, not s\n }\n return { seed, k2sig };\n }\n const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };\n const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };\n /**\n * Signs message hash with a private key.\n * ```\n * sign(m, d, k) where\n * (x, y) = G × k\n * r = x mod n\n * s = (m + dr)/k mod n\n * ```\n * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`.\n * @param privKey private key\n * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg.\n * @returns signature with recovery param\n */\n function sign(msgHash, privKey, opts = defaultSigOpts) {\n const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2.\n const C = CURVE;\n const drbg = _utils_js__WEBPACK_IMPORTED_MODULE_1__.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);\n return drbg(seed, k2sig); // Steps B, C, D, E, F, G\n }\n // Enable precomputes. Slows down first publicKey computation by 20ms.\n Point.BASE._setWindowSize(8);\n // utils.precompute(8, ProjectivePoint.BASE)\n /**\n * Verifies a signature against message hash and public key.\n * Rejects lowS signatures by default: to override,\n * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf:\n *\n * ```\n * verify(r, s, h, P) where\n * U1 = hs^-1 mod n\n * U2 = rs^-1 mod n\n * R = U1⋅G - U2⋅P\n * mod(R.x, n) == r\n * ```\n */\n function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {\n const sg = signature;\n msgHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('msgHash', msgHash);\n publicKey = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('publicKey', publicKey);\n if ('strict' in opts)\n throw new Error('options.strict was renamed to lowS');\n const { lowS, prehash } = opts;\n let _sig = undefined;\n let P;\n try {\n if (typeof sg === 'string' || _utils_js__WEBPACK_IMPORTED_MODULE_1__.isBytes(sg)) {\n // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).\n // Since DER can also be 2*nByteLength bytes, we check for it first.\n try {\n _sig = Signature.fromDER(sg);\n }\n catch (derError) {\n if (!(derError instanceof DER.Err))\n throw derError;\n _sig = Signature.fromCompact(sg);\n }\n }\n else if (typeof sg === 'object' && typeof sg.r === 'bigint' && typeof sg.s === 'bigint') {\n const { r, s } = sg;\n _sig = new Signature(r, s);\n }\n else {\n throw new Error('PARSE');\n }\n P = Point.fromHex(publicKey);\n }\n catch (error) {\n if (error.message === 'PARSE')\n throw new Error(`signature must be Signature instance, Uint8Array or hex string`);\n return false;\n }\n if (lowS && _sig.hasHighS())\n return false;\n if (prehash)\n msgHash = CURVE.hash(msgHash);\n const { r, s } = _sig;\n const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element\n const is = invN(s); // s^-1\n const u1 = modN(h * is); // u1 = hs^-1 mod n\n const u2 = modN(r * is); // u2 = rs^-1 mod n\n const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P\n if (!R)\n return false;\n const v = modN(R.x);\n return v === r;\n }\n return {\n CURVE,\n getPublicKey,\n getSharedSecret,\n sign,\n verify,\n ProjectivePoint: Point,\n Signature,\n utils,\n };\n}\n/**\n * Implementation of the Shallue and van de Woestijne method for any weierstrass curve.\n * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular.\n * b = True and y = sqrt(u / v) if (u / v) is square in F, and\n * b = False and y = sqrt(Z * (u / v)) otherwise.\n * @param Fp\n * @param Z\n * @returns\n */\nfunction SWUFpSqrtRatio(Fp, Z) {\n // Generic implementation\n const q = Fp.ORDER;\n let l = _0n;\n for (let o = q - _1n; o % _2n === _0n; o /= _2n)\n l += _1n;\n const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1.\n // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<.\n // 2n ** c1 == 2n << (c1-1)\n const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n);\n const _2n_pow_c1 = _2n_pow_c1_1 * _2n;\n const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic\n const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic\n const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic\n const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic\n const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2\n const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2)\n let sqrtRatio = (u, v) => {\n let tv1 = c6; // 1. tv1 = c6\n let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4\n let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2\n tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v\n let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3\n tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3\n tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2\n tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v\n tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u\n let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2\n tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5\n let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1\n tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7\n tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR)\n tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR)\n // 17. for i in (c1, c1 - 1, ..., 2):\n for (let i = c1; i > _1n; i--) {\n let tv5 = i - _2n; // 18. tv5 = i - 2\n tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5\n let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5\n const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1\n tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1\n tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1\n tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1)\n tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1)\n }\n return { isValid: isQR, value: tv3 };\n };\n if (Fp.ORDER % _4n === _3n) {\n // sqrt_ratio_3mod4(u, v)\n const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic\n const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z)\n sqrtRatio = (u, v) => {\n let tv1 = Fp.sqr(v); // 1. tv1 = v^2\n const tv2 = Fp.mul(u, v); // 2. tv2 = u * v\n tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2\n let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1\n y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2\n const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2\n const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v\n const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u\n let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR)\n return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2\n };\n }\n // No curves uses that\n // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8\n return sqrtRatio;\n}\n/**\n * Simplified Shallue-van de Woestijne-Ulas Method\n * https://www.rfc-editor.org/rfc/rfc9380#section-6.6.2\n */\nfunction mapToCurveSimpleSWU(Fp, opts) {\n _modular_js__WEBPACK_IMPORTED_MODULE_2__.validateField(Fp);\n if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))\n throw new Error('mapToCurveSimpleSWU: invalid opts');\n const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);\n if (!Fp.isOdd)\n throw new Error('Fp.isOdd is not implemented!');\n // Input: u, an element of F.\n // Output: (x, y), a point on E.\n return (u) => {\n // prettier-ignore\n let tv1, tv2, tv3, tv4, tv5, tv6, x, y;\n tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1\n tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2\n tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1\n tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1\n tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3\n tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0)\n tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4\n tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2\n tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2\n tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6\n tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5\n tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3\n tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4\n tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6\n tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5\n x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3\n const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6)\n y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1\n y = Fp.mul(y, value); // 20. y = y * y1\n x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square)\n y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square)\n const e1 = Fp.isOdd(u) === Fp.isOdd(y); // 23. e1 = sgn0(u) == sgn0(y)\n y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1)\n x = Fp.div(x, tv4); // 25. x = x / tv4\n return { x, y };\n };\n}\n//# sourceMappingURL=weierstrass.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/curves/esm/abstract/weierstrass.js?"); + +/***/ }), + /***/ "./node_modules/@noble/curves/esm/ed25519.js": /*!***************************************************!*\ !*** ./node_modules/@noble/curves/esm/ed25519.js ***! @@ -4524,14 +4586,14 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@noble/ed25519/lib/esm/index.js": -/*!******************************************************!*\ - !*** ./node_modules/@noble/ed25519/lib/esm/index.js ***! - \******************************************************/ +/***/ "./node_modules/@noble/curves/esm/secp256k1.js": +/*!*****************************************************!*\ + !*** ./node_modules/@noble/curves/esm/secp256k1.js ***! + \*****************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("var crypto__WEBPACK_IMPORTED_MODULE_0___namespace_cache;\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CURVE: () => (/* binding */ CURVE),\n/* harmony export */ ExtendedPoint: () => (/* binding */ ExtendedPoint),\n/* harmony export */ Point: () => (/* binding */ Point),\n/* harmony export */ RistrettoPoint: () => (/* binding */ RistrettoPoint),\n/* harmony export */ Signature: () => (/* binding */ Signature),\n/* harmony export */ curve25519: () => (/* binding */ curve25519),\n/* harmony export */ getPublicKey: () => (/* binding */ getPublicKey),\n/* harmony export */ getSharedSecret: () => (/* binding */ getSharedSecret),\n/* harmony export */ sign: () => (/* binding */ sign),\n/* harmony export */ sync: () => (/* binding */ sync),\n/* harmony export */ utils: () => (/* binding */ utils),\n/* harmony export */ verify: () => (/* binding */ verify)\n/* harmony export */ });\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto */ \"?51ea\");\n/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */\n\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst _8n = BigInt(8);\nconst CU_O = BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989');\nconst CURVE = Object.freeze({\n a: BigInt(-1),\n d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n P: BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'),\n l: CU_O,\n n: CU_O,\n h: BigInt(8),\n Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n});\n\nconst POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');\nconst SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\nconst SQRT_D = BigInt('6853475219497561581579357271197624642482790079785650197046958215289687604742');\nconst SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\nconst INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\nconst ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\nconst D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\nclass ExtendedPoint {\n constructor(x, y, z, t) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.t = t;\n }\n static fromAffine(p) {\n if (!(p instanceof Point)) {\n throw new TypeError('ExtendedPoint#fromAffine: expected Point');\n }\n if (p.equals(Point.ZERO))\n return ExtendedPoint.ZERO;\n return new ExtendedPoint(p.x, p.y, _1n, mod(p.x * p.y));\n }\n static toAffineBatch(points) {\n const toInv = invertBatch(points.map((p) => p.z));\n return points.map((p, i) => p.toAffine(toInv[i]));\n }\n static normalizeZ(points) {\n return this.toAffineBatch(points).map(this.fromAffine);\n }\n equals(other) {\n assertExtPoint(other);\n const { x: X1, y: Y1, z: Z1 } = this;\n const { x: X2, y: Y2, z: Z2 } = other;\n const X1Z2 = mod(X1 * Z2);\n const X2Z1 = mod(X2 * Z1);\n const Y1Z2 = mod(Y1 * Z2);\n const Y2Z1 = mod(Y2 * Z1);\n return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n }\n negate() {\n return new ExtendedPoint(mod(-this.x), this.y, this.z, mod(-this.t));\n }\n double() {\n const { x: X1, y: Y1, z: Z1 } = this;\n const { a } = CURVE;\n const A = mod(X1 * X1);\n const B = mod(Y1 * Y1);\n const C = mod(_2n * mod(Z1 * Z1));\n const D = mod(a * A);\n const x1y1 = X1 + Y1;\n const E = mod(mod(x1y1 * x1y1) - A - B);\n const G = D + B;\n const F = G - C;\n const H = D - B;\n const X3 = mod(E * F);\n const Y3 = mod(G * H);\n const T3 = mod(E * H);\n const Z3 = mod(F * G);\n return new ExtendedPoint(X3, Y3, Z3, T3);\n }\n add(other) {\n assertExtPoint(other);\n const { x: X1, y: Y1, z: Z1, t: T1 } = this;\n const { x: X2, y: Y2, z: Z2, t: T2 } = other;\n const A = mod((Y1 - X1) * (Y2 + X2));\n const B = mod((Y1 + X1) * (Y2 - X2));\n const F = mod(B - A);\n if (F === _0n)\n return this.double();\n const C = mod(Z1 * _2n * T2);\n const D = mod(T1 * _2n * Z2);\n const E = D + C;\n const G = B + A;\n const H = D - C;\n const X3 = mod(E * F);\n const Y3 = mod(G * H);\n const T3 = mod(E * H);\n const Z3 = mod(F * G);\n return new ExtendedPoint(X3, Y3, Z3, T3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n precomputeWindow(W) {\n const windows = 1 + 256 / W;\n const points = [];\n let p = this;\n let base = p;\n for (let window = 0; window < windows; window++) {\n base = p;\n points.push(base);\n for (let i = 1; i < 2 ** (W - 1); i++) {\n base = base.add(p);\n points.push(base);\n }\n p = base.double();\n }\n return points;\n }\n wNAF(n, affinePoint) {\n if (!affinePoint && this.equals(ExtendedPoint.BASE))\n affinePoint = Point.BASE;\n const W = (affinePoint && affinePoint._WINDOW_SIZE) || 1;\n if (256 % W) {\n throw new Error('Point#wNAF: Invalid precomputation window, must be power of 2');\n }\n let precomputes = affinePoint && pointPrecomputes.get(affinePoint);\n if (!precomputes) {\n precomputes = this.precomputeWindow(W);\n if (affinePoint && W !== 1) {\n precomputes = ExtendedPoint.normalizeZ(precomputes);\n pointPrecomputes.set(affinePoint, precomputes);\n }\n }\n let p = ExtendedPoint.ZERO;\n let f = ExtendedPoint.BASE;\n const windows = 1 + 256 / W;\n const windowSize = 2 ** (W - 1);\n const mask = BigInt(2 ** W - 1);\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for (let window = 0; window < windows; window++) {\n const offset = window * windowSize;\n let wbits = Number(n & mask);\n n >>= shiftBy;\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n const offset1 = offset;\n const offset2 = offset + Math.abs(wbits) - 1;\n const cond1 = window % 2 !== 0;\n const cond2 = wbits < 0;\n if (wbits === 0) {\n f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n }\n else {\n p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n }\n }\n return ExtendedPoint.normalizeZ([p, f])[0];\n }\n multiply(scalar, affinePoint) {\n return this.wNAF(normalizeScalar(scalar, CURVE.l), affinePoint);\n }\n multiplyUnsafe(scalar) {\n let n = normalizeScalar(scalar, CURVE.l, false);\n const G = ExtendedPoint.BASE;\n const P0 = ExtendedPoint.ZERO;\n if (n === _0n)\n return P0;\n if (this.equals(P0) || n === _1n)\n return this;\n if (this.equals(G))\n return this.wNAF(n);\n let p = P0;\n let d = this;\n while (n > _0n) {\n if (n & _1n)\n p = p.add(d);\n d = d.double();\n n >>= _1n;\n }\n return p;\n }\n isSmallOrder() {\n return this.multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n }\n isTorsionFree() {\n let p = this.multiplyUnsafe(CURVE.l / _2n).double();\n if (CURVE.l % _2n)\n p = p.add(this);\n return p.equals(ExtendedPoint.ZERO);\n }\n toAffine(invZ) {\n const { x, y, z } = this;\n const is0 = this.equals(ExtendedPoint.ZERO);\n if (invZ == null)\n invZ = is0 ? _8n : invert(z);\n const ax = mod(x * invZ);\n const ay = mod(y * invZ);\n const zz = mod(z * invZ);\n if (is0)\n return Point.ZERO;\n if (zz !== _1n)\n throw new Error('invZ was invalid');\n return new Point(ax, ay);\n }\n fromRistrettoBytes() {\n legacyRist();\n }\n toRistrettoBytes() {\n legacyRist();\n }\n fromRistrettoHash() {\n legacyRist();\n }\n}\nExtendedPoint.BASE = new ExtendedPoint(CURVE.Gx, CURVE.Gy, _1n, mod(CURVE.Gx * CURVE.Gy));\nExtendedPoint.ZERO = new ExtendedPoint(_0n, _1n, _1n, _0n);\nfunction constTimeNegate(condition, item) {\n const neg = item.negate();\n return condition ? neg : item;\n}\nfunction assertExtPoint(other) {\n if (!(other instanceof ExtendedPoint))\n throw new TypeError('ExtendedPoint expected');\n}\nfunction assertRstPoint(other) {\n if (!(other instanceof RistrettoPoint))\n throw new TypeError('RistrettoPoint expected');\n}\nfunction legacyRist() {\n throw new Error('Legacy method: switch to RistrettoPoint');\n}\nclass RistrettoPoint {\n constructor(ep) {\n this.ep = ep;\n }\n static calcElligatorRistrettoMap(r0) {\n const { d } = CURVE;\n const r = mod(SQRT_M1 * r0 * r0);\n const Ns = mod((r + _1n) * ONE_MINUS_D_SQ);\n let c = BigInt(-1);\n const D = mod((c - d * r) * mod(r + d));\n let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);\n let s_ = mod(s * r0);\n if (!edIsNegative(s_))\n s_ = mod(-s_);\n if (!Ns_D_is_sq)\n s = s_;\n if (!Ns_D_is_sq)\n c = r;\n const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D);\n const s2 = s * s;\n const W0 = mod((s + s) * D);\n const W1 = mod(Nt * SQRT_AD_MINUS_ONE);\n const W2 = mod(_1n - s2);\n const W3 = mod(_1n + s2);\n return new ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n }\n static hashToCurve(hex) {\n hex = ensureBytes(hex, 64);\n const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n const R1 = this.calcElligatorRistrettoMap(r1);\n const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n const R2 = this.calcElligatorRistrettoMap(r2);\n return new RistrettoPoint(R1.add(R2));\n }\n static fromHex(hex) {\n hex = ensureBytes(hex, 32);\n const { a, d } = CURVE;\n const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n const s = bytes255ToNumberLE(hex);\n if (!equalBytes(numberTo32BytesLE(s), hex) || edIsNegative(s))\n throw new Error(emsg);\n const s2 = mod(s * s);\n const u1 = mod(_1n + a * s2);\n const u2 = mod(_1n - a * s2);\n const u1_2 = mod(u1 * u1);\n const u2_2 = mod(u2 * u2);\n const v = mod(a * d * u1_2 - u2_2);\n const { isValid, value: I } = invertSqrt(mod(v * u2_2));\n const Dx = mod(I * u2);\n const Dy = mod(I * Dx * v);\n let x = mod((s + s) * Dx);\n if (edIsNegative(x))\n x = mod(-x);\n const y = mod(u1 * Dy);\n const t = mod(x * y);\n if (!isValid || edIsNegative(t) || y === _0n)\n throw new Error(emsg);\n return new RistrettoPoint(new ExtendedPoint(x, y, _1n, t));\n }\n toRawBytes() {\n let { x, y, z, t } = this.ep;\n const u1 = mod(mod(z + y) * mod(z - y));\n const u2 = mod(x * y);\n const u2sq = mod(u2 * u2);\n const { value: invsqrt } = invertSqrt(mod(u1 * u2sq));\n const D1 = mod(invsqrt * u1);\n const D2 = mod(invsqrt * u2);\n const zInv = mod(D1 * D2 * t);\n let D;\n if (edIsNegative(t * zInv)) {\n let _x = mod(y * SQRT_M1);\n let _y = mod(x * SQRT_M1);\n x = _x;\n y = _y;\n D = mod(D1 * INVSQRT_A_MINUS_D);\n }\n else {\n D = D2;\n }\n if (edIsNegative(x * zInv))\n y = mod(-y);\n let s = mod((z - y) * D);\n if (edIsNegative(s))\n s = mod(-s);\n return numberTo32BytesLE(s);\n }\n toHex() {\n return bytesToHex(this.toRawBytes());\n }\n toString() {\n return this.toHex();\n }\n equals(other) {\n assertRstPoint(other);\n const a = this.ep;\n const b = other.ep;\n const one = mod(a.x * b.y) === mod(a.y * b.x);\n const two = mod(a.y * b.y) === mod(a.x * b.x);\n return one || two;\n }\n add(other) {\n assertRstPoint(other);\n return new RistrettoPoint(this.ep.add(other.ep));\n }\n subtract(other) {\n assertRstPoint(other);\n return new RistrettoPoint(this.ep.subtract(other.ep));\n }\n multiply(scalar) {\n return new RistrettoPoint(this.ep.multiply(scalar));\n }\n multiplyUnsafe(scalar) {\n return new RistrettoPoint(this.ep.multiplyUnsafe(scalar));\n }\n}\nRistrettoPoint.BASE = new RistrettoPoint(ExtendedPoint.BASE);\nRistrettoPoint.ZERO = new RistrettoPoint(ExtendedPoint.ZERO);\nconst pointPrecomputes = new WeakMap();\nclass Point {\n constructor(x, y) {\n this.x = x;\n this.y = y;\n }\n _setWindowSize(windowSize) {\n this._WINDOW_SIZE = windowSize;\n pointPrecomputes.delete(this);\n }\n static fromHex(hex, strict = true) {\n const { d, P } = CURVE;\n hex = ensureBytes(hex, 32);\n const normed = hex.slice();\n normed[31] = hex[31] & ~0x80;\n const y = bytesToNumberLE(normed);\n if (strict && y >= P)\n throw new Error('Expected 0 < hex < P');\n if (!strict && y >= POW_2_256)\n throw new Error('Expected 0 < hex < 2**256');\n const y2 = mod(y * y);\n const u = mod(y2 - _1n);\n const v = mod(d * y2 + _1n);\n let { isValid, value: x } = uvRatio(u, v);\n if (!isValid)\n throw new Error('Point.fromHex: invalid y coordinate');\n const isXOdd = (x & _1n) === _1n;\n const isLastByteOdd = (hex[31] & 0x80) !== 0;\n if (isLastByteOdd !== isXOdd) {\n x = mod(-x);\n }\n return new Point(x, y);\n }\n static async fromPrivateKey(privateKey) {\n return (await getExtendedPublicKey(privateKey)).point;\n }\n toRawBytes() {\n const bytes = numberTo32BytesLE(this.y);\n bytes[31] |= this.x & _1n ? 0x80 : 0;\n return bytes;\n }\n toHex() {\n return bytesToHex(this.toRawBytes());\n }\n toX25519() {\n const { y } = this;\n const u = mod((_1n + y) * invert(_1n - y));\n return numberTo32BytesLE(u);\n }\n isTorsionFree() {\n return ExtendedPoint.fromAffine(this).isTorsionFree();\n }\n equals(other) {\n return this.x === other.x && this.y === other.y;\n }\n negate() {\n return new Point(mod(-this.x), this.y);\n }\n add(other) {\n return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(other)).toAffine();\n }\n subtract(other) {\n return this.add(other.negate());\n }\n multiply(scalar) {\n return ExtendedPoint.fromAffine(this).multiply(scalar, this).toAffine();\n }\n}\nPoint.BASE = new Point(CURVE.Gx, CURVE.Gy);\nPoint.ZERO = new Point(_0n, _1n);\nclass Signature {\n constructor(r, s) {\n this.r = r;\n this.s = s;\n this.assertValidity();\n }\n static fromHex(hex) {\n const bytes = ensureBytes(hex, 64);\n const r = Point.fromHex(bytes.slice(0, 32), false);\n const s = bytesToNumberLE(bytes.slice(32, 64));\n return new Signature(r, s);\n }\n assertValidity() {\n const { r, s } = this;\n if (!(r instanceof Point))\n throw new Error('Expected Point instance');\n normalizeScalar(s, CURVE.l, false);\n return this;\n }\n toRawBytes() {\n const u8 = new Uint8Array(64);\n u8.set(this.r.toRawBytes());\n u8.set(numberTo32BytesLE(this.s), 32);\n return u8;\n }\n toHex() {\n return bytesToHex(this.toRawBytes());\n }\n}\n\nfunction concatBytes(...arrays) {\n if (!arrays.every((a) => a instanceof Uint8Array))\n throw new Error('Expected Uint8Array list');\n if (arrays.length === 1)\n return arrays[0];\n const length = arrays.reduce((a, arr) => a + arr.length, 0);\n const result = new Uint8Array(length);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const arr = arrays[i];\n result.set(arr, pad);\n pad += arr.length;\n }\n return result;\n}\nconst hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));\nfunction bytesToHex(uint8a) {\n if (!(uint8a instanceof Uint8Array))\n throw new Error('Uint8Array expected');\n let hex = '';\n for (let i = 0; i < uint8a.length; i++) {\n hex += hexes[uint8a[i]];\n }\n return hex;\n}\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string') {\n throw new TypeError('hexToBytes: expected string, got ' + typeof hex);\n }\n if (hex.length % 2)\n throw new Error('hexToBytes: received invalid unpadded hex');\n const array = new Uint8Array(hex.length / 2);\n for (let i = 0; i < array.length; i++) {\n const j = i * 2;\n const hexByte = hex.slice(j, j + 2);\n const byte = Number.parseInt(hexByte, 16);\n if (Number.isNaN(byte) || byte < 0)\n throw new Error('Invalid byte sequence');\n array[i] = byte;\n }\n return array;\n}\nfunction numberTo32BytesBE(num) {\n const length = 32;\n const hex = num.toString(16).padStart(length * 2, '0');\n return hexToBytes(hex);\n}\nfunction numberTo32BytesLE(num) {\n return numberTo32BytesBE(num).reverse();\n}\nfunction edIsNegative(num) {\n return (mod(num) & _1n) === _1n;\n}\nfunction bytesToNumberLE(uint8a) {\n if (!(uint8a instanceof Uint8Array))\n throw new Error('Expected Uint8Array');\n return BigInt('0x' + bytesToHex(Uint8Array.from(uint8a).reverse()));\n}\nconst MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\nfunction bytes255ToNumberLE(bytes) {\n return mod(bytesToNumberLE(bytes) & MAX_255B);\n}\nfunction mod(a, b = CURVE.P) {\n const res = a % b;\n return res >= _0n ? res : b + res;\n}\nfunction invert(number, modulo = CURVE.P) {\n if (number === _0n || modulo <= _0n) {\n throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);\n }\n let a = mod(number, modulo);\n let b = modulo;\n let x = _0n, y = _1n, u = _1n, v = _0n;\n while (a !== _0n) {\n const q = b / a;\n const r = b % a;\n const m = x - u * q;\n const n = y - v * q;\n b = a, a = r, x = u, y = v, u = m, v = n;\n }\n const gcd = b;\n if (gcd !== _1n)\n throw new Error('invert: does not exist');\n return mod(x, modulo);\n}\nfunction invertBatch(nums, p = CURVE.P) {\n const tmp = new Array(nums.length);\n const lastMultiplied = nums.reduce((acc, num, i) => {\n if (num === _0n)\n return acc;\n tmp[i] = acc;\n return mod(acc * num, p);\n }, _1n);\n const inverted = invert(lastMultiplied, p);\n nums.reduceRight((acc, num, i) => {\n if (num === _0n)\n return acc;\n tmp[i] = mod(acc * tmp[i], p);\n return mod(acc * num, p);\n }, inverted);\n return tmp;\n}\nfunction pow2(x, power) {\n const { P } = CURVE;\n let res = x;\n while (power-- > _0n) {\n res *= res;\n res %= P;\n }\n return res;\n}\nfunction pow_2_252_3(x) {\n const { P } = CURVE;\n const _5n = BigInt(5);\n const _10n = BigInt(10);\n const _20n = BigInt(20);\n const _40n = BigInt(40);\n const _80n = BigInt(80);\n const x2 = (x * x) % P;\n const b2 = (x2 * x) % P;\n const b4 = (pow2(b2, _2n) * b2) % P;\n const b5 = (pow2(b4, _1n) * x) % P;\n const b10 = (pow2(b5, _5n) * b5) % P;\n const b20 = (pow2(b10, _10n) * b10) % P;\n const b40 = (pow2(b20, _20n) * b20) % P;\n const b80 = (pow2(b40, _40n) * b40) % P;\n const b160 = (pow2(b80, _80n) * b80) % P;\n const b240 = (pow2(b160, _80n) * b80) % P;\n const b250 = (pow2(b240, _10n) * b10) % P;\n const pow_p_5_8 = (pow2(b250, _2n) * x) % P;\n return { pow_p_5_8, b2 };\n}\nfunction uvRatio(u, v) {\n const v3 = mod(v * v * v);\n const v7 = mod(v3 * v3 * v);\n const pow = pow_2_252_3(u * v7).pow_p_5_8;\n let x = mod(u * v3 * pow);\n const vx2 = mod(v * x * x);\n const root1 = x;\n const root2 = mod(x * SQRT_M1);\n const useRoot1 = vx2 === u;\n const useRoot2 = vx2 === mod(-u);\n const noRoot = vx2 === mod(-u * SQRT_M1);\n if (useRoot1)\n x = root1;\n if (useRoot2 || noRoot)\n x = root2;\n if (edIsNegative(x))\n x = mod(-x);\n return { isValid: useRoot1 || useRoot2, value: x };\n}\nfunction invertSqrt(number) {\n return uvRatio(_1n, number);\n}\nfunction modlLE(hash) {\n return mod(bytesToNumberLE(hash), CURVE.l);\n}\nfunction equalBytes(b1, b2) {\n if (b1.length !== b2.length) {\n return false;\n }\n for (let i = 0; i < b1.length; i++) {\n if (b1[i] !== b2[i]) {\n return false;\n }\n }\n return true;\n}\nfunction ensureBytes(hex, expectedLength) {\n const bytes = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex);\n if (typeof expectedLength === 'number' && bytes.length !== expectedLength)\n throw new Error(`Expected ${expectedLength} bytes`);\n return bytes;\n}\nfunction normalizeScalar(num, max, strict = true) {\n if (!max)\n throw new TypeError('Specify max value');\n if (typeof num === 'number' && Number.isSafeInteger(num))\n num = BigInt(num);\n if (typeof num === 'bigint' && num < max) {\n if (strict) {\n if (_0n < num)\n return num;\n }\n else {\n if (_0n <= num)\n return num;\n }\n }\n throw new TypeError('Expected valid scalar: 0 < scalar < max');\n}\nfunction adjustBytes25519(bytes) {\n bytes[0] &= 248;\n bytes[31] &= 127;\n bytes[31] |= 64;\n return bytes;\n}\nfunction decodeScalar25519(n) {\n return bytesToNumberLE(adjustBytes25519(ensureBytes(n, 32)));\n}\nfunction checkPrivateKey(key) {\n key =\n typeof key === 'bigint' || typeof key === 'number'\n ? numberTo32BytesBE(normalizeScalar(key, POW_2_256))\n : ensureBytes(key);\n if (key.length !== 32)\n throw new Error(`Expected 32 bytes`);\n return key;\n}\nfunction getKeyFromHash(hashed) {\n const head = adjustBytes25519(hashed.slice(0, 32));\n const prefix = hashed.slice(32, 64);\n const scalar = modlLE(head);\n const point = Point.BASE.multiply(scalar);\n const pointBytes = point.toRawBytes();\n return { head, prefix, scalar, point, pointBytes };\n}\nlet _sha512Sync;\nfunction sha512s(...m) {\n if (typeof _sha512Sync !== 'function')\n throw new Error('utils.sha512Sync must be set to use sync methods');\n return _sha512Sync(...m);\n}\nasync function getExtendedPublicKey(key) {\n return getKeyFromHash(await utils.sha512(checkPrivateKey(key)));\n}\nfunction getExtendedPublicKeySync(key) {\n return getKeyFromHash(sha512s(checkPrivateKey(key)));\n}\nasync function getPublicKey(privateKey) {\n return (await getExtendedPublicKey(privateKey)).pointBytes;\n}\nfunction getPublicKeySync(privateKey) {\n return getExtendedPublicKeySync(privateKey).pointBytes;\n}\nasync function sign(message, privateKey) {\n message = ensureBytes(message);\n const { prefix, scalar, pointBytes } = await getExtendedPublicKey(privateKey);\n const r = modlLE(await utils.sha512(prefix, message));\n const R = Point.BASE.multiply(r);\n const k = modlLE(await utils.sha512(R.toRawBytes(), pointBytes, message));\n const s = mod(r + k * scalar, CURVE.l);\n return new Signature(R, s).toRawBytes();\n}\nfunction signSync(message, privateKey) {\n message = ensureBytes(message);\n const { prefix, scalar, pointBytes } = getExtendedPublicKeySync(privateKey);\n const r = modlLE(sha512s(prefix, message));\n const R = Point.BASE.multiply(r);\n const k = modlLE(sha512s(R.toRawBytes(), pointBytes, message));\n const s = mod(r + k * scalar, CURVE.l);\n return new Signature(R, s).toRawBytes();\n}\nfunction prepareVerification(sig, message, publicKey) {\n message = ensureBytes(message);\n if (!(publicKey instanceof Point))\n publicKey = Point.fromHex(publicKey, false);\n const { r, s } = sig instanceof Signature ? sig.assertValidity() : Signature.fromHex(sig);\n const SB = ExtendedPoint.BASE.multiplyUnsafe(s);\n return { r, s, SB, pub: publicKey, msg: message };\n}\nfunction finishVerification(publicKey, r, SB, hashed) {\n const k = modlLE(hashed);\n const kA = ExtendedPoint.fromAffine(publicKey).multiplyUnsafe(k);\n const RkA = ExtendedPoint.fromAffine(r).add(kA);\n return RkA.subtract(SB).multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n}\nasync function verify(sig, message, publicKey) {\n const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n const hashed = await utils.sha512(r.toRawBytes(), pub.toRawBytes(), msg);\n return finishVerification(pub, r, SB, hashed);\n}\nfunction verifySync(sig, message, publicKey) {\n const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n const hashed = sha512s(r.toRawBytes(), pub.toRawBytes(), msg);\n return finishVerification(pub, r, SB, hashed);\n}\nconst sync = {\n getExtendedPublicKey: getExtendedPublicKeySync,\n getPublicKey: getPublicKeySync,\n sign: signSync,\n verify: verifySync,\n};\nasync function getSharedSecret(privateKey, publicKey) {\n const { head } = await getExtendedPublicKey(privateKey);\n const u = Point.fromHex(publicKey).toX25519();\n return curve25519.scalarMult(head, u);\n}\nPoint.BASE._setWindowSize(8);\nfunction cswap(swap, x_2, x_3) {\n const dummy = mod(swap * (x_2 - x_3));\n x_2 = mod(x_2 - dummy);\n x_3 = mod(x_3 + dummy);\n return [x_2, x_3];\n}\nfunction montgomeryLadder(pointU, scalar) {\n const { P } = CURVE;\n const u = normalizeScalar(pointU, P);\n const k = normalizeScalar(scalar, P);\n const a24 = BigInt(121665);\n const x_1 = u;\n let x_2 = _1n;\n let z_2 = _0n;\n let x_3 = u;\n let z_3 = _1n;\n let swap = _0n;\n let sw;\n for (let t = BigInt(255 - 1); t >= _0n; t--) {\n const k_t = (k >> t) & _1n;\n swap ^= k_t;\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n swap = k_t;\n const A = x_2 + z_2;\n const AA = mod(A * A);\n const B = x_2 - z_2;\n const BB = mod(B * B);\n const E = AA - BB;\n const C = x_3 + z_3;\n const D = x_3 - z_3;\n const DA = mod(D * A);\n const CB = mod(C * B);\n const dacb = DA + CB;\n const da_cb = DA - CB;\n x_3 = mod(dacb * dacb);\n z_3 = mod(x_1 * mod(da_cb * da_cb));\n x_2 = mod(AA * BB);\n z_2 = mod(E * (AA + mod(a24 * E)));\n }\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n const { pow_p_5_8, b2 } = pow_2_252_3(z_2);\n const xp2 = mod(pow2(pow_p_5_8, BigInt(3)) * b2);\n return mod(x_2 * xp2);\n}\nfunction encodeUCoordinate(u) {\n return numberTo32BytesLE(mod(u, CURVE.P));\n}\nfunction decodeUCoordinate(uEnc) {\n const u = ensureBytes(uEnc, 32);\n u[31] &= 127;\n return bytesToNumberLE(u);\n}\nconst curve25519 = {\n BASE_POINT_U: '0900000000000000000000000000000000000000000000000000000000000000',\n scalarMult(privateKey, publicKey) {\n const u = decodeUCoordinate(publicKey);\n const p = decodeScalar25519(privateKey);\n const pu = montgomeryLadder(u, p);\n if (pu === _0n)\n throw new Error('Invalid private or public key received');\n return encodeUCoordinate(pu);\n },\n scalarMultBase(privateKey) {\n return curve25519.scalarMult(privateKey, curve25519.BASE_POINT_U);\n },\n};\nconst crypto = {\n node: /*#__PURE__*/ (crypto__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (crypto__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(crypto__WEBPACK_IMPORTED_MODULE_0__, 2))),\n web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,\n};\nconst utils = {\n bytesToHex,\n hexToBytes,\n concatBytes,\n getExtendedPublicKey,\n mod,\n invert,\n TORSION_SUBGROUP: [\n '0100000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n '0000000000000000000000000000000000000000000000000000000000000080',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n '0000000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n ],\n hashToPrivateScalar: (hash) => {\n hash = ensureBytes(hash);\n if (hash.length < 40 || hash.length > 1024)\n throw new Error('Expected 40-1024 bytes of private key as per FIPS 186');\n return mod(bytesToNumberLE(hash), CURVE.l - _1n) + _1n;\n },\n randomBytes: (bytesLength = 32) => {\n if (crypto.web) {\n return crypto.web.getRandomValues(new Uint8Array(bytesLength));\n }\n else if (crypto.node) {\n const { randomBytes } = crypto.node;\n return new Uint8Array(randomBytes(bytesLength).buffer);\n }\n else {\n throw new Error(\"The environment doesn't have randomBytes function\");\n }\n },\n randomPrivateKey: () => {\n return utils.randomBytes(32);\n },\n sha512: async (...messages) => {\n const message = concatBytes(...messages);\n if (crypto.web) {\n const buffer = await crypto.web.subtle.digest('SHA-512', message.buffer);\n return new Uint8Array(buffer);\n }\n else if (crypto.node) {\n return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest());\n }\n else {\n throw new Error(\"The environment doesn't have sha512 function\");\n }\n },\n precompute(windowSize = 8, point = Point.BASE) {\n const cached = point.equals(Point.BASE) ? point : new Point(point.x, point.y);\n cached._setWindowSize(windowSize);\n cached.multiply(_2n);\n return cached;\n },\n sha512Sync: undefined,\n};\nObject.defineProperties(utils, {\n sha512Sync: {\n configurable: false,\n get() {\n return _sha512Sync;\n },\n set(val) {\n if (!_sha512Sync)\n _sha512Sync = val;\n },\n },\n});\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/ed25519/lib/esm/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encodeToCurve: () => (/* binding */ encodeToCurve),\n/* harmony export */ hashToCurve: () => (/* binding */ hashToCurve),\n/* harmony export */ schnorr: () => (/* binding */ schnorr),\n/* harmony export */ secp256k1: () => (/* binding */ secp256k1)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _noble_hashes_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @noble/hashes/utils */ \"./node_modules/@noble/hashes/esm/utils.js\");\n/* harmony import */ var _abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstract/modular.js */ \"./node_modules/@noble/curves/esm/abstract/modular.js\");\n/* harmony import */ var _abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./abstract/weierstrass.js */ \"./node_modules/@noble/curves/esm/abstract/weierstrass.js\");\n/* harmony import */ var _abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./abstract/utils.js */ \"./node_modules/@noble/curves/esm/abstract/utils.js\");\n/* harmony import */ var _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./abstract/hash-to-curve.js */ \"./node_modules/@noble/curves/esm/abstract/hash-to-curve.js\");\n/* harmony import */ var _shortw_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_shortw_utils.js */ \"./node_modules/@noble/curves/esm/_shortw_utils.js\");\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n\n\n\n\n\n\nconst secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f');\nconst secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst divNearest = (a, b) => (a + b / _2n) / b;\n/**\n * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit.\n * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00]\n */\nfunction sqrtMod(y) {\n const P = secp256k1P;\n // prettier-ignore\n const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);\n // prettier-ignore\n const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);\n const b2 = (y * y * y) % P; // x^3, 11\n const b3 = (b2 * b2 * y) % P; // x^7\n const b6 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b3, _3n, P) * b3) % P;\n const b9 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b6, _3n, P) * b3) % P;\n const b11 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b9, _2n, P) * b2) % P;\n const b22 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b11, _11n, P) * b11) % P;\n const b44 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b22, _22n, P) * b22) % P;\n const b88 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b44, _44n, P) * b44) % P;\n const b176 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b88, _88n, P) * b88) % P;\n const b220 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b176, _44n, P) * b44) % P;\n const b223 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b220, _3n, P) * b3) % P;\n const t1 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(b223, _23n, P) * b22) % P;\n const t2 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(t1, _6n, P) * b2) % P;\n const root = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.pow2)(t2, _2n, P);\n if (!Fp.eql(Fp.sqr(root), y))\n throw new Error('Cannot find square root');\n return root;\n}\nconst Fp = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod });\nconst secp256k1 = (0,_shortw_utils_js__WEBPACK_IMPORTED_MODULE_1__.createCurve)({\n a: BigInt(0), // equation params: a, b\n b: BigInt(7), // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975\n Fp, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n\n n: secp256k1N, // Curve order, total count of valid points in the field\n // Base point (x, y) aka generator point\n Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),\n Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),\n h: BigInt(1), // Cofactor\n lowS: true, // Allow only low-S signatures by default in sign() and verify()\n /**\n * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.\n * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.\n * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.\n * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066\n */\n endo: {\n beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),\n splitScalar: (k) => {\n const n = secp256k1N;\n const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');\n const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');\n const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');\n const b2 = a1;\n const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16)\n const c1 = divNearest(b2 * k, n);\n const c2 = divNearest(-b1 * k, n);\n let k1 = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.mod)(k - c1 * a1 - c2 * a2, n);\n let k2 = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.mod)(-c1 * b1 - c2 * b2, n);\n const k1neg = k1 > POW_2_128;\n const k2neg = k2 > POW_2_128;\n if (k1neg)\n k1 = n - k1;\n if (k2neg)\n k2 = n - k2;\n if (k1 > POW_2_128 || k2 > POW_2_128) {\n throw new Error('splitScalar: Endomorphism failed, k=' + k);\n }\n return { k1neg, k1, k2neg, k2 };\n },\n },\n}, _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256);\n// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.\n// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\nconst _0n = BigInt(0);\nconst fe = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1P;\nconst ge = (x) => typeof x === 'bigint' && _0n < x && x < secp256k1N;\n/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */\nconst TAGGED_HASH_PREFIXES = {};\nfunction taggedHash(tag, ...messages) {\n let tagP = TAGGED_HASH_PREFIXES[tag];\n if (tagP === undefined) {\n const tagH = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0)));\n tagP = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.concatBytes)(tagH, tagH);\n TAGGED_HASH_PREFIXES[tag] = tagP;\n }\n return (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256)((0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.concatBytes)(tagP, ...messages));\n}\n// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03\nconst pointToBytes = (point) => point.toRawBytes(true).slice(1);\nconst numTo32b = (n) => (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.numberToBytesBE)(n, 32);\nconst modP = (x) => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.mod)(x, secp256k1P);\nconst modN = (x) => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.mod)(x, secp256k1N);\nconst Point = secp256k1.ProjectivePoint;\nconst GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b);\n// Calculate point, scalar and bytes\nfunction schnorrGetExtPubKey(priv) {\n let d_ = secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey\n let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside\n const scalar = p.hasEvenY() ? d_ : modN(-d_);\n return { scalar: scalar, bytes: pointToBytes(p) };\n}\n/**\n * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point.\n * @returns valid point checked for being on-curve\n */\nfunction lift_x(x) {\n if (!fe(x))\n throw new Error('bad x: need 0 < x < p'); // Fail if x ≥ p.\n const xx = modP(x * x);\n const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.\n let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p.\n if (y % _2n !== _0n)\n y = modP(-y); // Return the unique point P such that x(P) = x and\n const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.\n p.assertValidity();\n return p;\n}\n/**\n * Create tagged hash, convert it to bigint, reduce modulo-n.\n */\nfunction challenge(...args) {\n return modN((0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(taggedHash('BIP0340/challenge', ...args)));\n}\n/**\n * Schnorr public key is just `x` coordinate of Point as per BIP340.\n */\nfunction schnorrGetPublicKey(privateKey) {\n return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G)\n}\n/**\n * Creates Schnorr signature as per BIP340. Verifies itself before returning anything.\n * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.\n */\nfunction schnorrSign(message, privateKey, auxRand = (0,_noble_hashes_utils__WEBPACK_IMPORTED_MODULE_4__.randomBytes)(32)) {\n const m = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.ensureBytes)('message', message);\n const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder\n const a = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.ensureBytes)('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array\n const t = numTo32b(d ^ (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a)\n const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m)\n const k_ = modN((0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(rand)); // Let k' = int(rand) mod n\n if (k_ === _0n)\n throw new Error('sign failed: k is zero'); // Fail if k' = 0.\n const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G.\n const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n.\n const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n).\n sig.set(rx, 0);\n sig.set(numTo32b(modN(k + e * d)), 32);\n // If Verify(bytes(P), m, sig) (see below) returns failure, abort\n if (!schnorrVerify(sig, m, px))\n throw new Error('sign: Invalid signature produced');\n return sig;\n}\n/**\n * Verifies Schnorr signature.\n * Will swallow errors & return false except for initial type validation of arguments.\n */\nfunction schnorrVerify(signature, message, publicKey) {\n const sig = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.ensureBytes)('signature', signature, 64);\n const m = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.ensureBytes)('message', message);\n const pub = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.ensureBytes)('publicKey', publicKey, 32);\n try {\n const P = lift_x((0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(pub)); // P = lift_x(int(pk)); fail if that fails\n const r = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p.\n if (!fe(r))\n return false;\n const s = (0,_abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE)(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n.\n if (!ge(s))\n return false;\n const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n\n const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P\n if (!R || !R.hasEvenY() || R.toAffine().x !== r)\n return false; // -eP == (n-e)P\n return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r.\n }\n catch (error) {\n return false;\n }\n}\nconst schnorr = /* @__PURE__ */ (() => ({\n getPublicKey: schnorrGetPublicKey,\n sign: schnorrSign,\n verify: schnorrVerify,\n utils: {\n randomPrivateKey: secp256k1.utils.randomPrivateKey,\n lift_x,\n pointToBytes,\n numberToBytesBE: _abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.numberToBytesBE,\n bytesToNumberBE: _abstract_utils_js__WEBPACK_IMPORTED_MODULE_3__.bytesToNumberBE,\n taggedHash,\n mod: _abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.mod,\n },\n}))();\nconst isoMap = /* @__PURE__ */ (() => (0,_abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_5__.isogenyMap)(Fp, [\n // xNum\n [\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7',\n '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581',\n '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262',\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c',\n ],\n // xDen\n [\n '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b',\n '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n // yNum\n [\n '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c',\n '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3',\n '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931',\n '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84',\n ],\n // yDen\n [\n '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b',\n '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573',\n '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n].map((i) => i.map((j) => BigInt(j)))))();\nconst mapSWU = /* @__PURE__ */ (() => (0,_abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_6__.mapToCurveSimpleSWU)(Fp, {\n A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'),\n B: BigInt('1771'),\n Z: Fp.create(BigInt('-11')),\n}))();\nconst htf = /* @__PURE__ */ (() => (0,_abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_5__.createHasher)(secp256k1.ProjectivePoint, (scalars) => {\n const { x, y } = mapSWU(Fp.create(scalars[0]));\n return isoMap(x, y);\n}, {\n DST: 'secp256k1_XMD:SHA-256_SSWU_RO_',\n encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_',\n p: Fp.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256,\n}))();\nconst hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)();\nconst encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)();\n//# sourceMappingURL=secp256k1.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/curves/esm/secp256k1.js?"); /***/ }), @@ -4601,6 +4663,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@noble/hashes/esm/pbkdf2.js": +/*!**************************************************!*\ + !*** ./node_modules/@noble/hashes/esm/pbkdf2.js ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pbkdf2: () => (/* binding */ pbkdf2),\n/* harmony export */ pbkdf2Async: () => (/* binding */ pbkdf2Async)\n/* harmony export */ });\n/* harmony import */ var _assert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_assert.js */ \"./node_modules/@noble/hashes/esm/_assert.js\");\n/* harmony import */ var _hmac_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hmac.js */ \"./node_modules/@noble/hashes/esm/hmac.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@noble/hashes/esm/utils.js\");\n\n\n\n// Common prologue and epilogue for sync/async functions\nfunction pbkdf2Init(hash, _password, _salt, _opts) {\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.hash)(hash);\n const opts = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.checkOpts)({ dkLen: 32, asyncTick: 10 }, _opts);\n const { c, dkLen, asyncTick } = opts;\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(c);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(dkLen);\n (0,_assert_js__WEBPACK_IMPORTED_MODULE_0__.number)(asyncTick);\n if (c < 1)\n throw new Error('PBKDF2: iterations (c) should be >= 1');\n const password = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.toBytes)(_password);\n const salt = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.toBytes)(_salt);\n // DK = PBKDF2(PRF, Password, Salt, c, dkLen);\n const DK = new Uint8Array(dkLen);\n // U1 = PRF(Password, Salt + INT_32_BE(i))\n const PRF = _hmac_js__WEBPACK_IMPORTED_MODULE_2__.hmac.create(hash, password);\n const PRFSalt = PRF._cloneInto().update(salt);\n return { c, dkLen, asyncTick, DK, PRF, PRFSalt };\n}\nfunction pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {\n PRF.destroy();\n PRFSalt.destroy();\n if (prfW)\n prfW.destroy();\n u.fill(0);\n return DK;\n}\n/**\n * PBKDF2-HMAC: RFC 2898 key derivation function\n * @param hash - hash function that would be used e.g. sha256\n * @param password - password from which a derived key is generated\n * @param salt - cryptographic salt\n * @param opts - {c, dkLen} where c is work factor and dkLen is output message size\n */\nfunction pbkdf2(hash, password, salt, opts) {\n const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);\n let prfW; // Working copy\n const arr = new Uint8Array(4);\n const view = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.createView)(arr);\n const u = new Uint8Array(PRF.outputLen);\n // DK = T1 + T2 + ⋯ + Tdklen/hlen\n for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {\n // Ti = F(Password, Salt, c, i)\n const Ti = DK.subarray(pos, pos + PRF.outputLen);\n view.setInt32(0, ti, false);\n // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc\n // U1 = PRF(Password, Salt + INT_32_BE(i))\n (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);\n Ti.set(u.subarray(0, Ti.length));\n for (let ui = 1; ui < c; ui++) {\n // Uc = PRF(Password, Uc−1)\n PRF._cloneInto(prfW).update(u).digestInto(u);\n for (let i = 0; i < Ti.length; i++)\n Ti[i] ^= u[i];\n }\n }\n return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);\n}\nasync function pbkdf2Async(hash, password, salt, opts) {\n const { c, dkLen, asyncTick, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);\n let prfW; // Working copy\n const arr = new Uint8Array(4);\n const view = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.createView)(arr);\n const u = new Uint8Array(PRF.outputLen);\n // DK = T1 + T2 + ⋯ + Tdklen/hlen\n for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {\n // Ti = F(Password, Salt, c, i)\n const Ti = DK.subarray(pos, pos + PRF.outputLen);\n view.setInt32(0, ti, false);\n // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc\n // U1 = PRF(Password, Salt + INT_32_BE(i))\n (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);\n Ti.set(u.subarray(0, Ti.length));\n await (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.asyncLoop)(c - 1, asyncTick, () => {\n // Uc = PRF(Password, Uc−1)\n PRF._cloneInto(prfW).update(u).digestInto(u);\n for (let i = 0; i < Ti.length; i++)\n Ti[i] ^= u[i];\n });\n }\n return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);\n}\n//# sourceMappingURL=pbkdf2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@noble/hashes/esm/pbkdf2.js?"); + +/***/ }), + /***/ "./node_modules/@noble/hashes/esm/sha256.js": /*!**************************************************!*\ !*** ./node_modules/@noble/hashes/esm/sha256.js ***! @@ -4652,205 +4725,1063 @@ eval("var crypto__WEBPACK_IMPORTED_MODULE_0___namespace_cache;\n__webpack_requir /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* binding */ DecodedMessage),\n/* harmony export */ Decoder: () => (/* binding */ Decoder),\n/* harmony export */ Encoder: () => (/* binding */ Encoder),\n/* harmony export */ Version: () => (/* binding */ Version),\n/* harmony export */ createDecoder: () => (/* binding */ createDecoder),\n/* harmony export */ createEncoder: () => (/* binding */ createEncoder),\n/* harmony export */ proto: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:message:version-0\");\nconst OneMillion = BigInt(1000000);\nconst Version = 0;\n\nclass DecodedMessage {\n constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n }\n get ephemeral() {\n return Boolean(this.proto.ephemeral);\n }\n get payload() {\n return this.proto.payload;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n get _rawTimestamp() {\n return this.proto.timestamp;\n }\n get timestamp() {\n // In the case we receive a value that is bigger than JS's max number,\n // we catch the error and return undefined.\n try {\n if (this.proto.timestamp) {\n // nanoseconds 10^-9 to milliseconds 10^-3\n const timestamp = this.proto.timestamp / OneMillion;\n return new Date(Number(timestamp));\n }\n return;\n }\n catch (e) {\n return;\n }\n }\n get meta() {\n return this.proto.meta;\n }\n get version() {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n return this.proto.version ?? 0;\n }\n get rateLimitProof() {\n return this.proto.rateLimitProof;\n }\n}\nclass Encoder {\n constructor(contentTopic, ephemeral = false, metaSetter) {\n this.contentTopic = contentTopic;\n this.ephemeral = ephemeral;\n this.metaSetter = metaSetter;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n async toWire(message) {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.encode(await this.toProtoObj(message));\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n const protoMessage = {\n payload: message.payload,\n version: Version,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n meta: undefined,\n rateLimitProof: message.rateLimitProof,\n ephemeral: this.ephemeral,\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * Creates an encoder that encode messages without Waku level encryption or signature.\n *\n * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format to be sent over the Waku network. The resulting encoder can then be\n * pass to { @link @waku/interfaces.LightPush.push } or\n * { @link @waku/interfaces.Relay.send } to automatically encode outgoing\n * messages.\n */\nfunction createEncoder({ contentTopic, ephemeral, metaSetter, }) {\n return new Encoder(contentTopic, ephemeral, metaSetter);\n}\nclass Decoder {\n constructor(contentTopic) {\n this.contentTopic = contentTopic;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve({\n payload: protoMessage.payload,\n contentTopic: protoMessage.contentTopic,\n version: protoMessage.version ?? undefined,\n timestamp: protoMessage.timestamp ?? undefined,\n meta: protoMessage.meta ?? undefined,\n rateLimitProof: protoMessage.rateLimitProof ?? undefined,\n ephemeral: protoMessage.ephemeral ?? false,\n });\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n if (proto.version ?? 0 !== Version) {\n log(\"Failed to decode due to incorrect version, expected:\", Version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n return new DecodedMessage(pubSubTopic, proto);\n }\n}\n/**\n * Creates a decoder that decode messages without Waku level encryption.\n *\n * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format when received from the Waku network. The resulting decoder can then be\n * pass to { @link @waku/interfaces.Filter.subscribe } or\n * { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming\n * messages.\n *\n * @param contentTopic The resulting decoder will only decode messages with this content topic.\n */\nfunction createDecoder(contentTopic) {\n return new Decoder(contentTopic);\n}\n//# sourceMappingURL=version_0.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/message/version_0.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* binding */ DecodedMessage),\n/* harmony export */ Decoder: () => (/* binding */ Decoder),\n/* harmony export */ Encoder: () => (/* binding */ Encoder),\n/* harmony export */ Version: () => (/* binding */ Version),\n/* harmony export */ createDecoder: () => (/* binding */ createDecoder),\n/* harmony export */ createEncoder: () => (/* binding */ createEncoder),\n/* harmony export */ proto: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/index.js\");\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"message:version-0\");\nconst OneMillion = BigInt(1_000_000);\nconst Version = 0;\n\nclass DecodedMessage {\n pubsubTopic;\n proto;\n constructor(pubsubTopic, proto) {\n this.pubsubTopic = pubsubTopic;\n this.proto = proto;\n }\n get ephemeral() {\n return Boolean(this.proto.ephemeral);\n }\n get payload() {\n return this.proto.payload;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n get _rawTimestamp() {\n return this.proto.timestamp;\n }\n get timestamp() {\n // In the case we receive a value that is bigger than JS's max number,\n // we catch the error and return undefined.\n try {\n if (this.proto.timestamp) {\n // nanoseconds 10^-9 to milliseconds 10^-3\n const timestamp = this.proto.timestamp / OneMillion;\n return new Date(Number(timestamp));\n }\n return;\n }\n catch (e) {\n return;\n }\n }\n get meta() {\n return this.proto.meta;\n }\n get version() {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n return this.proto.version ?? 0;\n }\n get rateLimitProof() {\n return this.proto.rateLimitProof;\n }\n}\nclass Encoder {\n contentTopic;\n ephemeral;\n pubsubTopic;\n metaSetter;\n constructor(contentTopic, ephemeral = false, pubsubTopic, metaSetter) {\n this.contentTopic = contentTopic;\n this.ephemeral = ephemeral;\n this.pubsubTopic = pubsubTopic;\n this.metaSetter = metaSetter;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n async toWire(message) {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.encode(await this.toProtoObj(message));\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n const protoMessage = {\n payload: message.payload,\n version: Version,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n meta: undefined,\n rateLimitProof: message.rateLimitProof,\n ephemeral: this.ephemeral\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * Creates an encoder that encode messages without Waku level encryption or signature.\n *\n * An encoder is used to encode messages in the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format to be sent over the Waku network. The resulting encoder can then be\n * pass to { @link @waku/interfaces!ISender.send } to automatically encode outgoing\n * messages.\n */\nfunction createEncoder({ pubsubTopic, pubsubTopicShardInfo, contentTopic, ephemeral, metaSetter }) {\n return new Encoder(contentTopic, ephemeral, (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.determinePubsubTopic)(contentTopic, pubsubTopic ?? pubsubTopicShardInfo), metaSetter);\n}\nclass Decoder {\n pubsubTopic;\n contentTopic;\n constructor(pubsubTopic, contentTopic) {\n this.pubsubTopic = pubsubTopic;\n this.contentTopic = contentTopic;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(bytes);\n return Promise.resolve({\n payload: protoMessage.payload,\n contentTopic: protoMessage.contentTopic,\n version: protoMessage.version ?? undefined,\n timestamp: protoMessage.timestamp ?? undefined,\n meta: protoMessage.meta ?? undefined,\n rateLimitProof: protoMessage.rateLimitProof ?? undefined,\n ephemeral: protoMessage.ephemeral ?? false\n });\n }\n async fromProtoObj(pubsubTopic, proto) {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n if (proto.version ?? 0 !== Version) {\n log.error(\"Failed to decode due to incorrect version, expected:\", Version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n return new DecodedMessage(pubsubTopic, proto);\n }\n}\n/**\n * Creates a decoder that decode messages without Waku level encryption.\n *\n * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format when received from the Waku network. The resulting decoder can then be\n * pass to { @link @waku/interfaces!IReceiver.subscribe } to automatically decode incoming\n * messages.\n *\n * @param contentTopic The resulting decoder will only decode messages with this content topic.\n */\nfunction createDecoder(contentTopic, pubsubTopicShardInfo) {\n return new Decoder((0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.determinePubsubTopic)(contentTopic, pubsubTopicShardInfo), contentTopic);\n}\n//# sourceMappingURL=version_0.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/message/version_0.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/dist/dns.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/connection_manager.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/connection_manager.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EConnectionStateEvents: () => (/* binding */ EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n Tags[\"LOCAL\"] = \"local-peer-cache\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\nvar EConnectionStateEvents;\n(function (EConnectionStateEvents) {\n EConnectionStateEvents[\"CONNECTION_STATUS\"] = \"waku:connection\";\n})(EConnectionStateEvents || (EConnectionStateEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/connection_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/constants.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/constants.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* binding */ DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* binding */ DefaultPubsubTopic)\n/* harmony export */ });\n/**\n * DefaultPubsubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubsubTopic = \"/waku/2/default-waku/proto\";\n/**\n * The default cluster ID for The Waku Network\n */\nconst DEFAULT_CLUSTER_ID = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/dns_discovery.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/dns_discovery.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/dns_discovery.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/enr.js": +/*!***************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/enr.js ***! + \***************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/enr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/filter.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/filter.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/index.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/index.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DefaultPubsubTopic),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n/* harmony import */ var _dns_discovery_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./dns_discovery.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/dns_discovery.js\");\n/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./metadata.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/metadata.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/constants.js\");\n/* harmony import */ var _local_storage_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./local_storage.js */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/local_storage.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/keep_alive_manager.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/keep_alive_manager.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/keep_alive_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/libp2p.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/libp2p.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/libp2p.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/light_push.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/light_push.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/local_storage.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/local_storage.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=local_storage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/local_storage.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/message.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/message.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/metadata.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/metadata.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/misc.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/misc.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=misc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/misc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/peer_exchange.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/peer_exchange.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/protocols.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/protocols.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ProtocolError: () => (/* binding */ ProtocolError),\n/* harmony export */ Protocols: () => (/* binding */ Protocols)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar ProtocolError;\n(function (ProtocolError) {\n /** Could not determine the origin of the fault. Best to check connectivity and try again */\n ProtocolError[\"GENERIC_FAIL\"] = \"Generic error\";\n /**\n * Failure to protobuf encode the message. This is not recoverable and needs\n * further investigation.\n */\n ProtocolError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n /**\n * Failure to protobuf decode the message. May be due to a remote peer issue,\n * ensuring that messages are sent via several peer enable mitigation of this error.\n */\n ProtocolError[\"DECODE_FAILED\"] = \"Failed to decode\";\n /**\n * The message payload is empty, making the message invalid. Ensure that a non-empty\n * payload is set on the outgoing message.\n */\n ProtocolError[\"EMPTY_PAYLOAD\"] = \"Payload is empty\";\n /**\n * The message size is above the maximum message size allowed on the Waku Network.\n * Compressing the message or using an alternative strategy for large messages is recommended.\n */\n ProtocolError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n /**\n * The PubsubTopic passed to the send function is not configured on the Waku node.\n * Please ensure that the PubsubTopic is used when initializing the Waku node.\n */\n ProtocolError[\"TOPIC_NOT_CONFIGURED\"] = \"Topic not configured\";\n /**\n * Failure to find a peer with suitable protocols. This may due to a connection issue.\n * Mitigation can be: retrying after a given time period, display connectivity issue\n * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`\n * on the connection manager before retrying.\n */\n ProtocolError[\"NO_PEER_AVAILABLE\"] = \"No peer available\";\n /**\n * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_FAULT\"] = \"Remote peer fault\";\n /**\n * The remote peer rejected the message. Information provided by the remote peer\n * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_REJECTED\"] = \"Remote peer rejected\";\n /**\n * The protocol request timed out without a response. This may be due to a connection issue.\n * Mitigation can be: retrying after a given time period\n */\n ProtocolError[\"REQUEST_TIMEOUT\"] = \"Request timeout\";\n})(ProtocolError || (ProtocolError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/protocols.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/receiver.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/receiver.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=receiver.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/receiver.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/relay.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/relay.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=relay.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/relay.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/sender.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/sender.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=sender.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/sender.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/store.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/store.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/interfaces/dist/waku.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/interfaces/dist/waku.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/interfaces/dist/waku.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/bytes/index.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/bytes/index.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),\n/* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),\n/* harmony export */ concat: () => (/* binding */ concat),\n/* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),\n/* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@waku/core/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@waku/core/node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n/**\n * Convert input to a byte array.\n *\n * Handles both `0x` prefixed and non-prefixed strings.\n */\nfunction hexToBytes(hex) {\n if (typeof hex === \"string\") {\n const _hex = hex.replace(/^0x/i, \"\");\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(_hex.toLowerCase(), \"base16\");\n }\n return hex;\n}\n/**\n * Convert byte array to hex string (no `0x` prefix).\n */\nconst bytesToHex = (bytes) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(bytes, \"base16\");\n/**\n * Decode byte array to utf-8 string.\n */\nconst bytesToUtf8 = (b) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(b, \"utf8\");\n/**\n * Encode utf-8 string to byte array.\n */\nconst utf8ToBytes = (s) => (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(s, \"utf8\");\n/**\n * Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`\n */\nfunction concat(byteArrays, totalLength) {\n const len = totalLength ?? byteArrays.reduce((acc, curr) => acc + curr.length, 0);\n const res = new Uint8Array(len);\n let offset = 0;\n for (const bytes of byteArrays) {\n res.set(bytes, offset);\n offset += bytes.length;\n }\n return res;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/bytes/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/group_by.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/group_by.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ groupByContentTopic: () => (/* binding */ groupByContentTopic)\n/* harmony export */ });\nfunction groupByContentTopic(values) {\n const groupedDecoders = new Map();\n values.forEach((value) => {\n let decs = groupedDecoders.get(value.contentTopic);\n if (!decs) {\n groupedDecoders.set(value.contentTopic, []);\n decs = groupedDecoders.get(value.contentTopic);\n }\n decs.push(value);\n });\n return groupedDecoders;\n}\n//# sourceMappingURL=group_by.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/group_by.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/index.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentTopicToPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicsByPubsubTopic),\n/* harmony export */ decodeRelayShard: () => (/* reexport safe */ _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__.decodeRelayShard),\n/* harmony export */ determinePubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.determinePubsubTopic),\n/* harmony export */ encodeRelayShard: () => (/* reexport safe */ _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__.encodeRelayShard),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensureValidContentTopic),\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _random_subset_js__WEBPACK_IMPORTED_MODULE_1__.getPseudoRandomSubset),\n/* harmony export */ getWsMultiaddrFromMultiaddrs: () => (/* binding */ getWsMultiaddrFromMultiaddrs),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _group_by_js__WEBPACK_IMPORTED_MODULE_2__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _is_defined_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isMessageSizeUnderCap: () => (/* reexport safe */ _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__.isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* reexport safe */ _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__.isWireSizeUnderCap),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.pubsubTopicToSingleShardInfo),\n/* harmony export */ pushOrInitMapSet: () => (/* reexport safe */ _push_or_init_map_js__WEBPACK_IMPORTED_MODULE_6__.pushOrInitMapSet),\n/* harmony export */ removeItemFromArray: () => (/* binding */ removeItemFromArray),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.singleShardInfosToShardInfo),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _is_defined_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is_defined.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_defined.js\");\n/* harmony import */ var _random_subset_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./random_subset.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/random_subset.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./group_by.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/group_by.js\");\n/* harmony import */ var _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./to_async_iterator.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/to_async_iterator.js\");\n/* harmony import */ var _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./is_size_valid.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_size_valid.js\");\n/* harmony import */ var _sharding_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sharding.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/sharding.js\");\n/* harmony import */ var _push_or_init_map_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./push_or_init_map.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/push_or_init_map.js\");\n/* harmony import */ var _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./relay_shard_codec.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/relay_shard_codec.js\");\n\n\n\n\n\n\n\n\nfunction removeItemFromArray(arr, value) {\n const index = arr.indexOf(value);\n if (index > -1) {\n arr.splice(index, 1);\n }\n return arr;\n}\nfunction getWsMultiaddrFromMultiaddrs(addresses) {\n const wsMultiaddr = addresses.find((addr) => addr.toString().includes(\"ws\") || addr.toString().includes(\"wss\"));\n if (!wsMultiaddr) {\n throw new Error(\"No ws multiaddr found in the given addresses\");\n }\n return wsMultiaddr;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_defined.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_defined.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isDefined: () => (/* binding */ isDefined)\n/* harmony export */ });\nfunction isDefined(value) {\n return Boolean(value);\n}\n//# sourceMappingURL=is_defined.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_defined.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_size_valid.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_size_valid.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isMessageSizeUnderCap: () => (/* binding */ isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* binding */ isWireSizeUnderCap)\n/* harmony export */ });\nconst MB = 1024 ** 2;\nconst SIZE_CAP_IN_MB = 1;\n/**\n * Return whether the size of the message is under the upper limit for the network.\n * This performs a protobuf encoding! If you have access to the fully encoded message,\n * use {@link isSizeUnderCapBuf} instead.\n * @param message\n * @param encoder\n */\nasync function isMessageSizeUnderCap(encoder, message) {\n const buf = await encoder.toWire(message);\n if (!buf)\n return false;\n return isWireSizeUnderCap(buf);\n}\nconst isWireSizeUnderCap = (buf) => buf.length / MB <= SIZE_CAP_IN_MB;\n//# sourceMappingURL=is_size_valid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_size_valid.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/push_or_init_map.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/push_or_init_map.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pushOrInitMapSet: () => (/* binding */ pushOrInitMapSet)\n/* harmony export */ });\nfunction pushOrInitMapSet(map, key, newValue) {\n let arr = map.get(key);\n if (typeof arr === \"undefined\") {\n map.set(key, new Set());\n arr = map.get(key);\n }\n arr.add(newValue);\n}\n//# sourceMappingURL=push_or_init_map.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/push_or_init_map.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/random_subset.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/random_subset.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPseudoRandomSubset: () => (/* binding */ getPseudoRandomSubset)\n/* harmony export */ });\n/**\n * Return pseudo random subset of the input.\n */\nfunction getPseudoRandomSubset(values, wantedNumber) {\n if (values.length <= wantedNumber || values.length <= 1) {\n return values;\n }\n return shuffle(values).slice(0, wantedNumber);\n}\nfunction shuffle(arr) {\n if (arr.length <= 1) {\n return arr;\n }\n const randInt = () => {\n return Math.floor(Math.random() * Math.floor(arr.length));\n };\n for (let i = 0; i < arr.length; i++) {\n const j = randInt();\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n return arr;\n}\n//# sourceMappingURL=random_subset.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/random_subset.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/relay_shard_codec.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/relay_shard_codec.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeRelayShard: () => (/* binding */ decodeRelayShard),\n/* harmony export */ encodeRelayShard: () => (/* binding */ encodeRelayShard)\n/* harmony export */ });\nconst decodeRelayShard = (bytes) => {\n // explicitly converting to Uint8Array to avoid Buffer\n // https://github.com/libp2p/js-libp2p/issues/2146\n bytes = new Uint8Array(bytes);\n if (bytes.length < 3)\n throw new Error(\"Insufficient data\");\n const view = new DataView(bytes.buffer);\n const clusterId = view.getUint16(0);\n const shards = [];\n if (bytes.length === 130) {\n // rsv format (Bit Vector)\n for (let i = 0; i < 1024; i++) {\n const byteIndex = Math.floor(i / 8) + 2; // Adjusted for the 2-byte cluster field\n const bitIndex = 7 - (i % 8);\n if (view.getUint8(byteIndex) & (1 << bitIndex)) {\n shards.push(i);\n }\n }\n }\n else {\n // rs format (Index List)\n const numIndices = view.getUint8(2);\n for (let i = 0, offset = 3; i < numIndices; i++, offset += 2) {\n if (offset + 1 >= bytes.length)\n throw new Error(\"Unexpected end of data\");\n shards.push(view.getUint16(offset));\n }\n }\n return { clusterId, shards };\n};\nconst encodeRelayShard = (shardInfo) => {\n const { clusterId, shards } = shardInfo;\n const totalLength = shards.length >= 64 ? 130 : 3 + 2 * shards.length;\n const buffer = new ArrayBuffer(totalLength);\n const view = new DataView(buffer);\n view.setUint16(0, clusterId);\n if (shards.length >= 64) {\n // rsv format (Bit Vector)\n for (const index of shards) {\n const byteIndex = Math.floor(index / 8) + 2; // Adjusted for the 2-byte cluster field\n const bitIndex = 7 - (index % 8);\n view.setUint8(byteIndex, view.getUint8(byteIndex) | (1 << bitIndex));\n }\n }\n else {\n // rs format (Index List)\n view.setUint8(2, shards.length);\n for (let i = 0, offset = 3; i < shards.length; i++, offset += 2) {\n view.setUint16(offset, shards[i]);\n }\n }\n return new Uint8Array(buffer);\n};\n//# sourceMappingURL=relay_shard_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/relay_shard_codec.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/sharding.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/sharding.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentTopicToPubsubTopic: () => (/* binding */ contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* binding */ contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* binding */ contentTopicsByPubsubTopic),\n/* harmony export */ determinePubsubTopic: () => (/* binding */ determinePubsubTopic),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* binding */ ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* binding */ ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* binding */ ensureValidContentTopic),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* binding */ pubsubTopicToSingleShardInfo),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* binding */ shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* binding */ singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* binding */ singleShardInfosToShardInfo)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/core/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _bytes_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes/index.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/bytes/index.js\");\n\n\n\nconst singleShardInfoToPubsubTopic = (shardInfo) => {\n if (shardInfo.clusterId === undefined || shardInfo.shard === undefined)\n throw new Error(\"Invalid shard\");\n return `/waku/2/rs/${shardInfo.clusterId}/${shardInfo.shard}`;\n};\nconst singleShardInfosToShardInfo = (singleShardInfos) => {\n if (singleShardInfos.length === 0)\n throw new Error(\"Invalid shard\");\n const clusterIds = singleShardInfos.map((shardInfo) => shardInfo.clusterId);\n if (new Set(clusterIds).size !== 1) {\n throw new Error(\"Passed shard infos have different clusterIds\");\n }\n const shards = singleShardInfos\n .map((shardInfo) => shardInfo.shard)\n .filter((shard) => shard !== undefined);\n return {\n clusterId: singleShardInfos[0].clusterId,\n shards\n };\n};\nconst shardInfoToPubsubTopics = (shardInfo) => {\n if (\"contentTopics\" in shardInfo && shardInfo.contentTopics) {\n // Autosharding: explicitly defined content topics\n return Array.from(new Set(shardInfo.contentTopics.map((contentTopic) => contentTopicToPubsubTopic(contentTopic, shardInfo.clusterId))));\n }\n else if (\"shards\" in shardInfo) {\n // Static sharding\n if (shardInfo.shards === undefined)\n throw new Error(\"Invalid shard\");\n return Array.from(new Set(shardInfo.shards.map((index) => `/waku/2/rs/${shardInfo.clusterId ?? _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID}/${index}`)));\n }\n else if (\"application\" in shardInfo && \"version\" in shardInfo) {\n // Autosharding: single shard from application and version\n return [\n contentTopicToPubsubTopic(`/${shardInfo.application}/${shardInfo.version}/default/default`, shardInfo.clusterId)\n ];\n }\n else {\n throw new Error(\"Missing required configuration in shard parameters\");\n }\n};\nconst pubsubTopicToSingleShardInfo = (pubsubTopics) => {\n const parts = pubsubTopics.split(\"/\");\n if (parts.length != 6 ||\n parts[1] !== \"waku\" ||\n parts[2] !== \"2\" ||\n parts[3] !== \"rs\")\n throw new Error(\"Invalid pubsub topic\");\n const clusterId = parseInt(parts[4]);\n const shard = parseInt(parts[5]);\n if (isNaN(clusterId) || isNaN(shard))\n throw new Error(\"Invalid clusterId or shard\");\n return {\n clusterId,\n shard\n };\n};\n//TODO: move part of BaseProtocol instead of utils\n// return `ProtocolError.TOPIC_NOT_CONFIGURED` instead of throwing\nfunction ensurePubsubTopicIsConfigured(pubsubTopic, configuredTopics) {\n if (!configuredTopics.includes(pubsubTopic)) {\n throw new Error(`Pubsub topic ${pubsubTopic} has not been configured on this instance. Configured topics are: ${configuredTopics}. Please update your configuration by passing in the topic during Waku node instantiation.`);\n }\n}\n/**\n * Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/\n * @param contentTopic String to validate\n * @returns Object with each content topic field as an attribute\n */\nfunction ensureValidContentTopic(contentTopic) {\n const parts = contentTopic.split(\"/\");\n if (parts.length < 5 || parts.length > 6) {\n throw Error(\"Content topic format is invalid\");\n }\n // Validate generation field if present\n let generation = 0;\n if (parts.length == 6) {\n generation = parseInt(parts[1]);\n if (isNaN(generation)) {\n throw new Error(\"Invalid generation field in content topic\");\n }\n if (generation > 0) {\n throw new Error(\"Generation greater than 0 is not supported\");\n }\n }\n // Validate remaining fields\n const fields = parts.splice(-4);\n // Validate application field\n if (fields[0].length == 0) {\n throw new Error(\"Application field cannot be empty\");\n }\n // Validate version field\n if (fields[1].length == 0) {\n throw new Error(\"Version field cannot be empty\");\n }\n // Validate topic name field\n if (fields[2].length == 0) {\n throw new Error(\"Topic name field cannot be empty\");\n }\n // Validate encoding field\n if (fields[3].length == 0) {\n throw new Error(\"Encoding field cannot be empty\");\n }\n return {\n generation,\n application: fields[0],\n version: fields[1],\n topicName: fields[2],\n encoding: fields[3]\n };\n}\n/**\n * Given a string, determines which autoshard index to use for its pubsub topic.\n * Based on the algorithm described in the RFC: https://rfc.vac.dev/spec/51//#algorithm\n */\nfunction contentTopicToShardIndex(contentTopic, networkShards = 8) {\n const { application, version } = ensureValidContentTopic(contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256)((0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.concat)([(0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(application), (0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(version)]));\n const dataview = new DataView(digest.buffer.slice(-8));\n return Number(dataview.getBigUint64(0, false) % BigInt(networkShards));\n}\nfunction contentTopicToPubsubTopic(contentTopic, clusterId = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID, networkShards = 8) {\n const shardIndex = contentTopicToShardIndex(contentTopic, networkShards);\n return `/waku/2/rs/${clusterId}/${shardIndex}`;\n}\n/**\n * Given an array of content topics, groups them together by their Pubsub topic as derived using the algorithm for autosharding.\n * If any of the content topics are not properly formatted, the function will throw an error.\n */\nfunction contentTopicsByPubsubTopic(contentTopics, clusterId = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID, networkShards = 8) {\n const groupedContentTopics = new Map();\n for (const contentTopic of contentTopics) {\n const pubsubTopic = contentTopicToPubsubTopic(contentTopic, clusterId, networkShards);\n let topics = groupedContentTopics.get(pubsubTopic);\n if (!topics) {\n groupedContentTopics.set(pubsubTopic, []);\n topics = groupedContentTopics.get(pubsubTopic);\n }\n topics.push(contentTopic);\n }\n return groupedContentTopics;\n}\n/**\n * Used when creating encoders/decoders to determine which pubsub topic to use\n */\nfunction determinePubsubTopic(contentTopic, pubsubTopicShardInfo = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DefaultPubsubTopic) {\n if (typeof pubsubTopicShardInfo == \"string\") {\n return pubsubTopicShardInfo;\n }\n else {\n return pubsubTopicShardInfo\n ? pubsubTopicShardInfo.shard\n ? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)\n : contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo.clusterId)\n : _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DefaultPubsubTopic;\n }\n}\n/**\n * Validates sharding configuration and sets defaults where possible.\n * @returns Validated sharding parameters, with any missing values set to defaults\n */\nconst ensureShardingConfigured = (shardInfo) => {\n const clusterId = shardInfo.clusterId ?? _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID;\n const shards = \"shards\" in shardInfo ? shardInfo.shards : [];\n const contentTopics = \"contentTopics\" in shardInfo ? shardInfo.contentTopics : [];\n const [application, version] = \"application\" in shardInfo && \"version\" in shardInfo\n ? [shardInfo.application, shardInfo.version]\n : [undefined, undefined];\n const isShardsConfigured = shards && shards.length > 0;\n const isContentTopicsConfigured = contentTopics && contentTopics.length > 0;\n const isApplicationVersionConfigured = application && version;\n if (isShardsConfigured) {\n return {\n shardingParams: { clusterId, shards },\n shardInfo: { clusterId, shards },\n pubsubTopics: shardInfoToPubsubTopics({ clusterId, shards })\n };\n }\n if (isContentTopicsConfigured) {\n const pubsubTopics = Array.from(new Set(contentTopics.map((topic) => contentTopicToPubsubTopic(topic, clusterId))));\n const shards = Array.from(new Set(contentTopics.map((topic) => contentTopicToShardIndex(topic))));\n return {\n shardingParams: { clusterId, contentTopics },\n shardInfo: { clusterId, shards },\n pubsubTopics\n };\n }\n if (isApplicationVersionConfigured) {\n const pubsubTopic = contentTopicToPubsubTopic(`/${application}/${version}/default/default`, clusterId);\n return {\n shardingParams: { clusterId, application, version },\n shardInfo: {\n clusterId,\n shards: [pubsubTopicToSingleShardInfo(pubsubTopic).shard]\n },\n pubsubTopics: [pubsubTopic]\n };\n }\n throw new Error(\"Missing minimum required configuration options for static sharding or autosharding.\");\n};\n//# sourceMappingURL=sharding.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/sharding.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/common/to_async_iterator.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/common/to_async_iterator.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toAsyncIterator: () => (/* binding */ toAsyncIterator)\n/* harmony export */ });\nconst FRAME_RATE = 60;\n/**\n * Function that transforms IReceiver subscription to iterable stream of data.\n * @param receiver - object that allows to be subscribed to;\n * @param decoder - parameter to be passed to receiver for subscription;\n * @param options - options for receiver for subscription;\n * @param iteratorOptions - optional configuration for iterator;\n * @returns iterator and stop function to terminate it.\n */\nasync function toAsyncIterator(receiver, decoder, iteratorOptions) {\n const iteratorDelay = iteratorOptions?.iteratorDelay ?? FRAME_RATE;\n const messages = [];\n let unsubscribe;\n unsubscribe = await receiver.subscribe(decoder, (message) => {\n messages.push(message);\n });\n const isWithTimeout = Number.isInteger(iteratorOptions?.timeoutMs);\n const timeoutMs = iteratorOptions?.timeoutMs ?? 0;\n const startTime = Date.now();\n async function* iterator() {\n while (true) {\n if (isWithTimeout && Date.now() - startTime >= timeoutMs) {\n return;\n }\n await wait(iteratorDelay);\n const message = messages.shift();\n if (!unsubscribe && messages.length === 0) {\n return message;\n }\n if (!message && unsubscribe) {\n continue;\n }\n yield message;\n }\n }\n return {\n iterator: iterator(),\n async stop() {\n if (unsubscribe) {\n await unsubscribe();\n unsubscribe = undefined;\n }\n }\n };\n}\nfunction wait(ms) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n//# sourceMappingURL=to_async_iterator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/to_async_iterator.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/index.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Logger: () => (/* reexport safe */ _logger_index_js__WEBPACK_IMPORTED_MODULE_1__.Logger),\n/* harmony export */ contentTopicToPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicsByPubsubTopic),\n/* harmony export */ decodeRelayShard: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.decodeRelayShard),\n/* harmony export */ determinePubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.determinePubsubTopic),\n/* harmony export */ encodeRelayShard: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.encodeRelayShard),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensureValidContentTopic),\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getPseudoRandomSubset),\n/* harmony export */ getWsMultiaddrFromMultiaddrs: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getWsMultiaddrFromMultiaddrs),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isMessageSizeUnderCap: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isWireSizeUnderCap),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.pubsubTopicToSingleShardInfo),\n/* harmony export */ pushOrInitMapSet: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.pushOrInitMapSet),\n/* harmony export */ removeItemFromArray: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.removeItemFromArray),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.singleShardInfosToShardInfo),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _common_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common/index.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/common/index.js\");\n/* harmony import */ var _logger_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger/index.js */ \"./node_modules/@waku/core/node_modules/@waku/utils/dist/logger/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/logger/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/logger/index.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Logger: () => (/* binding */ Logger)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\nconst APP_NAME = \"waku\";\nclass Logger {\n _info;\n _warn;\n _error;\n static createDebugNamespace(level, prefix) {\n return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;\n }\n constructor(prefix) {\n this._info = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"info\", prefix));\n this._warn = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"warn\", prefix));\n this._error = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"error\", prefix));\n }\n get info() {\n return this._info;\n }\n get warn() {\n return this._warn;\n }\n get error() {\n return this._error;\n }\n log(level, ...args) {\n const logger = this[level];\n logger(...args);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@waku/utils/dist/logger/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/uint8arrays/dist/src/alloc.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/uint8arrays/dist/src/alloc.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/uint8arrays/dist/src/from-string.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/uint8arrays/dist/src/from-string.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@waku/core/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/uint8arrays/dist/src/to-string.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/uint8arrays/dist/src/to-string.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@waku/core/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/uint8arrays/dist/src/util/bases.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/uint8arrays/dist/src/util/bases.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@waku/core/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/dns/constants.js": +/*!************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/dns/constants.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_BOOTSTRAP_TAG_NAME: () => (/* binding */ DEFAULT_BOOTSTRAP_TAG_NAME),\n/* harmony export */ DEFAULT_BOOTSTRAP_TAG_TTL: () => (/* binding */ DEFAULT_BOOTSTRAP_TAG_TTL),\n/* harmony export */ DEFAULT_BOOTSTRAP_TAG_VALUE: () => (/* binding */ DEFAULT_BOOTSTRAP_TAG_VALUE),\n/* harmony export */ DEFAULT_NODE_REQUIREMENTS: () => (/* binding */ DEFAULT_NODE_REQUIREMENTS),\n/* harmony export */ enrTree: () => (/* binding */ enrTree)\n/* harmony export */ });\nconst enrTree = {\n TEST: \"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im\",\n SANDBOX: \"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im\"\n};\nconst DEFAULT_BOOTSTRAP_TAG_NAME = \"bootstrap\";\nconst DEFAULT_BOOTSTRAP_TAG_VALUE = 50;\nconst DEFAULT_BOOTSTRAP_TAG_TTL = 100_000_000;\nconst DEFAULT_NODE_REQUIREMENTS = {\n store: 2,\n filter: 1,\n lightPush: 1\n};\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/dns/dns.js": /*!******************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/dist/dns.js ***! + !*** ./node_modules/@waku/discovery/dist/dns/dns.js ***! \******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsNodeDiscovery: () => (/* binding */ DnsNodeDiscovery)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/enr/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _dns_over_https_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dns_over_https.js */ \"./node_modules/@waku/dns-discovery/dist/dns_over_https.js\");\n/* harmony import */ var _enrtree_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enrtree.js */ \"./node_modules/@waku/dns-discovery/dist/enrtree.js\");\n/* harmony import */ var _fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fetch_nodes.js */ \"./node_modules/@waku/dns-discovery/dist/fetch_nodes.js\");\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:discovery:dns\");\nclass DnsNodeDiscovery {\n dns;\n _DNSTreeCache;\n _errorTolerance = 10;\n static async dnsOverHttp(dnsClient) {\n if (!dnsClient) {\n dnsClient = await _dns_over_https_js__WEBPACK_IMPORTED_MODULE_2__.DnsOverHttps.create();\n }\n return new DnsNodeDiscovery(dnsClient);\n }\n /**\n * Returns a list of verified peers listed in an EIP-1459 DNS tree. Method may\n * return fewer peers than requested if @link wantedNodeCapabilityCount requires\n * larger quantity of peers than available or the number of errors/duplicate\n * peers encountered by randomized search exceeds the sum of the fields of\n * @link wantedNodeCapabilityCount plus the @link _errorTolerance factor.\n */\n async getPeers(enrTreeUrls, wantedNodeCapabilityCount) {\n const networkIndex = Math.floor(Math.random() * enrTreeUrls.length);\n const { publicKey, domain } = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseTree(enrTreeUrls[networkIndex]);\n const context = {\n domain,\n publicKey,\n visits: {},\n };\n const peers = await (0,_fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__.fetchNodesUntilCapabilitiesFulfilled)(wantedNodeCapabilityCount, this._errorTolerance, () => this._search(domain, context));\n log(\"retrieved peers: \", peers.map((peer) => {\n return {\n id: peer.peerId?.toString(),\n multiaddrs: peer.multiaddrs?.map((ma) => ma.toString()),\n };\n }));\n return peers;\n }\n constructor(dns) {\n this._DNSTreeCache = {};\n this.dns = dns;\n }\n /**\n * {@inheritDoc getPeers}\n */\n async *getNextPeer(enrTreeUrls, wantedNodeCapabilityCount) {\n const networkIndex = Math.floor(Math.random() * enrTreeUrls.length);\n const { publicKey, domain } = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseTree(enrTreeUrls[networkIndex]);\n const context = {\n domain,\n publicKey,\n visits: {},\n };\n for await (const peer of (0,_fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__.yieldNodesUntilCapabilitiesFulfilled)(wantedNodeCapabilityCount, this._errorTolerance, () => this._search(domain, context))) {\n yield peer;\n }\n }\n /**\n * Runs a recursive, randomized descent of the DNS tree to retrieve a single\n * ENR record as an ENR. Returns null if parsing or DNS resolution fails.\n */\n async _search(subdomain, context) {\n try {\n const entry = await this._getTXTRecord(subdomain, context);\n context.visits[subdomain] = true;\n let next;\n let branches;\n const entryType = getEntryType(entry);\n try {\n switch (entryType) {\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX:\n next = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseAndVerifyRoot(entry, context.publicKey);\n return await this._search(next, context);\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX:\n branches = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseBranch(entry);\n next = selectRandomPath(branches, context);\n return await this._search(next, context);\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX:\n return _waku_enr__WEBPACK_IMPORTED_MODULE_0__.EnrDecoder.fromString(entry);\n default:\n return null;\n }\n }\n catch (error) {\n log(`Failed to search DNS tree ${entryType} at subdomain ${subdomain}: ${error}`);\n return null;\n }\n }\n catch (error) {\n log(`Failed to retrieve TXT record at subdomain ${subdomain}: ${error}`);\n return null;\n }\n }\n /**\n * Retrieves the TXT record stored at a location from either\n * this DNS tree cache or via DNS query.\n *\n * @throws if the TXT Record contains non-UTF-8 values.\n */\n async _getTXTRecord(subdomain, context) {\n if (this._DNSTreeCache[subdomain]) {\n return this._DNSTreeCache[subdomain];\n }\n // Location is either the top level tree entry host or a subdomain of it.\n const location = subdomain !== context.domain\n ? `${subdomain}.${context.domain}`\n : context.domain;\n const response = await this.dns.resolveTXT(location);\n if (!response.length)\n throw new Error(\"Received empty result array while fetching TXT record\");\n if (!response[0].length)\n throw new Error(\"Received empty TXT record\");\n // Branch entries can be an array of strings of comma delimited subdomains, with\n // some subdomain strings split across the array elements\n const result = response.join(\"\");\n this._DNSTreeCache[subdomain] = result;\n return result;\n }\n}\nfunction getEntryType(entry) {\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX;\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX;\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX;\n return \"\";\n}\n/**\n * Returns a randomly selected subdomain string from the list provided by a branch\n * entry record.\n *\n * The client must track subdomains which are already resolved to avoid\n * going into an infinite loop b/c branch entries can contain\n * circular references. It’s in the client’s best interest to traverse the\n * tree in random order.\n */\nfunction selectRandomPath(branches, context) {\n // Identify domains already visited in this traversal of the DNS tree.\n // Then filter against them to prevent cycles.\n const circularRefs = {};\n for (const [idx, subdomain] of branches.entries()) {\n if (context.visits[subdomain]) {\n circularRefs[idx] = true;\n }\n }\n // If all possible paths are circular...\n if (Object.keys(circularRefs).length === branches.length) {\n throw new Error(\"Unresolvable circular path detected\");\n }\n // Randomly select a viable path\n let index;\n do {\n index = Math.floor(Math.random() * branches.length);\n } while (circularRefs[index]);\n return branches[index];\n}\n//# sourceMappingURL=dns.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/dns.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsNodeDiscovery: () => (/* binding */ DnsNodeDiscovery)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _dns_over_https_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dns_over_https.js */ \"./node_modules/@waku/discovery/dist/dns/dns_over_https.js\");\n/* harmony import */ var _enrtree_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enrtree.js */ \"./node_modules/@waku/discovery/dist/dns/enrtree.js\");\n/* harmony import */ var _fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fetch_nodes.js */ \"./node_modules/@waku/discovery/dist/dns/fetch_nodes.js\");\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"discovery:dns\");\nclass DnsNodeDiscovery {\n dns;\n _DNSTreeCache;\n _errorTolerance = 10;\n static async dnsOverHttp(dnsClient) {\n if (!dnsClient) {\n dnsClient = await _dns_over_https_js__WEBPACK_IMPORTED_MODULE_2__.DnsOverHttps.create();\n }\n return new DnsNodeDiscovery(dnsClient);\n }\n /**\n * Returns a list of verified peers listed in an EIP-1459 DNS tree. Method may\n * return fewer peers than requested if @link wantedNodeCapabilityCount requires\n * larger quantity of peers than available or the number of errors/duplicate\n * peers encountered by randomized search exceeds the sum of the fields of\n * @link wantedNodeCapabilityCount plus the @link _errorTolerance factor.\n */\n async getPeers(enrTreeUrls, wantedNodeCapabilityCount) {\n const networkIndex = Math.floor(Math.random() * enrTreeUrls.length);\n const { publicKey, domain } = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseTree(enrTreeUrls[networkIndex]);\n const context = {\n domain,\n publicKey,\n visits: {}\n };\n const peers = await (0,_fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__.fetchNodesUntilCapabilitiesFulfilled)(wantedNodeCapabilityCount, this._errorTolerance, () => this._search(domain, context));\n log.info(\"retrieved peers: \", peers.map((peer) => {\n return {\n id: peer.peerId?.toString(),\n multiaddrs: peer.multiaddrs?.map((ma) => ma.toString())\n };\n }));\n return peers;\n }\n constructor(dns) {\n this._DNSTreeCache = {};\n this.dns = dns;\n }\n /**\n * {@inheritDoc getPeers}\n */\n async *getNextPeer(enrTreeUrls, wantedNodeCapabilityCount) {\n const networkIndex = Math.floor(Math.random() * enrTreeUrls.length);\n const { publicKey, domain } = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseTree(enrTreeUrls[networkIndex]);\n const context = {\n domain,\n publicKey,\n visits: {}\n };\n for await (const peer of (0,_fetch_nodes_js__WEBPACK_IMPORTED_MODULE_4__.yieldNodesUntilCapabilitiesFulfilled)(wantedNodeCapabilityCount, this._errorTolerance, () => this._search(domain, context))) {\n yield peer;\n }\n }\n /**\n * Runs a recursive, randomized descent of the DNS tree to retrieve a single\n * ENR record as an ENR. Returns null if parsing or DNS resolution fails.\n */\n async _search(subdomain, context) {\n try {\n const entry = await this._getTXTRecord(subdomain, context);\n context.visits[subdomain] = true;\n let next;\n let branches;\n const entryType = getEntryType(entry);\n try {\n switch (entryType) {\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX:\n next = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseAndVerifyRoot(entry, context.publicKey);\n return await this._search(next, context);\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX:\n branches = _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.parseBranch(entry);\n next = selectRandomPath(branches, context);\n return await this._search(next, context);\n case _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX:\n return _waku_enr__WEBPACK_IMPORTED_MODULE_0__.EnrDecoder.fromString(entry);\n default:\n return null;\n }\n }\n catch (error) {\n log.error(`Failed to search DNS tree ${entryType} at subdomain ${subdomain}: ${error}`);\n return null;\n }\n }\n catch (error) {\n log.error(`Failed to retrieve TXT record at subdomain ${subdomain}: ${error}`);\n return null;\n }\n }\n /**\n * Retrieves the TXT record stored at a location from either\n * this DNS tree cache or via DNS query.\n *\n * @throws if the TXT Record contains non-UTF-8 values.\n */\n async _getTXTRecord(subdomain, context) {\n if (this._DNSTreeCache[subdomain]) {\n return this._DNSTreeCache[subdomain];\n }\n // Location is either the top level tree entry host or a subdomain of it.\n const location = subdomain !== context.domain\n ? `${subdomain}.${context.domain}`\n : context.domain;\n const response = await this.dns.resolveTXT(location);\n if (!response.length)\n throw new Error(\"Received empty result array while fetching TXT record\");\n if (!response[0].length)\n throw new Error(\"Received empty TXT record\");\n // Branch entries can be an array of strings of comma delimited subdomains, with\n // some subdomain strings split across the array elements\n const result = response.join(\"\");\n this._DNSTreeCache[subdomain] = result;\n return result;\n }\n}\nfunction getEntryType(entry) {\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.ROOT_PREFIX;\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.BRANCH_PREFIX;\n if (entry.startsWith(_enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX))\n return _enrtree_js__WEBPACK_IMPORTED_MODULE_3__.ENRTree.RECORD_PREFIX;\n return \"\";\n}\n/**\n * Returns a randomly selected subdomain string from the list provided by a branch\n * entry record.\n *\n * The client must track subdomains which are already resolved to avoid\n * going into an infinite loop b/c branch entries can contain\n * circular references. It’s in the client’s best interest to traverse the\n * tree in random order.\n */\nfunction selectRandomPath(branches, context) {\n // Identify domains already visited in this traversal of the DNS tree.\n // Then filter against them to prevent cycles.\n const circularRefs = {};\n for (const [idx, subdomain] of branches.entries()) {\n if (context.visits[subdomain]) {\n circularRefs[idx] = true;\n }\n }\n // If all possible paths are circular...\n if (Object.keys(circularRefs).length === branches.length) {\n throw new Error(\"Unresolvable circular path detected\");\n }\n // Randomly select a viable path\n let index;\n do {\n index = Math.floor(Math.random() * branches.length);\n } while (circularRefs[index]);\n return branches[index];\n}\n//# sourceMappingURL=dns.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/dns.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/dist/dns_over_https.js": +/***/ "./node_modules/@waku/discovery/dist/dns/dns_discovery.js": +/*!****************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/dns/dns_discovery.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerDiscoveryDns: () => (/* binding */ PeerDiscoveryDns),\n/* harmony export */ wakuDnsDiscovery: () => (/* binding */ wakuDnsDiscovery)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/dist/dns/constants.js\");\n/* harmony import */ var _dns_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dns.js */ \"./node_modules/@waku/discovery/dist/dns/dns.js\");\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"peer-discovery-dns\");\n/**\n * Parse options and expose function to return bootstrap peer addresses.\n */\nclass PeerDiscoveryDns extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.TypedEventEmitter {\n nextPeer;\n _started;\n _components;\n _options;\n constructor(components, options) {\n super();\n this._started = false;\n this._components = components;\n this._options = options;\n const { enrUrls } = options;\n log.info(\"Use following EIP-1459 ENR Tree URLs: \", enrUrls);\n }\n /**\n * Start discovery process\n */\n async start() {\n log.info(\"Starting peer discovery via dns\");\n this._started = true;\n if (this.nextPeer === undefined) {\n let { enrUrls } = this._options;\n if (!Array.isArray(enrUrls))\n enrUrls = [enrUrls];\n const { wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_2__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, enrUrls, wantedNodeCapabilityCount);\n }\n for await (const peerEnr of this.nextPeer()) {\n if (!this._started) {\n return;\n }\n const { peerInfo, shardInfo } = peerEnr;\n if (!peerInfo) {\n continue;\n }\n const tagsToUpdate = {\n [_constants_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_BOOTSTRAP_TAG_NAME]: {\n value: this._options.tagValue ?? _constants_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? _constants_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_BOOTSTRAP_TAG_TTL\n }\n };\n let isPeerChanged = false;\n const isPeerExists = await this._components.peerStore.has(peerInfo.id);\n if (isPeerExists) {\n const peer = await this._components.peerStore.get(peerInfo.id);\n const hasBootstrapTag = peer.tags.has(_constants_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_BOOTSTRAP_TAG_NAME);\n if (!hasBootstrapTag) {\n isPeerChanged = true;\n await this._components.peerStore.merge(peerInfo.id, {\n tags: tagsToUpdate\n });\n }\n }\n else {\n isPeerChanged = true;\n await this._components.peerStore.save(peerInfo.id, {\n tags: tagsToUpdate,\n ...(shardInfo && {\n metadata: {\n shardInfo: (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.encodeRelayShard)(shardInfo)\n }\n })\n });\n }\n if (isPeerChanged) {\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(\"peer\", { detail: peerInfo }));\n }\n }\n }\n /**\n * Stop emitting events\n */\n stop() {\n this._started = false;\n }\n get [_libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.peerDiscoverySymbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrls, wantedNodeCapabilityCount = _constants_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_NODE_REQUIREMENTS) {\n return (components) => new PeerDiscoveryDns(components, { enrUrls, wantedNodeCapabilityCount });\n}\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/dns_discovery.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/dns/dns_over_https.js": /*!*****************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/dist/dns_over_https.js ***! + !*** ./node_modules/@waku/discovery/dist/dns/dns_over_https.js ***! \*****************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsOverHttps: () => (/* binding */ DnsOverHttps)\n/* harmony export */ });\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var dns_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! dns-query */ \"./node_modules/dns-query/index.mjs\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:dns-over-https\");\nclass DnsOverHttps {\n endpoints;\n retries;\n /**\n * Create new Dns-Over-Http DNS client.\n *\n * @param endpoints The endpoints for Dns-Over-Https queries;\n * Defaults to using dns-query's API..\n * @param retries Retries if a given endpoint fails.\n *\n * @throws {code: string} If DNS query fails.\n */\n static async create(endpoints, retries) {\n const _endpoints = endpoints ?? (await dns_query__WEBPACK_IMPORTED_MODULE_2__.wellknown.endpoints(\"doh\"));\n return new DnsOverHttps(_endpoints, retries);\n }\n constructor(endpoints, retries = 3) {\n this.endpoints = endpoints;\n this.retries = retries;\n }\n /**\n * Resolves a TXT record\n *\n * @param domain The domain name\n *\n * @throws if the query fails\n */\n async resolveTXT(domain) {\n let answers;\n try {\n const res = await (0,dns_query__WEBPACK_IMPORTED_MODULE_2__.query)({\n question: { type: \"TXT\", name: domain },\n }, {\n endpoints: this.endpoints,\n retries: this.retries,\n });\n answers = res.answers;\n }\n catch (error) {\n log(\"query failed: \", error);\n throw new Error(\"DNS query failed\");\n }\n if (!answers)\n throw new Error(`Could not resolve ${domain}`);\n const data = answers.map((a) => a.data);\n const result = [];\n data.forEach((d) => {\n if (typeof d === \"string\") {\n result.push(d);\n }\n else if (Array.isArray(d)) {\n d.forEach((sd) => {\n if (typeof sd === \"string\") {\n result.push(sd);\n }\n else {\n result.push((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.bytesToUtf8)(sd));\n }\n });\n }\n else {\n result.push((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.bytesToUtf8)(d));\n }\n });\n return result;\n }\n}\n//# sourceMappingURL=dns_over_https.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/dns_over_https.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsOverHttps: () => (/* binding */ DnsOverHttps)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var dns_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! dns-query */ \"./node_modules/dns-query/index.mjs\");\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"dns-over-https\");\nclass DnsOverHttps {\n endpoints;\n retries;\n /**\n * Create new Dns-Over-Http DNS client.\n *\n * @param endpoints The endpoints for Dns-Over-Https queries;\n * Defaults to using dns-query's API..\n * @param retries Retries if a given endpoint fails.\n *\n * @throws {code: string} If DNS query fails.\n */\n static async create(endpoints, retries) {\n const _endpoints = endpoints ?? (await dns_query__WEBPACK_IMPORTED_MODULE_2__.wellknown.endpoints(\"doh\"));\n return new DnsOverHttps(_endpoints, retries);\n }\n constructor(endpoints, retries = 3) {\n this.endpoints = endpoints;\n this.retries = retries;\n }\n /**\n * Resolves a TXT record\n *\n * @param domain The domain name\n *\n * @throws if the query fails\n */\n async resolveTXT(domain) {\n let answers;\n try {\n const res = await (0,dns_query__WEBPACK_IMPORTED_MODULE_2__.query)({\n question: { type: \"TXT\", name: domain }\n }, {\n endpoints: this.endpoints,\n retries: this.retries\n });\n answers = res.answers;\n }\n catch (error) {\n log.error(\"query failed: \", error);\n throw new Error(\"DNS query failed\");\n }\n if (!answers)\n throw new Error(`Could not resolve ${domain}`);\n const data = answers.map((a) => a.data);\n const result = [];\n data.forEach((d) => {\n if (typeof d === \"string\") {\n result.push(d);\n }\n else if (Array.isArray(d)) {\n d.forEach((sd) => {\n if (typeof sd === \"string\") {\n result.push(sd);\n }\n else {\n result.push((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8)(sd));\n }\n });\n }\n else {\n result.push((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8)(d));\n }\n });\n return result;\n }\n}\n//# sourceMappingURL=dns_over_https.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/dns_over_https.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/dist/enrtree.js": +/***/ "./node_modules/@waku/discovery/dist/dns/enrtree.js": /*!**********************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/dist/enrtree.js ***! + !*** ./node_modules/@waku/discovery/dist/dns/enrtree.js ***! \**********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENRTree: () => (/* binding */ ENRTree)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/enr/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var hi_base32__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! hi-base32 */ \"./node_modules/hi-base32/src/base32.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\n\n\nclass ENRTree {\n static RECORD_PREFIX = _waku_enr__WEBPACK_IMPORTED_MODULE_0__.ENR.RECORD_PREFIX;\n static TREE_PREFIX = \"enrtree:\";\n static BRANCH_PREFIX = \"enrtree-branch:\";\n static ROOT_PREFIX = \"enrtree-root:\";\n /**\n * Extracts the branch subdomain referenced by a DNS tree root string after verifying\n * the root record signature with its base32 compressed public key.\n */\n static parseAndVerifyRoot(root, publicKey) {\n if (!root.startsWith(this.ROOT_PREFIX))\n throw new Error(`ENRTree root entry must start with '${this.ROOT_PREFIX}'`);\n const rootValues = ENRTree.parseRootValues(root);\n const decodedPublicKey = hi_base32__WEBPACK_IMPORTED_MODULE_2__.decode.asBytes(publicKey);\n // The signature is a 65-byte secp256k1 over the keccak256 hash\n // of the record content, excluding the `sig=` part, encoded as URL-safe base64 string\n // (Trailing recovery bit must be trimmed to pass `ecdsaVerify` method)\n const signedComponent = root.split(\" sig\")[0];\n const signedComponentBuffer = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(signedComponent);\n const signatureBuffer = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(rootValues.signature, \"base64url\").slice(0, 64);\n const isVerified = (0,_waku_enr__WEBPACK_IMPORTED_MODULE_0__.verifySignature)(signatureBuffer, (0,_waku_enr__WEBPACK_IMPORTED_MODULE_0__.keccak256)(signedComponentBuffer), new Uint8Array(decodedPublicKey));\n if (!isVerified)\n throw new Error(\"Unable to verify ENRTree root signature\");\n return rootValues.eRoot;\n }\n static parseRootValues(txt) {\n const matches = txt.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\\d+) sig=([^ ]+)$/);\n if (!Array.isArray(matches))\n throw new Error(\"Could not parse ENRTree root entry\");\n matches.shift(); // The first entry is the full match\n const [eRoot, lRoot, seq, signature] = matches;\n if (!eRoot)\n throw new Error(\"Could not parse 'e' value from ENRTree root entry\");\n if (!lRoot)\n throw new Error(\"Could not parse 'l' value from ENRTree root entry\");\n if (!seq)\n throw new Error(\"Could not parse 'seq' value from ENRTree root entry\");\n if (!signature)\n throw new Error(\"Could not parse 'sig' value from ENRTree root entry\");\n return { eRoot, lRoot, seq: Number(seq), signature };\n }\n /**\n * Returns the public key and top level domain of an ENR tree entry.\n * The domain is the starting point for traversing a set of linked DNS TXT records\n * and the public key is used to verify the root entry record\n */\n static parseTree(tree) {\n if (!tree.startsWith(this.TREE_PREFIX))\n throw new Error(`ENRTree tree entry must start with '${this.TREE_PREFIX}'`);\n const matches = tree.match(/^enrtree:\\/\\/([^@]+)@(.+)$/);\n if (!Array.isArray(matches))\n throw new Error(\"Could not parse ENRTree tree entry\");\n matches.shift(); // The first entry is the full match\n const [publicKey, domain] = matches;\n if (!publicKey)\n throw new Error(\"Could not parse public key from ENRTree tree entry\");\n if (!domain)\n throw new Error(\"Could not parse domain from ENRTree tree entry\");\n return { publicKey, domain };\n }\n /**\n * Returns subdomains listed in an ENR branch entry. These in turn lead to\n * either further branch entries or ENR records.\n */\n static parseBranch(branch) {\n if (!branch.startsWith(this.BRANCH_PREFIX))\n throw new Error(`ENRTree branch entry must start with '${this.BRANCH_PREFIX}'`);\n return branch.split(this.BRANCH_PREFIX)[1].split(\",\");\n }\n}\n\n//# sourceMappingURL=enrtree.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/enrtree.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENRTree: () => (/* binding */ ENRTree)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var hi_base32__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! hi-base32 */ \"./node_modules/hi-base32/src/base32.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\n\n\nclass ENRTree {\n static RECORD_PREFIX = _waku_enr__WEBPACK_IMPORTED_MODULE_0__.ENR.RECORD_PREFIX;\n static TREE_PREFIX = \"enrtree:\";\n static BRANCH_PREFIX = \"enrtree-branch:\";\n static ROOT_PREFIX = \"enrtree-root:\";\n /**\n * Extracts the branch subdomain referenced by a DNS tree root string after verifying\n * the root record signature with its base32 compressed public key.\n */\n static parseAndVerifyRoot(root, publicKey) {\n if (!root.startsWith(this.ROOT_PREFIX))\n throw new Error(`ENRTree root entry must start with '${this.ROOT_PREFIX}'`);\n const rootValues = ENRTree.parseRootValues(root);\n const decodedPublicKey = hi_base32__WEBPACK_IMPORTED_MODULE_2__.decode.asBytes(publicKey);\n // The signature is a 65-byte secp256k1 over the keccak256 hash\n // of the record content, excluding the `sig=` part, encoded as URL-safe base64 string\n // (Trailing recovery bit must be trimmed to pass `ecdsaVerify` method)\n const signedComponent = root.split(\" sig\")[0];\n const signedComponentBuffer = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(signedComponent);\n const signatureBuffer = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(rootValues.signature, \"base64url\").slice(0, 64);\n const isVerified = (0,_waku_enr__WEBPACK_IMPORTED_MODULE_0__.verifySignature)(signatureBuffer, (0,_waku_enr__WEBPACK_IMPORTED_MODULE_0__.keccak256)(signedComponentBuffer), new Uint8Array(decodedPublicKey));\n if (!isVerified)\n throw new Error(\"Unable to verify ENRTree root signature\");\n return rootValues.eRoot;\n }\n static parseRootValues(txt) {\n const matches = txt.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\\d+) sig=([^ ]+)$/);\n if (!Array.isArray(matches))\n throw new Error(\"Could not parse ENRTree root entry\");\n matches.shift(); // The first entry is the full match\n const [eRoot, lRoot, seq, signature] = matches;\n if (!eRoot)\n throw new Error(\"Could not parse 'e' value from ENRTree root entry\");\n if (!lRoot)\n throw new Error(\"Could not parse 'l' value from ENRTree root entry\");\n if (!seq)\n throw new Error(\"Could not parse 'seq' value from ENRTree root entry\");\n if (!signature)\n throw new Error(\"Could not parse 'sig' value from ENRTree root entry\");\n return { eRoot, lRoot, seq: Number(seq), signature };\n }\n /**\n * Returns the public key and top level domain of an ENR tree entry.\n * The domain is the starting point for traversing a set of linked DNS TXT records\n * and the public key is used to verify the root entry record\n */\n static parseTree(tree) {\n if (!tree.startsWith(this.TREE_PREFIX))\n throw new Error(`ENRTree tree entry must start with '${this.TREE_PREFIX}'`);\n const matches = tree.match(/^enrtree:\\/\\/([^@]+)@(.+)$/);\n if (!Array.isArray(matches))\n throw new Error(\"Could not parse ENRTree tree entry\");\n matches.shift(); // The first entry is the full match\n const [publicKey, domain] = matches;\n if (!publicKey)\n throw new Error(\"Could not parse public key from ENRTree tree entry\");\n if (!domain)\n throw new Error(\"Could not parse domain from ENRTree tree entry\");\n return { publicKey, domain };\n }\n /**\n * Returns subdomains listed in an ENR branch entry. These in turn lead to\n * either further branch entries or ENR records.\n */\n static parseBranch(branch) {\n if (!branch.startsWith(this.BRANCH_PREFIX))\n throw new Error(`ENRTree branch entry must start with '${this.BRANCH_PREFIX}'`);\n return branch.split(this.BRANCH_PREFIX)[1].split(\",\");\n }\n}\n//# sourceMappingURL=enrtree.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/enrtree.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/dist/fetch_nodes.js": +/***/ "./node_modules/@waku/discovery/dist/dns/fetch_nodes.js": /*!**************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/dist/fetch_nodes.js ***! + !*** ./node_modules/@waku/discovery/dist/dns/fetch_nodes.js ***! \**************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fetchNodesUntilCapabilitiesFulfilled: () => (/* binding */ fetchNodesUntilCapabilitiesFulfilled),\n/* harmony export */ yieldNodesUntilCapabilitiesFulfilled: () => (/* binding */ yieldNodesUntilCapabilitiesFulfilled)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:discovery:fetch_nodes\");\n/**\n * Fetch nodes using passed [[getNode]] until all wanted capabilities are\n * fulfilled or the number of [[getNode]] call exceeds the sum of\n * [[wantedNodeCapabilityCount]] plus [[errorTolerance]].\n */\nasync function fetchNodesUntilCapabilitiesFulfilled(wantedNodeCapabilityCount, errorTolerance, getNode) {\n const wanted = {\n relay: wantedNodeCapabilityCount.relay ?? 0,\n store: wantedNodeCapabilityCount.store ?? 0,\n filter: wantedNodeCapabilityCount.filter ?? 0,\n lightPush: wantedNodeCapabilityCount.lightPush ?? 0,\n };\n const maxSearches = wanted.relay + wanted.store + wanted.filter + wanted.lightPush;\n const actual = {\n relay: 0,\n store: 0,\n filter: 0,\n lightPush: 0,\n };\n let totalSearches = 0;\n const peers = [];\n while (!isSatisfied(wanted, actual) &&\n totalSearches < maxSearches + errorTolerance) {\n const peer = await getNode();\n if (peer && isNewPeer(peer, peers)) {\n // ENRs without a waku2 key are ignored.\n if (peer.waku2) {\n if (helpsSatisfyCapabilities(peer.waku2, wanted, actual)) {\n addCapabilities(peer.waku2, actual);\n peers.push(peer);\n }\n }\n log(`got new peer candidate from DNS address=${peer.nodeId}@${peer.ip}`);\n }\n totalSearches++;\n }\n return peers;\n}\n/**\n * Fetch nodes using passed [[getNode]] until all wanted capabilities are\n * fulfilled or the number of [[getNode]] call exceeds the sum of\n * [[wantedNodeCapabilityCount]] plus [[errorTolerance]].\n */\nasync function* yieldNodesUntilCapabilitiesFulfilled(wantedNodeCapabilityCount, errorTolerance, getNode) {\n const wanted = {\n relay: wantedNodeCapabilityCount.relay ?? 0,\n store: wantedNodeCapabilityCount.store ?? 0,\n filter: wantedNodeCapabilityCount.filter ?? 0,\n lightPush: wantedNodeCapabilityCount.lightPush ?? 0,\n };\n const maxSearches = wanted.relay + wanted.store + wanted.filter + wanted.lightPush;\n const actual = {\n relay: 0,\n store: 0,\n filter: 0,\n lightPush: 0,\n };\n let totalSearches = 0;\n const peerNodeIds = new Set();\n while (!isSatisfied(wanted, actual) &&\n totalSearches < maxSearches + errorTolerance) {\n const peer = await getNode();\n if (peer && peer.nodeId && !peerNodeIds.has(peer.nodeId)) {\n peerNodeIds.add(peer.nodeId);\n // ENRs without a waku2 key are ignored.\n if (peer.waku2) {\n if (helpsSatisfyCapabilities(peer.waku2, wanted, actual)) {\n addCapabilities(peer.waku2, actual);\n yield peer;\n }\n }\n log(`got new peer candidate from DNS address=${peer.nodeId}@${peer.ip}`);\n }\n totalSearches++;\n }\n}\nfunction isSatisfied(wanted, actual) {\n return (actual.relay >= wanted.relay &&\n actual.store >= wanted.store &&\n actual.filter >= wanted.filter &&\n actual.lightPush >= wanted.lightPush);\n}\nfunction isNewPeer(peer, peers) {\n if (!peer.nodeId)\n return false;\n for (const existingPeer of peers) {\n if (peer.nodeId === existingPeer.nodeId) {\n return false;\n }\n }\n return true;\n}\nfunction addCapabilities(node, total) {\n if (node.relay)\n total.relay += 1;\n if (node.store)\n total.store += 1;\n if (node.filter)\n total.filter += 1;\n if (node.lightPush)\n total.lightPush += 1;\n}\n/**\n * Checks if the proposed ENR [[node]] helps satisfy the [[wanted]] capabilities,\n * considering the [[actual]] capabilities of nodes retrieved so far..\n *\n * @throws If the function is called when the wanted capabilities are already fulfilled.\n */\nfunction helpsSatisfyCapabilities(node, wanted, actual) {\n if (isSatisfied(wanted, actual)) {\n throw \"Internal Error: Waku2 wanted capabilities are already fulfilled\";\n }\n const missing = missingCapabilities(wanted, actual);\n return ((missing.relay && node.relay) ||\n (missing.store && node.store) ||\n (missing.filter && node.filter) ||\n (missing.lightPush && node.lightPush));\n}\n/**\n * Return a [[Waku2]] Object for which capabilities are set to true if they are\n * [[wanted]] yet missing from [[actual]].\n */\nfunction missingCapabilities(wanted, actual) {\n return {\n relay: actual.relay < wanted.relay,\n store: actual.store < wanted.store,\n filter: actual.filter < wanted.filter,\n lightPush: actual.lightPush < wanted.lightPush,\n };\n}\n//# sourceMappingURL=fetch_nodes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/fetch_nodes.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fetchNodesUntilCapabilitiesFulfilled: () => (/* binding */ fetchNodesUntilCapabilitiesFulfilled),\n/* harmony export */ yieldNodesUntilCapabilitiesFulfilled: () => (/* binding */ yieldNodesUntilCapabilitiesFulfilled)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"discovery:fetch_nodes\");\n/**\n * Fetch nodes using passed [[getNode]] until all wanted capabilities are\n * fulfilled or the number of [[getNode]] call exceeds the sum of\n * [[wantedNodeCapabilityCount]] plus [[errorTolerance]].\n */\nasync function fetchNodesUntilCapabilitiesFulfilled(wantedNodeCapabilityCount, errorTolerance, getNode) {\n const wanted = {\n relay: wantedNodeCapabilityCount.relay ?? 0,\n store: wantedNodeCapabilityCount.store ?? 0,\n filter: wantedNodeCapabilityCount.filter ?? 0,\n lightPush: wantedNodeCapabilityCount.lightPush ?? 0\n };\n const maxSearches = wanted.relay + wanted.store + wanted.filter + wanted.lightPush;\n const actual = {\n relay: 0,\n store: 0,\n filter: 0,\n lightPush: 0\n };\n let totalSearches = 0;\n const peers = [];\n while (!isSatisfied(wanted, actual) &&\n totalSearches < maxSearches + errorTolerance) {\n const peer = await getNode();\n if (peer && isNewPeer(peer, peers)) {\n // ENRs without a waku2 key are ignored.\n if (peer.waku2) {\n if (helpsSatisfyCapabilities(peer.waku2, wanted, actual)) {\n addCapabilities(peer.waku2, actual);\n peers.push(peer);\n }\n }\n log.info(`got new peer candidate from DNS address=${peer.nodeId}@${peer.ip}`);\n }\n totalSearches++;\n }\n return peers;\n}\n/**\n * Fetch nodes using passed [[getNode]] until all wanted capabilities are\n * fulfilled or the number of [[getNode]] call exceeds the sum of\n * [[wantedNodeCapabilityCount]] plus [[errorTolerance]].\n */\nasync function* yieldNodesUntilCapabilitiesFulfilled(wantedNodeCapabilityCount, errorTolerance, getNode) {\n const wanted = {\n relay: wantedNodeCapabilityCount.relay ?? 0,\n store: wantedNodeCapabilityCount.store ?? 0,\n filter: wantedNodeCapabilityCount.filter ?? 0,\n lightPush: wantedNodeCapabilityCount.lightPush ?? 0\n };\n const maxSearches = wanted.relay + wanted.store + wanted.filter + wanted.lightPush;\n const actual = {\n relay: 0,\n store: 0,\n filter: 0,\n lightPush: 0\n };\n let totalSearches = 0;\n const peerNodeIds = new Set();\n while (!isSatisfied(wanted, actual) &&\n totalSearches < maxSearches + errorTolerance) {\n const peer = await getNode();\n if (peer && peer.nodeId && !peerNodeIds.has(peer.nodeId)) {\n peerNodeIds.add(peer.nodeId);\n // ENRs without a waku2 key are ignored.\n if (peer.waku2) {\n if (helpsSatisfyCapabilities(peer.waku2, wanted, actual)) {\n addCapabilities(peer.waku2, actual);\n yield peer;\n }\n }\n log.info(`got new peer candidate from DNS address=${peer.nodeId}@${peer.ip}`);\n }\n totalSearches++;\n }\n}\nfunction isSatisfied(wanted, actual) {\n return (actual.relay >= wanted.relay &&\n actual.store >= wanted.store &&\n actual.filter >= wanted.filter &&\n actual.lightPush >= wanted.lightPush);\n}\nfunction isNewPeer(peer, peers) {\n if (!peer.nodeId)\n return false;\n for (const existingPeer of peers) {\n if (peer.nodeId === existingPeer.nodeId) {\n return false;\n }\n }\n return true;\n}\nfunction addCapabilities(node, total) {\n if (node.relay)\n total.relay += 1;\n if (node.store)\n total.store += 1;\n if (node.filter)\n total.filter += 1;\n if (node.lightPush)\n total.lightPush += 1;\n}\n/**\n * Checks if the proposed ENR [[node]] helps satisfy the [[wanted]] capabilities,\n * considering the [[actual]] capabilities of nodes retrieved so far..\n *\n * @throws If the function is called when the wanted capabilities are already fulfilled.\n */\nfunction helpsSatisfyCapabilities(node, wanted, actual) {\n if (isSatisfied(wanted, actual)) {\n throw \"Internal Error: Waku2 wanted capabilities are already fulfilled\";\n }\n const missing = missingCapabilities(wanted, actual);\n return ((missing.relay && node.relay) ||\n (missing.store && node.store) ||\n (missing.filter && node.filter) ||\n (missing.lightPush && node.lightPush));\n}\n/**\n * Return a [[Waku2]] Object for which capabilities are set to true if they are\n * [[wanted]] yet missing from [[actual]].\n */\nfunction missingCapabilities(wanted, actual) {\n return {\n relay: actual.relay < wanted.relay,\n store: actual.store < wanted.store,\n filter: actual.filter < wanted.filter,\n lightPush: actual.lightPush < wanted.lightPush\n };\n}\n//# sourceMappingURL=fetch_nodes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/dns/fetch_nodes.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/dist/index.js": -/*!********************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/dist/index.js ***! - \********************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsNodeDiscovery: () => (/* reexport safe */ _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery),\n/* harmony export */ PeerDiscoveryDns: () => (/* binding */ PeerDiscoveryDns),\n/* harmony export */ enrTree: () => (/* binding */ enrTree),\n/* harmony export */ wakuDnsDiscovery: () => (/* binding */ wakuDnsDiscovery)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_discovery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-discovery */ \"./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _dns_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dns.js */ \"./node_modules/@waku/dns-discovery/dist/dns.js\");\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:peer-discovery-dns\");\nconst enrTree = {\n TEST: \"enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@test.waku.nodes.status.im\",\n PROD: \"enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.waku.nodes.status.im\",\n};\nconst DEFAULT_BOOTSTRAP_TAG_NAME = \"bootstrap\";\nconst DEFAULT_BOOTSTRAP_TAG_VALUE = 50;\nconst DEFAULT_BOOTSTRAP_TAG_TTL = 100000000;\n/**\n * Parse options and expose function to return bootstrap peer addresses.\n */\nclass PeerDiscoveryDns extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter {\n nextPeer;\n _started;\n _components;\n _options;\n constructor(components, options) {\n super();\n this._started = false;\n this._components = components;\n this._options = options;\n const { enrUrls } = options;\n log(\"Use following EIP-1459 ENR Tree URLs: \", enrUrls);\n }\n /**\n * Start discovery process\n */\n async start() {\n log(\"Starting peer discovery via dns\");\n this._started = true;\n if (this.nextPeer === undefined) {\n let { enrUrls } = this._options;\n if (!Array.isArray(enrUrls))\n enrUrls = [enrUrls];\n const { wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, enrUrls, wantedNodeCapabilityCount);\n }\n for await (const peerEnr of this.nextPeer()) {\n if (!this._started) {\n return;\n }\n const peerInfo = peerEnr.peerInfo;\n if (!peerInfo) {\n continue;\n }\n const tagsToUpdate = {\n tags: {\n [DEFAULT_BOOTSTRAP_TAG_NAME]: {\n value: this._options.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL,\n },\n },\n };\n let isPeerChanged = false;\n const isPeerExists = await this._components.peerStore.has(peerInfo.id);\n if (isPeerExists) {\n const peer = await this._components.peerStore.get(peerInfo.id);\n const hasBootstrapTag = peer.tags.has(DEFAULT_BOOTSTRAP_TAG_NAME);\n if (!hasBootstrapTag) {\n isPeerChanged = true;\n await this._components.peerStore.merge(peerInfo.id, tagsToUpdate);\n }\n }\n else {\n isPeerChanged = true;\n await this._components.peerStore.save(peerInfo.id, tagsToUpdate);\n }\n if (isPeerChanged) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent(\"peer\", { detail: peerInfo }));\n }\n }\n }\n /**\n * Stop emitting events\n */\n stop() {\n this._started = false;\n }\n get [_libp2p_interface_peer_discovery__WEBPACK_IMPORTED_MODULE_0__.peerDiscovery]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrls, wantedNodeCapabilityCount) {\n return (components) => new PeerDiscoveryDns(components, { enrUrls, wantedNodeCapabilityCount });\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/constants.js": -/*!**************************************************!*\ - !*** ./node_modules/@waku/enr/dist/constants.js ***! - \**************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ERR_INVALID_ID: () => (/* binding */ ERR_INVALID_ID),\n/* harmony export */ ERR_NO_SIGNATURE: () => (/* binding */ ERR_NO_SIGNATURE),\n/* harmony export */ MAX_RECORD_SIZE: () => (/* binding */ MAX_RECORD_SIZE),\n/* harmony export */ MULTIADDR_LENGTH_SIZE: () => (/* binding */ MULTIADDR_LENGTH_SIZE)\n/* harmony export */ });\n// Maximum encoded size of an ENR\nconst MAX_RECORD_SIZE = 300;\nconst ERR_INVALID_ID = \"Invalid record id\";\nconst ERR_NO_SIGNATURE = \"No valid signature found\";\n// The maximum length of byte size of a multiaddr to encode in the `multiaddr` field\n// The size is a big endian 16-bit unsigned integer\nconst MULTIADDR_LENGTH_SIZE = 2;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/creator.js": -/*!************************************************!*\ - !*** ./node_modules/@waku/enr/dist/creator.js ***! - \************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EnrCreator: () => (/* binding */ EnrCreator)\n/* harmony export */ });\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/enr/dist/crypto.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/enr/dist/enr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/enr/dist/peer_id.js\");\n\n\n\n\nclass EnrCreator {\n static fromPublicKey(publicKey, kvs = {}) {\n // EIP-778 specifies that the key must be in compressed format, 33 bytes\n if (publicKey.length !== 33) {\n publicKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_1__.compressPublicKey)(publicKey);\n }\n return _enr_js__WEBPACK_IMPORTED_MODULE_2__.ENR.create({\n ...kvs,\n id: (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.utf8ToBytes)(\"v4\"),\n secp256k1: publicKey,\n });\n }\n static async fromPeerId(peerId, kvs = {}) {\n switch (peerId.type) {\n case \"secp256k1\":\n return EnrCreator.fromPublicKey((0,_peer_id_js__WEBPACK_IMPORTED_MODULE_3__.getPublicKeyFromPeerId)(peerId), kvs);\n default:\n throw new Error();\n }\n }\n}\n//# sourceMappingURL=creator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/creator.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/crypto.js": -/*!***********************************************!*\ - !*** ./node_modules/@waku/enr/dist/crypto.js ***! - \***********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compressPublicKey: () => (/* binding */ compressPublicKey),\n/* harmony export */ keccak256: () => (/* binding */ keccak256),\n/* harmony export */ sign: () => (/* binding */ sign),\n/* harmony export */ verifySignature: () => (/* binding */ verifySignature)\n/* harmony export */ });\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var js_sha3__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! js-sha3 */ \"./node_modules/js-sha3/src/sha3.js\");\n\n\n\n/**\n * ECDSA Sign a message with the given private key.\n *\n * @param message The message to sign, usually a hash.\n * @param privateKey The ECDSA private key to use to sign the message.\n *\n * @returns The signature and the recovery id concatenated.\n */\nasync function sign(message, privateKey) {\n const [signature, recoveryId] = await _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.sign(message, privateKey, {\n recovered: true,\n der: false,\n });\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.concat)([signature, new Uint8Array([recoveryId])], signature.length + 1);\n}\nfunction keccak256(input) {\n return new Uint8Array(js_sha3__WEBPACK_IMPORTED_MODULE_2__.keccak256.arrayBuffer(input));\n}\nfunction compressPublicKey(publicKey) {\n if (publicKey.length === 64) {\n publicKey = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.concat)([new Uint8Array([4]), publicKey], 65);\n }\n const point = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Point.fromHex(publicKey);\n return point.toRawBytes(true);\n}\n/**\n * Verify an ECDSA signature.\n */\nfunction verifySignature(signature, message, publicKey) {\n try {\n const _signature = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Signature.fromCompact(signature.slice(0, 64));\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.verify(_signature, message, publicKey);\n }\n catch {\n return false;\n }\n}\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/crypto.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/decoder.js": -/*!************************************************!*\ - !*** ./node_modules/@waku/enr/dist/decoder.js ***! - \************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EnrDecoder: () => (/* binding */ EnrDecoder)\n/* harmony export */ });\n/* harmony import */ var _ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @ethersproject/rlp */ \"./node_modules/@ethersproject/rlp/lib.esm/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/enr/dist/enr.js\");\n\n\n\n\n\nclass EnrDecoder {\n static fromString(encoded) {\n if (!encoded.startsWith(_enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.RECORD_PREFIX)) {\n throw new Error(`\"string encoded ENR must start with '${_enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.RECORD_PREFIX}'`);\n }\n return EnrDecoder.fromRLP((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(encoded.slice(4), \"base64url\"));\n }\n static fromRLP(encoded) {\n const decoded = _ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__.decode(encoded).map(_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.hexToBytes);\n return fromValues(decoded);\n }\n}\nasync function fromValues(values) {\n const { signature, seq, kvs } = checkValues(values);\n const obj = {};\n for (let i = 0; i < kvs.length; i += 2) {\n try {\n obj[(0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.bytesToUtf8)(kvs[i])] = kvs[i + 1];\n }\n catch (e) {\n (0,debug__WEBPACK_IMPORTED_MODULE_1__.log)(\"Failed to decode ENR key to UTF-8, skipping it\", kvs[i], e);\n }\n }\n const _seq = decodeSeq(seq);\n const enr = await _enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.create(obj, _seq, signature);\n checkSignature(seq, kvs, enr, signature);\n return enr;\n}\nfunction decodeSeq(seq) {\n // If seq is an empty array, translate as value 0\n if (!seq.length)\n return BigInt(0);\n return BigInt(\"0x\" + (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.bytesToHex)(seq));\n}\nfunction checkValues(values) {\n if (!Array.isArray(values)) {\n throw new Error(\"Decoded ENR must be an array\");\n }\n if (values.length % 2 !== 0) {\n throw new Error(\"Decoded ENR must have an even number of elements\");\n }\n const [signature, seq, ...kvs] = values;\n if (!signature || Array.isArray(signature)) {\n throw new Error(\"Decoded ENR invalid signature: must be a byte array\");\n }\n if (!seq || Array.isArray(seq)) {\n throw new Error(\"Decoded ENR invalid sequence number: must be a byte array\");\n }\n return { signature, seq, kvs };\n}\nfunction checkSignature(seq, kvs, enr, signature) {\n const rlpEncodedBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.hexToBytes)(_ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__.encode([seq, ...kvs]));\n if (!enr.verify(rlpEncodedBytes, signature)) {\n throw new Error(\"Unable to verify ENR signature\");\n }\n}\n//# sourceMappingURL=decoder.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/decoder.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/enr.js": -/*!********************************************!*\ - !*** ./node_modules/@waku/enr/dist/enr.js ***! - \********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENR: () => (/* binding */ ENR),\n/* harmony export */ TransportProtocol: () => (/* binding */ TransportProtocol),\n/* harmony export */ TransportProtocolPerIpVersion: () => (/* binding */ TransportProtocolPerIpVersion)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/enr/dist/crypto.js\");\n/* harmony import */ var _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./get_multiaddr.js */ \"./node_modules/@waku/enr/dist/get_multiaddr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/enr/dist/peer_id.js\");\n/* harmony import */ var _raw_enr_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./raw_enr.js */ \"./node_modules/@waku/enr/dist/raw_enr.js\");\n/* harmony import */ var _v4_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./v4.js */ \"./node_modules/@waku/enr/dist/v4.js\");\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:enr\");\nvar TransportProtocol;\n(function (TransportProtocol) {\n TransportProtocol[\"TCP\"] = \"tcp\";\n TransportProtocol[\"UDP\"] = \"udp\";\n})(TransportProtocol || (TransportProtocol = {}));\nvar TransportProtocolPerIpVersion;\n(function (TransportProtocolPerIpVersion) {\n TransportProtocolPerIpVersion[\"TCP4\"] = \"tcp4\";\n TransportProtocolPerIpVersion[\"UDP4\"] = \"udp4\";\n TransportProtocolPerIpVersion[\"TCP6\"] = \"tcp6\";\n TransportProtocolPerIpVersion[\"UDP6\"] = \"udp6\";\n})(TransportProtocolPerIpVersion || (TransportProtocolPerIpVersion = {}));\nclass ENR extends _raw_enr_js__WEBPACK_IMPORTED_MODULE_5__.RawEnr {\n static RECORD_PREFIX = \"enr:\";\n peerId;\n static async create(kvs = {}, seq = BigInt(1), signature) {\n const enr = new ENR(kvs, seq, signature);\n try {\n const publicKey = enr.publicKey;\n if (publicKey) {\n enr.peerId = await (0,_peer_id_js__WEBPACK_IMPORTED_MODULE_4__.createPeerIdFromPublicKey)(publicKey);\n }\n }\n catch (e) {\n log(\"Could not calculate peer id for ENR\", e);\n }\n return enr;\n }\n get nodeId() {\n switch (this.id) {\n case \"v4\":\n return this.publicKey ? _v4_js__WEBPACK_IMPORTED_MODULE_6__.nodeId(this.publicKey) : undefined;\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n }\n getLocationMultiaddr = _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__.locationMultiaddrFromEnrFields.bind({}, this);\n setLocationMultiaddr(multiaddr) {\n const protoNames = multiaddr.protoNames();\n if (protoNames.length !== 2 &&\n protoNames[1] !== \"udp\" &&\n protoNames[1] !== \"tcp\") {\n throw new Error(\"Invalid multiaddr\");\n }\n const tuples = multiaddr.tuples();\n if (!tuples[0][1] || !tuples[1][1]) {\n throw new Error(\"Invalid multiaddr\");\n }\n // IPv4\n if (tuples[0][0] === 4) {\n this.set(\"ip\", tuples[0][1]);\n this.set(protoNames[1], tuples[1][1]);\n }\n else {\n this.set(\"ip6\", tuples[0][1]);\n this.set(protoNames[1] + \"6\", tuples[1][1]);\n }\n }\n getAllLocationMultiaddrs() {\n const multiaddrs = [];\n for (const protocol of Object.values(TransportProtocolPerIpVersion)) {\n const ma = this.getLocationMultiaddr(protocol);\n if (ma)\n multiaddrs.push(ma);\n }\n const _multiaddrs = this.multiaddrs ?? [];\n return multiaddrs.concat(_multiaddrs);\n }\n get peerInfo() {\n const id = this.peerId;\n if (!id)\n return;\n return {\n id,\n multiaddrs: this.getAllLocationMultiaddrs(),\n protocols: [],\n };\n }\n /**\n * Returns the full multiaddr from the ENR fields matching the provided\n * `protocol` parameter.\n * To return full multiaddrs from the `multiaddrs` ENR field,\n * use { @link ENR.getFullMultiaddrs }.\n *\n * @param protocol\n */\n getFullMultiaddr(protocol) {\n if (this.peerId) {\n const locationMultiaddr = this.getLocationMultiaddr(protocol);\n if (locationMultiaddr) {\n return locationMultiaddr.encapsulate(`/p2p/${this.peerId.toString()}`);\n }\n }\n return;\n }\n /**\n * Returns the full multiaddrs from the `multiaddrs` ENR field.\n */\n getFullMultiaddrs() {\n if (this.peerId && this.multiaddrs) {\n const peerId = this.peerId;\n return this.multiaddrs.map((ma) => {\n return ma.encapsulate(`/p2p/${peerId.toString()}`);\n });\n }\n return [];\n }\n verify(data, signature) {\n if (!this.get(\"id\") || this.id !== \"v4\") {\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n if (!this.publicKey) {\n throw new Error(\"Failed to verify ENR: No public key\");\n }\n return (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.verifySignature)(signature, (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(data), this.publicKey);\n }\n async sign(data, privateKey) {\n switch (this.id) {\n case \"v4\":\n this.signature = await _v4_js__WEBPACK_IMPORTED_MODULE_6__.sign(privateKey, data);\n break;\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n return this.signature;\n }\n}\n\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/enr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/get_multiaddr.js": -/*!******************************************************!*\ - !*** ./node_modules/@waku/enr/dist/get_multiaddr.js ***! - \******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ locationMultiaddrFromEnrFields: () => (/* binding */ locationMultiaddrFromEnrFields)\n/* harmony export */ });\n/* harmony import */ var _multiaddr_from_fields_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./multiaddr_from_fields.js */ \"./node_modules/@waku/enr/dist/multiaddr_from_fields.js\");\n\nfunction locationMultiaddrFromEnrFields(enr, protocol) {\n switch (protocol) {\n case \"udp\":\n return (locationMultiaddrFromEnrFields(enr, \"udp4\") ||\n locationMultiaddrFromEnrFields(enr, \"udp6\"));\n case \"tcp\":\n return (locationMultiaddrFromEnrFields(enr, \"tcp4\") ||\n locationMultiaddrFromEnrFields(enr, \"tcp6\"));\n }\n const isIpv6 = protocol.endsWith(\"6\");\n const ipVal = enr.get(isIpv6 ? \"ip6\" : \"ip\");\n if (!ipVal)\n return;\n const protoName = protocol.slice(0, 3);\n let protoVal;\n switch (protoName) {\n case \"udp\":\n protoVal = isIpv6 ? enr.get(\"udp6\") : enr.get(\"udp\");\n break;\n case \"tcp\":\n protoVal = isIpv6 ? enr.get(\"tcp6\") : enr.get(\"tcp\");\n break;\n default:\n return;\n }\n if (!protoVal)\n return;\n return (0,_multiaddr_from_fields_js__WEBPACK_IMPORTED_MODULE_0__.multiaddrFromFields)(isIpv6 ? \"ip6\" : \"ip4\", protoName, ipVal, protoVal);\n}\n//# sourceMappingURL=get_multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/get_multiaddr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/index.js": -/*!**********************************************!*\ - !*** ./node_modules/@waku/enr/dist/index.js ***! - \**********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENR: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR),\n/* harmony export */ ERR_INVALID_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_ID),\n/* harmony export */ ERR_NO_SIGNATURE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_NO_SIGNATURE),\n/* harmony export */ EnrCreator: () => (/* reexport safe */ _creator_js__WEBPACK_IMPORTED_MODULE_1__.EnrCreator),\n/* harmony export */ EnrDecoder: () => (/* reexport safe */ _decoder_js__WEBPACK_IMPORTED_MODULE_2__.EnrDecoder),\n/* harmony export */ MAX_RECORD_SIZE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.MAX_RECORD_SIZE),\n/* harmony export */ MULTIADDR_LENGTH_SIZE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.MULTIADDR_LENGTH_SIZE),\n/* harmony export */ TransportProtocol: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.TransportProtocol),\n/* harmony export */ TransportProtocolPerIpVersion: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.TransportProtocolPerIpVersion),\n/* harmony export */ compressPublicKey: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.compressPublicKey),\n/* harmony export */ createPeerIdFromPublicKey: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.createPeerIdFromPublicKey),\n/* harmony export */ decodeWaku2: () => (/* reexport safe */ _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.decodeWaku2),\n/* harmony export */ encodeWaku2: () => (/* reexport safe */ _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.encodeWaku2),\n/* harmony export */ getPrivateKeyFromPeerId: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.getPrivateKeyFromPeerId),\n/* harmony export */ getPublicKeyFromPeerId: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.getPublicKeyFromPeerId),\n/* harmony export */ keccak256: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.keccak256),\n/* harmony export */ sign: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.sign),\n/* harmony export */ verifySignature: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.verifySignature)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _creator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./creator.js */ \"./node_modules/@waku/enr/dist/creator.js\");\n/* harmony import */ var _decoder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./decoder.js */ \"./node_modules/@waku/enr/dist/decoder.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/enr/dist/enr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/enr/dist/peer_id.js\");\n/* harmony import */ var _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./waku2_codec.js */ \"./node_modules/@waku/enr/dist/waku2_codec.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/enr/dist/crypto.js\");\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/multiaddr_from_fields.js": -/*!**************************************************************!*\ - !*** ./node_modules/@waku/enr/dist/multiaddr_from_fields.js ***! - \**************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrFromFields: () => (/* binding */ multiaddrFromFields)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n\n\nfunction multiaddrFromFields(ipFamily, protocol, ipBytes, protocolBytes) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(\"/\" + ipFamily + \"/\" + (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__.convertToString)(ipFamily, ipBytes));\n ma = ma.encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(\"/\" + protocol + \"/\" + (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__.convertToString)(protocol, protocolBytes)));\n return ma;\n}\n//# sourceMappingURL=multiaddr_from_fields.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/multiaddr_from_fields.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/multiaddrs_codec.js": -/*!*********************************************************!*\ - !*** ./node_modules/@waku/enr/dist/multiaddrs_codec.js ***! - \*********************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeMultiaddrs: () => (/* binding */ decodeMultiaddrs),\n/* harmony export */ encodeMultiaddrs: () => (/* binding */ encodeMultiaddrs)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/enr/dist/constants.js\");\n\n\nfunction decodeMultiaddrs(bytes) {\n const multiaddrs = [];\n let index = 0;\n while (index < bytes.length) {\n const sizeDataView = new DataView(bytes.buffer, index, _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE);\n const size = sizeDataView.getUint16(0);\n index += _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE;\n const multiaddrBytes = bytes.slice(index, index + size);\n index += size;\n multiaddrs.push((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(multiaddrBytes));\n }\n return multiaddrs;\n}\nfunction encodeMultiaddrs(multiaddrs) {\n const totalLength = multiaddrs.reduce((acc, ma) => acc + _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE + ma.bytes.length, 0);\n const bytes = new Uint8Array(totalLength);\n const dataView = new DataView(bytes.buffer);\n let index = 0;\n multiaddrs.forEach((multiaddr) => {\n if (multiaddr.getPeerId())\n throw new Error(\"`multiaddr` field MUST not contain peer id\");\n // Prepend the size of the next entry\n dataView.setUint16(index, multiaddr.bytes.length);\n index += _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE;\n bytes.set(multiaddr.bytes, index);\n index += multiaddr.bytes.length;\n });\n return bytes;\n}\n//# sourceMappingURL=multiaddrs_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/multiaddrs_codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/peer_id.js": -/*!************************************************!*\ - !*** ./node_modules/@waku/enr/dist/peer_id.js ***! - \************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerIdFromPublicKey: () => (/* binding */ createPeerIdFromPublicKey),\n/* harmony export */ getPrivateKeyFromPeerId: () => (/* binding */ getPrivateKeyFromPeerId),\n/* harmony export */ getPublicKeyFromPeerId: () => (/* binding */ getPublicKeyFromPeerId)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\nfunction createPeerIdFromPublicKey(publicKey) {\n const _publicKey = new _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.supportedKeys.secp256k1.Secp256k1PublicKey(publicKey);\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)(_publicKey.bytes, undefined);\n}\nfunction getPublicKeyFromPeerId(peerId) {\n if (peerId.type !== \"secp256k1\") {\n throw new Error(\"Unsupported peer id type\");\n }\n return (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(peerId.publicKey).marshal();\n}\n// Only used in tests\nasync function getPrivateKeyFromPeerId(peerId) {\n if (peerId.type !== \"secp256k1\") {\n throw new Error(\"Unsupported peer id type\");\n }\n if (!peerId.privateKey) {\n throw new Error(\"Private key not present on peer id\");\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n return privateKey.marshal();\n}\n//# sourceMappingURL=peer_id.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/peer_id.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/raw_enr.js": -/*!************************************************!*\ - !*** ./node_modules/@waku/enr/dist/raw_enr.js ***! - \************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RawEnr: () => (/* binding */ RawEnr)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./multiaddrs_codec.js */ \"./node_modules/@waku/enr/dist/multiaddrs_codec.js\");\n/* harmony import */ var _waku2_codec_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./waku2_codec.js */ \"./node_modules/@waku/enr/dist/waku2_codec.js\");\n\n\n\n\n\nclass RawEnr extends Map {\n seq;\n signature;\n constructor(kvs = {}, seq = BigInt(1), signature) {\n super(Object.entries(kvs));\n this.seq = seq;\n this.signature = signature;\n }\n set(k, v) {\n this.signature = undefined;\n this.seq++;\n return super.set(k, v);\n }\n get id() {\n const id = this.get(\"id\");\n if (!id)\n throw new Error(\"id not found.\");\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8)(id);\n }\n get publicKey() {\n switch (this.id) {\n case \"v4\":\n return this.get(\"secp256k1\");\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_2__.ERR_INVALID_ID);\n }\n }\n get ip() {\n return getStringValue(this, \"ip\", \"ip4\");\n }\n set ip(ip) {\n setStringValue(this, \"ip\", \"ip4\", ip);\n }\n get tcp() {\n return getNumberAsStringValue(this, \"tcp\", \"tcp\");\n }\n set tcp(port) {\n setNumberAsStringValue(this, \"tcp\", \"tcp\", port);\n }\n get udp() {\n return getNumberAsStringValue(this, \"udp\", \"udp\");\n }\n set udp(port) {\n setNumberAsStringValue(this, \"udp\", \"udp\", port);\n }\n get ip6() {\n return getStringValue(this, \"ip6\", \"ip6\");\n }\n set ip6(ip) {\n setStringValue(this, \"ip6\", \"ip6\", ip);\n }\n get tcp6() {\n return getNumberAsStringValue(this, \"tcp6\", \"tcp\");\n }\n set tcp6(port) {\n setNumberAsStringValue(this, \"tcp6\", \"tcp\", port);\n }\n get udp6() {\n return getNumberAsStringValue(this, \"udp6\", \"udp\");\n }\n set udp6(port) {\n setNumberAsStringValue(this, \"udp6\", \"udp\", port);\n }\n /**\n * Get the `multiaddrs` field from ENR.\n *\n * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.\n * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host\n * address (e.g. `dns4`, `dnsaddr`, etc)..\n *\n * If the peer information only contains information that can be represented with the ENR pre-defined keys\n * (ip, tcp, etc) then the usage of { @link ENR.getLocationMultiaddr } should be preferred.\n *\n * The multiaddresses stored in this field are expected to be location multiaddresses, ie, peer id less.\n */\n get multiaddrs() {\n const raw = this.get(\"multiaddrs\");\n if (raw)\n return (0,_multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_3__.decodeMultiaddrs)(raw);\n return;\n }\n /**\n * Set the `multiaddrs` field on the ENR.\n *\n * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.\n * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host\n * address (e.g. `dns4`, `dnsaddr`, etc)..\n *\n * If the peer information only contains information that can be represented with the ENR pre-defined keys\n * (ip, tcp, etc) then the usage of { @link ENR.setLocationMultiaddr } should be preferred.\n * The multiaddresses stored in this field must be location multiaddresses,\n * ie, without a peer id.\n */\n set multiaddrs(multiaddrs) {\n deleteUndefined(this, \"multiaddrs\", multiaddrs, _multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_3__.encodeMultiaddrs);\n }\n /**\n * Get the `waku2` field from ENR.\n */\n get waku2() {\n const raw = this.get(\"waku2\");\n if (raw)\n return (0,_waku2_codec_js__WEBPACK_IMPORTED_MODULE_4__.decodeWaku2)(raw[0]);\n return;\n }\n /**\n * Set the `waku2` field on the ENR.\n */\n set waku2(waku2) {\n deleteUndefined(this, \"waku2\", waku2, (w) => new Uint8Array([(0,_waku2_codec_js__WEBPACK_IMPORTED_MODULE_4__.encodeWaku2)(w)]));\n }\n}\nfunction getStringValue(map, key, proto) {\n const raw = map.get(key);\n if (!raw)\n return;\n return (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto, raw);\n}\nfunction getNumberAsStringValue(map, key, proto) {\n const raw = map.get(key);\n if (!raw)\n return;\n return Number((0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto, raw));\n}\nfunction setStringValue(map, key, proto, value) {\n deleteUndefined(map, key, value, _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToBytes.bind({}, proto));\n}\nfunction setNumberAsStringValue(map, key, proto, value) {\n setStringValue(map, key, proto, value?.toString(10));\n}\nfunction deleteUndefined(map, key, value, transform) {\n if (value !== undefined) {\n map.set(key, transform(value));\n }\n else {\n map.delete(key);\n }\n}\n//# sourceMappingURL=raw_enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/raw_enr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/v4.js": -/*!*******************************************!*\ - !*** ./node_modules/@waku/enr/dist/v4.js ***! - \*******************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ nodeId: () => (/* binding */ nodeId),\n/* harmony export */ sign: () => (/* binding */ sign)\n/* harmony export */ });\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/enr/dist/crypto.js\");\n\n\n\nasync function sign(privKey, msg) {\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.sign((0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(msg), privKey, {\n der: false,\n });\n}\nfunction nodeId(pubKey) {\n const publicKey = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Point.fromHex(pubKey);\n const uncompressedPubkey = publicKey.toRawBytes(false);\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)((0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(uncompressedPubkey.slice(1)));\n}\n//# sourceMappingURL=v4.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/v4.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/dist/waku2_codec.js": +/***/ "./node_modules/@waku/discovery/dist/index.js": /*!****************************************************!*\ - !*** ./node_modules/@waku/enr/dist/waku2_codec.js ***! + !*** ./node_modules/@waku/discovery/dist/index.js ***! \****************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeWaku2: () => (/* binding */ decodeWaku2),\n/* harmony export */ encodeWaku2: () => (/* binding */ encodeWaku2)\n/* harmony export */ });\nfunction encodeWaku2(protocols) {\n let byte = 0;\n if (protocols.lightPush)\n byte += 1;\n byte = byte << 1;\n if (protocols.filter)\n byte += 1;\n byte = byte << 1;\n if (protocols.store)\n byte += 1;\n byte = byte << 1;\n if (protocols.relay)\n byte += 1;\n return byte;\n}\nfunction decodeWaku2(byte) {\n const waku2 = {\n relay: false,\n store: false,\n filter: false,\n lightPush: false,\n };\n if (byte % 2)\n waku2.relay = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.store = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.filter = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.lightPush = true;\n return waku2;\n}\n//# sourceMappingURL=waku2_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/enr/dist/waku2_codec.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DnsNodeDiscovery: () => (/* reexport safe */ _dns_dns_js__WEBPACK_IMPORTED_MODULE_2__.DnsNodeDiscovery),\n/* harmony export */ LocalPeerCacheDiscovery: () => (/* reexport safe */ _local_peer_cache_index_js__WEBPACK_IMPORTED_MODULE_5__.LocalPeerCacheDiscovery),\n/* harmony export */ PeerDiscoveryDns: () => (/* reexport safe */ _dns_dns_discovery_js__WEBPACK_IMPORTED_MODULE_0__.PeerDiscoveryDns),\n/* harmony export */ PeerExchangeCodec: () => (/* reexport safe */ _peer_exchange_waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_3__.PeerExchangeCodec),\n/* harmony export */ PeerExchangeDiscovery: () => (/* reexport safe */ _peer_exchange_waku_peer_exchange_discovery_js__WEBPACK_IMPORTED_MODULE_4__.PeerExchangeDiscovery),\n/* harmony export */ WakuPeerExchange: () => (/* reexport safe */ _peer_exchange_waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_3__.WakuPeerExchange),\n/* harmony export */ enrTree: () => (/* reexport safe */ _dns_constants_js__WEBPACK_IMPORTED_MODULE_1__.enrTree),\n/* harmony export */ wakuDnsDiscovery: () => (/* reexport safe */ _dns_dns_discovery_js__WEBPACK_IMPORTED_MODULE_0__.wakuDnsDiscovery),\n/* harmony export */ wakuLocalPeerCacheDiscovery: () => (/* reexport safe */ _local_peer_cache_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuLocalPeerCacheDiscovery),\n/* harmony export */ wakuPeerExchange: () => (/* reexport safe */ _peer_exchange_waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_3__.wakuPeerExchange),\n/* harmony export */ wakuPeerExchangeDiscovery: () => (/* reexport safe */ _peer_exchange_waku_peer_exchange_discovery_js__WEBPACK_IMPORTED_MODULE_4__.wakuPeerExchangeDiscovery)\n/* harmony export */ });\n/* harmony import */ var _dns_dns_discovery_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dns/dns_discovery.js */ \"./node_modules/@waku/discovery/dist/dns/dns_discovery.js\");\n/* harmony import */ var _dns_constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dns/constants.js */ \"./node_modules/@waku/discovery/dist/dns/constants.js\");\n/* harmony import */ var _dns_dns_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dns/dns.js */ \"./node_modules/@waku/discovery/dist/dns/dns.js\");\n/* harmony import */ var _peer_exchange_waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-exchange/waku_peer_exchange.js */ \"./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange.js\");\n/* harmony import */ var _peer_exchange_waku_peer_exchange_discovery_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer-exchange/waku_peer_exchange_discovery.js */ \"./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange_discovery.js\");\n/* harmony import */ var _local_peer_cache_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./local-peer-cache/index.js */ \"./node_modules/@waku/discovery/dist/local-peer-cache/index.js\");\n// DNS Discovery\n\n\n\n// Peer Exchange Discovery\n\n\n// Local Peer Cache Discovery\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/local-peer-cache/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/local-peer-cache/index.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_LOCAL_TAG_NAME: () => (/* binding */ DEFAULT_LOCAL_TAG_NAME),\n/* harmony export */ LocalPeerCacheDiscovery: () => (/* binding */ LocalPeerCacheDiscovery),\n/* harmony export */ wakuLocalPeerCacheDiscovery: () => (/* binding */ wakuLocalPeerCacheDiscovery)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"peer-exchange-discovery\");\nconst DEFAULT_LOCAL_TAG_NAME = _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.LOCAL;\nconst DEFAULT_LOCAL_TAG_VALUE = 50;\nconst DEFAULT_LOCAL_TAG_TTL = 100_000_000;\nclass LocalPeerCacheDiscovery extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.TypedEventEmitter {\n components;\n options;\n isStarted;\n peers = [];\n constructor(components, options) {\n super();\n this.components = components;\n this.options = options;\n this.isStarted = false;\n this.peers = this.getPeersFromLocalStorage();\n }\n get [Symbol.toStringTag]() {\n return \"@waku/local-peer-cache-discovery\";\n }\n async start() {\n if (this.isStarted)\n return;\n log.info(\"Starting Local Storage Discovery\");\n this.components.events.addEventListener(\"peer:identify\", this.handleNewPeers);\n for (const { id: idStr, address } of this.peers) {\n const peerId = await (0,_libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_4__.createFromJSON)({ id: idStr });\n if (await this.components.peerStore.has(peerId))\n continue;\n await this.components.peerStore.save(peerId, {\n multiaddrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(address)],\n tags: {\n [this.options?.tagName ?? DEFAULT_LOCAL_TAG_NAME]: {\n value: this.options?.tagValue ?? DEFAULT_LOCAL_TAG_VALUE,\n ttl: this.options?.tagTTL ?? DEFAULT_LOCAL_TAG_TTL\n }\n }\n });\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(\"peer\", {\n detail: {\n id: peerId,\n multiaddrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(address)]\n }\n }));\n }\n log.info(`Discovered ${this.peers.length} peers`);\n this.isStarted = true;\n }\n stop() {\n if (!this.isStarted)\n return;\n log.info(\"Stopping Local Storage Discovery\");\n this.components.events.removeEventListener(\"peer:identify\", this.handleNewPeers);\n this.isStarted = false;\n this.savePeersToLocalStorage();\n }\n handleNewPeers = (event) => {\n const { peerId, listenAddrs } = event.detail;\n const websocketMultiaddr = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.getWsMultiaddrFromMultiaddrs)(listenAddrs);\n const localStoragePeers = this.getPeersFromLocalStorage();\n const existingPeerIndex = localStoragePeers.findIndex((_peer) => _peer.id === peerId.toString());\n if (existingPeerIndex >= 0) {\n localStoragePeers[existingPeerIndex].address =\n websocketMultiaddr.toString();\n }\n else {\n localStoragePeers.push({\n id: peerId.toString(),\n address: websocketMultiaddr.toString()\n });\n }\n this.peers = localStoragePeers;\n this.savePeersToLocalStorage();\n };\n getPeersFromLocalStorage() {\n try {\n const storedPeersData = localStorage.getItem(\"waku:peers\");\n if (!storedPeersData)\n return [];\n const peers = JSON.parse(storedPeersData);\n return peers.filter(isValidStoredPeer);\n }\n catch (error) {\n log.error(\"Error parsing peers from local storage:\", error);\n return [];\n }\n }\n savePeersToLocalStorage() {\n try {\n localStorage.setItem(\"waku:peers\", JSON.stringify(this.peers));\n }\n catch (error) {\n log.error(\"Error saving peers to local storage:\", error);\n }\n }\n}\nfunction isValidStoredPeer(peer) {\n return (peer &&\n typeof peer === \"object\" &&\n typeof peer.id === \"string\" &&\n typeof peer.address === \"string\");\n}\nfunction wakuLocalPeerCacheDiscovery() {\n return (components, options) => new LocalPeerCacheDiscovery(components, options);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/local-peer-cache/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/peer-exchange/rpc.js": +/*!****************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/peer-exchange/rpc.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/index.js\");\n\n/**\n * PeerExchangeRPC represents a message conforming to the Waku Peer Exchange protocol\n */\nclass PeerExchangeRPC {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(params) {\n const { numPeers } = params;\n return new PeerExchangeRPC({\n query: {\n numPeers: numPeers\n },\n response: undefined\n });\n }\n /**\n * Encode the current PeerExchangeRPC request to bytes\n * @returns Uint8Array\n */\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_peer_exchange.PeerExchangeRPC.encode(this.proto);\n }\n /**\n * Decode the current PeerExchangeRPC request to bytes\n * @returns Uint8Array\n */\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_peer_exchange.PeerExchangeRPC.decode(bytes);\n return new PeerExchangeRPC(res);\n }\n get query() {\n return this.proto.query;\n }\n get response() {\n return this.proto.response;\n }\n}\n//# sourceMappingURL=rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/peer-exchange/rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeCodec: () => (/* binding */ PeerExchangeCodec),\n/* harmony export */ WakuPeerExchange: () => (/* binding */ WakuPeerExchange),\n/* harmony export */ wakuPeerExchange: () => (/* binding */ wakuPeerExchange)\n/* harmony export */ });\n/* harmony import */ var _waku_core_lib_base_protocol__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core/lib/base_protocol */ \"./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rpc.js */ \"./node_modules/@waku/discovery/dist/peer-exchange/rpc.js\");\n\n\n\n\n\n\n\n\n\n\nconst PeerExchangeCodec = \"/vac/waku/peer-exchange/2.0.0-alpha1\";\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_3__.Logger(\"peer-exchange\");\n/**\n * Implementation of the Peer Exchange protocol (https://rfc.vac.dev/spec/34/)\n */\nclass WakuPeerExchange extends _waku_core_lib_base_protocol__WEBPACK_IMPORTED_MODULE_0__.BaseProtocol {\n /**\n * @param components - libp2p components\n */\n constructor(components, pubsubTopics) {\n super(PeerExchangeCodec, components, log, pubsubTopics);\n }\n /**\n * Make a peer exchange query to a peer\n */\n async query(params) {\n const { numPeers } = params;\n const rpcQuery = _rpc_js__WEBPACK_IMPORTED_MODULE_8__.PeerExchangeRPC.createRequest({\n numPeers: BigInt(numPeers)\n });\n const peer = await this.peerStore.get(params.peerId);\n if (!peer) {\n return {\n peerInfos: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.ProtocolError.NO_PEER_AVAILABLE\n };\n }\n const stream = await this.getStream(peer);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)([rpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n try {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const { response } = _rpc_js__WEBPACK_IMPORTED_MODULE_8__.PeerExchangeRPC.decode(bytes);\n if (!response) {\n log.error(\"PeerExchangeRPC message did not contains a `response` field\");\n return {\n peerInfos: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.ProtocolError.EMPTY_PAYLOAD\n };\n }\n const peerInfos = await Promise.all(response.peerInfos\n .map((peerInfo) => peerInfo.enr)\n .filter(_waku_utils__WEBPACK_IMPORTED_MODULE_3__.isDefined)\n .map(async (enr) => {\n return { ENR: await _waku_enr__WEBPACK_IMPORTED_MODULE_1__.EnrDecoder.fromRLP(enr) };\n }));\n return {\n peerInfos,\n error: null\n };\n }\n catch (err) {\n log.error(\"Failed to decode push reply\", err);\n return {\n peerInfos: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.ProtocolError.DECODE_FAILED\n };\n }\n }\n}\n/**\n *\n * @returns A function that creates a new peer exchange protocol\n */\nfunction wakuPeerExchange(pubsubTopics) {\n return (components) => new WakuPeerExchange(components, pubsubTopics);\n}\n//# sourceMappingURL=waku_peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange_discovery.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange_discovery.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_PEER_EXCHANGE_TAG_NAME: () => (/* binding */ DEFAULT_PEER_EXCHANGE_TAG_NAME),\n/* harmony export */ PeerExchangeDiscovery: () => (/* binding */ PeerExchangeDiscovery),\n/* harmony export */ wakuPeerExchangeDiscovery: () => (/* binding */ wakuPeerExchangeDiscovery)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./waku_peer_exchange.js */ \"./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange.js\");\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"peer-exchange-discovery\");\nconst DEFAULT_PEER_EXCHANGE_REQUEST_NODES = 10;\nconst DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS = 10 * 1000;\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_PEER_EXCHANGE_TAG_NAME = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.PEER_EXCHANGE;\nconst DEFAULT_PEER_EXCHANGE_TAG_VALUE = 50;\nconst DEFAULT_PEER_EXCHANGE_TAG_TTL = 100_000_000;\nclass PeerExchangeDiscovery extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.TypedEventEmitter {\n components;\n peerExchange;\n options;\n isStarted;\n queryingPeers = new Set();\n queryAttempts = new Map();\n handleDiscoveredPeer = (event) => {\n const { protocols, peerId } = event.detail;\n if (!protocols.includes(_waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_2__.PeerExchangeCodec) ||\n this.queryingPeers.has(peerId.toString()))\n return;\n this.queryingPeers.add(peerId.toString());\n this.startRecurringQueries(peerId).catch((error) => log.error(`Error querying peer ${error}`));\n };\n constructor(components, pubsubTopics, options = {}) {\n super();\n this.components = components;\n this.peerExchange = new _waku_peer_exchange_js__WEBPACK_IMPORTED_MODULE_2__.WakuPeerExchange(components, pubsubTopics);\n this.options = options;\n this.isStarted = false;\n }\n /**\n * Start emitting events\n */\n start() {\n if (this.isStarted) {\n return;\n }\n log.info(\"Starting peer exchange node discovery, discovering peers\");\n // might be better to use \"peer:identify\" or \"peer:update\"\n this.components.events.addEventListener(\"peer:identify\", this.handleDiscoveredPeer);\n }\n /**\n * Remove event listener\n */\n stop() {\n if (!this.isStarted)\n return;\n log.info(\"Stopping peer exchange node discovery\");\n this.isStarted = false;\n this.queryingPeers.clear();\n this.components.events.removeEventListener(\"peer:identify\", this.handleDiscoveredPeer);\n }\n get [_libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.peerDiscoverySymbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/peer-exchange\";\n }\n startRecurringQueries = async (peerId) => {\n const peerIdStr = peerId.toString();\n const { queryInterval = DEFAULT_PEER_EXCHANGE_QUERY_INTERVAL_MS, maxRetries = DEFAULT_MAX_RETRIES } = this.options;\n log.info(`Querying peer: ${peerIdStr} (attempt ${this.queryAttempts.get(peerIdStr) ?? 1})`);\n await this.query(peerId);\n const currentAttempt = this.queryAttempts.get(peerIdStr) ?? 1;\n if (currentAttempt > maxRetries) {\n this.abortQueriesForPeer(peerIdStr);\n return;\n }\n setTimeout(() => {\n this.queryAttempts.set(peerIdStr, currentAttempt + 1);\n this.startRecurringQueries(peerId).catch((error) => {\n log.error(`Error in startRecurringQueries: ${error}`);\n });\n }, queryInterval * currentAttempt);\n };\n async query(peerId) {\n const { error, peerInfos } = await this.peerExchange.query({\n numPeers: DEFAULT_PEER_EXCHANGE_REQUEST_NODES,\n peerId\n });\n if (error) {\n log.error(\"Peer exchange query failed\", error);\n return { error, peerInfos: null };\n }\n for (const _peerInfo of peerInfos) {\n const { ENR } = _peerInfo;\n if (!ENR) {\n log.warn(\"No ENR in peerInfo object, skipping\");\n continue;\n }\n const { peerId, peerInfo, shardInfo } = ENR;\n if (!peerId || !peerInfo) {\n continue;\n }\n const hasPeer = await this.components.peerStore.has(peerId);\n if (hasPeer) {\n continue;\n }\n // update the tags for the peer\n await this.components.peerStore.save(peerId, {\n tags: {\n [DEFAULT_PEER_EXCHANGE_TAG_NAME]: {\n value: this.options.tagValue ?? DEFAULT_PEER_EXCHANGE_TAG_VALUE,\n ttl: this.options.tagTTL ?? DEFAULT_PEER_EXCHANGE_TAG_TTL\n }\n },\n ...(shardInfo && {\n metadata: {\n shardInfo: (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.encodeRelayShard)(shardInfo)\n }\n })\n });\n log.info(`Discovered peer: ${peerId.toString()}`);\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(\"peer\", {\n detail: {\n id: peerId,\n multiaddrs: peerInfo.multiaddrs\n }\n }));\n }\n return { error: null, peerInfos };\n }\n abortQueriesForPeer(peerIdStr) {\n log.info(`Aborting queries for peer: ${peerIdStr}`);\n this.queryingPeers.delete(peerIdStr);\n this.queryAttempts.delete(peerIdStr);\n }\n}\nfunction wakuPeerExchangeDiscovery(pubsubTopics) {\n return (components) => new PeerExchangeDiscovery(components, pubsubTopics);\n}\n//# sourceMappingURL=waku_peer_exchange_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/dist/peer-exchange/waku_peer_exchange_discovery.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/base_protocol.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/base_protocol.js ***! + \****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseProtocol: () => (/* binding */ BaseProtocol)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n/* harmony import */ var _filterPeers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filterPeers.js */ \"./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/filterPeers.js\");\n/* harmony import */ var _stream_manager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream_manager.js */ \"./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/stream_manager.js\");\n\n\n\n\n/**\n * A class with predefined helpers, to be used as a base to implement Waku\n * Protocols.\n */\nclass BaseProtocol {\n multicodec;\n components;\n log;\n pubsubTopics;\n options;\n addLibp2pEventListener;\n removeLibp2pEventListener;\n streamManager;\n constructor(multicodec, components, log, pubsubTopics, options) {\n this.multicodec = multicodec;\n this.components = components;\n this.log = log;\n this.pubsubTopics = pubsubTopics;\n this.options = options;\n this.addLibp2pEventListener = components.events.addEventListener.bind(components.events);\n this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);\n this.streamManager = new _stream_manager_js__WEBPACK_IMPORTED_MODULE_3__.StreamManager(multicodec, components.connectionManager.getConnections.bind(components.connectionManager), this.addLibp2pEventListener);\n }\n async getStream(peer) {\n return this.streamManager.getStream(peer);\n }\n get peerStore() {\n return this.components.peerStore;\n }\n /**\n * Returns known peers from the address book (`libp2p.peerStore`) that support\n * the class protocol. Waku may or may not be currently connected to these\n * peers.\n */\n async allPeers() {\n return (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.getPeersForProtocol)(this.peerStore, [this.multicodec]);\n }\n async connectedPeers() {\n const peers = await this.allPeers();\n return peers.filter((peer) => {\n return (this.components.connectionManager.getConnections(peer.id).length > 0);\n });\n }\n /**\n * Retrieves a list of connected peers that support the protocol. The list is sorted by latency.\n *\n * @param numPeers - The total number of peers to retrieve. If 0, all peers are returned.\n * @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.\n \n * @returns A list of peers that support the protocol sorted by latency.\n */\n async getPeers({ numPeers, maxBootstrapPeers } = {\n maxBootstrapPeers: 1,\n numPeers: 0\n }) {\n // Retrieve all connected peers that support the protocol & shard (if configured)\n const connectedPeersForProtocolAndShard = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.getConnectedPeersForProtocolAndShard)(this.components.connectionManager.getConnections(), this.peerStore, [this.multicodec], this.options?.shardInfo\n ? (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.ensureShardingConfigured)(this.options.shardInfo).shardInfo\n : undefined);\n // Filter the peers based on discovery & number of peers requested\n const filteredPeers = (0,_filterPeers_js__WEBPACK_IMPORTED_MODULE_2__.filterPeersByDiscovery)(connectedPeersForProtocolAndShard, numPeers, maxBootstrapPeers);\n // Sort the peers by latency\n const sortedFilteredPeers = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.sortPeersByLatency)(this.peerStore, filteredPeers);\n if (sortedFilteredPeers.length === 0) {\n this.log.warn(\"No peers found. Ensure you have a connection to the network.\");\n }\n if (sortedFilteredPeers.length < numPeers) {\n this.log.warn(`Only ${sortedFilteredPeers.length} peers found. Requested ${numPeers}.`);\n }\n return sortedFilteredPeers;\n }\n}\n//# sourceMappingURL=base_protocol.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/base_protocol.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/filterPeers.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/filterPeers.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ filterPeersByDiscovery: () => (/* binding */ filterPeersByDiscovery)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js\");\n\n/**\n * Retrieves a list of peers based on the specified criteria:\n * 1. If numPeers is 0, return all peers\n * 2. Bootstrap peers are prioritized\n * 3. Non-bootstrap peers are randomly selected to fill up to numPeers\n *\n * @param peers - The list of peers to filter from.\n * @param numPeers - The total number of peers to retrieve. If 0, all peers are returned, irrespective of `maxBootstrapPeers`.\n * @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.\n * @returns An array of peers based on the specified criteria.\n */\nfunction filterPeersByDiscovery(peers, numPeers, maxBootstrapPeers) {\n // Collect the bootstrap peers up to the specified maximum\n let bootstrapPeers = peers\n .filter((peer) => peer.tags.has(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP))\n .slice(0, maxBootstrapPeers);\n // If numPeers is less than the number of bootstrap peers, adjust the bootstrapPeers array\n if (numPeers > 0 && numPeers < bootstrapPeers.length) {\n bootstrapPeers = bootstrapPeers.slice(0, numPeers);\n }\n // Collect non-bootstrap peers\n const nonBootstrapPeers = peers.filter((peer) => !peer.tags.has(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP));\n // If numPeers is 0, return all peers\n if (numPeers === 0) {\n return [...bootstrapPeers, ...nonBootstrapPeers];\n }\n // Initialize the list of selected peers with the bootstrap peers\n const selectedPeers = [...bootstrapPeers];\n // Fill up to numPeers with remaining random peers if needed\n while (selectedPeers.length < numPeers && nonBootstrapPeers.length > 0) {\n const randomIndex = Math.floor(Math.random() * nonBootstrapPeers.length);\n const randomPeer = nonBootstrapPeers.splice(randomIndex, 1)[0];\n selectedPeers.push(randomPeer);\n }\n return selectedPeers;\n}\n//# sourceMappingURL=filterPeers.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/filterPeers.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/stream_manager.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/stream_manager.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StreamManager: () => (/* binding */ StreamManager)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n\n\nclass StreamManager {\n multicodec;\n getConnections;\n addEventListener;\n streamPool;\n log;\n constructor(multicodec, getConnections, addEventListener) {\n this.multicodec = multicodec;\n this.getConnections = getConnections;\n this.addEventListener = addEventListener;\n this.log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(`stream-manager:${multicodec}`);\n this.addEventListener(\"peer:update\", this.handlePeerUpdateStreamPool.bind(this));\n this.getStream = this.getStream.bind(this);\n this.streamPool = new Map();\n }\n async getStream(peer) {\n const peerIdStr = peer.id.toString();\n const streamPromise = this.streamPool.get(peerIdStr);\n if (!streamPromise) {\n return this.newStream(peer); // fallback by creating a new stream on the spot\n }\n // We have the stream, let's remove it from the map\n this.streamPool.delete(peerIdStr);\n this.prepareNewStream(peer);\n const stream = await streamPromise;\n if (!stream || stream.status === \"closed\") {\n return this.newStream(peer); // fallback by creating a new stream on the spot\n }\n return stream;\n }\n async newStream(peer) {\n const connections = this.getConnections(peer.id);\n const connection = (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.selectConnection)(connections);\n if (!connection) {\n throw new Error(\"Failed to get a connection to the peer\");\n }\n return connection.newStream(this.multicodec);\n }\n prepareNewStream(peer) {\n const streamPromise = this.newStream(peer).catch(() => {\n // No error thrown as this call is not triggered by the user\n this.log.error(`Failed to prepare a new stream for ${peer.id.toString()}`);\n });\n this.streamPool.set(peer.id.toString(), streamPromise);\n }\n handlePeerUpdateStreamPool = (evt) => {\n const peer = evt.detail.peer;\n if (peer.protocols.includes(this.multicodec)) {\n this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);\n this.prepareNewStream(peer);\n }\n };\n}\n//# sourceMappingURL=stream_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/core/dist/lib/stream_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ERR_INVALID_ID: () => (/* binding */ ERR_INVALID_ID),\n/* harmony export */ ERR_NO_SIGNATURE: () => (/* binding */ ERR_NO_SIGNATURE),\n/* harmony export */ MAX_RECORD_SIZE: () => (/* binding */ MAX_RECORD_SIZE),\n/* harmony export */ MULTIADDR_LENGTH_SIZE: () => (/* binding */ MULTIADDR_LENGTH_SIZE)\n/* harmony export */ });\n// Maximum encoded size of an ENR\nconst MAX_RECORD_SIZE = 300;\nconst ERR_INVALID_ID = \"Invalid record id\";\nconst ERR_NO_SIGNATURE = \"No valid signature found\";\n// The maximum length of byte size of a multiaddr to encode in the `multiaddr` field\n// The size is a big endian 16-bit unsigned integer\nconst MULTIADDR_LENGTH_SIZE = 2;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/creator.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/creator.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EnrCreator: () => (/* binding */ EnrCreator)\n/* harmony export */ });\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js\");\n\n\n\n\nclass EnrCreator {\n static fromPublicKey(publicKey, kvs = {}) {\n // EIP-778 specifies that the key must be in compressed format, 33 bytes\n if (publicKey.length !== 33) {\n publicKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_1__.compressPublicKey)(publicKey);\n }\n return _enr_js__WEBPACK_IMPORTED_MODULE_2__.ENR.create({\n ...kvs,\n id: (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.utf8ToBytes)(\"v4\"),\n secp256k1: publicKey\n });\n }\n static async fromPeerId(peerId, kvs = {}) {\n switch (peerId.type) {\n case \"secp256k1\":\n return EnrCreator.fromPublicKey((0,_peer_id_js__WEBPACK_IMPORTED_MODULE_3__.getPublicKeyFromPeerId)(peerId), kvs);\n default:\n throw new Error();\n }\n }\n}\n//# sourceMappingURL=creator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/creator.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ compressPublicKey: () => (/* binding */ compressPublicKey),\n/* harmony export */ keccak256: () => (/* binding */ keccak256),\n/* harmony export */ sign: () => (/* binding */ sign),\n/* harmony export */ verifySignature: () => (/* binding */ verifySignature)\n/* harmony export */ });\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var js_sha3__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! js-sha3 */ \"./node_modules/js-sha3/src/sha3.js\");\n\n\n\n/**\n * ECDSA Sign a message with the given private key.\n *\n * @param message The message to sign, usually a hash.\n * @param privateKey The ECDSA private key to use to sign the message.\n *\n * @returns The signature and the recovery id concatenated.\n */\nasync function sign(message, privateKey) {\n const [signature, recoveryId] = await _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.sign(message, privateKey, {\n recovered: true,\n der: false\n });\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.concat)([signature, new Uint8Array([recoveryId])], signature.length + 1);\n}\nfunction keccak256(input) {\n return new Uint8Array(js_sha3__WEBPACK_IMPORTED_MODULE_2__.keccak256.arrayBuffer(input));\n}\nfunction compressPublicKey(publicKey) {\n if (publicKey.length === 64) {\n publicKey = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.concat)([new Uint8Array([4]), publicKey], 65);\n }\n const point = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Point.fromHex(publicKey);\n return point.toRawBytes(true);\n}\n/**\n * Verify an ECDSA signature.\n */\nfunction verifySignature(signature, message, publicKey) {\n try {\n const _signature = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Signature.fromCompact(signature.slice(0, 64));\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.verify(_signature, message, publicKey);\n }\n catch {\n return false;\n }\n}\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/decoder.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/decoder.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EnrDecoder: () => (/* binding */ EnrDecoder)\n/* harmony export */ });\n/* harmony import */ var _ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @ethersproject/rlp */ \"./node_modules/@ethersproject/rlp/lib.esm/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js\");\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"enr:decoder\");\nclass EnrDecoder {\n static fromString(encoded) {\n if (!encoded.startsWith(_enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.RECORD_PREFIX)) {\n throw new Error(`\"string encoded ENR must start with '${_enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.RECORD_PREFIX}'`);\n }\n return EnrDecoder.fromRLP((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(encoded.slice(4), \"base64url\"));\n }\n static fromRLP(encoded) {\n const decoded = _ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__.decode(encoded).map(_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes);\n return fromValues(decoded);\n }\n}\nasync function fromValues(values) {\n const { signature, seq, kvs } = checkValues(values);\n const obj = {};\n for (let i = 0; i < kvs.length; i += 2) {\n try {\n obj[(0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToUtf8)(kvs[i])] = kvs[i + 1];\n }\n catch (e) {\n log.error(\"Failed to decode ENR key to UTF-8, skipping it\", kvs[i], e);\n }\n }\n const _seq = decodeSeq(seq);\n const enr = await _enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR.create(obj, _seq, signature);\n checkSignature(seq, kvs, enr, signature);\n return enr;\n}\nfunction decodeSeq(seq) {\n // If seq is an empty array, translate as value 0\n if (!seq.length)\n return BigInt(0);\n return BigInt(\"0x\" + (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)(seq));\n}\nfunction checkValues(values) {\n if (!Array.isArray(values)) {\n throw new Error(\"Decoded ENR must be an array\");\n }\n if (values.length % 2 !== 0) {\n throw new Error(\"Decoded ENR must have an even number of elements\");\n }\n const [signature, seq, ...kvs] = values;\n if (!signature || Array.isArray(signature)) {\n throw new Error(\"Decoded ENR invalid signature: must be a byte array\");\n }\n if (!seq || Array.isArray(seq)) {\n throw new Error(\"Decoded ENR invalid sequence number: must be a byte array\");\n }\n return { signature, seq, kvs };\n}\nfunction checkSignature(seq, kvs, enr, signature) {\n const rlpEncodedBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes)(_ethersproject_rlp__WEBPACK_IMPORTED_MODULE_4__.encode([seq, ...kvs]));\n if (!enr.verify(rlpEncodedBytes, signature)) {\n throw new Error(\"Unable to verify ENR signature\");\n }\n}\n//# sourceMappingURL=decoder.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/decoder.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENR: () => (/* binding */ ENR),\n/* harmony export */ TransportProtocol: () => (/* binding */ TransportProtocol),\n/* harmony export */ TransportProtocolPerIpVersion: () => (/* binding */ TransportProtocolPerIpVersion)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js\");\n/* harmony import */ var _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./get_multiaddr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/get_multiaddr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js\");\n/* harmony import */ var _raw_enr_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./raw_enr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/raw_enr.js\");\n/* harmony import */ var _v4_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./v4.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/v4.js\");\n\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"enr\");\nvar TransportProtocol;\n(function (TransportProtocol) {\n TransportProtocol[\"TCP\"] = \"tcp\";\n TransportProtocol[\"UDP\"] = \"udp\";\n})(TransportProtocol || (TransportProtocol = {}));\nvar TransportProtocolPerIpVersion;\n(function (TransportProtocolPerIpVersion) {\n TransportProtocolPerIpVersion[\"TCP4\"] = \"tcp4\";\n TransportProtocolPerIpVersion[\"UDP4\"] = \"udp4\";\n TransportProtocolPerIpVersion[\"TCP6\"] = \"tcp6\";\n TransportProtocolPerIpVersion[\"UDP6\"] = \"udp6\";\n})(TransportProtocolPerIpVersion || (TransportProtocolPerIpVersion = {}));\nclass ENR extends _raw_enr_js__WEBPACK_IMPORTED_MODULE_5__.RawEnr {\n static RECORD_PREFIX = \"enr:\";\n peerId;\n static async create(kvs = {}, seq = BigInt(1), signature) {\n const enr = new ENR(kvs, seq, signature);\n try {\n const publicKey = enr.publicKey;\n if (publicKey) {\n enr.peerId = await (0,_peer_id_js__WEBPACK_IMPORTED_MODULE_4__.createPeerIdFromPublicKey)(publicKey);\n }\n }\n catch (e) {\n log.error(\"Could not calculate peer id for ENR\", e);\n }\n return enr;\n }\n get nodeId() {\n switch (this.id) {\n case \"v4\":\n return this.publicKey ? _v4_js__WEBPACK_IMPORTED_MODULE_6__.nodeId(this.publicKey) : undefined;\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n }\n getLocationMultiaddr = _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__.locationMultiaddrFromEnrFields.bind({}, this);\n get shardInfo() {\n if (this.rs && this.rsv) {\n log.warn(\"ENR contains both `rs` and `rsv` fields.\");\n }\n return this.rs || this.rsv;\n }\n setLocationMultiaddr(multiaddr) {\n const protoNames = multiaddr.protoNames();\n if (protoNames.length !== 2 &&\n protoNames[1] !== \"udp\" &&\n protoNames[1] !== \"tcp\") {\n throw new Error(\"Invalid multiaddr\");\n }\n const tuples = multiaddr.tuples();\n if (!tuples[0][1] || !tuples[1][1]) {\n throw new Error(\"Invalid multiaddr\");\n }\n // IPv4\n if (tuples[0][0] === 4) {\n this.set(\"ip\", tuples[0][1]);\n this.set(protoNames[1], tuples[1][1]);\n }\n else {\n this.set(\"ip6\", tuples[0][1]);\n this.set(protoNames[1] + \"6\", tuples[1][1]);\n }\n }\n getAllLocationMultiaddrs() {\n const multiaddrs = [];\n for (const protocol of Object.values(TransportProtocolPerIpVersion)) {\n const ma = this.getLocationMultiaddr(protocol);\n if (ma)\n multiaddrs.push(ma);\n }\n const _multiaddrs = this.multiaddrs ?? [];\n return multiaddrs.concat(_multiaddrs).map((ma) => {\n if (this.peerId) {\n return ma.encapsulate(`/p2p/${this.peerId.toString()}`);\n }\n return ma;\n });\n }\n get peerInfo() {\n const id = this.peerId;\n if (!id)\n return;\n return {\n id,\n multiaddrs: this.getAllLocationMultiaddrs()\n };\n }\n /**\n * Returns the full multiaddr from the ENR fields matching the provided\n * `protocol` parameter.\n * To return full multiaddrs from the `multiaddrs` ENR field,\n * use { @link ENR.getFullMultiaddrs }.\n *\n * @param protocol\n */\n getFullMultiaddr(protocol) {\n if (this.peerId) {\n const locationMultiaddr = this.getLocationMultiaddr(protocol);\n if (locationMultiaddr) {\n return locationMultiaddr.encapsulate(`/p2p/${this.peerId.toString()}`);\n }\n }\n return;\n }\n /**\n * Returns the full multiaddrs from the `multiaddrs` ENR field.\n */\n getFullMultiaddrs() {\n if (this.peerId && this.multiaddrs) {\n const peerId = this.peerId;\n return this.multiaddrs.map((ma) => {\n return ma.encapsulate(`/p2p/${peerId.toString()}`);\n });\n }\n return [];\n }\n verify(data, signature) {\n if (!this.get(\"id\") || this.id !== \"v4\") {\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n if (!this.publicKey) {\n throw new Error(\"Failed to verify ENR: No public key\");\n }\n return (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.verifySignature)(signature, (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(data), this.publicKey);\n }\n async sign(data, privateKey) {\n switch (this.id) {\n case \"v4\":\n this.signature = await _v4_js__WEBPACK_IMPORTED_MODULE_6__.sign(privateKey, data);\n break;\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_1__.ERR_INVALID_ID);\n }\n return this.signature;\n }\n}\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/get_multiaddr.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/get_multiaddr.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ locationMultiaddrFromEnrFields: () => (/* binding */ locationMultiaddrFromEnrFields)\n/* harmony export */ });\n/* harmony import */ var _multiaddr_from_fields_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./multiaddr_from_fields.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js\");\n\nfunction locationMultiaddrFromEnrFields(enr, protocol) {\n switch (protocol) {\n case \"udp\":\n return (locationMultiaddrFromEnrFields(enr, \"udp4\") ||\n locationMultiaddrFromEnrFields(enr, \"udp6\"));\n case \"tcp\":\n return (locationMultiaddrFromEnrFields(enr, \"tcp4\") ||\n locationMultiaddrFromEnrFields(enr, \"tcp6\"));\n }\n const isIpv6 = protocol.endsWith(\"6\");\n const ipVal = enr.get(isIpv6 ? \"ip6\" : \"ip\");\n if (!ipVal)\n return;\n const protoName = protocol.slice(0, 3);\n let protoVal;\n switch (protoName) {\n case \"udp\":\n protoVal = isIpv6 ? enr.get(\"udp6\") : enr.get(\"udp\");\n break;\n case \"tcp\":\n protoVal = isIpv6 ? enr.get(\"tcp6\") : enr.get(\"tcp\");\n break;\n default:\n return;\n }\n if (!protoVal)\n return;\n return (0,_multiaddr_from_fields_js__WEBPACK_IMPORTED_MODULE_0__.multiaddrFromFields)(isIpv6 ? \"ip6\" : \"ip4\", protoName, ipVal, protoVal);\n}\n//# sourceMappingURL=get_multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/get_multiaddr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js": +/*!***************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js ***! + \***************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENR: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.ENR),\n/* harmony export */ ERR_INVALID_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_ID),\n/* harmony export */ ERR_NO_SIGNATURE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_NO_SIGNATURE),\n/* harmony export */ EnrCreator: () => (/* reexport safe */ _creator_js__WEBPACK_IMPORTED_MODULE_1__.EnrCreator),\n/* harmony export */ EnrDecoder: () => (/* reexport safe */ _decoder_js__WEBPACK_IMPORTED_MODULE_2__.EnrDecoder),\n/* harmony export */ MAX_RECORD_SIZE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.MAX_RECORD_SIZE),\n/* harmony export */ MULTIADDR_LENGTH_SIZE: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_0__.MULTIADDR_LENGTH_SIZE),\n/* harmony export */ TransportProtocol: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.TransportProtocol),\n/* harmony export */ TransportProtocolPerIpVersion: () => (/* reexport safe */ _enr_js__WEBPACK_IMPORTED_MODULE_3__.TransportProtocolPerIpVersion),\n/* harmony export */ compressPublicKey: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.compressPublicKey),\n/* harmony export */ createPeerIdFromPublicKey: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.createPeerIdFromPublicKey),\n/* harmony export */ decodeWaku2: () => (/* reexport safe */ _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.decodeWaku2),\n/* harmony export */ encodeWaku2: () => (/* reexport safe */ _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.encodeWaku2),\n/* harmony export */ getPrivateKeyFromPeerId: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.getPrivateKeyFromPeerId),\n/* harmony export */ getPublicKeyFromPeerId: () => (/* reexport safe */ _peer_id_js__WEBPACK_IMPORTED_MODULE_4__.getPublicKeyFromPeerId),\n/* harmony export */ keccak256: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.keccak256),\n/* harmony export */ sign: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.sign),\n/* harmony export */ verifySignature: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_6__.verifySignature)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _creator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./creator.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/creator.js\");\n/* harmony import */ var _decoder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./decoder.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/decoder.js\");\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/enr.js\");\n/* harmony import */ var _peer_id_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_id.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js\");\n/* harmony import */ var _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./waku2_codec.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/waku2_codec.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js\");\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrFromFields: () => (/* binding */ multiaddrFromFields)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n\n\nfunction multiaddrFromFields(ipFamily, protocol, ipBytes, protocolBytes) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(\"/\" + ipFamily + \"/\" + (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__.convertToString)(ipFamily, ipBytes));\n ma = ma.encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(\"/\" + protocol + \"/\" + (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_1__.convertToString)(protocol, protocolBytes)));\n return ma;\n}\n//# sourceMappingURL=multiaddr_from_fields.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeMultiaddrs: () => (/* binding */ decodeMultiaddrs),\n/* harmony export */ encodeMultiaddrs: () => (/* binding */ encodeMultiaddrs)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js\");\n\n\nfunction decodeMultiaddrs(bytes) {\n const multiaddrs = [];\n let index = 0;\n while (index < bytes.length) {\n const sizeDataView = new DataView(bytes.buffer, index, _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE);\n const size = sizeDataView.getUint16(0);\n index += _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE;\n const multiaddrBytes = bytes.slice(index, index + size);\n index += size;\n multiaddrs.push((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(multiaddrBytes));\n }\n return multiaddrs;\n}\nfunction encodeMultiaddrs(multiaddrs) {\n const totalLength = multiaddrs.reduce((acc, ma) => acc + _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE + ma.bytes.length, 0);\n const bytes = new Uint8Array(totalLength);\n const dataView = new DataView(bytes.buffer);\n let index = 0;\n multiaddrs.forEach((multiaddr) => {\n if (multiaddr.getPeerId())\n throw new Error(\"`multiaddr` field MUST not contain peer id\");\n // Prepend the size of the next entry\n dataView.setUint16(index, multiaddr.bytes.length);\n index += _constants_js__WEBPACK_IMPORTED_MODULE_1__.MULTIADDR_LENGTH_SIZE;\n bytes.set(multiaddr.bytes, index);\n index += multiaddr.bytes.length;\n });\n return bytes;\n}\n//# sourceMappingURL=multiaddrs_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerIdFromPublicKey: () => (/* binding */ createPeerIdFromPublicKey),\n/* harmony export */ getPrivateKeyFromPeerId: () => (/* binding */ getPrivateKeyFromPeerId),\n/* harmony export */ getPublicKeyFromPeerId: () => (/* binding */ getPublicKeyFromPeerId)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\nfunction createPeerIdFromPublicKey(publicKey) {\n const _publicKey = new _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.supportedKeys.secp256k1.Secp256k1PublicKey(publicKey);\n return (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromKeys)(_publicKey.bytes, undefined);\n}\nfunction getPublicKeyFromPeerId(peerId) {\n if (peerId.type !== \"secp256k1\") {\n throw new Error(\"Unsupported peer id type\");\n }\n return (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(peerId.publicKey).marshal();\n}\n// Only used in tests\nasync function getPrivateKeyFromPeerId(peerId) {\n if (peerId.type !== \"secp256k1\") {\n throw new Error(\"Unsupported peer id type\");\n }\n if (!peerId.privateKey) {\n throw new Error(\"Private key not present on peer id\");\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n return privateKey.marshal();\n}\n//# sourceMappingURL=peer_id.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/peer_id.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/raw_enr.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/raw_enr.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RawEnr: () => (/* binding */ RawEnr)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/constants.js\");\n/* harmony import */ var _multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./multiaddrs_codec.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js\");\n/* harmony import */ var _waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./waku2_codec.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/waku2_codec.js\");\n\n\n\n\n\n\nclass RawEnr extends Map {\n seq;\n signature;\n constructor(kvs = {}, seq = BigInt(1), signature) {\n super(Object.entries(kvs));\n this.seq = seq;\n this.signature = signature;\n }\n set(k, v) {\n this.signature = undefined;\n this.seq++;\n return super.set(k, v);\n }\n get id() {\n const id = this.get(\"id\");\n if (!id)\n throw new Error(\"id not found.\");\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.bytesToUtf8)(id);\n }\n get publicKey() {\n switch (this.id) {\n case \"v4\":\n return this.get(\"secp256k1\");\n default:\n throw new Error(_constants_js__WEBPACK_IMPORTED_MODULE_3__.ERR_INVALID_ID);\n }\n }\n get rs() {\n const rs = this.get(\"rs\");\n if (!rs)\n return undefined;\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.decodeRelayShard)(rs);\n }\n get rsv() {\n const rsv = this.get(\"rsv\");\n if (!rsv)\n return undefined;\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.decodeRelayShard)(rsv);\n }\n get ip() {\n return getStringValue(this, \"ip\", \"ip4\");\n }\n set ip(ip) {\n setStringValue(this, \"ip\", \"ip4\", ip);\n }\n get tcp() {\n return getNumberAsStringValue(this, \"tcp\", \"tcp\");\n }\n set tcp(port) {\n setNumberAsStringValue(this, \"tcp\", \"tcp\", port);\n }\n get udp() {\n return getNumberAsStringValue(this, \"udp\", \"udp\");\n }\n set udp(port) {\n setNumberAsStringValue(this, \"udp\", \"udp\", port);\n }\n get ip6() {\n return getStringValue(this, \"ip6\", \"ip6\");\n }\n set ip6(ip) {\n setStringValue(this, \"ip6\", \"ip6\", ip);\n }\n get tcp6() {\n return getNumberAsStringValue(this, \"tcp6\", \"tcp\");\n }\n set tcp6(port) {\n setNumberAsStringValue(this, \"tcp6\", \"tcp\", port);\n }\n get udp6() {\n return getNumberAsStringValue(this, \"udp6\", \"udp\");\n }\n set udp6(port) {\n setNumberAsStringValue(this, \"udp6\", \"udp\", port);\n }\n /**\n * Get the `multiaddrs` field from ENR.\n *\n * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.\n * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host\n * address (e.g. `dns4`, `dnsaddr`, etc)..\n *\n * If the peer information only contains information that can be represented with the ENR pre-defined keys\n * (ip, tcp, etc) then the usage of { @link ENR.getLocationMultiaddr } should be preferred.\n *\n * The multiaddresses stored in this field are expected to be location multiaddresses, ie, peer id less.\n */\n get multiaddrs() {\n const raw = this.get(\"multiaddrs\");\n if (raw)\n return (0,_multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_4__.decodeMultiaddrs)(raw);\n return;\n }\n /**\n * Set the `multiaddrs` field on the ENR.\n *\n * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.\n * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host\n * address (e.g. `dns4`, `dnsaddr`, etc)..\n *\n * If the peer information only contains information that can be represented with the ENR pre-defined keys\n * (ip, tcp, etc) then the usage of { @link ENR.setLocationMultiaddr } should be preferred.\n * The multiaddresses stored in this field must be location multiaddresses,\n * ie, without a peer id.\n */\n set multiaddrs(multiaddrs) {\n deleteUndefined(this, \"multiaddrs\", multiaddrs, _multiaddrs_codec_js__WEBPACK_IMPORTED_MODULE_4__.encodeMultiaddrs);\n }\n /**\n * Get the `waku2` field from ENR.\n */\n get waku2() {\n const raw = this.get(\"waku2\");\n if (raw)\n return (0,_waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.decodeWaku2)(raw[0]);\n return;\n }\n /**\n * Set the `waku2` field on the ENR.\n */\n set waku2(waku2) {\n deleteUndefined(this, \"waku2\", waku2, (w) => new Uint8Array([(0,_waku2_codec_js__WEBPACK_IMPORTED_MODULE_5__.encodeWaku2)(w)]));\n }\n}\nfunction getStringValue(map, key, proto) {\n const raw = map.get(key);\n if (!raw)\n return;\n return (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto, raw);\n}\nfunction getNumberAsStringValue(map, key, proto) {\n const raw = map.get(key);\n if (!raw)\n return;\n return Number((0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto, raw));\n}\nfunction setStringValue(map, key, proto, value) {\n deleteUndefined(map, key, value, _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToBytes.bind({}, proto));\n}\nfunction setNumberAsStringValue(map, key, proto, value) {\n setStringValue(map, key, proto, value?.toString(10));\n}\nfunction deleteUndefined(map, key, value, transform) {\n if (value !== undefined) {\n map.set(key, transform(value));\n }\n else {\n map.delete(key);\n }\n}\n//# sourceMappingURL=raw_enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/raw_enr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/v4.js": +/*!************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/v4.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ nodeId: () => (/* binding */ nodeId),\n/* harmony export */ sign: () => (/* binding */ sign)\n/* harmony export */ });\n/* harmony import */ var _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/discovery/node_modules/@waku/enr/dist/crypto.js\");\n\n\n\nasync function sign(privKey, msg) {\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.sign((0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(msg), privKey, {\n der: false\n });\n}\nfunction nodeId(pubKey) {\n const publicKey = _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.Point.fromHex(pubKey);\n const uncompressedPubkey = publicKey.toRawBytes(false);\n return (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.bytesToHex)((0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.keccak256)(uncompressedPubkey.slice(1)));\n}\n//# sourceMappingURL=v4.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/v4.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/enr/dist/waku2_codec.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/enr/dist/waku2_codec.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeWaku2: () => (/* binding */ decodeWaku2),\n/* harmony export */ encodeWaku2: () => (/* binding */ encodeWaku2)\n/* harmony export */ });\nfunction encodeWaku2(protocols) {\n let byte = 0;\n if (protocols.lightPush)\n byte += 1;\n byte = byte << 1;\n if (protocols.filter)\n byte += 1;\n byte = byte << 1;\n if (protocols.store)\n byte += 1;\n byte = byte << 1;\n if (protocols.relay)\n byte += 1;\n return byte;\n}\nfunction decodeWaku2(byte) {\n const waku2 = {\n relay: false,\n store: false,\n filter: false,\n lightPush: false\n };\n if (byte % 2)\n waku2.relay = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.store = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.filter = true;\n byte = byte >> 1;\n if (byte % 2)\n waku2.lightPush = true;\n return waku2;\n}\n//# sourceMappingURL=waku2_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/enr/dist/waku2_codec.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/connection_manager.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/connection_manager.js ***! + \***********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EConnectionStateEvents: () => (/* binding */ EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n Tags[\"LOCAL\"] = \"local-peer-cache\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\nvar EConnectionStateEvents;\n(function (EConnectionStateEvents) {\n EConnectionStateEvents[\"CONNECTION_STATUS\"] = \"waku:connection\";\n})(EConnectionStateEvents || (EConnectionStateEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/connection_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/constants.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/constants.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* binding */ DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* binding */ DefaultPubsubTopic)\n/* harmony export */ });\n/**\n * DefaultPubsubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubsubTopic = \"/waku/2/default-waku/proto\";\n/**\n * The default cluster ID for The Waku Network\n */\nconst DEFAULT_CLUSTER_ID = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/dns_discovery.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/dns_discovery.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/dns_discovery.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/enr.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/enr.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/enr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/filter.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/filter.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DefaultPubsubTopic),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n/* harmony import */ var _dns_discovery_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./dns_discovery.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/dns_discovery.js\");\n/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./metadata.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/metadata.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/constants.js\");\n/* harmony import */ var _local_storage_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./local_storage.js */ \"./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/local_storage.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/keep_alive_manager.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/keep_alive_manager.js ***! + \***********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/keep_alive_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/libp2p.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/libp2p.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/libp2p.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/light_push.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/light_push.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/local_storage.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/local_storage.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=local_storage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/local_storage.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/message.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/message.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/metadata.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/metadata.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/misc.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/misc.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=misc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/misc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/peer_exchange.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/peer_exchange.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/protocols.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/protocols.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ProtocolError: () => (/* binding */ ProtocolError),\n/* harmony export */ Protocols: () => (/* binding */ Protocols)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar ProtocolError;\n(function (ProtocolError) {\n /** Could not determine the origin of the fault. Best to check connectivity and try again */\n ProtocolError[\"GENERIC_FAIL\"] = \"Generic error\";\n /**\n * Failure to protobuf encode the message. This is not recoverable and needs\n * further investigation.\n */\n ProtocolError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n /**\n * Failure to protobuf decode the message. May be due to a remote peer issue,\n * ensuring that messages are sent via several peer enable mitigation of this error.\n */\n ProtocolError[\"DECODE_FAILED\"] = \"Failed to decode\";\n /**\n * The message payload is empty, making the message invalid. Ensure that a non-empty\n * payload is set on the outgoing message.\n */\n ProtocolError[\"EMPTY_PAYLOAD\"] = \"Payload is empty\";\n /**\n * The message size is above the maximum message size allowed on the Waku Network.\n * Compressing the message or using an alternative strategy for large messages is recommended.\n */\n ProtocolError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n /**\n * The PubsubTopic passed to the send function is not configured on the Waku node.\n * Please ensure that the PubsubTopic is used when initializing the Waku node.\n */\n ProtocolError[\"TOPIC_NOT_CONFIGURED\"] = \"Topic not configured\";\n /**\n * Failure to find a peer with suitable protocols. This may due to a connection issue.\n * Mitigation can be: retrying after a given time period, display connectivity issue\n * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`\n * on the connection manager before retrying.\n */\n ProtocolError[\"NO_PEER_AVAILABLE\"] = \"No peer available\";\n /**\n * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_FAULT\"] = \"Remote peer fault\";\n /**\n * The remote peer rejected the message. Information provided by the remote peer\n * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_REJECTED\"] = \"Remote peer rejected\";\n /**\n * The protocol request timed out without a response. This may be due to a connection issue.\n * Mitigation can be: retrying after a given time period\n */\n ProtocolError[\"REQUEST_TIMEOUT\"] = \"Request timeout\";\n})(ProtocolError || (ProtocolError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/protocols.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/receiver.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/receiver.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=receiver.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/receiver.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/relay.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/relay.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=relay.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/relay.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/sender.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/sender.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=sender.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/sender.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/store.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/store.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/waku.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/waku.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/interfaces/dist/waku.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter.js ***! + \****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.subscribe != null && obj.subscribe !== false)) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if ((obj.topic != null && obj.topic !== '')) {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n subscribe: false,\n topic: '',\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.subscribe = reader.bool();\n break;\n }\n case 2: {\n obj.topic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec(), opts);\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = FilterRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.push = MessagePush.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.push\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec(), opts);\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter_v2.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter_v2.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null && __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.filterSubscribeType = FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n }\n case 10: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 11: {\n if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentTopics\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentTopics.push(reader.string());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec(), opts);\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if ((obj.statusCode != null && obj.statusCode !== 0)) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n statusCode: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 10: {\n obj.statusCode = reader.uint32();\n break;\n }\n case 11: {\n obj.statusDesc = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec(), opts);\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.wakuMessage\n });\n break;\n }\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter_v2.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/light_push.js": +/*!********************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/light_push.js ***! + \********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 2: {\n obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.message\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec(), opts);\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.isSuccess != null && obj.isSuccess !== false)) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n isSuccess: false\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.isSuccess = reader.bool();\n break;\n }\n case 2: {\n obj.info = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec(), opts);\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = PushRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.response = PushResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec(), opts);\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/message.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/message.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/metadata.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/metadata.js ***! + \******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ WakuMetadataRequest: () => (/* binding */ WakuMetadataRequest),\n/* harmony export */ WakuMetadataResponse: () => (/* binding */ WakuMetadataResponse)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar WakuMetadataRequest;\n(function (WakuMetadataRequest) {\n let _codec;\n WakuMetadataRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataRequest.codec());\n };\n WakuMetadataRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataRequest.codec(), opts);\n };\n})(WakuMetadataRequest || (WakuMetadataRequest = {}));\nvar WakuMetadataResponse;\n(function (WakuMetadataResponse) {\n let _codec;\n WakuMetadataResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataResponse.codec());\n };\n WakuMetadataResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataResponse.codec(), opts);\n };\n})(WakuMetadataResponse || (WakuMetadataResponse = {}));\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/peer_exchange.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/peer_exchange.js ***! + \***********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.enr = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec(), opts);\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.numPeers = reader.uint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec(), opts);\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n peerInfos: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"peerInfos\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.peerInfos$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec(), opts);\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 2: {\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec(), opts);\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/store.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/store.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.digest != null && obj.digest.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if ((obj.receiverTime != null && obj.receiverTime !== 0n)) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if ((obj.senderTime != null && obj.senderTime !== 0n)) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n digest: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.digest = reader.bytes();\n break;\n }\n case 2: {\n obj.receiverTime = reader.sint64();\n break;\n }\n case 3: {\n obj.senderTime = reader.sint64();\n break;\n }\n case 4: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec(), opts);\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pageSize = reader.uint64();\n break;\n }\n case 2: {\n obj.cursor = Index.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.cursor\n });\n break;\n }\n case 3: {\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec(), opts);\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n case 4: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 5: {\n obj.startTime = reader.sint64();\n break;\n }\n case 6: {\n obj.endTime = reader.sint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec(), opts);\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n HistoryError[\"TOO_MANY_RESULTS\"] = \"TOO_MANY_RESULTS\";\n HistoryError[\"SERVICE_UNAVAILABLE\"] = \"SERVICE_UNAVAILABLE\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n __HistoryErrorValues[__HistoryErrorValues[\"TOO_MANY_RESULTS\"] = 429] = \"TOO_MANY_RESULTS\";\n __HistoryErrorValues[__HistoryErrorValues[\"SERVICE_UNAVAILABLE\"] = 503] = \"SERVICE_UNAVAILABLE\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n case 3: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 4: {\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec(), opts);\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 3: {\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec(), opts);\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/topic_only_message.js": +/*!****************************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/topic_only_message.js ***! + \****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec(), opts);\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/topic_only_message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/@waku/proto/dist/index.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/@waku/proto/dist/index.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _generated_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_metadata: () => (/* reexport module object */ _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _generated_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _generated_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generated/message.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/message.js\");\n/* harmony import */ var _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./generated/filter.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter.js\");\n/* harmony import */ var _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./generated/topic_only_message.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/topic_only_message.js\");\n/* harmony import */ var _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./generated/filter_v2.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/filter_v2.js\");\n/* harmony import */ var _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generated/light_push.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/light_push.js\");\n/* harmony import */ var _generated_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./generated/store.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/store.js\");\n/* harmony import */ var _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./generated/peer_exchange.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/peer_exchange.js\");\n/* harmony import */ var _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./generated/metadata.js */ \"./node_modules/@waku/discovery/node_modules/@waku/proto/dist/generated/metadata.js\");\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/@waku/proto/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/from-string.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/from-string.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/util/bases.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/util/bases.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/discovery/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/noise/dist/chachapoly.js": +/*!*****************************************************!*\ + !*** ./node_modules/@waku/noise/dist/chachapoly.js ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChaChaPoly: () => (/* binding */ ChaChaPoly)\n/* harmony export */ });\n/* harmony import */ var _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.js\");\n\nclass ChaChaPoly {\n encrypt(k, nonce, ad, plaintext) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.ChaCha20Poly1305(k);\n const n = nonce.getBytes(true);\n return ctx.seal(n, plaintext, ad);\n }\n decrypt(k, nonce, ad, ciphertext) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.ChaCha20Poly1305(k);\n const n = nonce.getBytes(true);\n return ctx.open(n, ciphertext, ad);\n }\n}\n//# sourceMappingURL=chachapoly.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/chachapoly.js?"); /***/ }), @@ -4861,7 +5792,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseHandshakeDecoder: () => (/* binding */ NoiseHandshakeDecoder),\n/* harmony export */ NoiseHandshakeEncoder: () => (/* binding */ NoiseHandshakeEncoder),\n/* harmony export */ NoiseHandshakeMessage: () => (/* binding */ NoiseHandshakeMessage),\n/* harmony export */ NoiseSecureMessage: () => (/* binding */ NoiseSecureMessage),\n/* harmony export */ NoiseSecureTransferDecoder: () => (/* binding */ NoiseSecureTransferDecoder),\n/* harmony export */ NoiseSecureTransferEncoder: () => (/* binding */ NoiseSecureTransferEncoder)\n/* harmony export */ });\n/* harmony import */ var _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core/lib/message/version_0 */ \"./node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _payload_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./payload.js */ \"./node_modules/@waku/noise/dist/payload.js\");\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:message:noise-codec\");\nconst OneMillion = BigInt(1000000);\n// WakuMessage version for noise protocol\nconst version = 2;\n/**\n * Used internally in the pairing object to represent a handshake message\n */\nclass NoiseHandshakeMessage extends _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__.DecodedMessage {\n get payloadV2() {\n if (!this.payload)\n throw new Error(\"no payload available\");\n return _payload_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2.deserialize(this.payload);\n }\n}\n/**\n * Used in the pairing object for encoding the messages exchanged\n * during the handshake process\n */\nclass NoiseHandshakeEncoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages will be sent\n * @param hsStepResult the result of a step executed while performing the handshake process\n * @param ephemeral makes messages ephemeral in the Waku network\n */\n constructor(contentTopic, hsStepResult, ephemeral = true) {\n this.contentTopic = contentTopic;\n this.hsStepResult = hsStepResult;\n this.ephemeral = ephemeral;\n }\n async toWire(message) {\n const protoMessage = await this.toProtoObj(message);\n if (!protoMessage)\n return;\n return _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.encode(protoMessage);\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n return {\n ephemeral: this.ephemeral,\n rateLimitProof: undefined,\n payload: this.hsStepResult.payload2.serialize(),\n version: version,\n meta: undefined,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n };\n }\n}\n/**\n * Used in the pairing object for decoding the messages exchanged\n * during the handshake process\n */\nclass NoiseHandshakeDecoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages were sent\n */\n constructor(contentTopic) {\n this.contentTopic = contentTopic;\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve(protoMessage);\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://github.com/status-im/js-waku/issues/921\n if (proto.version === undefined) {\n proto.version = 0;\n }\n if (proto.version !== version) {\n log(\"Failed to decode due to incorrect version, expected:\", version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n if (!proto.payload) {\n log(\"No payload, skipping: \", proto);\n return;\n }\n return new NoiseHandshakeMessage(pubSubTopic, proto);\n }\n}\n/**\n * Represents a secure message. These are messages that are transmitted\n * after a successful handshake is performed.\n */\nclass NoiseSecureMessage extends _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__.DecodedMessage {\n constructor(pubSubTopic, proto, decodedPayload) {\n super(pubSubTopic, proto);\n this._decodedPayload = decodedPayload;\n }\n get payload() {\n return this._decodedPayload;\n }\n}\n/**\n * js-waku encoder for secure messages. After a handshake is successful, a\n * codec for encoding messages is generated. The messages encoded with this\n * codec will be encrypted with the cipherstates and message nametags that were\n * created after a handshake is complete\n */\nclass NoiseSecureTransferEncoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages were sent.\n * @param hsResult handshake result obtained after the handshake is successful.\n * @param ephemeral whether messages should be tagged as ephemeral defaults to true.\n * @param metaSetter callback function that set the `meta` field.\n */\n constructor(contentTopic, hsResult, ephemeral = true, metaSetter) {\n this.contentTopic = contentTopic;\n this.hsResult = hsResult;\n this.ephemeral = ephemeral;\n this.metaSetter = metaSetter;\n }\n async toWire(message) {\n const protoMessage = await this.toProtoObj(message);\n if (!protoMessage)\n return;\n return _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.encode(protoMessage);\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n if (!message.payload) {\n log(\"No payload to encrypt, skipping: \", message);\n return;\n }\n const preparedPayload = this.hsResult.writeMessage(message.payload);\n const payload = preparedPayload.serialize();\n const protoMessage = {\n payload,\n rateLimitProof: undefined,\n ephemeral: this.ephemeral,\n version: version,\n meta: undefined,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * js-waku decoder for secure messages. After a handshake is successful, a codec\n * for decoding messages is generated. This decoder will attempt to decrypt\n * messages with the cipherstates and message nametags that were created after a\n * handshake is complete\n */\nclass NoiseSecureTransferDecoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages were sent\n * @param hsResult handshake result obtained after the handshake is successful\n */\n constructor(contentTopic, hsResult) {\n this.contentTopic = contentTopic;\n this.hsResult = hsResult;\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve(protoMessage);\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://github.com/status-im/js-waku/issues/921\n if (proto.version === undefined) {\n proto.version = 0;\n }\n if (proto.version !== version) {\n log(\"Failed to decode due to incorrect version, expected:\", version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n if (!proto.payload) {\n log(\"No payload, skipping: \", proto);\n return;\n }\n try {\n const payloadV2 = _payload_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2.deserialize(proto.payload);\n const decryptedPayload = this.hsResult.readMessage(payloadV2);\n return new NoiseSecureMessage(pubSubTopic, proto, decryptedPayload);\n }\n catch (err) {\n log(\"could not decode message \", err);\n return;\n }\n }\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/codec.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseHandshakeDecoder: () => (/* binding */ NoiseHandshakeDecoder),\n/* harmony export */ NoiseHandshakeEncoder: () => (/* binding */ NoiseHandshakeEncoder),\n/* harmony export */ NoiseHandshakeMessage: () => (/* binding */ NoiseHandshakeMessage),\n/* harmony export */ NoiseSecureMessage: () => (/* binding */ NoiseSecureMessage),\n/* harmony export */ NoiseSecureTransferDecoder: () => (/* binding */ NoiseSecureTransferDecoder),\n/* harmony export */ NoiseSecureTransferEncoder: () => (/* binding */ NoiseSecureTransferEncoder)\n/* harmony export */ });\n/* harmony import */ var _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core/lib/message/version_0 */ \"./node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _payload_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./payload.js */ \"./node_modules/@waku/noise/dist/payload.js\");\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:message:noise-codec\");\nconst OneMillion = BigInt(1000000);\n// WakuMessage version for noise protocol\nconst version = 2;\n/**\n * Used internally in the pairing object to represent a handshake message\n */\nclass NoiseHandshakeMessage extends _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__.DecodedMessage {\n get payloadV2() {\n if (!this.payload)\n throw new Error(\"no payload available\");\n return _payload_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2.deserialize(this.payload);\n }\n}\n/**\n * Used in the pairing object for encoding the messages exchanged\n * during the handshake process\n */\nclass NoiseHandshakeEncoder {\n /**\n * @param pubsubTopic pubsub topic on which handshake happens\n * @param contentTopic content topic on which the encoded WakuMessages will be sent\n * @param hsStepResult the result of a step executed while performing the handshake process\n * @param ephemeral makes messages ephemeral in the Waku network\n */\n constructor(contentTopic, pubsubTopic, hsStepResult, ephemeral = true) {\n this.contentTopic = contentTopic;\n this.pubsubTopic = pubsubTopic;\n this.hsStepResult = hsStepResult;\n this.ephemeral = ephemeral;\n }\n async toWire(message) {\n const protoMessage = await this.toProtoObj(message);\n if (!protoMessage)\n return;\n return _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.encode(protoMessage);\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n return {\n ephemeral: this.ephemeral,\n rateLimitProof: undefined,\n payload: this.hsStepResult.payload2.serialize(),\n version: version,\n meta: undefined,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n };\n }\n}\n/**\n * Used in the pairing object for decoding the messages exchanged\n * during the handshake process\n */\nclass NoiseHandshakeDecoder {\n /**\n * @param pubsubTopic pubsub topic on which handshake happens\n * @param contentTopic content topic on which the encoded WakuMessages were sent\n */\n constructor(contentTopic, pubsubTopic) {\n this.contentTopic = contentTopic;\n this.pubsubTopic = pubsubTopic;\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve(protoMessage);\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://github.com/status-im/js-waku/issues/921\n if (proto.version === undefined) {\n proto.version = 0;\n }\n if (proto.version !== version) {\n log(\"Failed to decode due to incorrect version, expected:\", version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n if (!proto.payload) {\n log(\"No payload, skipping: \", proto);\n return;\n }\n return new NoiseHandshakeMessage(pubSubTopic, proto);\n }\n}\n/**\n * Represents a secure message. These are messages that are transmitted\n * after a successful handshake is performed.\n */\nclass NoiseSecureMessage extends _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_0__.DecodedMessage {\n constructor(pubSubTopic, proto, decodedPayload) {\n super(pubSubTopic, proto);\n this._decodedPayload = decodedPayload;\n this.pubsubTopic = pubSubTopic;\n }\n get payload() {\n return this._decodedPayload;\n }\n}\n/**\n * js-waku encoder for secure messages. After a handshake is successful, a\n * codec for encoding messages is generated. The messages encoded with this\n * codec will be encrypted with the cipherstates and message nametags that were\n * created after a handshake is complete\n */\nclass NoiseSecureTransferEncoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages were sent.\n * @param pubsubTopic pubsub topic on which handshake happens\n * @param hsResult handshake result obtained after the handshake is successful.\n * @param ephemeral whether messages should be tagged as ephemeral defaults to true.\n * @param metaSetter callback function that set the `meta` field.\n */\n constructor(contentTopic, pubsubTopic, hsResult, ephemeral = true, metaSetter) {\n this.contentTopic = contentTopic;\n this.pubsubTopic = pubsubTopic;\n this.hsResult = hsResult;\n this.ephemeral = ephemeral;\n this.metaSetter = metaSetter;\n }\n async toWire(message) {\n const protoMessage = await this.toProtoObj(message);\n if (!protoMessage)\n return;\n return _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.encode(protoMessage);\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n if (!message.payload) {\n log(\"No payload to encrypt, skipping: \", message);\n return;\n }\n const preparedPayload = this.hsResult.writeMessage(message.payload);\n const payload = preparedPayload.serialize();\n const protoMessage = {\n payload,\n rateLimitProof: undefined,\n ephemeral: this.ephemeral,\n version: version,\n meta: undefined,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * js-waku decoder for secure messages. After a handshake is successful, a codec\n * for decoding messages is generated. This decoder will attempt to decrypt\n * messages with the cipherstates and message nametags that were created after a\n * handshake is complete\n */\nclass NoiseSecureTransferDecoder {\n /**\n * @param contentTopic content topic on which the encoded WakuMessages were sent\n * @param pubsubTopic pubsub topic on which handshake happens\n * @param hsResult handshake result obtained after the handshake is successful\n */\n constructor(contentTopic, pubsubTopic, hsResult) {\n this.contentTopic = contentTopic;\n this.pubsubTopic = pubsubTopic;\n this.hsResult = hsResult;\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve(protoMessage);\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://github.com/status-im/js-waku/issues/921\n if (proto.version === undefined) {\n proto.version = 0;\n }\n if (proto.version !== version) {\n log(\"Failed to decode due to incorrect version, expected:\", version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n if (!proto.payload) {\n log(\"No payload, skipping: \", proto);\n return;\n }\n try {\n const payloadV2 = _payload_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2.deserialize(proto.payload);\n const decryptedPayload = this.hsResult.readMessage(payloadV2);\n return new NoiseSecureMessage(pubSubTopic, proto, decryptedPayload);\n }\n catch (err) {\n log(\"could not decode message \", err);\n return;\n }\n }\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/codec.js?"); /***/ }), @@ -4872,7 +5803,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChachaPolyTagLen: () => (/* binding */ ChachaPolyTagLen),\n/* harmony export */ Curve25519KeySize: () => (/* binding */ Curve25519KeySize),\n/* harmony export */ HKDF: () => (/* binding */ HKDF),\n/* harmony export */ chaCha20Poly1305Decrypt: () => (/* binding */ chaCha20Poly1305Decrypt),\n/* harmony export */ chaCha20Poly1305Encrypt: () => (/* binding */ chaCha20Poly1305Encrypt),\n/* harmony export */ commitPublicKey: () => (/* binding */ commitPublicKey),\n/* harmony export */ dh: () => (/* binding */ dh),\n/* harmony export */ generateX25519KeyPair: () => (/* binding */ generateX25519KeyPair),\n/* harmony export */ generateX25519KeyPairFromSeed: () => (/* binding */ generateX25519KeyPairFromSeed),\n/* harmony export */ hashSHA256: () => (/* binding */ hashSHA256),\n/* harmony export */ intoCurve25519Key: () => (/* binding */ intoCurve25519Key)\n/* harmony export */ });\n/* harmony import */ var _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.js\");\n/* harmony import */ var _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @stablelib/hkdf */ \"./node_modules/@stablelib/hkdf/lib/hkdf.js\");\n/* harmony import */ var _stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @stablelib/sha256 */ \"./node_modules/@stablelib/sha256/lib/sha256.js\");\n/* harmony import */ var _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @stablelib/x25519 */ \"./node_modules/@stablelib/x25519/lib/x25519.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n\n\n\n\n\nconst Curve25519KeySize = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__.PUBLIC_KEY_LENGTH;\nconst ChachaPolyTagLen = _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.TAG_LENGTH;\n/**\n * Generate hash using SHA2-256\n * @param data data to hash\n * @returns hash digest\n */\nfunction hashSHA256(data) {\n return (0,_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.hash)(data);\n}\n/**\n * Convert an Uint8Array into a 32-byte value. If the input data length is different\n * from 32, throw an error. This is used mostly as a validation function to ensure\n * that an Uint8Array represents a valid x25519 key\n * @param s input data\n * @return 32-byte key\n */\nfunction intoCurve25519Key(s) {\n if (s.length != _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__.PUBLIC_KEY_LENGTH) {\n throw new Error(\"invalid public key length\");\n }\n return s;\n}\n/**\n * HKDF key derivation function using SHA256\n * @param ck chaining key\n * @param ikm input key material\n * @param length length of each generated key\n * @param numKeys number of keys to generate\n * @returns array of `numValues` length containing Uint8Array keys of a given byte `length`\n */\nfunction HKDF(ck, ikm, length, numKeys) {\n const numBytes = length * numKeys;\n const okm = new _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_1__.HKDF(_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.SHA256, ikm, ck).expand(numBytes);\n const result = [];\n for (let i = 0; i < numBytes; i += length) {\n const k = okm.subarray(i, i + length);\n result.push(k);\n }\n return result;\n}\n/**\n * Generate a random keypair\n * @returns Keypair\n */\nfunction generateX25519KeyPair() {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__.generateKeyPair();\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey,\n };\n}\n/**\n * Generate x25519 keypair using an input seed\n * @param seed 32-byte secret\n * @returns Keypair\n */\nfunction generateX25519KeyPairFromSeed(seed) {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__.generateKeyPairFromSeed(seed);\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey,\n };\n}\n/**\n * Encrypt and authenticate data using ChaCha20-Poly1305\n * @param plaintext data to encrypt\n * @param nonce 12 byte little-endian nonce\n * @param ad associated data\n * @param k 32-byte key\n * @returns sealed ciphertext including authentication tag\n */\nfunction chaCha20Poly1305Encrypt(plaintext, nonce, ad, k) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.ChaCha20Poly1305(k);\n return ctx.seal(nonce, plaintext, ad);\n}\n/**\n * Authenticate and decrypt data using ChaCha20-Poly1305\n * @param ciphertext data to decrypt\n * @param nonce 12 byte little-endian nonce\n * @param ad associated data\n * @param k 32-byte key\n * @returns plaintext if decryption was successful, `null` otherwise\n */\nfunction chaCha20Poly1305Decrypt(ciphertext, nonce, ad, k) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.ChaCha20Poly1305(k);\n return ctx.open(nonce, ciphertext, ad);\n}\n/**\n * Perform a Diffie–Hellman key exchange\n * @param privateKey x25519 private key\n * @param publicKey x25519 public key\n * @returns shared secret\n */\nfunction dh(privateKey, publicKey) {\n try {\n const derivedU8 = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_3__.sharedKey(privateKey, publicKey);\n if (derivedU8.length === 32) {\n return derivedU8;\n }\n return derivedU8.subarray(0, 32);\n }\n catch (e) {\n console.error(e);\n return new Uint8Array(32);\n }\n}\n/**\n * Generates a random static key commitment using a public key pk for randomness r as H(pk || s)\n * @param publicKey x25519 public key\n * @param r random fixed-length value\n * @returns 32 byte hash\n */\nfunction commitPublicKey(publicKey, r) {\n return hashSHA256((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_4__.concat)([publicKey, r]));\n}\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/crypto.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HKDF: () => (/* binding */ HKDF),\n/* harmony export */ commitPublicKey: () => (/* binding */ commitPublicKey),\n/* harmony export */ hash: () => (/* binding */ hash)\n/* harmony export */ });\n/* harmony import */ var _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/hkdf */ \"./node_modules/@stablelib/hkdf/lib/hkdf.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n\n\n/**\n * HKDF key derivation function\n * @param ck chaining key\n * @param ikm input key material\n * @param length length of each generated key\n * @param numKeys number of keys to generate\n * @returns array of `numValues` length containing Uint8Array keys of a given byte `length`\n */\nfunction HKDF(hash, ck, ikm, length, numKeys) {\n const numBytes = length * numKeys;\n const okm = new _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_0__.HKDF(hash, ikm, ck).expand(numBytes);\n const result = [];\n for (let i = 0; i < numBytes; i += length) {\n const k = okm.subarray(i, i + length);\n result.push(k);\n }\n return result;\n}\nfunction hash(hash, data) {\n const h = new hash();\n h.update(data);\n const digest = h.digest();\n h.clean();\n return digest;\n}\n/**\n * Generates a random static key commitment using a public key pk for randomness r as H(pk || s)\n * @param h Hash function\n * @param publicKey x25519 public key\n * @param r random fixed-length value\n * @returns 32 byte hash\n */\nfunction commitPublicKey(h, publicKey, r) {\n const data = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([publicKey, r]);\n return hash(h, data);\n}\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/crypto.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/noise/dist/dh25519.js": +/*!**************************************************!*\ + !*** ./node_modules/@waku/noise/dist/dh25519.js ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DH25519: () => (/* binding */ DH25519)\n/* harmony export */ });\n/* harmony import */ var _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/x25519 */ \"./node_modules/@stablelib/x25519/lib/x25519.js\");\n\nclass DH25519 {\n intoKey(s) {\n if (s.length != _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__.PUBLIC_KEY_LENGTH) {\n throw new Error(\"invalid public key length\");\n }\n return s;\n }\n generateKeyPair() {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__.generateKeyPair();\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey,\n };\n }\n generateKeyPairFromSeed(seed) {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__.generateKeyPairFromSeed(seed);\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey,\n };\n }\n DH(privateKey, publicKey) {\n try {\n const derivedU8 = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__.sharedKey(privateKey, publicKey);\n if (derivedU8.length === 32) {\n return derivedU8;\n }\n return derivedU8.subarray(0, 32);\n }\n catch (e) {\n console.error(e);\n return new Uint8Array(32);\n }\n }\n DHLen() {\n return _stablelib_x25519__WEBPACK_IMPORTED_MODULE_0__.PUBLIC_KEY_LENGTH;\n }\n}\n//# sourceMappingURL=dh25519.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/dh25519.js?"); /***/ }), @@ -4883,7 +5825,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Handshake: () => (/* binding */ Handshake),\n/* harmony export */ HandshakeResult: () => (/* binding */ HandshakeResult),\n/* harmony export */ HandshakeStepResult: () => (/* binding */ HandshakeStepResult),\n/* harmony export */ MessageNametagError: () => (/* binding */ MessageNametagError)\n/* harmony export */ });\n/* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! bn.js */ \"./node_modules/bn.js/lib/bn.js\");\n/* harmony import */ var pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! pkcs7-padding */ \"./node_modules/pkcs7-padding/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./handshake_state.js */ \"./node_modules/@waku/noise/dist/handshake_state.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _payload_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./payload.js */ \"./node_modules/@waku/noise/dist/payload.js\");\n\n\n\n\n\n\n\n\n// Noise state machine\n// While processing messages patterns, users either:\n// - read (decrypt) the other party's (encrypted) transport message\n// - write (encrypt) a message, sent through a PayloadV2\n// These two intermediate results are stored in the HandshakeStepResult data structure\nclass HandshakeStepResult {\n constructor() {\n this.payload2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2();\n this.transportMessage = new Uint8Array();\n }\n equals(b) {\n return this.payload2.equals(b.payload2) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.transportMessage, b.transportMessage);\n }\n clone() {\n const r = new HandshakeStepResult();\n r.transportMessage = new Uint8Array(this.transportMessage);\n r.payload2 = this.payload2.clone();\n return r;\n }\n}\n// When a handshake is complete, the HandshakeResult will contain the two\n// Cipher States used to encrypt/decrypt outbound/inbound messages\n// The recipient static key rs and handshake hash values h are stored to address some possible future applications (channel-binding, session management, etc.).\n// However, are not required by Noise specifications and are thus optional\nclass HandshakeResult {\n constructor(csOutbound, csInbound) {\n this.csOutbound = csOutbound;\n this.csInbound = csInbound;\n // Optional fields:\n this.nametagsInbound = new _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.MessageNametagBuffer();\n this.nametagsOutbound = new _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.MessageNametagBuffer();\n this.rs = new Uint8Array();\n this.h = new Uint8Array();\n }\n // Noise specification, Section 5:\n // Transport messages are then encrypted and decrypted by calling EncryptWithAd()\n // and DecryptWithAd() on the relevant CipherState with zero-length associated data.\n // If DecryptWithAd() signals an error due to DECRYPT() failure, then the input message is discarded.\n // The application may choose to delete the CipherState and terminate the session on such an error,\n // or may continue to attempt communications. If EncryptWithAd() or DecryptWithAd() signal an error\n // due to nonce exhaustion, then the application must delete the CipherState and terminate the session.\n // Writes an encrypted message using the proper Cipher State\n writeMessage(transportMessage, outboundMessageNametagBuffer = undefined) {\n const payload2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2();\n // We set the message nametag using the input buffer\n payload2.messageNametag = (outboundMessageNametagBuffer ?? this.nametagsOutbound).pop();\n // According to 35/WAKU2-NOISE RFC, no Handshake protocol information is sent when exchanging messages\n // This correspond to setting protocol-id to 0\n payload2.protocolId = 0;\n // We pad the transport message\n const paddedTransportMessage = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.pad(transportMessage, _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__.NoisePaddingBlockSize);\n // Encryption is done with zero-length associated data as per specification\n payload2.transportMessage = this.csOutbound.encryptWithAd(payload2.messageNametag, paddedTransportMessage);\n return payload2;\n }\n // Reads an encrypted message using the proper Cipher State\n // Decryption is attempted only if the input PayloadV2 has a messageNametag equal to the one expected\n readMessage(readPayload2, inboundMessageNametagBuffer = undefined) {\n // The output decrypted message\n let message = new Uint8Array();\n // If the message nametag does not correspond to the nametag expected in the inbound message nametag buffer\n // an error is raised (to be handled externally, i.e. re-request lost messages, discard, etc.)\n const nametagIsOk = (inboundMessageNametagBuffer ?? this.nametagsInbound).checkNametag(readPayload2.messageNametag);\n if (!nametagIsOk) {\n throw new Error(\"nametag is not ok\");\n }\n // At this point the messageNametag matches the expected nametag.\n // According to 35/WAKU2-NOISE RFC, no Handshake protocol information is sent when exchanging messages\n if (readPayload2.protocolId == 0) {\n // On application level we decide to discard messages which fail decryption, without raising an error\n try {\n // Decryption is done with messageNametag as associated data\n const paddedMessage = this.csInbound.decryptWithAd(readPayload2.messageNametag, readPayload2.transportMessage);\n // We unpad the decrypted message\n message = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.unpad(paddedMessage);\n // The message successfully decrypted, we can delete the first element of the inbound Message Nametag Buffer\n this.nametagsInbound.delete(1);\n }\n catch (err) {\n console.debug(\"A read message failed decryption. Returning empty message as plaintext.\");\n message = new Uint8Array();\n }\n }\n return message;\n }\n}\nclass MessageNametagError extends Error {\n constructor(expectedNametag, actualNametag) {\n super(\"the message nametag of the read message doesn't match the expected one\");\n this.expectedNametag = expectedNametag;\n this.actualNametag = actualNametag;\n this.name = \"MessageNametagError\";\n }\n}\nclass Handshake {\n constructor({ hsPattern, ephemeralKey, staticKey, prologue = new Uint8Array(), psk = new Uint8Array(), preMessagePKs = [], initiator = false, }) {\n this.hs = new _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__.HandshakeState(hsPattern, psk);\n this.hs.ss.mixHash(prologue);\n this.hs.e = ephemeralKey;\n this.hs.s = staticKey;\n this.hs.psk = psk;\n this.hs.msgPatternIdx = 0;\n this.hs.initiator = initiator;\n // We process any eventual handshake pre-message pattern by processing pre-message public keys\n this.hs.processPreMessagePatternTokens(preMessagePKs);\n }\n equals(b) {\n return this.hs.equals(b.hs);\n }\n clone() {\n const result = new Handshake({\n hsPattern: this.hs.handshakePattern,\n });\n result.hs = this.hs.clone();\n return result;\n }\n // Generates an 8 decimal digits authorization code using HKDF and the handshake state\n genAuthcode() {\n const [output0] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.hs.ss.h, new Uint8Array(), 8, 1);\n const bn = new bn_js__WEBPACK_IMPORTED_MODULE_0__.BN(output0);\n const code = bn.mod(new bn_js__WEBPACK_IMPORTED_MODULE_0__.BN(100000000)).toString().padStart(8, \"0\");\n return code.toString();\n }\n // Advances 1 step in handshake\n // Each user in a handshake alternates writing and reading of handshake messages.\n // If the user is writing the handshake message, the transport message (if not empty) and eventually a non-empty message nametag has to be passed to transportMessage and messageNametag and readPayloadV2 can be left to its default value\n // It the user is reading the handshake message, the read payload v2 has to be passed to readPayloadV2 and the transportMessage can be left to its default values. Decryption is skipped if the PayloadV2 read doesn't have a message nametag equal to messageNametag (empty input nametags are converted to all-0 MessageNametagLength bytes arrays)\n stepHandshake({ readPayloadV2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2(), transportMessage = new Uint8Array(), messageNametag = new Uint8Array(), }) {\n const hsStepResult = new HandshakeStepResult();\n // If there are no more message patterns left for processing\n // we return an empty HandshakeStepResult\n if (this.hs.msgPatternIdx > this.hs.handshakePattern.messagePatterns.length - 1) {\n console.debug(\"stepHandshake called more times than the number of message patterns present in handshake\");\n return hsStepResult;\n }\n // We process the next handshake message pattern\n // We get if the user is reading or writing the input handshake message\n const direction = this.hs.handshakePattern.messagePatterns[this.hs.msgPatternIdx].direction;\n const { reading, writing } = this.hs.getReadingWritingState(direction);\n // If we write an answer at this handshake step\n if (writing) {\n // We initialize a payload v2 and we set proper protocol ID (if supported)\n const protocolId = _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PayloadV2ProtocolIDs[this.hs.handshakePattern.name];\n if (protocolId === undefined) {\n throw new Error(\"handshake pattern not supported\");\n }\n hsStepResult.payload2.protocolId = protocolId;\n // We set the messageNametag and the handshake and transport messages\n hsStepResult.payload2.messageNametag = (0,_messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.toMessageNametag)(messageNametag);\n hsStepResult.payload2.handshakeMessage = this.hs.processMessagePatternTokens();\n // We write the payload by passing the messageNametag as extra additional data\n hsStepResult.payload2.transportMessage = this.hs.processMessagePatternPayload(transportMessage, hsStepResult.payload2.messageNametag);\n // If we read an answer during this handshake step\n }\n else if (reading) {\n // If the read message nametag doesn't match the expected input one we raise an error\n const expectedNametag = (0,_messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.toMessageNametag)(messageNametag);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(readPayloadV2.messageNametag, expectedNametag)) {\n throw new MessageNametagError(expectedNametag, readPayloadV2.messageNametag);\n }\n // We process the read public keys and (eventually decrypt) the read transport message\n const readHandshakeMessage = readPayloadV2.handshakeMessage;\n const readTransportMessage = readPayloadV2.transportMessage;\n // Since we only read, nothing meaningful (i.e. public keys) is returned\n this.hs.processMessagePatternTokens(readHandshakeMessage);\n // We retrieve and store the (decrypted) received transport message by passing the messageNametag as extra additional data\n hsStepResult.transportMessage = this.hs.processMessagePatternPayload(readTransportMessage, readPayloadV2.messageNametag);\n }\n else {\n throw new Error(\"handshake Error: neither writing or reading user\");\n }\n // We increase the handshake state message pattern index to progress to next step\n this.hs.msgPatternIdx += 1;\n return hsStepResult;\n }\n // Finalizes the handshake by calling Split and assigning the proper Cipher States to users\n finalizeHandshake() {\n let hsResult;\n // Noise specification, Section 5:\n // Processing the final handshake message returns two CipherState objects,\n // the first for encrypting transport messages from initiator to responder,\n // and the second for messages in the other direction.\n // We call Split()\n const { cs1, cs2 } = this.hs.ss.split();\n // Optional: We derive a secret for the nametag derivation\n const { nms1, nms2 } = this.hs.genMessageNametagSecrets();\n // We assign the proper Cipher States\n if (this.hs.initiator) {\n hsResult = new HandshakeResult(cs1, cs2);\n // and nametags secrets\n hsResult.nametagsInbound.secret = nms1;\n hsResult.nametagsOutbound.secret = nms2;\n }\n else {\n hsResult = new HandshakeResult(cs2, cs1);\n // and nametags secrets\n hsResult.nametagsInbound.secret = nms2;\n hsResult.nametagsOutbound.secret = nms1;\n }\n // We initialize the message nametags inbound/outbound buffers\n hsResult.nametagsInbound.initNametagsBuffer();\n hsResult.nametagsOutbound.initNametagsBuffer();\n if (!this.hs.rs)\n throw new Error(\"invalid handshake state\");\n // We store the optional fields rs and h\n hsResult.rs = new Uint8Array(this.hs.rs);\n hsResult.h = new Uint8Array(this.hs.ss.h);\n return hsResult;\n }\n}\n//# sourceMappingURL=handshake.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/handshake.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Handshake: () => (/* binding */ Handshake),\n/* harmony export */ HandshakeResult: () => (/* binding */ HandshakeResult),\n/* harmony export */ HandshakeStepResult: () => (/* binding */ HandshakeStepResult),\n/* harmony export */ MessageNametagError: () => (/* binding */ MessageNametagError)\n/* harmony export */ });\n/* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! bn.js */ \"./node_modules/bn.js/lib/bn.js\");\n/* harmony import */ var pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! pkcs7-padding */ \"./node_modules/pkcs7-padding/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./handshake_state.js */ \"./node_modules/@waku/noise/dist/handshake_state.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _payload_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./payload.js */ \"./node_modules/@waku/noise/dist/payload.js\");\n\n\n\n\n\n\n\n\n// Noise state machine\n// While processing messages patterns, users either:\n// - read (decrypt) the other party's (encrypted) transport message\n// - write (encrypt) a message, sent through a PayloadV2\n// These two intermediate results are stored in the HandshakeStepResult data structure\nclass HandshakeStepResult {\n constructor() {\n this.payload2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2();\n this.transportMessage = new Uint8Array();\n }\n equals(b) {\n return this.payload2.equals(b.payload2) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.transportMessage, b.transportMessage);\n }\n clone() {\n const r = new HandshakeStepResult();\n r.transportMessage = new Uint8Array(this.transportMessage);\n r.payload2 = this.payload2.clone();\n return r;\n }\n}\n// When a handshake is complete, the HandshakeResult will contain the two\n// Cipher States used to encrypt/decrypt outbound/inbound messages\n// The recipient static key rs and handshake hash values h are stored to address some possible future applications (channel-binding, session management, etc.).\n// However, are not required by Noise specifications and are thus optional\nclass HandshakeResult {\n constructor(csOutbound, csInbound) {\n this.csOutbound = csOutbound;\n this.csInbound = csInbound;\n // Optional fields:\n this.nametagsInbound = new _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.MessageNametagBuffer();\n this.nametagsOutbound = new _messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.MessageNametagBuffer();\n this.rs = new Uint8Array();\n this.h = new Uint8Array();\n }\n getCSOutbound() {\n return this.csOutbound;\n }\n getCSInbound() {\n return this.csInbound;\n }\n // Noise specification, Section 5:\n // Transport messages are then encrypted and decrypted by calling EncryptWithAd()\n // and DecryptWithAd() on the relevant CipherState with zero-length associated data.\n // If DecryptWithAd() signals an error due to DECRYPT() failure, then the input message is discarded.\n // The application may choose to delete the CipherState and terminate the session on such an error,\n // or may continue to attempt communications. If EncryptWithAd() or DecryptWithAd() signal an error\n // due to nonce exhaustion, then the application must delete the CipherState and terminate the session.\n // Writes an encrypted message using the proper Cipher State\n writeMessage(transportMessage, outboundMessageNametagBuffer = undefined) {\n const payload2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2();\n // We set the message nametag using the input buffer\n payload2.messageNametag = (outboundMessageNametagBuffer ?? this.nametagsOutbound).pop();\n // According to 35/WAKU2-NOISE RFC, no Handshake protocol information is sent when exchanging messages\n // This correspond to setting protocol-id to 0\n payload2.protocolId = 0;\n // We pad the transport message\n const paddedTransportMessage = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.pad(transportMessage, _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__.NoisePaddingBlockSize);\n // Encryption is done with zero-length associated data as per specification\n payload2.transportMessage = this.csOutbound.encryptWithAd(payload2.messageNametag, paddedTransportMessage);\n return payload2;\n }\n // Reads an encrypted message using the proper Cipher State\n // Decryption is attempted only if the input PayloadV2 has a messageNametag equal to the one expected\n readMessage(readPayload2, inboundMessageNametagBuffer = undefined) {\n // The output decrypted message\n let message = new Uint8Array();\n // If the message nametag does not correspond to the nametag expected in the inbound message nametag buffer\n // an error is raised (to be handled externally, i.e. re-request lost messages, discard, etc.)\n const nametagIsOk = (inboundMessageNametagBuffer ?? this.nametagsInbound).checkNametag(readPayload2.messageNametag);\n if (!nametagIsOk) {\n throw new Error(\"nametag is not ok\");\n }\n // At this point the messageNametag matches the expected nametag.\n // According to 35/WAKU2-NOISE RFC, no Handshake protocol information is sent when exchanging messages\n if (readPayload2.protocolId == 0) {\n // On application level we decide to discard messages which fail decryption, without raising an error\n try {\n // Decryption is done with messageNametag as associated data\n const paddedMessage = this.csInbound.decryptWithAd(readPayload2.messageNametag, readPayload2.transportMessage);\n // We unpad the decrypted message\n message = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.unpad(paddedMessage);\n // The message successfully decrypted, we can delete the first element of the inbound Message Nametag Buffer\n this.nametagsInbound.delete(1);\n }\n catch (err) {\n console.debug(\"A read message failed decryption. Returning empty message as plaintext.\");\n message = new Uint8Array();\n }\n }\n return message;\n }\n}\nclass MessageNametagError extends Error {\n constructor(expectedNametag, actualNametag) {\n super(\"the message nametag of the read message doesn't match the expected one\");\n this.expectedNametag = expectedNametag;\n this.actualNametag = actualNametag;\n this.name = \"MessageNametagError\";\n }\n}\nclass Handshake {\n constructor({ hsPattern, ephemeralKey, staticKey, prologue = new Uint8Array(), psk = new Uint8Array(), preMessagePKs = [], initiator = false, }) {\n this.hs = new _handshake_state_js__WEBPACK_IMPORTED_MODULE_4__.HandshakeState(hsPattern, psk);\n this.hs.ss.mixHash(prologue);\n this.hs.e = ephemeralKey;\n this.hs.s = staticKey;\n this.hs.psk = psk;\n this.hs.msgPatternIdx = 0;\n this.hs.initiator = initiator;\n // We process any eventual handshake pre-message pattern by processing pre-message public keys\n this.hs.processPreMessagePatternTokens(preMessagePKs);\n }\n equals(b) {\n return this.hs.equals(b.hs);\n }\n clone() {\n const result = new Handshake({\n hsPattern: this.hs.handshakePattern,\n });\n result.hs = this.hs.clone();\n return result;\n }\n // Generates an 8 decimal digits authorization code using HKDF and the handshake state\n genAuthcode() {\n const [output0] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.hs.handshakePattern.hash, this.hs.ss.h, new Uint8Array(), 8, 1);\n const bn = new bn_js__WEBPACK_IMPORTED_MODULE_0__.BN(output0);\n const code = bn.mod(new bn_js__WEBPACK_IMPORTED_MODULE_0__.BN(100000000)).toString().padStart(8, \"0\");\n return code.toString();\n }\n // Advances 1 step in handshake\n // Each user in a handshake alternates writing and reading of handshake messages.\n // If the user is writing the handshake message, the transport message (if not empty) and eventually a non-empty message nametag has to be passed to transportMessage and messageNametag and readPayloadV2 can be left to its default value\n // It the user is reading the handshake message, the read payload v2 has to be passed to readPayloadV2 and the transportMessage can be left to its default values. Decryption is skipped if the PayloadV2 read doesn't have a message nametag equal to messageNametag (empty input nametags are converted to all-0 MessageNametagLength bytes arrays)\n stepHandshake({ readPayloadV2 = new _payload_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2(), transportMessage = new Uint8Array(), messageNametag = new Uint8Array(), }) {\n const hsStepResult = new HandshakeStepResult();\n // If there are no more message patterns left for processing\n // we return an empty HandshakeStepResult\n if (this.hs.msgPatternIdx > this.hs.handshakePattern.messagePatterns.length - 1) {\n console.debug(\"stepHandshake called more times than the number of message patterns present in handshake\");\n return hsStepResult;\n }\n // We process the next handshake message pattern\n // We get if the user is reading or writing the input handshake message\n const direction = this.hs.handshakePattern.messagePatterns[this.hs.msgPatternIdx].direction;\n const { reading, writing } = this.hs.getReadingWritingState(direction);\n // If we write an answer at this handshake step\n if (writing) {\n // We initialize a payload v2 and we set proper protocol ID (if supported)\n const protocolId = _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PayloadV2ProtocolIDs[this.hs.handshakePattern.name];\n if (protocolId === undefined) {\n throw new Error(\"handshake pattern not supported\");\n }\n hsStepResult.payload2.protocolId = protocolId;\n // We set the messageNametag and the handshake and transport messages\n hsStepResult.payload2.messageNametag = (0,_messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.toMessageNametag)(messageNametag);\n hsStepResult.payload2.handshakeMessage = this.hs.processMessagePatternTokens();\n // We write the payload by passing the messageNametag as extra additional data\n hsStepResult.payload2.transportMessage = this.hs.processMessagePatternPayload(transportMessage, hsStepResult.payload2.messageNametag);\n // If we read an answer during this handshake step\n }\n else if (reading) {\n // If the read message nametag doesn't match the expected input one we raise an error\n const expectedNametag = (0,_messagenametag_js__WEBPACK_IMPORTED_MODULE_5__.toMessageNametag)(messageNametag);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(readPayloadV2.messageNametag, expectedNametag)) {\n throw new MessageNametagError(expectedNametag, readPayloadV2.messageNametag);\n }\n // We process the read public keys and (eventually decrypt) the read transport message\n const readHandshakeMessage = readPayloadV2.handshakeMessage;\n const readTransportMessage = readPayloadV2.transportMessage;\n // Since we only read, nothing meaningful (i.e. public keys) is returned\n this.hs.processMessagePatternTokens(readHandshakeMessage);\n // We retrieve and store the (decrypted) received transport message by passing the messageNametag as extra additional data\n hsStepResult.transportMessage = this.hs.processMessagePatternPayload(readTransportMessage, readPayloadV2.messageNametag);\n }\n else {\n throw new Error(\"handshake Error: neither writing or reading user\");\n }\n // We increase the handshake state message pattern index to progress to next step\n this.hs.msgPatternIdx += 1;\n return hsStepResult;\n }\n // Finalizes the handshake by calling Split and assigning the proper Cipher States to users\n finalizeHandshake() {\n let hsResult;\n // Noise specification, Section 5:\n // Processing the final handshake message returns two CipherState objects,\n // the first for encrypting transport messages from initiator to responder,\n // and the second for messages in the other direction.\n // We call Split()\n const { cs1, cs2 } = this.hs.ss.split();\n // Optional: We derive a secret for the nametag derivation\n const { nms1, nms2 } = this.hs.genMessageNametagSecrets();\n // We assign the proper Cipher States\n if (this.hs.initiator) {\n hsResult = new HandshakeResult(cs1, cs2);\n // and nametags secrets\n hsResult.nametagsInbound.secret = nms1;\n hsResult.nametagsOutbound.secret = nms2;\n }\n else {\n hsResult = new HandshakeResult(cs2, cs1);\n // and nametags secrets\n hsResult.nametagsInbound.secret = nms2;\n hsResult.nametagsOutbound.secret = nms1;\n }\n // We initialize the message nametags inbound/outbound buffers\n hsResult.nametagsInbound.initNametagsBuffer();\n hsResult.nametagsOutbound.initNametagsBuffer();\n if (!this.hs.rs)\n throw new Error(\"invalid handshake state\");\n // We store the optional fields rs and h\n hsResult.rs = new Uint8Array(this.hs.rs);\n hsResult.h = new Uint8Array(this.hs.ss.h);\n return hsResult;\n }\n}\n//# sourceMappingURL=handshake.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/handshake.js?"); /***/ }), @@ -4894,7 +5836,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HandshakeState: () => (/* binding */ HandshakeState),\n/* harmony export */ NoisePaddingBlockSize: () => (/* binding */ NoisePaddingBlockSize)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! pkcs7-padding */ \"./node_modules/pkcs7-padding/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@waku/noise/dist/noise.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:noise:handshake-state\");\n// The padding blocksize of a transport message\nconst NoisePaddingBlockSize = 248;\n// The Handshake State as in https://noiseprotocol.org/noise.html#the-handshakestate-object\n// Contains\n// - the local and remote ephemeral/static keys e,s,re,rs (if any)\n// - the initiator flag (true if the user creating the state is the handshake initiator, false otherwise)\n// - the handshakePattern (containing the handshake protocol name, and (pre)message patterns)\n// This object is further extended from specifications by storing:\n// - a message pattern index msgPatternIdx indicating the next handshake message pattern to process\n// - the user's preshared psk, if any\nclass HandshakeState {\n constructor(hsPattern, psk) {\n // By default the Handshake State initiator flag is set to false\n // Will be set to true when the user associated to the handshake state starts an handshake\n this.initiator = false;\n this.handshakePattern = hsPattern;\n this.psk = psk;\n this.ss = new _noise_js__WEBPACK_IMPORTED_MODULE_5__.SymmetricState(hsPattern);\n this.msgPatternIdx = 0;\n }\n equals(b) {\n if (this.s != null && b.s != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.privateKey, b.s.privateKey))\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.publicKey, b.s.publicKey))\n return false;\n }\n else {\n return false;\n }\n if (this.e != null && b.e != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.privateKey, b.e.privateKey))\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.publicKey, b.e.publicKey))\n return false;\n }\n else {\n return false;\n }\n if (this.rs != null && b.rs != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.rs, b.rs))\n return false;\n }\n else {\n return false;\n }\n if (this.re != null && b.re != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.re, b.re))\n return false;\n }\n else {\n return false;\n }\n if (!this.ss.equals(b.ss))\n return false;\n if (this.initiator != b.initiator)\n return false;\n if (!this.handshakePattern.equals(b.handshakePattern))\n return false;\n if (this.msgPatternIdx != b.msgPatternIdx)\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.psk, b.psk))\n return false;\n return true;\n }\n clone() {\n const result = new HandshakeState(this.handshakePattern, this.psk);\n result.s = this.s;\n result.e = this.e;\n result.rs = this.rs ? new Uint8Array(this.rs) : undefined;\n result.re = this.re ? new Uint8Array(this.re) : undefined;\n result.ss = this.ss.clone();\n result.initiator = this.initiator;\n result.msgPatternIdx = this.msgPatternIdx;\n return result;\n }\n genMessageNametagSecrets() {\n const [nms1, nms2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.ss.h, new Uint8Array(), 2, 32);\n return { nms1, nms2 };\n }\n // Uses the cryptographic information stored in the input handshake state to generate a random message nametag\n // In current implementation the messageNametag = HKDF(handshake hash value), but other derivation mechanisms can be implemented\n toMessageNametag() {\n const [output] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.ss.h, new Uint8Array(), 32, 1);\n return output.subarray(0, _messagenametag_js__WEBPACK_IMPORTED_MODULE_4__.MessageNametagLength);\n }\n // Handshake Processing\n // Based on the message handshake direction and if the user is or not the initiator, returns a boolean tuple telling if the user\n // has to read or write the next handshake message\n getReadingWritingState(direction) {\n let reading = false;\n let writing = false;\n if (this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r) {\n // I'm Alice and direction is ->\n reading = false;\n writing = true;\n }\n else if (this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l) {\n // I'm Alice and direction is <-\n reading = true;\n writing = false;\n }\n else if (!this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r) {\n // I'm Bob and direction is ->\n reading = true;\n writing = false;\n }\n else if (!this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l) {\n // I'm Bob and direction is <-\n reading = false;\n writing = true;\n }\n return { reading, writing };\n }\n // Checks if a pre-message is valid according to Noise specifications\n // http://www.noiseprotocol.org/noise.html#handshake-patterns\n isValid(msg) {\n let isValid = true;\n // Non-empty pre-messages can only have patterns \"e\", \"s\", \"e,s\" in each direction\n const allowedPatterns = [\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e, _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e, _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n ];\n // We check if pre message patterns are allowed\n for (const pattern of msg) {\n if (!allowedPatterns.find((x) => x.equals(pattern))) {\n isValid = false;\n break;\n }\n }\n return isValid;\n }\n // Handshake messages processing procedures\n // Processes pre-message patterns\n processPreMessagePatternTokens(inPreMessagePKs = []) {\n // I make a copy of the input pre-message public keys, so that I can easily delete processed ones without using iterators/counters\n const preMessagePKs = inPreMessagePKs.map((x) => x.clone());\n // Here we store currently processed pre message public key\n let currPK;\n // We retrieve the pre-message patterns to process, if any\n // If none, there's nothing to do\n if (this.handshakePattern.preMessagePatterns.length == 0) {\n return;\n }\n // If not empty, we check that pre-message is valid according to Noise specifications\n if (!this.isValid(this.handshakePattern.preMessagePatterns)) {\n throw new Error(\"invalid pre-message in handshake\");\n }\n // We iterate over each pattern contained in the pre-message\n for (const messagePattern of this.handshakePattern.preMessagePatterns) {\n const direction = messagePattern.direction;\n const tokens = messagePattern.tokens;\n // We get if the user is reading or writing the current pre-message pattern\n const { reading, writing } = this.getReadingWritingState(direction);\n // We process each message pattern token\n for (const token of tokens) {\n // We process the pattern token\n switch (token) {\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e:\n // We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (preMessagePKs.length > 0) {\n currPK = preMessagePKs[0];\n }\n else {\n throw new Error(\"noise pre-message read e, expected a public key\");\n }\n // If user is reading the \"e\" token\n if (reading) {\n log(\"noise pre-message read e\");\n // We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end\n if (currPK.flag == 0) {\n // Sets re and calls MixHash(re.public_key).\n this.re = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk);\n this.ss.mixHash(this.re);\n }\n else {\n throw new Error(\"noise read e, incorrect encryption flag for pre-message public key\");\n }\n // If user is writing the \"e\" token\n }\n else if (writing) {\n log(\"noise pre-message write e\");\n // When writing, the user is sending a public key,\n // We check that the public part corresponds to the set local key and we call MixHash(e.public_key).\n if (this.e && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.publicKey, (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk))) {\n this.ss.mixHash(this.e.publicKey);\n }\n else {\n throw new Error(\"noise pre-message e key doesn't correspond to locally set e key pair\");\n }\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(currPK.pk);\n }\n // We delete processed public key\n preMessagePKs.shift();\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s:\n // We expect a static key, so we attempt to read it (next PK to process will always be at index of preMessagePKs)\n if (preMessagePKs.length > 0) {\n currPK = preMessagePKs[0];\n }\n else {\n throw new Error(\"noise pre-message read s, expected a public key\");\n }\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise pre-message read s\");\n // We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end\n if (currPK.flag == 0) {\n // Sets re and calls MixHash(re.public_key).\n this.rs = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk);\n this.ss.mixHash(this.rs);\n }\n else {\n throw new Error(\"noise read s, incorrect encryption flag for pre-message public key\");\n }\n // If user is writing the \"s\" token\n }\n else if (writing) {\n log(\"noise pre-message write s\");\n // If writing, it means that the user is sending a public key,\n // We check that the public part corresponds to the set local key and we call MixHash(s.public_key).\n if (this.s && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.publicKey, (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk))) {\n this.ss.mixHash(this.s.publicKey);\n }\n else {\n throw new Error(\"noise pre-message s key doesn't correspond to locally set s key pair\");\n }\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(currPK.pk);\n }\n // We delete processed public key\n preMessagePKs.shift();\n break;\n default:\n throw new Error(\"invalid Token for pre-message pattern\");\n }\n }\n }\n }\n // This procedure encrypts/decrypts the implicit payload attached at the end of every message pattern\n // An optional extraAd to pass extra additional data in encryption/decryption can be set (useful to authenticate messageNametag)\n processMessagePatternPayload(transportMessage, extraAd = new Uint8Array()) {\n let payload;\n // We retrieve current message pattern (direction + tokens) to process\n const direction = this.handshakePattern.messagePatterns[this.msgPatternIdx].direction;\n // We get if the user is reading or writing the input handshake message\n const { reading, writing } = this.getReadingWritingState(direction);\n // We decrypt the transportMessage, if any\n if (reading) {\n payload = this.ss.decryptAndHash(transportMessage, extraAd);\n payload = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.unpad(payload);\n }\n else if (writing) {\n payload = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.pad(transportMessage, NoisePaddingBlockSize);\n payload = this.ss.encryptAndHash(payload, extraAd);\n }\n else {\n throw new Error(\"undefined state\");\n }\n return payload;\n }\n // We process an input handshake message according to current handshake state and we return the next handshake step's handshake message\n processMessagePatternTokens(inputHandshakeMessage = []) {\n // We retrieve current message pattern (direction + tokens) to process\n const messagePattern = this.handshakePattern.messagePatterns[this.msgPatternIdx];\n const direction = messagePattern.direction;\n const tokens = messagePattern.tokens;\n // We get if the user is reading or writing the input handshake message\n const { reading, writing } = this.getReadingWritingState(direction);\n // I make a copy of the handshake message so that I can easily delete processed PKs without using iterators/counters\n // (Possibly) non-empty if reading\n const inHandshakeMessage = inputHandshakeMessage;\n // The party's output public keys\n // (Possibly) non-empty if writing\n const outHandshakeMessage = [];\n // In currPK we store the currently processed public key from the handshake message\n let currPK;\n // We process each message pattern token\n for (const token of tokens) {\n switch (token) {\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e:\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise read e\");\n // We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (inHandshakeMessage.length > 0) {\n currPK = inHandshakeMessage[0];\n }\n else {\n throw new Error(\"noise read e, expected a public key\");\n }\n // We check if current key is encrypted or not\n // Note: by specification, ephemeral keys should always be unencrypted. But we support encrypted ones.\n if (currPK.flag == 0) {\n // Unencrypted Public Key\n // Sets re and calls MixHash(re.public_key).\n this.re = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk);\n this.ss.mixHash(this.re);\n // The following is out of specification: we call decryptAndHash for encrypted ephemeral keys, similarly as happens for (encrypted) static keys\n }\n else if (currPK.flag == 1) {\n // Encrypted public key\n // Decrypts re, sets re and calls MixHash(re.public_key).\n this.re = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(this.ss.decryptAndHash(currPK.pk));\n }\n else {\n throw new Error(\"noise read e, incorrect encryption flag for public key\");\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(this.re);\n }\n // We delete processed public key\n inHandshakeMessage.shift();\n // If user is writing the \"e\" token\n }\n else if (writing) {\n log(\"noise write e\");\n // We generate a new ephemeral keypair\n this.e = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.generateX25519KeyPair)();\n // We update the state\n this.ss.mixHash(this.e.publicKey);\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(this.e.publicKey);\n }\n // We add the ephemeral public key to the Waku payload\n outHandshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey.fromPublicKey(this.e.publicKey));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s:\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise read s\");\n // We expect a static key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (inHandshakeMessage.length > 0) {\n currPK = inHandshakeMessage[0];\n }\n else {\n throw new Error(\"noise read s, expected a public key\");\n }\n // We check if current key is encrypted or not\n if (currPK.flag == 0) {\n // Unencrypted Public Key\n // Sets re and calls MixHash(re.public_key).\n this.rs = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(currPK.pk);\n this.ss.mixHash(this.rs);\n }\n else if (currPK.flag == 1) {\n // Encrypted public key\n // Decrypts rs, sets rs and calls MixHash(rs.public_key).\n this.rs = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.intoCurve25519Key)(this.ss.decryptAndHash(currPK.pk));\n }\n else {\n throw new Error(\"noise read s, incorrect encryption flag for public key\");\n }\n // We delete processed public key\n inHandshakeMessage.shift();\n // If user is writing the \"s\" token\n }\n else if (writing) {\n log(\"noise write s\");\n // If the local static key is not set (the handshake state was not properly initialized), we raise an error\n if (!this.s) {\n throw new Error(\"static key not set\");\n }\n // We encrypt the public part of the static key in case a key is set in the Cipher State\n // That is, encS may either be an encrypted or unencrypted static key.\n const encS = this.ss.encryptAndHash(this.s.publicKey);\n // We add the (encrypted) static public key to the Waku payload\n // Note that encS = (Enc(s) || tag) if encryption key is set, otherwise encS = s.\n // We distinguish these two cases by checking length of encryption and we set the proper encryption flag\n if (encS.length > _crypto_js__WEBPACK_IMPORTED_MODULE_3__.Curve25519KeySize) {\n outHandshakeMessage.push(new _publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey(1, encS));\n }\n else {\n outHandshakeMessage.push(new _publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey(0, encS));\n }\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.psk:\n // If user is reading the \"psk\" token\n log(\"noise psk\");\n // Calls MixKeyAndHash(psk)\n this.ss.mixKeyAndHash(this.psk);\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.ee:\n // If user is reading the \"ee\" token\n log(\"noise dh ee\");\n // If local and/or remote ephemeral keys are not set, we raise an error\n if (!this.e || !this.re) {\n throw new Error(\"local or remote ephemeral key not set\");\n }\n // Calls MixKey(DH(e, re)).\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.e.privateKey, this.re));\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.es:\n // If user is reading the \"es\" token\n log(\"noise dh es\");\n // We check if keys are correctly set.\n // If both present, we call MixKey(DH(e, rs)) if initiator, MixKey(DH(s, re)) if responder.\n if (this.initiator) {\n if (!this.e || !this.rs) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.e.privateKey, this.rs));\n }\n else {\n if (!this.re || !this.s) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.s.privateKey, this.re));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.se:\n // If user is reading the \"se\" token\n log(\"noise dh se\");\n // We check if keys are correctly set.\n // If both present, call MixKey(DH(s, re)) if initiator, MixKey(DH(e, rs)) if responder.\n if (this.initiator) {\n if (!this.s || !this.re) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.s.privateKey, this.re));\n }\n else {\n if (!this.rs || !this.e) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.e.privateKey, this.rs));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.ss:\n // If user is reading the \"ss\" token\n log(\"noise dh ss\");\n // If local and/or remote static keys are not set, we raise an error\n if (!this.s || !this.rs) {\n throw new Error(\"local or remote static key not set\");\n }\n // Calls MixKey(DH(s, rs)).\n this.ss.mixKey((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.dh)(this.s.privateKey, this.rs));\n break;\n }\n }\n return outHandshakeMessage;\n }\n}\n//# sourceMappingURL=handshake_state.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/handshake_state.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HandshakeState: () => (/* binding */ HandshakeState),\n/* harmony export */ NoisePaddingBlockSize: () => (/* binding */ NoisePaddingBlockSize)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! pkcs7-padding */ \"./node_modules/pkcs7-padding/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@waku/noise/dist/noise.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:noise:handshake-state\");\n// The padding blocksize of a transport message\nconst NoisePaddingBlockSize = 248;\n// The Handshake State as in https://noiseprotocol.org/noise.html#the-handshakestate-object\n// Contains\n// - the local and remote ephemeral/static keys e,s,re,rs (if any)\n// - the initiator flag (true if the user creating the state is the handshake initiator, false otherwise)\n// - the handshakePattern (containing the handshake protocol name, and (pre)message patterns)\n// This object is further extended from specifications by storing:\n// - a message pattern index msgPatternIdx indicating the next handshake message pattern to process\n// - the user's preshared psk, if any\nclass HandshakeState {\n constructor(handshakePattern, psk) {\n this.handshakePattern = handshakePattern;\n this.psk = psk;\n // By default the Handshake State initiator flag is set to false\n // Will be set to true when the user associated to the handshake state starts an handshake\n this.initiator = false;\n this.ss = new _noise_js__WEBPACK_IMPORTED_MODULE_5__.SymmetricState(handshakePattern);\n this.msgPatternIdx = 0;\n }\n equals(b) {\n if (this.s != null && b.s != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.privateKey, b.s.privateKey))\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.publicKey, b.s.publicKey))\n return false;\n }\n else {\n return false;\n }\n if (this.e != null && b.e != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.privateKey, b.e.privateKey))\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.publicKey, b.e.publicKey))\n return false;\n }\n else {\n return false;\n }\n if (this.rs != null && b.rs != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.rs, b.rs))\n return false;\n }\n else {\n return false;\n }\n if (this.re != null && b.re != null) {\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.re, b.re))\n return false;\n }\n else {\n return false;\n }\n if (!this.ss.equals(b.ss))\n return false;\n if (this.initiator != b.initiator)\n return false;\n if (!this.handshakePattern.equals(b.handshakePattern))\n return false;\n if (this.msgPatternIdx != b.msgPatternIdx)\n return false;\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.psk, b.psk))\n return false;\n return true;\n }\n clone() {\n const result = new HandshakeState(this.handshakePattern, this.psk);\n result.s = this.s;\n result.e = this.e;\n result.rs = this.rs ? new Uint8Array(this.rs) : undefined;\n result.re = this.re ? new Uint8Array(this.re) : undefined;\n result.ss = this.ss.clone();\n result.initiator = this.initiator;\n result.msgPatternIdx = this.msgPatternIdx;\n return result;\n }\n genMessageNametagSecrets() {\n const [nms1, nms2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.handshakePattern.hash, this.ss.h, new Uint8Array(), 32, 2);\n return { nms1, nms2 };\n }\n // Uses the cryptographic information stored in the input handshake state to generate a random message nametag\n // In current implementation the messageNametag = HKDF(handshake hash value), but other derivation mechanisms can be implemented\n toMessageNametag() {\n const [output] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__.HKDF)(this.handshakePattern.hash, this.ss.h, new Uint8Array(), 32, 1);\n return output.subarray(0, _messagenametag_js__WEBPACK_IMPORTED_MODULE_4__.MessageNametagLength);\n }\n // Handshake Processing\n // Based on the message handshake direction and if the user is or not the initiator, returns a boolean tuple telling if the user\n // has to read or write the next handshake message\n getReadingWritingState(direction) {\n let reading = false;\n let writing = false;\n if (this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r) {\n // I'm Alice and direction is ->\n reading = false;\n writing = true;\n }\n else if (this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l) {\n // I'm Alice and direction is <-\n reading = true;\n writing = false;\n }\n else if (!this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r) {\n // I'm Bob and direction is ->\n reading = true;\n writing = false;\n }\n else if (!this.initiator && direction == _patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l) {\n // I'm Bob and direction is <-\n reading = false;\n writing = true;\n }\n return { reading, writing };\n }\n // Checks if a pre-message is valid according to Noise specifications\n // http://www.noiseprotocol.org/noise.html#handshake-patterns\n isValid(msg) {\n let isValid = true;\n // Non-empty pre-messages can only have patterns \"e\", \"s\", \"e,s\" in each direction\n const allowedPatterns = [\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.r, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e, _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e]),\n new _patterns_js__WEBPACK_IMPORTED_MODULE_6__.PreMessagePattern(_patterns_js__WEBPACK_IMPORTED_MODULE_6__.MessageDirection.l, [_patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e, _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s]),\n ];\n // We check if pre message patterns are allowed\n for (const pattern of msg) {\n if (!allowedPatterns.find((x) => x.equals(pattern))) {\n isValid = false;\n break;\n }\n }\n return isValid;\n }\n // Handshake messages processing procedures\n // Processes pre-message patterns\n processPreMessagePatternTokens(inPreMessagePKs = []) {\n // I make a copy of the input pre-message public keys, so that I can easily delete processed ones without using iterators/counters\n const preMessagePKs = inPreMessagePKs.map((x) => x.clone());\n // Here we store currently processed pre message public key\n let currPK;\n // We retrieve the pre-message patterns to process, if any\n // If none, there's nothing to do\n if (this.handshakePattern.preMessagePatterns.length == 0) {\n return;\n }\n // If not empty, we check that pre-message is valid according to Noise specifications\n if (!this.isValid(this.handshakePattern.preMessagePatterns)) {\n throw new Error(\"invalid pre-message in handshake\");\n }\n // We iterate over each pattern contained in the pre-message\n for (const messagePattern of this.handshakePattern.preMessagePatterns) {\n const direction = messagePattern.direction;\n const tokens = messagePattern.tokens;\n // We get if the user is reading or writing the current pre-message pattern\n const { reading, writing } = this.getReadingWritingState(direction);\n // We process each message pattern token\n for (const token of tokens) {\n // We process the pattern token\n switch (token) {\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e:\n // We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (preMessagePKs.length > 0) {\n currPK = preMessagePKs[0];\n }\n else {\n throw new Error(\"noise pre-message read e, expected a public key\");\n }\n // If user is reading the \"e\" token\n if (reading) {\n log(\"noise pre-message read e\");\n // We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end\n if (currPK.flag == 0) {\n // Sets re and calls MixHash(re.public_key).\n this.re = this.handshakePattern.dhKey.intoKey(currPK.pk);\n this.ss.mixHash(this.re);\n }\n else {\n throw new Error(\"noise read e, incorrect encryption flag for pre-message public key\");\n }\n // If user is writing the \"e\" token\n }\n else if (writing) {\n log(\"noise pre-message write e\");\n // When writing, the user is sending a public key,\n // We check that the public part corresponds to the set local key and we call MixHash(e.public_key).\n if (this.e && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.e.publicKey, this.handshakePattern.dhKey.intoKey(currPK.pk))) {\n this.ss.mixHash(this.e.publicKey);\n }\n else {\n throw new Error(\"noise pre-message e key doesn't correspond to locally set e key pair\");\n }\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(currPK.pk);\n }\n // We delete processed public key\n preMessagePKs.shift();\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s:\n // We expect a static key, so we attempt to read it (next PK to process will always be at index of preMessagePKs)\n if (preMessagePKs.length > 0) {\n currPK = preMessagePKs[0];\n }\n else {\n throw new Error(\"noise pre-message read s, expected a public key\");\n }\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise pre-message read s\");\n // We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end\n if (currPK.flag == 0) {\n // Sets re and calls MixHash(re.public_key).\n this.rs = this.handshakePattern.dhKey.intoKey(currPK.pk);\n this.ss.mixHash(this.rs);\n }\n else {\n throw new Error(\"noise read s, incorrect encryption flag for pre-message public key\");\n }\n // If user is writing the \"s\" token\n }\n else if (writing) {\n log(\"noise pre-message write s\");\n // If writing, it means that the user is sending a public key,\n // We check that the public part corresponds to the set local key and we call MixHash(s.public_key).\n if (this.s && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(this.s.publicKey, this.handshakePattern.dhKey.intoKey(currPK.pk))) {\n this.ss.mixHash(this.s.publicKey);\n }\n else {\n throw new Error(\"noise pre-message s key doesn't correspond to locally set s key pair\");\n }\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(currPK.pk);\n }\n // We delete processed public key\n preMessagePKs.shift();\n break;\n default:\n throw new Error(\"invalid Token for pre-message pattern\");\n }\n }\n }\n }\n // This procedure encrypts/decrypts the implicit payload attached at the end of every message pattern\n // An optional extraAd to pass extra additional data in encryption/decryption can be set (useful to authenticate messageNametag)\n processMessagePatternPayload(transportMessage, extraAd = new Uint8Array()) {\n let payload;\n // We retrieve current message pattern (direction + tokens) to process\n const direction = this.handshakePattern.messagePatterns[this.msgPatternIdx].direction;\n // We get if the user is reading or writing the input handshake message\n const { reading, writing } = this.getReadingWritingState(direction);\n // We decrypt the transportMessage, if any\n if (reading) {\n payload = this.ss.decryptAndHash(transportMessage, extraAd);\n payload = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.unpad(payload);\n }\n else if (writing) {\n payload = pkcs7_padding__WEBPACK_IMPORTED_MODULE_1__.pad(transportMessage, NoisePaddingBlockSize);\n payload = this.ss.encryptAndHash(payload, extraAd);\n }\n else {\n throw new Error(\"undefined state\");\n }\n return payload;\n }\n // We process an input handshake message according to current handshake state and we return the next handshake step's handshake message\n processMessagePatternTokens(inputHandshakeMessage = []) {\n // We retrieve current message pattern (direction + tokens) to process\n const messagePattern = this.handshakePattern.messagePatterns[this.msgPatternIdx];\n const direction = messagePattern.direction;\n const tokens = messagePattern.tokens;\n // We get if the user is reading or writing the input handshake message\n const { reading, writing } = this.getReadingWritingState(direction);\n // I make a copy of the handshake message so that I can easily delete processed PKs without using iterators/counters\n // (Possibly) non-empty if reading\n const inHandshakeMessage = inputHandshakeMessage;\n // The party's output public keys\n // (Possibly) non-empty if writing\n const outHandshakeMessage = [];\n // In currPK we store the currently processed public key from the handshake message\n let currPK;\n // We process each message pattern token\n for (const token of tokens) {\n switch (token) {\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.e:\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise read e\");\n // We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (inHandshakeMessage.length > 0) {\n currPK = inHandshakeMessage[0];\n }\n else {\n throw new Error(\"noise read e, expected a public key\");\n }\n // We check if current key is encrypted or not\n // Note: by specification, ephemeral keys should always be unencrypted. But we support encrypted ones.\n if (currPK.flag == 0) {\n // Unencrypted Public Key\n // Sets re and calls MixHash(re.public_key).\n this.re = this.handshakePattern.dhKey.intoKey(currPK.pk);\n this.ss.mixHash(this.re);\n // The following is out of specification: we call decryptAndHash for encrypted ephemeral keys, similarly as happens for (encrypted) static keys\n }\n else if (currPK.flag == 1) {\n // Encrypted public key\n // Decrypts re, sets re and calls MixHash(re.public_key).\n this.re = this.handshakePattern.dhKey.intoKey(this.ss.decryptAndHash(currPK.pk));\n }\n else {\n throw new Error(\"noise read e, incorrect encryption flag for public key\");\n }\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(this.re);\n }\n // We delete processed public key\n inHandshakeMessage.shift();\n // If user is writing the \"e\" token\n }\n else if (writing) {\n log(\"noise write e\");\n // We generate a new ephemeral keypair\n this.e = this.handshakePattern.dhKey.generateKeyPair();\n // We update the state\n this.ss.mixHash(this.e.publicKey);\n // Noise specification: section 9.2\n // In non-PSK handshakes, the \"e\" token in a pre-message pattern or message pattern always results\n // in a call to MixHash(e.public_key).\n // In a PSK handshake, all of these calls are followed by MixKey(e.public_key).\n if (this.handshakePattern.name.indexOf(\"psk\") > -1) {\n this.ss.mixKey(this.e.publicKey);\n }\n // We add the ephemeral public key to the Waku payload\n outHandshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey.fromPublicKey(this.e.publicKey));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.s:\n // If user is reading the \"s\" token\n if (reading) {\n log(\"noise read s\");\n // We expect a static key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)\n if (inHandshakeMessage.length > 0) {\n currPK = inHandshakeMessage[0];\n }\n else {\n throw new Error(\"noise read s, expected a public key\");\n }\n // We check if current key is encrypted or not\n if (currPK.flag == 0) {\n // Unencrypted Public Key\n // Sets re and calls MixHash(re.public_key).\n this.rs = this.handshakePattern.dhKey.intoKey(currPK.pk);\n this.ss.mixHash(this.rs);\n }\n else if (currPK.flag == 1) {\n // Encrypted public key\n // Decrypts rs, sets rs and calls MixHash(rs.public_key).\n this.rs = this.handshakePattern.dhKey.intoKey(this.ss.decryptAndHash(currPK.pk));\n }\n else {\n throw new Error(\"noise read s, incorrect encryption flag for public key\");\n }\n // We delete processed public key\n inHandshakeMessage.shift();\n // If user is writing the \"s\" token\n }\n else if (writing) {\n log(\"noise write s\");\n // If the local static key is not set (the handshake state was not properly initialized), we raise an error\n if (!this.s) {\n throw new Error(\"static key not set\");\n }\n // We encrypt the public part of the static key in case a key is set in the Cipher State\n // That is, encS may either be an encrypted or unencrypted static key.\n const encS = this.ss.encryptAndHash(this.s.publicKey);\n // We add the (encrypted) static public key to the Waku payload\n // Note that encS = (Enc(s) || tag) if encryption key is set, otherwise encS = s.\n // We distinguish these two cases by checking length of encryption and we set the proper encryption flag\n if (encS.length > this.handshakePattern.dhKey.DHLen()) {\n outHandshakeMessage.push(new _publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey(1, encS));\n }\n else {\n outHandshakeMessage.push(new _publickey_js__WEBPACK_IMPORTED_MODULE_7__.NoisePublicKey(0, encS));\n }\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.psk:\n // If user is reading the \"psk\" token\n log(\"noise psk\");\n // Calls MixKeyAndHash(psk)\n this.ss.mixKeyAndHash(this.psk);\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.ee:\n // If user is reading the \"ee\" token\n log(\"noise dh ee\");\n // If local and/or remote ephemeral keys are not set, we raise an error\n if (!this.e || !this.re) {\n throw new Error(\"local or remote ephemeral key not set\");\n }\n // Calls MixKey(DH(e, re)).\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.e.privateKey, this.re));\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.es:\n // If user is reading the \"es\" token\n log(\"noise dh es\");\n // We check if keys are correctly set.\n // If both present, we call MixKey(DH(e, rs)) if initiator, MixKey(DH(s, re)) if responder.\n if (this.initiator) {\n if (!this.e || !this.rs) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.e.privateKey, this.rs));\n }\n else {\n if (!this.re || !this.s) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.s.privateKey, this.re));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.se:\n // If user is reading the \"se\" token\n log(\"noise dh se\");\n // We check if keys are correctly set.\n // If both present, call MixKey(DH(s, re)) if initiator, MixKey(DH(e, rs)) if responder.\n if (this.initiator) {\n if (!this.s || !this.re) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.s.privateKey, this.re));\n }\n else {\n if (!this.rs || !this.e) {\n throw new Error(\"local or remote ephemeral/static key not set\");\n }\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.e.privateKey, this.rs));\n }\n break;\n case _patterns_js__WEBPACK_IMPORTED_MODULE_6__.NoiseTokens.ss:\n // If user is reading the \"ss\" token\n log(\"noise dh ss\");\n // If local and/or remote static keys are not set, we raise an error\n if (!this.s || !this.rs) {\n throw new Error(\"local or remote static key not set\");\n }\n // Calls MixKey(DH(s, rs)).\n this.ss.mixKey(this.handshakePattern.dhKey.DH(this.s.privateKey, this.rs));\n break;\n }\n }\n return outHandshakeMessage;\n }\n}\n//# sourceMappingURL=handshake_state.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/handshake_state.js?"); /***/ }), @@ -4905,7 +5847,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChaChaPolyCipherState: () => (/* reexport safe */ _publickey_js__WEBPACK_IMPORTED_MODULE_6__.ChaChaPolyCipherState),\n/* harmony export */ Handshake: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.Handshake),\n/* harmony export */ HandshakePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.HandshakePattern),\n/* harmony export */ HandshakeResult: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.HandshakeResult),\n/* harmony export */ HandshakeStepResult: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.HandshakeStepResult),\n/* harmony export */ InitiatorParameters: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_4__.InitiatorParameters),\n/* harmony export */ MessageDirection: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.MessageDirection),\n/* harmony export */ MessageNametagBuffer: () => (/* reexport safe */ _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagBuffer),\n/* harmony export */ MessageNametagError: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagError),\n/* harmony export */ MessagePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.MessagePattern),\n/* harmony export */ NoiseHandshakeDecoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseHandshakeDecoder),\n/* harmony export */ NoiseHandshakeEncoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseHandshakeEncoder),\n/* harmony export */ NoiseHandshakePatterns: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.NoiseHandshakePatterns),\n/* harmony export */ NoisePublicKey: () => (/* reexport safe */ _publickey_js__WEBPACK_IMPORTED_MODULE_6__.NoisePublicKey),\n/* harmony export */ NoiseSecureTransferDecoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseSecureTransferDecoder),\n/* harmony export */ NoiseSecureTransferEncoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseSecureTransferEncoder),\n/* harmony export */ NoiseTokens: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.NoiseTokens),\n/* harmony export */ PayloadV2ProtocolIDs: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.PayloadV2ProtocolIDs),\n/* harmony export */ PreMessagePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_5__.PreMessagePattern),\n/* harmony export */ QR: () => (/* reexport safe */ _qr_js__WEBPACK_IMPORTED_MODULE_7__.QR),\n/* harmony export */ ResponderParameters: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_4__.ResponderParameters),\n/* harmony export */ WakuPairing: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_4__.WakuPairing),\n/* harmony export */ generateX25519KeyPair: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_1__.generateX25519KeyPair),\n/* harmony export */ generateX25519KeyPairFromSeed: () => (/* reexport safe */ _crypto_js__WEBPACK_IMPORTED_MODULE_1__.generateX25519KeyPairFromSeed)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@waku/noise/dist/codec.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _handshake_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./handshake.js */ \"./node_modules/@waku/noise/dist/handshake.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _pairing_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pairing.js */ \"./node_modules/@waku/noise/dist/pairing.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _qr_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./qr.js */ \"./node_modules/@waku/noise/dist/qr.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CipherState: () => (/* reexport safe */ _noise_js__WEBPACK_IMPORTED_MODULE_4__.CipherState),\n/* harmony export */ Handshake: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.Handshake),\n/* harmony export */ HandshakePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.HandshakePattern),\n/* harmony export */ HandshakeResult: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.HandshakeResult),\n/* harmony export */ HandshakeStepResult: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.HandshakeStepResult),\n/* harmony export */ InitiatorParameters: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_6__.InitiatorParameters),\n/* harmony export */ MessageDirection: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.MessageDirection),\n/* harmony export */ MessageNametagBuffer: () => (/* reexport safe */ _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagBuffer),\n/* harmony export */ MessageNametagError: () => (/* reexport safe */ _handshake_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagError),\n/* harmony export */ MessagePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.MessagePattern),\n/* harmony export */ NoiseHandshakeDecoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseHandshakeDecoder),\n/* harmony export */ NoiseHandshakeEncoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseHandshakeEncoder),\n/* harmony export */ NoiseHandshakePatterns: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.NoiseHandshakePatterns),\n/* harmony export */ NoisePublicKey: () => (/* reexport safe */ _publickey_js__WEBPACK_IMPORTED_MODULE_9__.NoisePublicKey),\n/* harmony export */ NoiseSecureTransferDecoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseSecureTransferDecoder),\n/* harmony export */ NoiseSecureTransferEncoder: () => (/* reexport safe */ _codec_js__WEBPACK_IMPORTED_MODULE_0__.NoiseSecureTransferEncoder),\n/* harmony export */ NoiseTokens: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.NoiseTokens),\n/* harmony export */ Nonce: () => (/* reexport safe */ _nonce_js__WEBPACK_IMPORTED_MODULE_5__.Nonce),\n/* harmony export */ PayloadV2: () => (/* reexport safe */ _payload_js__WEBPACK_IMPORTED_MODULE_8__.PayloadV2),\n/* harmony export */ PayloadV2ProtocolIDs: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.PayloadV2ProtocolIDs),\n/* harmony export */ PreMessagePattern: () => (/* reexport safe */ _patterns_js__WEBPACK_IMPORTED_MODULE_7__.PreMessagePattern),\n/* harmony export */ QR: () => (/* reexport safe */ _qr_js__WEBPACK_IMPORTED_MODULE_10__.QR),\n/* harmony export */ ResponderParameters: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_6__.ResponderParameters),\n/* harmony export */ WakuPairing: () => (/* reexport safe */ _pairing_js__WEBPACK_IMPORTED_MODULE_6__.WakuPairing),\n/* harmony export */ X25519DHKey: () => (/* reexport safe */ _dh25519_js__WEBPACK_IMPORTED_MODULE_1__.DH25519)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@waku/noise/dist/codec.js\");\n/* harmony import */ var _dh25519_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dh25519.js */ \"./node_modules/@waku/noise/dist/dh25519.js\");\n/* harmony import */ var _handshake_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./handshake.js */ \"./node_modules/@waku/noise/dist/handshake.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@waku/noise/dist/noise.js\");\n/* harmony import */ var _nonce_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nonce.js */ \"./node_modules/@waku/noise/dist/nonce.js\");\n/* harmony import */ var _pairing_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./pairing.js */ \"./node_modules/@waku/noise/dist/pairing.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _payload_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./payload.js */ \"./node_modules/@waku/noise/dist/payload.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _qr_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./qr.js */ \"./node_modules/@waku/noise/dist/qr.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/index.js?"); /***/ }), @@ -4916,7 +5858,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageNametagBuffer: () => (/* binding */ MessageNametagBuffer),\n/* harmony export */ MessageNametagBufferSize: () => (/* binding */ MessageNametagBufferSize),\n/* harmony export */ MessageNametagLength: () => (/* binding */ MessageNametagLength),\n/* harmony export */ toMessageNametag: () => (/* binding */ toMessageNametag)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/noise/dist/utils.js\");\n\n\n\n\nconst MessageNametagLength = 16;\nconst MessageNametagBufferSize = 50;\n/**\n * Converts a sequence or array (arbitrary size) to a MessageNametag\n * @param input\n * @returns\n */\nfunction toMessageNametag(input) {\n return input.subarray(0, MessageNametagLength);\n}\nclass MessageNametagBuffer {\n constructor() {\n this.buffer = new Array(MessageNametagBufferSize);\n this.counter = 0;\n for (let i = 0; i < this.buffer.length; i++) {\n this.buffer[i] = new Uint8Array(MessageNametagLength);\n }\n }\n /**\n * Initializes the empty Message nametag buffer. The n-th nametag is equal to HKDF( secret || n )\n */\n initNametagsBuffer() {\n // We default the counter and buffer fields\n this.counter = 0;\n this.buffer = new Array(MessageNametagBufferSize);\n if (this.secret) {\n for (let i = 0; i < this.buffer.length; i++) {\n const counterBytesLE = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.writeUIntLE)(new Uint8Array(8), this.counter, 0, 8);\n const d = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.hashSHA256)((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([this.secret, counterBytesLE]));\n this.buffer[i] = toMessageNametag(d);\n this.counter++;\n }\n }\n else {\n // We warn users if no secret is set\n console.debug(\"The message nametags buffer has not a secret set\");\n }\n }\n /**\n * Pop the nametag from the message nametag buffer\n * @returns MessageNametag\n */\n pop() {\n // Note that if the input MessageNametagBuffer is set to default, an all 0 messageNametag is returned\n const messageNametag = new Uint8Array(this.buffer[0]);\n this.delete(1);\n return messageNametag;\n }\n /**\n * Checks if the input messageNametag is contained in the input MessageNametagBuffer\n * @param messageNametag Message nametag to verify\n * @returns true if it's the expected nametag, false otherwise\n */\n checkNametag(messageNametag) {\n const index = this.buffer.findIndex((x) => (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(x, messageNametag));\n if (index == -1) {\n console.debug(\"Message nametag not found in buffer\");\n return false;\n }\n else if (index > 0) {\n console.debug(\"Message nametag is present in buffer but is not the next expected nametag. One or more messages were probably lost\");\n return false;\n }\n // index is 0, hence the read message tag is the next expected one\n return true;\n }\n rotateLeft(k) {\n if (k < 0 || this.buffer.length == 0) {\n return;\n }\n const idx = this.buffer.length - (k % this.buffer.length);\n const a1 = this.buffer.slice(idx);\n const a2 = this.buffer.slice(0, idx);\n this.buffer = a1.concat(a2);\n }\n /**\n * Deletes the first n elements in buffer and appends n new ones\n * @param n number of message nametags to delete\n */\n delete(n) {\n if (n <= 0) {\n return;\n }\n // We ensure n is at most MessageNametagBufferSize (the buffer will be fully replaced)\n n = Math.min(n, MessageNametagBufferSize);\n // We update the last n values in the array if a secret is set\n // Note that if the input MessageNametagBuffer is set to default, nothing is done here\n if (this.secret) {\n // We rotate left the array by n\n this.rotateLeft(n);\n for (let i = 0; i < n; i++) {\n const counterBytesLE = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.writeUIntLE)(new Uint8Array(8), this.counter, 0, 8);\n const d = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.hashSHA256)((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([this.secret, counterBytesLE]));\n this.buffer[this.buffer.length - n + i] = toMessageNametag(d);\n this.counter++;\n }\n }\n else {\n // We warn users that no secret is set\n console.debug(\"The message nametags buffer has no secret set\");\n }\n }\n}\n//# sourceMappingURL=messagenametag.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/messagenametag.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageNametagBuffer: () => (/* binding */ MessageNametagBuffer),\n/* harmony export */ MessageNametagBufferSize: () => (/* binding */ MessageNametagBufferSize),\n/* harmony export */ MessageNametagLength: () => (/* binding */ MessageNametagLength),\n/* harmony export */ toMessageNametag: () => (/* binding */ toMessageNametag)\n/* harmony export */ });\n/* harmony import */ var _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/sha256 */ \"./node_modules/@stablelib/sha256/lib/sha256.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/noise/dist/utils.js\");\n\n\n\n\nconst MessageNametagLength = 16;\nconst MessageNametagBufferSize = 50;\n/**\n * Converts a sequence or array (arbitrary size) to a MessageNametag\n * @param input\n * @returns\n */\nfunction toMessageNametag(input) {\n return input.subarray(0, MessageNametagLength);\n}\nclass MessageNametagBuffer {\n constructor() {\n this.buffer = new Array(MessageNametagBufferSize);\n this.counter = 0;\n for (let i = 0; i < this.buffer.length; i++) {\n this.buffer[i] = new Uint8Array(MessageNametagLength);\n }\n }\n /**\n * Initializes the empty Message nametag buffer. The n-th nametag is equal to HKDF( secret || n )\n */\n initNametagsBuffer() {\n // We default the counter and buffer fields\n this.counter = 0;\n this.buffer = new Array(MessageNametagBufferSize);\n if (this.secret) {\n for (let i = 0; i < this.buffer.length; i++) {\n const counterBytesLE = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.writeUIntLE)(new Uint8Array(8), this.counter, 0, 8);\n // TODO: determine if this hash should be sha256, or if it should depend on the handshake pattern\n const d = hashSHA256((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([this.secret, counterBytesLE]));\n this.buffer[i] = toMessageNametag(d);\n this.counter++;\n }\n }\n else {\n // We warn users if no secret is set\n console.debug(\"The message nametags buffer has not a secret set\");\n }\n }\n /**\n * Pop the nametag from the message nametag buffer\n * @returns MessageNametag\n */\n pop() {\n // Note that if the input MessageNametagBuffer is set to default, an all 0 messageNametag is returned\n const messageNametag = new Uint8Array(this.buffer[0]);\n this.delete(1);\n return messageNametag;\n }\n /**\n * Checks if the input messageNametag is contained in the input MessageNametagBuffer\n * @param messageNametag Message nametag to verify\n * @returns true if it's the expected nametag, false otherwise\n */\n checkNametag(messageNametag) {\n const index = this.buffer.findIndex((x) => (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(x, messageNametag));\n if (index == -1) {\n console.debug(\"Message nametag not found in buffer\");\n return false;\n }\n else if (index > 0) {\n console.debug(\"Message nametag is present in buffer but is not the next expected nametag. One or more messages were probably lost\");\n return false;\n }\n // index is 0, hence the read message tag is the next expected one\n return true;\n }\n getNametagPosition(messageNametag) {\n const index = this.buffer.findIndex((x) => (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_2__.equals)(x, messageNametag));\n return index;\n }\n rotateLeft(k) {\n if (k < 0 || this.buffer.length == 0) {\n return;\n }\n const idx = k % this.buffer.length;\n const a1 = this.buffer.slice(idx);\n const a2 = this.buffer.slice(0, idx);\n this.buffer = a1.concat(a2);\n }\n /**\n * Deletes the first n elements in buffer and appends n new ones\n * @param n number of message nametags to delete\n */\n delete(n) {\n if (n <= 0) {\n return;\n }\n // We ensure n is at most MessageNametagBufferSize (the buffer will be fully replaced)\n n = Math.min(n, MessageNametagBufferSize);\n // We update the last n values in the array if a secret is set\n // Note that if the input MessageNametagBuffer is set to default, nothing is done here\n if (this.secret) {\n // We rotate left the array by n\n this.rotateLeft(n);\n for (let i = 0; i < n; i++) {\n const counterBytesLE = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.writeUIntLE)(new Uint8Array(8), this.counter, 0, 8);\n const d = hashSHA256((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_1__.concat)([this.secret, counterBytesLE]));\n this.buffer[this.buffer.length - n + i] = toMessageNametag(d);\n this.counter++;\n }\n }\n else {\n // We warn users that no secret is set\n console.debug(\"The message nametags buffer has no secret set\");\n }\n }\n getNametagAtPosition(position) {\n return this.buffer[position];\n }\n}\n/**\n * Generate hash using SHA2-256\n * @param data data to hash\n * @returns hash digest\n */\nfunction hashSHA256(data) {\n return (0,_stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.hash)(data);\n}\n//# sourceMappingURL=messagenametag.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/messagenametag.js?"); /***/ }), @@ -4927,7 +5869,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CipherState: () => (/* binding */ CipherState),\n/* harmony export */ SymmetricState: () => (/* binding */ SymmetricState),\n/* harmony export */ createEmptyKey: () => (/* binding */ createEmptyKey),\n/* harmony export */ isEmptyKey: () => (/* binding */ isEmptyKey)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _nonce_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nonce.js */ \"./node_modules/@waku/noise/dist/nonce.js\");\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:noise:handshake-state\");\n// Waku Noise Protocols for Waku Payload Encryption\n// Noise module implementing the Noise State Objects and ChaChaPoly encryption/decryption primitives\n// See spec for more details:\n// https://github.com/vacp2p/rfc/tree/master/content/docs/rfcs/35\n//\n// Implementation partially inspired by noise-libp2p and js-libp2p-noise\n// https://github.com/status-im/nim-libp2p/blob/master/libp2p/protocols/secure/noise.nim\n// https://github.com/ChainSafe/js-libp2p-noise\n/*\n# Noise state machine primitives\n\n# Overview :\n# - Alice and Bob process (i.e. read and write, based on their role) each token appearing in a handshake pattern, consisting of pre-message and message patterns;\n# - Both users initialize and update according to processed tokens a Handshake State, a Symmetric State and a Cipher State;\n# - A preshared key psk is processed by calling MixKeyAndHash(psk);\n# - When an ephemeral public key e is read or written, the handshake hash value h is updated by calling mixHash(e); If the handshake expects a psk, MixKey(e) is further called\n# - When an encrypted static public key s or a payload message m is read, it is decrypted with decryptAndHash;\n# - When a static public key s or a payload message is written, it is encrypted with encryptAndHash;\n# - When any Diffie-Hellman token ee, es, se, ss is read or written, the chaining key ck is updated by calling MixKey on the computed secret;\n# - If all tokens are processed, users compute two new Cipher States by calling Split;\n# - The two Cipher States obtained from Split are used to encrypt/decrypt outbound/inbound messages.\n\n#################################\n# Cipher State Primitives\n#################################\n*/\n/**\n * Create empty chaining key\n * @returns 32-byte empty key\n */\nfunction createEmptyKey() {\n return new Uint8Array(32);\n}\n/**\n * Checks if a 32-byte key is empty\n * @param k key to verify\n * @returns true if empty, false otherwise\n */\nfunction isEmptyKey(k) {\n const emptyKey = createEmptyKey();\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(emptyKey, k);\n}\n/**\n * The Cipher State as in https://noiseprotocol.org/noise.html#the-cipherstate-object\n * Contains an encryption key k and a nonce n (used in Noise as a counter)\n */\nclass CipherState {\n /**\n * @param k encryption key\n * @param n nonce\n */\n constructor(k = createEmptyKey(), n = new _nonce_js__WEBPACK_IMPORTED_MODULE_5__.Nonce()) {\n this.k = k;\n this.n = n;\n }\n /**\n * Create a copy of the CipherState\n * @returns a copy of the CipherState\n */\n clone() {\n return new CipherState(new Uint8Array(this.k), new _nonce_js__WEBPACK_IMPORTED_MODULE_5__.Nonce(this.n.getUint64()));\n }\n /**\n * Check CipherState equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.k, other.getKey()) && this.n.getUint64() == other.getNonce().getUint64();\n }\n /**\n * Checks if a Cipher State has an encryption key set\n * @returns true if a key is set, false otherwise`\n */\n hasKey() {\n return !isEmptyKey(this.k);\n }\n /**\n * Encrypts a plaintext using key material in a Noise Cipher State\n * The CipherState is updated increasing the nonce (used as a counter in Noise) by one\n * @param ad associated data\n * @param plaintext data to encrypt\n */\n encryptWithAd(ad, plaintext) {\n this.n.assertValue();\n let ciphertext = new Uint8Array();\n if (this.hasKey()) {\n // If an encryption key is set in the Cipher state, we proceed with encryption\n ciphertext = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.chaCha20Poly1305Encrypt)(plaintext, this.n.getBytes(), ad, this.k);\n this.n.increment();\n this.n.assertValue();\n log(\"encryptWithAd\", ciphertext, this.n.getUint64() - 1);\n }\n else {\n // Otherwise we return the input plaintext according to specification http://www.noiseprotocol.org/noise.html#the-cipherstate-object\n ciphertext = plaintext;\n log(\"encryptWithAd called with no encryption key set. Returning plaintext.\");\n }\n return ciphertext;\n }\n /**\n * Decrypts a ciphertext using key material in a Noise Cipher State\n * The CipherState is updated increasing the nonce (used as a counter in Noise) by one\n * @param ad associated data\n * @param ciphertext data to decrypt\n */\n decryptWithAd(ad, ciphertext) {\n this.n.assertValue();\n if (this.hasKey()) {\n const plaintext = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.chaCha20Poly1305Decrypt)(ciphertext, this.n.getBytes(), ad, this.k);\n if (!plaintext) {\n throw new Error(\"decryptWithAd failed\");\n }\n this.n.increment();\n this.n.assertValue();\n return plaintext;\n }\n else {\n // Otherwise we return the input ciphertext according to specification\n // http://www.noiseprotocol.org/noise.html#the-cipherstate-object\n log(\"decryptWithAd called with no encryption key set. Returning ciphertext.\");\n return ciphertext;\n }\n }\n /**\n * Sets the nonce of a Cipher State\n * @param nonce Nonce\n */\n setNonce(nonce) {\n this.n = nonce;\n }\n /**\n * Sets the key of a Cipher State\n * @param key set the cipherstate encryption key\n */\n setCipherStateKey(key) {\n this.k = key;\n }\n /**\n * Gets the encryption key of a Cipher State\n * @returns encryption key\n */\n getKey() {\n return this.k;\n }\n /**\n * Gets the nonce of a Cipher State\n * @returns Nonce\n */\n getNonce() {\n return this.n;\n }\n}\n/**\n * Hash protocol name\n * @param name name of the noise handshake pattern to hash\n * @returns sha256 digest of the protocol name\n */\nfunction hashProtocol(name) {\n // If protocol_name is less than or equal to HASHLEN bytes in length,\n // sets h equal to protocol_name with zero bytes appended to make HASHLEN bytes.\n // Otherwise sets h = HASH(protocol_name).\n const protocolName = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_1__.fromString)(name, \"utf-8\");\n if (protocolName.length <= 32) {\n const h = new Uint8Array(32);\n h.set(protocolName);\n return h;\n }\n else {\n return (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.hashSHA256)(protocolName);\n }\n}\n/**\n * The Symmetric State as in https://noiseprotocol.org/noise.html#the-symmetricstate-object\n * Contains a Cipher State cs, the chaining key ck and the handshake hash value h\n */\nclass SymmetricState {\n constructor(hsPattern) {\n this.hsPattern = hsPattern;\n this.h = hashProtocol(hsPattern.name);\n this.ck = this.h;\n this.cs = new CipherState();\n this.hsPattern = hsPattern;\n }\n /**\n * Check CipherState equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.cs.equals(other.cs) &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.ck, other.ck) &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.h, other.h) &&\n this.hsPattern.equals(other.hsPattern));\n }\n /**\n * Create a copy of the SymmetricState\n * @returns a copy of the SymmetricState\n */\n clone() {\n const ss = new SymmetricState(this.hsPattern);\n ss.cs = this.cs.clone();\n ss.ck = new Uint8Array(this.ck);\n ss.h = new Uint8Array(this.h);\n return ss;\n }\n /**\n * MixKey as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Updates a Symmetric state chaining key and symmetric state\n * @param inputKeyMaterial\n */\n mixKey(inputKeyMaterial) {\n // We derive two keys using HKDF\n const [ck, tempK] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.ck, inputKeyMaterial, 32, 2);\n // We update ck and the Cipher state's key k using the output of HDKF\n this.cs = new CipherState(tempK);\n this.ck = ck;\n log(\"mixKey\", this.ck, this.cs.k);\n }\n /**\n * MixHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Hashes data into a Symmetric State's handshake hash value h\n * @param data input data to hash into h\n */\n mixHash(data) {\n // We hash the previous handshake hash and input data and store the result in the Symmetric State's handshake hash value\n this.h = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.hashSHA256)((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, data]));\n log(\"mixHash\", this.h);\n }\n /**\n * mixKeyAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines MixKey and MixHash\n * @param inputKeyMaterial\n */\n mixKeyAndHash(inputKeyMaterial) {\n // Derives 3 keys using HKDF, the chaining key and the input key material\n const [tmpKey0, tmpKey1, tmpKey2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.ck, inputKeyMaterial, 32, 3);\n // Sets the chaining key\n this.ck = tmpKey0;\n // Updates the handshake hash value\n this.mixHash(tmpKey1);\n // Updates the Cipher state's key\n // Note for later support of 512 bits hash functions: \"If HASHLEN is 64, then truncates tempKeys[2] to 32 bytes.\"\n this.cs = new CipherState(tmpKey2);\n }\n /**\n * EncryptAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines encryptWithAd and mixHash\n * Note that by setting extraAd, it is possible to pass extra additional data that will be concatenated to the ad\n * specified by Noise (can be used to authenticate messageNametag)\n * @param plaintext data to encrypt\n * @param extraAd extra additional data\n */\n encryptAndHash(plaintext, extraAd = new Uint8Array()) {\n // The additional data\n const ad = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, extraAd]);\n // Note that if an encryption key is not set yet in the Cipher state, ciphertext will be equal to plaintext\n const ciphertext = this.cs.encryptWithAd(ad, plaintext);\n // We call mixHash over the result\n this.mixHash(ciphertext);\n return ciphertext;\n }\n /**\n * DecryptAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines decryptWithAd and mixHash\n * @param ciphertext data to decrypt\n * @param extraAd extra additional data\n */\n decryptAndHash(ciphertext, extraAd = new Uint8Array()) {\n // The additional data\n const ad = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, extraAd]);\n // Note that if an encryption key is not set yet in the Cipher state, plaintext will be equal to ciphertext\n const plaintext = this.cs.decryptWithAd(ad, ciphertext);\n // According to specification, the ciphertext enters mixHash (and not the plaintext)\n this.mixHash(ciphertext);\n return plaintext;\n }\n /**\n * Split as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Once a handshake is complete, returns two Cipher States to encrypt/decrypt outbound/inbound messages\n * @returns CipherState to encrypt and CipherState to decrypt\n */\n split() {\n // Derives 2 keys using HKDF and the chaining key\n const [tmpKey1, tmpKey2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.ck, new Uint8Array(0), 32, 2);\n // Returns a tuple of two Cipher States initialized with the derived keys\n return {\n cs1: new CipherState(tmpKey1),\n cs2: new CipherState(tmpKey2),\n };\n }\n /**\n * Gets the chaining key field of a Symmetric State\n * @returns Chaining key\n */\n getChainingKey() {\n return this.ck;\n }\n /**\n * Gets the handshake hash field of a Symmetric State\n * @returns Handshake hash\n */\n getHandshakeHash() {\n return this.h;\n }\n /**\n * Gets the Cipher State field of a Symmetric State\n * @returns Cipher State\n */\n getCipherState() {\n return this.cs;\n }\n}\n//# sourceMappingURL=noise.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/noise.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CipherState: () => (/* binding */ CipherState),\n/* harmony export */ SymmetricState: () => (/* binding */ SymmetricState),\n/* harmony export */ createEmptyKey: () => (/* binding */ createEmptyKey),\n/* harmony export */ isEmptyKey: () => (/* binding */ isEmptyKey)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _nonce_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nonce.js */ \"./node_modules/@waku/noise/dist/nonce.js\");\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:noise:handshake-state\");\n// Waku Noise Protocols for Waku Payload Encryption\n// Noise module implementing the Noise State Objects and ChaChaPoly encryption/decryption primitives\n// See spec for more details:\n// https://github.com/vacp2p/rfc/tree/master/content/docs/rfcs/35\n//\n// Implementation partially inspired by noise-libp2p and js-libp2p-noise\n// https://github.com/status-im/nim-libp2p/blob/master/libp2p/protocols/secure/noise.nim\n// https://github.com/ChainSafe/js-libp2p-noise\n/*\n# Noise state machine primitives\n\n# Overview :\n# - Alice and Bob process (i.e. read and write, based on their role) each token appearing in a handshake pattern, consisting of pre-message and message patterns;\n# - Both users initialize and update according to processed tokens a Handshake State, a Symmetric State and a Cipher State;\n# - A preshared key psk is processed by calling MixKeyAndHash(psk);\n# - When an ephemeral public key e is read or written, the handshake hash value h is updated by calling mixHash(e); If the handshake expects a psk, MixKey(e) is further called\n# - When an encrypted static public key s or a payload message m is read, it is decrypted with decryptAndHash;\n# - When a static public key s or a payload message is written, it is encrypted with encryptAndHash;\n# - When any Diffie-Hellman token ee, es, se, ss is read or written, the chaining key ck is updated by calling MixKey on the computed secret;\n# - If all tokens are processed, users compute two new Cipher States by calling Split;\n# - The two Cipher States obtained from Split are used to encrypt/decrypt outbound/inbound messages.\n\n#################################\n# Cipher State Primitives\n#################################\n*/\n/**\n * Create empty chaining key\n * @returns 32-byte empty key\n */\nfunction createEmptyKey() {\n return new Uint8Array(32);\n}\n/**\n * Checks if a 32-byte key is empty\n * @param k key to verify\n * @returns true if empty, false otherwise\n */\nfunction isEmptyKey(k) {\n const emptyKey = createEmptyKey();\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(emptyKey, k);\n}\n/**\n * The Cipher State as in https://noiseprotocol.org/noise.html#the-cipherstate-object\n * Contains an encryption key k and a nonce n (used in Noise as a counter)\n */\nclass CipherState {\n /**\n * @param k encryption key\n * @param n nonce\n */\n constructor(cipher, k = createEmptyKey(), n = new _nonce_js__WEBPACK_IMPORTED_MODULE_5__.Nonce()) {\n this.k = k;\n this.n = n;\n this.cipher = cipher;\n }\n /**\n * Create a copy of the CipherState\n * @returns a copy of the CipherState\n */\n clone() {\n return new CipherState(this.cipher, new Uint8Array(this.k), new _nonce_js__WEBPACK_IMPORTED_MODULE_5__.Nonce(this.n.getUint64()));\n }\n /**\n * Check CipherState equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.k, other.getKey()) && this.n.getUint64() == other.getNonce().getUint64();\n }\n /**\n * Checks if a Cipher State has an encryption key set\n * @returns true if a key is set, false otherwise`\n */\n hasKey() {\n return !isEmptyKey(this.k);\n }\n /**\n * Encrypts a plaintext using key material in a Noise Cipher State\n * The CipherState is updated increasing the nonce (used as a counter in Noise) by one\n * @param ad associated data\n * @param plaintext data to encrypt\n */\n encryptWithAd(ad, plaintext) {\n this.n.assertValue();\n let ciphertext = new Uint8Array();\n if (this.hasKey()) {\n // If an encryption key is set in the Cipher state, we proceed with encryption\n ciphertext = this.cipher.encrypt(this.k, this.n, ad, plaintext);\n this.n.increment();\n this.n.assertValue();\n log(\"encryptWithAd\", ciphertext, this.n.getUint64() - 1);\n }\n else {\n // Otherwise we return the input plaintext according to specification http://www.noiseprotocol.org/noise.html#the-cipherstate-object\n ciphertext = plaintext;\n log(\"encryptWithAd called with no encryption key set. Returning plaintext.\");\n }\n return ciphertext;\n }\n /**\n * Decrypts a ciphertext using key material in a Noise Cipher State\n * The CipherState is updated increasing the nonce (used as a counter in Noise) by one\n * @param ad associated data\n * @param ciphertext data to decrypt\n */\n decryptWithAd(ad, ciphertext) {\n this.n.assertValue();\n if (this.hasKey()) {\n const plaintext = this.cipher.decrypt(this.k, this.n, ad, ciphertext);\n if (!plaintext) {\n throw new Error(\"decryptWithAd failed\");\n }\n this.n.increment();\n this.n.assertValue();\n return plaintext;\n }\n else {\n // Otherwise we return the input ciphertext according to specification\n // http://www.noiseprotocol.org/noise.html#the-cipherstate-object\n log(\"decryptWithAd called with no encryption key set. Returning ciphertext.\");\n return ciphertext;\n }\n }\n /**\n * Sets the nonce of a Cipher State\n * @param nonce Nonce\n */\n setNonce(nonce) {\n this.n = nonce;\n }\n /**\n * Sets the key of a Cipher State\n * @param key set the cipherstate encryption key\n */\n setCipherStateKey(key) {\n this.k = key;\n }\n /**\n * Gets the encryption key of a Cipher State\n * @returns encryption key\n */\n getKey() {\n return this.k;\n }\n /**\n * Gets the nonce of a Cipher State\n * @returns Nonce\n */\n getNonce() {\n return this.n;\n }\n}\n/**\n * Hash protocol name\n * @param name name of the noise handshake pattern to hash\n * @returns sha256 digest of the protocol name\n */\nfunction hashProtocol(h, name) {\n // If protocol_name is less than or equal to HASHLEN bytes in length,\n // sets h equal to protocol_name with zero bytes appended to make HASHLEN bytes.\n // Otherwise sets h = HASH(protocol_name).\n const protocolName = (0,uint8arrays__WEBPACK_IMPORTED_MODULE_1__.fromString)(name, \"utf-8\");\n if (protocolName.length <= 32) {\n const h = new Uint8Array(32);\n h.set(protocolName);\n return h;\n }\n else {\n return (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.hash)(h, protocolName);\n }\n}\n/**\n * The Symmetric State as in https://noiseprotocol.org/noise.html#the-symmetricstate-object\n * Contains a Cipher State cs, the chaining key ck and the handshake hash value h\n */\nclass SymmetricState {\n constructor(handshakePattern) {\n this.handshakePattern = handshakePattern;\n this.h = hashProtocol(handshakePattern.hash, handshakePattern.name);\n this.ck = this.h;\n this.cs = new CipherState(handshakePattern.cipher);\n }\n /**\n * Check CipherState equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.cs.equals(other.cs) &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.ck, other.ck) &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.equals)(this.h, other.h) &&\n this.handshakePattern.equals(other.handshakePattern));\n }\n /**\n * Create a copy of the SymmetricState\n * @returns a copy of the SymmetricState\n */\n clone() {\n const ss = new SymmetricState(this.handshakePattern);\n ss.cs = this.cs.clone();\n ss.ck = new Uint8Array(this.ck);\n ss.h = new Uint8Array(this.h);\n return ss;\n }\n /**\n * MixKey as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Updates a Symmetric state chaining key and symmetric state\n * @param inputKeyMaterial\n */\n mixKey(inputKeyMaterial) {\n // We derive two keys using HKDF\n const [ck, tempK] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.handshakePattern.hash, this.ck, inputKeyMaterial, 32, 2);\n // We update ck and the Cipher state's key k using the output of HDKF\n this.cs = new CipherState(this.handshakePattern.cipher, tempK);\n this.ck = ck;\n log(\"mixKey\", this.ck, this.cs.k);\n }\n /**\n * MixHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Hashes data into a Symmetric State's handshake hash value h\n * @param data input data to hash into h\n */\n mixHash(data) {\n // We hash the previous handshake hash and input data and store the result in the Symmetric State's handshake hash value\n this.h = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.hash)(this.handshakePattern.hash, (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, data]));\n log(\"mixHash\", this.h);\n }\n /**\n * mixKeyAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines MixKey and MixHash\n * @param inputKeyMaterial\n */\n mixKeyAndHash(inputKeyMaterial) {\n // Derives 3 keys using HKDF, the chaining key and the input key material\n const [tmpKey0, tmpKey1, tmpKey2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.handshakePattern.hash, this.ck, inputKeyMaterial, 32, 3);\n // Sets the chaining key\n this.ck = tmpKey0;\n // Updates the handshake hash value\n this.mixHash(tmpKey1);\n // Updates the Cipher state's key\n // Note for later support of 512 bits hash functions: \"If HASHLEN is 64, then truncates tempKeys[2] to 32 bytes.\"\n this.cs = new CipherState(this.handshakePattern.cipher, tmpKey2);\n }\n /**\n * EncryptAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines encryptWithAd and mixHash\n * Note that by setting extraAd, it is possible to pass extra additional data that will be concatenated to the ad\n * specified by Noise (can be used to authenticate messageNametag)\n * @param plaintext data to encrypt\n * @param extraAd extra additional data\n */\n encryptAndHash(plaintext, extraAd = new Uint8Array()) {\n // The additional data\n const ad = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, extraAd]);\n // Note that if an encryption key is not set yet in the Cipher state, ciphertext will be equal to plaintext\n const ciphertext = this.cs.encryptWithAd(ad, plaintext);\n // We call mixHash over the result\n this.mixHash(ciphertext);\n return ciphertext;\n }\n /**\n * DecryptAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Combines decryptWithAd and mixHash\n * @param ciphertext data to decrypt\n * @param extraAd extra additional data\n */\n decryptAndHash(ciphertext, extraAd = new Uint8Array()) {\n // The additional data\n const ad = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([this.h, extraAd]);\n // Note that if an encryption key is not set yet in the Cipher state, plaintext will be equal to ciphertext\n const plaintext = this.cs.decryptWithAd(ad, ciphertext);\n // According to specification, the ciphertext enters mixHash (and not the plaintext)\n this.mixHash(ciphertext);\n return plaintext;\n }\n /**\n * Split as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object\n * Once a handshake is complete, returns two Cipher States to encrypt/decrypt outbound/inbound messages\n * @returns CipherState to encrypt and CipherState to decrypt\n */\n split() {\n // Derives 2 keys using HKDF and the chaining key\n const [tmpKey1, tmpKey2] = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_4__.HKDF)(this.handshakePattern.hash, this.ck, new Uint8Array(0), 32, 2);\n // Returns a tuple of two Cipher States initialized with the derived keys\n return {\n cs1: new CipherState(this.handshakePattern.cipher, tmpKey1),\n cs2: new CipherState(this.handshakePattern.cipher, tmpKey2),\n };\n }\n /**\n * Gets the chaining key field of a Symmetric State\n * @returns Chaining key\n */\n getChainingKey() {\n return this.ck;\n }\n /**\n * Gets the handshake hash field of a Symmetric State\n * @returns Handshake hash\n */\n getHandshakeHash() {\n return this.h;\n }\n /**\n * Gets the Cipher State field of a Symmetric State\n * @returns Cipher State\n */\n getCipherState() {\n return this.cs;\n }\n}\n//# sourceMappingURL=noise.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/noise.js?"); /***/ }), @@ -4938,7 +5880,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_NONCE: () => (/* binding */ MAX_NONCE),\n/* harmony export */ MIN_NONCE: () => (/* binding */ MIN_NONCE),\n/* harmony export */ Nonce: () => (/* binding */ Nonce)\n/* harmony export */ });\n// Adapted from https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/nonce.ts\nconst MIN_NONCE = 0;\n// For performance reasons, the nonce is represented as a JS `number`\n// Although JS `number` can safely represent integers up to 2 ** 53 - 1, we choose to only use\n// 4 bytes to store the data for performance reason.\n// This is a slight deviation from the noise spec, which describes the max nonce as 2 ** 64 - 2\n// The effect is that this implementation will need a new handshake to be performed after fewer messages are exchanged than other implementations with full uint64 nonces.\n// this MAX_NONCE is still a large number of messages, so the practical effect of this is negligible.\nconst MAX_NONCE = 0xffffffff;\nconst ERR_MAX_NONCE = \"Cipherstate has reached maximum n, a new handshake must be performed\";\n/**\n * The nonce is an uint that's increased over time.\n * Maintaining different representations help improve performance.\n */\nclass Nonce {\n constructor(n = MIN_NONCE) {\n this.n = n;\n this.bytes = new Uint8Array(12);\n this.view = new DataView(this.bytes.buffer, this.bytes.byteOffset, this.bytes.byteLength);\n this.view.setUint32(4, n, true);\n }\n increment() {\n this.n++;\n // Even though we're treating the nonce as 8 bytes, RFC7539 specifies 12 bytes for a nonce.\n this.view.setUint32(4, this.n, true);\n }\n getBytes() {\n return this.bytes;\n }\n getUint64() {\n return this.n;\n }\n clone() {\n return new Nonce(this.n);\n }\n equals(b) {\n return b.n == this.n;\n }\n assertValue() {\n if (this.n > MAX_NONCE) {\n throw new Error(ERR_MAX_NONCE);\n }\n }\n}\n//# sourceMappingURL=nonce.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/nonce.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_NONCE: () => (/* binding */ MAX_NONCE),\n/* harmony export */ MIN_NONCE: () => (/* binding */ MIN_NONCE),\n/* harmony export */ Nonce: () => (/* binding */ Nonce)\n/* harmony export */ });\n// Adapted from https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/nonce.ts\nconst MIN_NONCE = 0;\n// For performance reasons, the nonce is represented as a JS `number`\n// Although JS `number` can safely represent integers up to 2 ** 53 - 1, we choose to only use\n// 4 bytes to store the data for performance reason.\n// This is a slight deviation from the noise spec, which describes the max nonce as 2 ** 64 - 2\n// The effect is that this implementation will need a new handshake to be performed after fewer messages are exchanged than other implementations with full uint64 nonces.\n// this MAX_NONCE is still a large number of messages, so the practical effect of this is negligible.\nconst MAX_NONCE = 0xffffffff;\nconst ERR_MAX_NONCE = \"Cipherstate has reached maximum n, a new handshake must be performed\";\n/**\n * The nonce is an uint that's increased over time.\n * Maintaining different representations help improve performance.\n */\nclass Nonce {\n constructor(n = MIN_NONCE) {\n this.n = n;\n this.bytes = new Uint8Array(12);\n this.view = new DataView(this.bytes.buffer, this.bytes.byteOffset, this.bytes.byteLength);\n this.view.setUint32(4, n, true);\n }\n increment() {\n this.n++;\n }\n getBytes(littleEndian) {\n // Even though we're treating the nonce as 8 bytes, RFC7539 specifies 12 bytes for a nonce.\n this.view.setUint32(4, this.n, littleEndian);\n return this.bytes;\n }\n getUint64() {\n return this.n;\n }\n clone() {\n return new Nonce(this.n);\n }\n equals(b) {\n return b.n == this.n;\n }\n assertValue() {\n if (this.n > MAX_NONCE) {\n throw new Error(ERR_MAX_NONCE);\n }\n }\n}\n//# sourceMappingURL=nonce.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/nonce.js?"); /***/ }), @@ -4949,7 +5891,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InitiatorParameters: () => (/* binding */ InitiatorParameters),\n/* harmony export */ ResponderParameters: () => (/* binding */ ResponderParameters),\n/* harmony export */ WakuPairing: () => (/* binding */ WakuPairing)\n/* harmony export */ });\n/* harmony import */ var _stablelib_hmac_drbg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/hmac-drbg */ \"./node_modules/@stablelib/hmac-drbg/lib/hmac-drbg.js\");\n/* harmony import */ var _stablelib_random__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @stablelib/random */ \"./node_modules/@stablelib/random/lib/random.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_event__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! p-event */ \"./node_modules/p-event/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@waku/noise/dist/codec.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _handshake_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./handshake.js */ \"./node_modules/@waku/noise/dist/handshake.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _qr_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./qr.js */ \"./node_modules/@waku/noise/dist/qr.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:noise:pairing\");\nfunction delay(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\nconst rng = new _stablelib_hmac_drbg__WEBPACK_IMPORTED_MODULE_0__.HMACDRBG();\n/**\n * Initiator parameters used to setup the pairing object\n */\nclass InitiatorParameters {\n constructor(qrCode, qrMessageNameTag) {\n this.qrCode = qrCode;\n this.qrMessageNameTag = qrMessageNameTag;\n }\n}\n/**\n * Responder parameters used to setup the pairing object\n */\nclass ResponderParameters {\n constructor(applicationName = \"waku-noise-sessions\", applicationVersion = \"0.1\", shardId = \"10\") {\n this.applicationName = applicationName;\n this.applicationVersion = applicationVersion;\n this.shardId = shardId;\n }\n}\n/**\n * Pairing object to setup a noise session\n */\nclass WakuPairing {\n /**\n * Convert a QR into a content topic\n * @param qr\n * @returns content topic string\n */\n static toContentTopic(qr) {\n return (\"/\" + qr.applicationName + \"/\" + qr.applicationVersion + \"/wakunoise/1/sessions_shard-\" + qr.shardId + \"/proto\");\n }\n /**\n * @param sender object that implements Sender interface to publish waku messages\n * @param responder object that implements Responder interface to subscribe and receive waku messages\n * @param myStaticKey x25519 keypair\n * @param pairingParameters Pairing parameters (depending if this is the initiator or responder)\n * @param myEphemeralKey optional ephemeral key\n * @param encoderParameters optional parameters for the resulting encoders\n */\n constructor(sender, responder, myStaticKey, pairingParameters, myEphemeralKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.generateX25519KeyPair)(), encoderParameters = {}) {\n this.sender = sender;\n this.responder = responder;\n this.myStaticKey = myStaticKey;\n this.myEphemeralKey = myEphemeralKey;\n this.encoderParameters = encoderParameters;\n this.started = false;\n this.eventEmitter = new eventemitter3__WEBPACK_IMPORTED_MODULE_3__.EventEmitter();\n this.randomFixLenVal = (0,_stablelib_random__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(32, rng);\n this.myCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.myStaticKey.publicKey, this.randomFixLenVal);\n if (pairingParameters instanceof InitiatorParameters) {\n this.initiator = true;\n this.qr = _qr_js__WEBPACK_IMPORTED_MODULE_12__.QR.from(pairingParameters.qrCode);\n this.qrMessageNameTag = pairingParameters.qrMessageNameTag;\n }\n else {\n this.initiator = false;\n this.qrMessageNameTag = (0,_stablelib_random__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(_messagenametag_js__WEBPACK_IMPORTED_MODULE_9__.MessageNametagLength, rng);\n this.qr = new _qr_js__WEBPACK_IMPORTED_MODULE_12__.QR(pairingParameters.applicationName, pairingParameters.applicationVersion, pairingParameters.shardId, this.myEphemeralKey.publicKey, this.myCommittedStaticKey);\n }\n // We set the contentTopic from the content topic parameters exchanged in the QR\n this.contentTopic = WakuPairing.toContentTopic(this.qr);\n // Pre-handshake message\n // <- eB {H(sB||r), contentTopicParams, messageNametag}\n const preMessagePKs = [_publickey_js__WEBPACK_IMPORTED_MODULE_11__.NoisePublicKey.fromPublicKey(this.qr.ephemeralKey)];\n this.handshake = new _handshake_js__WEBPACK_IMPORTED_MODULE_8__.Handshake({\n hsPattern: _patterns_js__WEBPACK_IMPORTED_MODULE_10__.NoiseHandshakePatterns.WakuPairing,\n ephemeralKey: myEphemeralKey,\n staticKey: myStaticKey,\n prologue: this.qr.toByteArray(),\n preMessagePKs,\n initiator: this.initiator,\n });\n }\n /**\n * Get pairing information (as an InitiatorParameter object)\n * @returns InitiatorParameters\n */\n getPairingInfo() {\n return new InitiatorParameters(this.qr.toString(), this.qrMessageNameTag);\n }\n /**\n * Get auth code (to validate that pairing). It must be displayed on both\n * devices and the user(s) must confirm if the auth code match\n * @returns Promise that resolves to an auth code\n */\n async getAuthCode() {\n return new Promise((resolve) => {\n if (this.authCode) {\n resolve(this.authCode);\n }\n else {\n this.eventEmitter.on(\"authCodeGenerated\", (authCode) => {\n this.authCode = authCode;\n resolve(authCode);\n });\n }\n });\n }\n /**\n * Indicate if auth code is valid. This is a function that must be\n * manually called by the user(s) if the auth code in both devices being\n * paired match. If false, pairing session is terminated\n * @param isValid true if authcode is correct, false otherwise.\n */\n validateAuthCode(isValid) {\n this.eventEmitter.emit(\"confirmAuthCode\", isValid);\n }\n async isAuthCodeConfirmed() {\n // wait for user to confirm or not, or for the whole pairing process to time out\n const p1 = (0,p_event__WEBPACK_IMPORTED_MODULE_4__.pEvent)(this.eventEmitter, \"confirmAuthCode\");\n const p2 = (0,p_event__WEBPACK_IMPORTED_MODULE_4__.pEvent)(this.eventEmitter, \"pairingTimeout\");\n return Promise.race([p1, p2]);\n }\n async executeReadStepWithNextMessage(messageNametag, iterator) {\n // TODO: create test unit for this function\n let stopLoop = false;\n this.eventEmitter.once(\"pairingTimeout\", () => {\n stopLoop = true;\n });\n this.eventEmitter.once(\"pairingComplete\", () => {\n stopLoop = true;\n });\n while (!stopLoop) {\n try {\n const item = await iterator.next();\n if (!item.value) {\n throw Error(\"Received no message\");\n }\n const step = this.handshake.stepHandshake({\n readPayloadV2: item.value.payloadV2,\n messageNametag,\n });\n return step;\n }\n catch (err) {\n if (err instanceof _handshake_js__WEBPACK_IMPORTED_MODULE_8__.MessageNametagError) {\n log(\"Unexpected message nametag\", err.expectedNametag, err.actualNametag);\n }\n else {\n throw err;\n }\n }\n }\n throw new Error(\"could not obtain next message\");\n }\n async initiatorHandshake() {\n // Subscribe to the contact content topic\n const decoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeDecoder(this.contentTopic);\n const subscriptionIterator = await this.responder.toSubscriptionIterator(decoder);\n // The handshake initiator writes a Waku2 payload v2 containing the handshake message\n // and the (encrypted) transport message\n // The message is sent with a messageNametag equal to the one received through the QR code\n let hsStep = this.handshake.stepHandshake({\n transportMessage: this.myCommittedStaticKey,\n messageNametag: this.qrMessageNameTag,\n });\n // We prepare a message from initiator's payload2\n // At this point wakuMsg is sent over the Waku network to responder content topic\n let encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // We generate an authorization code using the handshake state\n // this check has to be confirmed with a user interaction, comparing auth codes in both ends\n const confirmationPromise = this.isAuthCodeConfirmed();\n await delay(100);\n this.eventEmitter.emit(\"authCodeGenerated\", this.handshake.genAuthcode());\n console.log(\"Waiting for authcode confirmation...\");\n const confirmed = await confirmationPromise;\n if (!confirmed) {\n throw new Error(\"authcode is not confirmed\");\n }\n // 2nd step\n // <- sB, eAsB {r}\n hsStep = await this.executeReadStepWithNextMessage(this.handshake.hs.toMessageNametag(), subscriptionIterator.iterator);\n await subscriptionIterator.stop();\n if (!this.handshake.hs.rs)\n throw new Error(\"invalid handshake state\");\n // Initiator further checks if responder's commitment opens to responder's static key received\n const expectedResponderCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.handshake.hs.rs, hsStep.transportMessage);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(expectedResponderCommittedStaticKey, this.qr.committedStaticKey)) {\n throw new Error(\"expected committed static key does not match the responder actual committed static key\");\n }\n // 3rd step\n // -> sA, sAeB, sAsB {s}\n // Similarly as in first step, the initiator writes a Waku2 payload containing the handshake message and the (encrypted) transport message\n hsStep = this.handshake.stepHandshake({\n transportMessage: this.randomFixLenVal,\n messageNametag: this.handshake.hs.toMessageNametag(),\n });\n encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // Secure Transfer Phase\n this.handshakeResult = this.handshake.finalizeHandshake();\n this.eventEmitter.emit(\"pairingComplete\");\n return WakuPairing.getSecureCodec(this.contentTopic, this.handshakeResult, this.encoderParameters);\n }\n async responderHandshake() {\n // Subscribe to the contact content topic\n const decoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeDecoder(this.contentTopic);\n const subscriptionIterator = await this.responder.toSubscriptionIterator(decoder);\n // the received reads the initiator's payloads, and returns the (decrypted) transport message the initiator sent\n // Note that the received verifies if the received payloadV2 has the expected messageNametag set\n let hsStep = await this.executeReadStepWithNextMessage(this.qrMessageNameTag, subscriptionIterator.iterator);\n const initiatorCommittedStaticKey = new Uint8Array(hsStep.transportMessage);\n const confirmationPromise = this.isAuthCodeConfirmed();\n await delay(100);\n this.eventEmitter.emit(\"authCodeGenerated\", this.handshake.genAuthcode());\n console.log(\"Waiting for authcode confirmation...\");\n const confirmed = await confirmationPromise;\n if (!confirmed) {\n throw new Error(\"authcode is not confirmed\");\n }\n // 2nd step\n // <- sB, eAsB {r}\n // Responder writes and returns a payload\n hsStep = this.handshake.stepHandshake({\n transportMessage: this.randomFixLenVal,\n messageNametag: this.handshake.hs.toMessageNametag(),\n });\n // We prepare a Waku message from responder's payload2\n const encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // 3rd step\n // -> sA, sAeB, sAsB {s}\n // The responder reads the initiator's payload sent by the initiator\n hsStep = await this.executeReadStepWithNextMessage(this.handshake.hs.toMessageNametag(), subscriptionIterator.iterator);\n await subscriptionIterator.stop();\n if (!this.handshake.hs.rs)\n throw new Error(\"invalid handshake state\");\n // The responder further checks if the initiator's commitment opens to the initiator's static key received\n const expectedInitiatorCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.handshake.hs.rs, hsStep.transportMessage);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(expectedInitiatorCommittedStaticKey, initiatorCommittedStaticKey)) {\n throw new Error(\"expected committed static key does not match the initiator actual committed static key\");\n }\n // Secure Transfer Phase\n this.handshakeResult = this.handshake.finalizeHandshake();\n this.eventEmitter.emit(\"pairingComplete\");\n return WakuPairing.getSecureCodec(this.contentTopic, this.handshakeResult, this.encoderParameters);\n }\n /**\n * Get codecs for encoding/decoding messages in js-waku. This function can be used\n * to continue a session using a stored hsResult\n * @param contentTopic Content topic for the waku messages\n * @param hsResult Noise Pairing result\n * @param encoderParameters Parameters for the resulting encoder\n * @returns an array with [NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]\n */\n static getSecureCodec(contentTopic, hsResult, encoderParameters) {\n const secureEncoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferEncoder(contentTopic, hsResult, encoderParameters.ephemeral, encoderParameters.metaSetter);\n const secureDecoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferDecoder(contentTopic, hsResult);\n return [secureEncoder, secureDecoder];\n }\n /**\n * Get handshake result\n * @returns result of a successful pairing\n */\n getHandshakeResult() {\n if (!this.handshakeResult) {\n throw new Error(\"handshake is not complete\");\n }\n return this.handshakeResult;\n }\n /**\n * Execute handshake\n * @param timeoutMs Timeout in milliseconds after which the pairing session is invalid\n * @returns promise that resolves to codecs for encoding/decoding messages in js-waku\n */\n async execute(timeoutMs = 60000) {\n if (this.started) {\n throw new Error(\"pairing already executed. Create new pairing object\");\n }\n this.started = true;\n return new Promise((resolve, reject) => {\n // Limit QR exposure to some timeout\n const timer = setTimeout(() => {\n reject(new Error(\"pairing has timed out\"));\n this.eventEmitter.emit(\"pairingTimeout\");\n }, timeoutMs);\n const handshakeFn = this.initiator ? this.initiatorHandshake : this.responderHandshake;\n handshakeFn\n .bind(this)()\n .then((response) => resolve(response), (err) => reject(err))\n .finally(() => clearTimeout(timer));\n });\n }\n}\n//# sourceMappingURL=pairing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/pairing.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InitiatorParameters: () => (/* binding */ InitiatorParameters),\n/* harmony export */ ResponderParameters: () => (/* binding */ ResponderParameters),\n/* harmony export */ WakuPairing: () => (/* binding */ WakuPairing)\n/* harmony export */ });\n/* harmony import */ var _stablelib_hmac_drbg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/hmac-drbg */ \"./node_modules/@stablelib/hmac-drbg/lib/hmac-drbg.js\");\n/* harmony import */ var _stablelib_random__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @stablelib/random */ \"./node_modules/@stablelib/random/lib/random.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_event__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! p-event */ \"./node_modules/p-event/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@waku/noise/dist/codec.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _handshake_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./handshake.js */ \"./node_modules/@waku/noise/dist/handshake.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _qr_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./qr.js */ \"./node_modules/@waku/noise/dist/qr.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:noise:pairing\");\nfunction delay(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\nconst rng = new _stablelib_hmac_drbg__WEBPACK_IMPORTED_MODULE_0__.HMACDRBG();\n/**\n * Initiator parameters used to setup the pairing object\n */\nclass InitiatorParameters {\n constructor(qrCode, qrMessageNameTag) {\n this.qrCode = qrCode;\n this.qrMessageNameTag = qrMessageNameTag;\n }\n}\n/**\n * Responder parameters used to setup the pairing object\n */\nclass ResponderParameters {\n constructor(applicationName = \"waku-noise-sessions\", applicationVersion = \"0.1\", shardId = \"10\") {\n this.applicationName = applicationName;\n this.applicationVersion = applicationVersion;\n this.shardId = shardId;\n }\n}\n/**\n * Pairing object to setup a noise session\n */\nclass WakuPairing {\n /**\n * Convert a QR into a content topic\n * Must follow - https://github.com/vacp2p/rfc-index/blob/main/waku/informational/23/topics.md\n * @param qr\n * @returns content topic string\n */\n static toContentTopic(qr) {\n return \"/\" + qr.applicationName + \"/\" + qr.applicationVersion + \"/\" + qr.shardId + \"/proto\";\n }\n /**\n * @param pubsubTopic pubsubTopic to be used for handshake\n * @param sender object that implements Sender interface to publish waku messages\n * @param responder object that implements Responder interface to subscribe and receive waku messages\n * @param myStaticKey x25519 keypair\n * @param pairingParameters Pairing parameters (depending if this is the initiator or responder)\n * @param myEphemeralKey optional ephemeral key\n * @param encoderParameters optional parameters for the resulting encoders\n */\n constructor(pubsubTopic, sender, responder, myStaticKey, pairingParameters, myEphemeralKey, encoderParameters = {}) {\n this.pubsubTopic = pubsubTopic;\n this.sender = sender;\n this.responder = responder;\n this.myStaticKey = myStaticKey;\n this.myEphemeralKey = myEphemeralKey;\n this.encoderParameters = encoderParameters;\n this.started = false;\n this.eventEmitter = new eventemitter3__WEBPACK_IMPORTED_MODULE_3__.EventEmitter();\n this.hsPattern = _patterns_js__WEBPACK_IMPORTED_MODULE_10__.NoiseHandshakePatterns.Noise_WakuPairing_25519_ChaChaPoly_SHA256;\n this.randomFixLenVal = (0,_stablelib_random__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(32, rng);\n this.myCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.hsPattern.hash, this.myStaticKey.publicKey, this.randomFixLenVal);\n if (!this.myEphemeralKey) {\n this.myEphemeralKey = _patterns_js__WEBPACK_IMPORTED_MODULE_10__.NoiseHandshakePatterns.Noise_WakuPairing_25519_ChaChaPoly_SHA256.dhKey.generateKeyPair();\n }\n if (pairingParameters instanceof InitiatorParameters) {\n this.initiator = true;\n this.qr = _qr_js__WEBPACK_IMPORTED_MODULE_12__.QR.from(pairingParameters.qrCode);\n this.qrMessageNameTag = pairingParameters.qrMessageNameTag;\n }\n else {\n this.initiator = false;\n this.qrMessageNameTag = (0,_stablelib_random__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(_messagenametag_js__WEBPACK_IMPORTED_MODULE_9__.MessageNametagLength, rng);\n this.qr = new _qr_js__WEBPACK_IMPORTED_MODULE_12__.QR(pairingParameters.applicationName, pairingParameters.applicationVersion, pairingParameters.shardId, this.myEphemeralKey.publicKey, this.myCommittedStaticKey);\n }\n // We set the contentTopic from the content topic parameters exchanged in the QR\n this.contentTopic = WakuPairing.toContentTopic(this.qr);\n // Pre-handshake message\n // <- eB {H(sB||r), contentTopicParams, messageNametag}\n const preMessagePKs = [_publickey_js__WEBPACK_IMPORTED_MODULE_11__.NoisePublicKey.fromPublicKey(this.qr.ephemeralKey)];\n this.handshake = new _handshake_js__WEBPACK_IMPORTED_MODULE_8__.Handshake({\n hsPattern: this.hsPattern,\n ephemeralKey: this.myEphemeralKey,\n staticKey: myStaticKey,\n prologue: this.qr.toByteArray(),\n preMessagePKs,\n initiator: this.initiator,\n });\n }\n /**\n * Get pairing information (as an InitiatorParameter object)\n * @returns InitiatorParameters\n */\n getPairingInfo() {\n return new InitiatorParameters(this.qr.toString(), this.qrMessageNameTag);\n }\n /**\n * Get auth code (to validate that pairing). It must be displayed on both\n * devices and the user(s) must confirm if the auth code match\n * @returns Promise that resolves to an auth code\n */\n async getAuthCode() {\n return new Promise((resolve) => {\n if (this.authCode) {\n resolve(this.authCode);\n }\n else {\n this.eventEmitter.on(\"authCodeGenerated\", (authCode) => {\n this.authCode = authCode;\n resolve(authCode);\n });\n }\n });\n }\n /**\n * Indicate if auth code is valid. This is a function that must be\n * manually called by the user(s) if the auth code in both devices being\n * paired match. If false, pairing session is terminated\n * @param isValid true if authcode is correct, false otherwise.\n */\n validateAuthCode(isValid) {\n this.eventEmitter.emit(\"confirmAuthCode\", isValid);\n }\n async isAuthCodeConfirmed() {\n // wait for user to confirm or not, or for the whole pairing process to time out\n const p1 = (0,p_event__WEBPACK_IMPORTED_MODULE_4__.pEvent)(this.eventEmitter, \"confirmAuthCode\");\n const p2 = (0,p_event__WEBPACK_IMPORTED_MODULE_4__.pEvent)(this.eventEmitter, \"pairingTimeout\");\n return Promise.race([p1, p2]);\n }\n async executeReadStepWithNextMessage(messageNametag, iterator) {\n // TODO: create test unit for this function\n let stopLoop = false;\n this.eventEmitter.once(\"pairingTimeout\", () => {\n stopLoop = true;\n });\n this.eventEmitter.once(\"pairingComplete\", () => {\n stopLoop = true;\n });\n while (!stopLoop) {\n try {\n const item = await iterator.next();\n if (!item.value) {\n throw Error(\"Received no message\");\n }\n const step = this.handshake.stepHandshake({\n readPayloadV2: item.value.payloadV2,\n messageNametag,\n });\n return step;\n }\n catch (err) {\n if (err instanceof _handshake_js__WEBPACK_IMPORTED_MODULE_8__.MessageNametagError) {\n log(\"Unexpected message nametag\", err.expectedNametag, err.actualNametag);\n }\n else {\n throw err;\n }\n }\n }\n throw new Error(\"could not obtain next message\");\n }\n async initiatorHandshake() {\n // Subscribe to the contact content topic\n const decoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeDecoder(this.contentTopic, this.pubsubTopic);\n const subscriptionIterator = await this.responder.toSubscriptionIterator(decoder);\n // The handshake initiator writes a Waku2 payload v2 containing the handshake message\n // and the (encrypted) transport message\n // The message is sent with a messageNametag equal to the one received through the QR code\n let hsStep = this.handshake.stepHandshake({\n transportMessage: this.myCommittedStaticKey,\n messageNametag: this.qrMessageNameTag,\n });\n // We prepare a message from initiator's payload2\n // At this point wakuMsg is sent over the Waku network to responder content topic\n let encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, this.pubsubTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // We generate an authorization code using the handshake state\n // this check has to be confirmed with a user interaction, comparing auth codes in both ends\n const confirmationPromise = this.isAuthCodeConfirmed();\n await delay(100);\n this.eventEmitter.emit(\"authCodeGenerated\", this.handshake.genAuthcode());\n log(\"Waiting for authcode confirmation...\");\n const confirmed = await confirmationPromise;\n if (!confirmed) {\n throw new Error(\"authcode is not confirmed\");\n }\n // 2nd step\n // <- sB, eAsB {r}\n hsStep = await this.executeReadStepWithNextMessage(this.handshake.hs.toMessageNametag(), subscriptionIterator.iterator);\n await subscriptionIterator.stop();\n if (!this.handshake.hs.rs)\n throw new Error(\"invalid handshake state\");\n // Initiator further checks if responder's commitment opens to responder's static key received\n const expectedResponderCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.hsPattern.hash, this.handshake.hs.rs, hsStep.transportMessage);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(expectedResponderCommittedStaticKey, this.qr.committedStaticKey)) {\n throw new Error(\"expected committed static key does not match the responder actual committed static key\");\n }\n // 3rd step\n // -> sA, sAeB, sAsB {s}\n // Similarly as in first step, the initiator writes a Waku2 payload containing the handshake message and the (encrypted) transport message\n hsStep = this.handshake.stepHandshake({\n transportMessage: this.randomFixLenVal,\n messageNametag: this.handshake.hs.toMessageNametag(),\n });\n encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, this.pubsubTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // Secure Transfer Phase\n this.handshakeResult = this.handshake.finalizeHandshake();\n this.eventEmitter.emit(\"pairingComplete\");\n return WakuPairing.getSecureCodec(this.contentTopic, this.pubsubTopic, this.handshakeResult, this.encoderParameters);\n }\n async responderHandshake() {\n // Subscribe to the contact content topic\n const decoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeDecoder(this.contentTopic, this.pubsubTopic);\n const subscriptionIterator = await this.responder.toSubscriptionIterator(decoder);\n // the received reads the initiator's payloads, and returns the (decrypted) transport message the initiator sent\n // Note that the received verifies if the received payloadV2 has the expected messageNametag set\n let hsStep = await this.executeReadStepWithNextMessage(this.qrMessageNameTag, subscriptionIterator.iterator);\n const initiatorCommittedStaticKey = new Uint8Array(hsStep.transportMessage);\n const confirmationPromise = this.isAuthCodeConfirmed();\n await delay(100);\n this.eventEmitter.emit(\"authCodeGenerated\", this.handshake.genAuthcode());\n log(\"Waiting for authcode confirmation...\");\n const confirmed = await confirmationPromise;\n if (!confirmed) {\n throw new Error(\"authcode is not confirmed\");\n }\n // 2nd step\n // <- sB, eAsB {r}\n // Responder writes and returns a payload\n hsStep = this.handshake.stepHandshake({\n transportMessage: this.randomFixLenVal,\n messageNametag: this.handshake.hs.toMessageNametag(),\n });\n // We prepare a Waku message from responder's payload2\n const encoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseHandshakeEncoder(this.contentTopic, this.pubsubTopic, hsStep);\n await this.sender.send(encoder, {\n payload: new Uint8Array(),\n });\n // 3rd step\n // -> sA, sAeB, sAsB {s}\n // The responder reads the initiator's payload sent by the initiator\n hsStep = await this.executeReadStepWithNextMessage(this.handshake.hs.toMessageNametag(), subscriptionIterator.iterator);\n await subscriptionIterator.stop();\n if (!this.handshake.hs.rs)\n throw new Error(\"invalid handshake state\");\n // The responder further checks if the initiator's commitment opens to the initiator's static key received\n const expectedInitiatorCommittedStaticKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.commitPublicKey)(this.hsPattern.hash, this.handshake.hs.rs, hsStep.transportMessage);\n if (!(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(expectedInitiatorCommittedStaticKey, initiatorCommittedStaticKey)) {\n throw new Error(\"expected committed static key does not match the initiator actual committed static key\");\n }\n // Secure Transfer Phase\n this.handshakeResult = this.handshake.finalizeHandshake();\n this.eventEmitter.emit(\"pairingComplete\");\n return WakuPairing.getSecureCodec(this.contentTopic, this.pubsubTopic, this.handshakeResult, this.encoderParameters);\n }\n /**\n * Get codecs for encoding/decoding messages in js-waku. This function can be used\n * to continue a session using a stored hsResult\n * @param contentTopic Content topic for the waku messages\n * @param hsResult Noise Pairing result\n * @param encoderParameters Parameters for the resulting encoder\n * @returns an array with [NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]\n */\n static getSecureCodec(contentTopic, pubsubTopic, hsResult, encoderParameters) {\n const secureEncoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferEncoder(contentTopic, pubsubTopic, hsResult, encoderParameters.ephemeral, encoderParameters.metaSetter);\n const secureDecoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferDecoder(contentTopic, pubsubTopic, hsResult);\n return [secureEncoder, secureDecoder];\n }\n /**\n * Get handshake result\n * @returns result of a successful pairing\n */\n getHandshakeResult() {\n if (!this.handshakeResult) {\n throw new Error(\"handshake is not complete\");\n }\n return this.handshakeResult;\n }\n /**\n * Execute handshake\n * @param timeoutMs Timeout in milliseconds after which the pairing session is invalid\n * @returns promise that resolves to codecs for encoding/decoding messages in js-waku\n */\n async execute(timeoutMs = 60000) {\n if (this.started) {\n throw new Error(\"pairing already executed. Create new pairing object\");\n }\n this.started = true;\n return new Promise((resolve, reject) => {\n // Limit QR exposure to some timeout\n const timer = setTimeout(() => {\n reject(new Error(\"pairing has timed out\"));\n this.eventEmitter.emit(\"pairingTimeout\");\n }, timeoutMs);\n const handshakeFn = this.initiator ? this.initiatorHandshake : this.responderHandshake;\n handshakeFn\n .bind(this)()\n .then((response) => resolve(response), (err) => reject(err))\n .finally(() => clearTimeout(timer));\n });\n }\n}\n//# sourceMappingURL=pairing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/pairing.js?"); /***/ }), @@ -4960,7 +5902,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HandshakePattern: () => (/* binding */ HandshakePattern),\n/* harmony export */ MessageDirection: () => (/* binding */ MessageDirection),\n/* harmony export */ MessagePattern: () => (/* binding */ MessagePattern),\n/* harmony export */ NoiseHandshakePatterns: () => (/* binding */ NoiseHandshakePatterns),\n/* harmony export */ NoiseTokens: () => (/* binding */ NoiseTokens),\n/* harmony export */ PayloadV2ProtocolIDs: () => (/* binding */ PayloadV2ProtocolIDs),\n/* harmony export */ PreMessagePattern: () => (/* binding */ PreMessagePattern)\n/* harmony export */ });\n/**\n * The Noise tokens appearing in Noise (pre)message patterns\n * as in http://www.noiseprotocol.org/noise.html#handshake-pattern-basics\n */\nvar NoiseTokens;\n(function (NoiseTokens) {\n NoiseTokens[\"e\"] = \"e\";\n NoiseTokens[\"s\"] = \"s\";\n NoiseTokens[\"es\"] = \"es\";\n NoiseTokens[\"ee\"] = \"ee\";\n NoiseTokens[\"se\"] = \"se\";\n NoiseTokens[\"ss\"] = \"ss\";\n NoiseTokens[\"psk\"] = \"psk\";\n})(NoiseTokens || (NoiseTokens = {}));\n/**\n * The direction of a (pre)message pattern in canonical form (i.e. Alice-initiated form)\n * as in http://www.noiseprotocol.org/noise.html#alice-and-bob\n */\nvar MessageDirection;\n(function (MessageDirection) {\n MessageDirection[\"r\"] = \"->\";\n MessageDirection[\"l\"] = \"<-\";\n})(MessageDirection || (MessageDirection = {}));\n/**\n * The pre message pattern consisting of a message direction and some Noise tokens, if any.\n * (if non empty, only tokens e and s are allowed: http://www.noiseprotocol.org/noise.html#handshake-pattern-basics)\n */\nclass PreMessagePattern {\n constructor(direction, tokens) {\n this.direction = direction;\n this.tokens = tokens;\n }\n /**\n * Check PreMessagePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.direction == other.direction &&\n this.tokens.length === other.tokens.length &&\n this.tokens.every((val, index) => val === other.tokens[index]));\n }\n}\n/**\n * The message pattern consisting of a message direction and some Noise tokens\n * All Noise tokens are allowed\n */\nclass MessagePattern {\n constructor(direction, tokens) {\n this.direction = direction;\n this.tokens = tokens;\n }\n /**\n * Check MessagePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.direction == other.direction &&\n this.tokens.length === other.tokens.length &&\n this.tokens.every((val, index) => val === other.tokens[index]));\n }\n}\n/**\n * The handshake pattern object. It stores the handshake protocol name, the\n * handshake pre message patterns and the handshake message patterns\n */\nclass HandshakePattern {\n constructor(name, preMessagePatterns, messagePatterns) {\n this.name = name;\n this.preMessagePatterns = preMessagePatterns;\n this.messagePatterns = messagePatterns;\n }\n /**\n * Check HandshakePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n if (this.preMessagePatterns.length != other.preMessagePatterns.length)\n return false;\n for (let i = 0; i < this.preMessagePatterns.length; i++) {\n if (!this.preMessagePatterns[i].equals(other.preMessagePatterns[i]))\n return false;\n }\n if (this.messagePatterns.length != other.messagePatterns.length)\n return false;\n for (let i = 0; i < this.messagePatterns.length; i++) {\n if (!this.messagePatterns[i].equals(other.messagePatterns[i]))\n return false;\n }\n return this.name == other.name;\n }\n}\n/**\n * Supported Noise handshake patterns as defined in https://rfc.vac.dev/spec/35/#specification\n */\nconst NoiseHandshakePatterns = {\n K1K1: new HandshakePattern(\"Noise_K1K1_25519_ChaChaPoly_SHA256\", [\n new PreMessagePattern(MessageDirection.r, [NoiseTokens.s]),\n new PreMessagePattern(MessageDirection.l, [NoiseTokens.s]),\n ], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.se]),\n ]),\n XK1: new HandshakePattern(\"Noise_XK1_25519_ChaChaPoly_SHA256\", [new PreMessagePattern(MessageDirection.l, [NoiseTokens.s])], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n XX: new HandshakePattern(\"Noise_XX_25519_ChaChaPoly_SHA256\", [], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n XXpsk0: new HandshakePattern(\"Noise_XXpsk0_25519_ChaChaPoly_SHA256\", [], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.psk, NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n WakuPairing: new HandshakePattern(\"Noise_WakuPairing_25519_ChaChaPoly_SHA256\", [new PreMessagePattern(MessageDirection.l, [NoiseTokens.e])], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e, NoiseTokens.ee]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se, NoiseTokens.ss]),\n ]),\n};\n/**\n * Supported Protocol ID for PayloadV2 objects\n * Protocol IDs are defined according to https://rfc.vac.dev/spec/35/#specification\n */\nconst PayloadV2ProtocolIDs = {\n \"\": 0,\n Noise_K1K1_25519_ChaChaPoly_SHA256: 10,\n Noise_XK1_25519_ChaChaPoly_SHA256: 11,\n Noise_XX_25519_ChaChaPoly_SHA256: 12,\n Noise_XXpsk0_25519_ChaChaPoly_SHA256: 13,\n Noise_WakuPairing_25519_ChaChaPoly_SHA256: 14,\n ChaChaPoly: 30,\n};\n//# sourceMappingURL=patterns.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/patterns.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HandshakePattern: () => (/* binding */ HandshakePattern),\n/* harmony export */ MessageDirection: () => (/* binding */ MessageDirection),\n/* harmony export */ MessagePattern: () => (/* binding */ MessagePattern),\n/* harmony export */ NoiseHandshakePatterns: () => (/* binding */ NoiseHandshakePatterns),\n/* harmony export */ NoiseTokens: () => (/* binding */ NoiseTokens),\n/* harmony export */ PayloadV2ProtocolIDs: () => (/* binding */ PayloadV2ProtocolIDs),\n/* harmony export */ PreMessagePattern: () => (/* binding */ PreMessagePattern)\n/* harmony export */ });\n/* harmony import */ var _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/sha256 */ \"./node_modules/@stablelib/sha256/lib/sha256.js\");\n/* harmony import */ var _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./chachapoly.js */ \"./node_modules/@waku/noise/dist/chachapoly.js\");\n/* harmony import */ var _dh25519_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dh25519.js */ \"./node_modules/@waku/noise/dist/dh25519.js\");\n\n\n\n/**\n * The Noise tokens appearing in Noise (pre)message patterns\n * as in http://www.noiseprotocol.org/noise.html#handshake-pattern-basics\n */\nvar NoiseTokens;\n(function (NoiseTokens) {\n NoiseTokens[\"e\"] = \"e\";\n NoiseTokens[\"s\"] = \"s\";\n NoiseTokens[\"es\"] = \"es\";\n NoiseTokens[\"ee\"] = \"ee\";\n NoiseTokens[\"se\"] = \"se\";\n NoiseTokens[\"ss\"] = \"ss\";\n NoiseTokens[\"psk\"] = \"psk\";\n})(NoiseTokens || (NoiseTokens = {}));\n/**\n * The direction of a (pre)message pattern in canonical form (i.e. Alice-initiated form)\n * as in http://www.noiseprotocol.org/noise.html#alice-and-bob\n */\nvar MessageDirection;\n(function (MessageDirection) {\n MessageDirection[\"r\"] = \"->\";\n MessageDirection[\"l\"] = \"<-\";\n})(MessageDirection || (MessageDirection = {}));\n/**\n * The pre message pattern consisting of a message direction and some Noise tokens, if any.\n * (if non empty, only tokens e and s are allowed: http://www.noiseprotocol.org/noise.html#handshake-pattern-basics)\n */\nclass PreMessagePattern {\n constructor(direction, tokens) {\n this.direction = direction;\n this.tokens = tokens;\n }\n /**\n * Check PreMessagePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.direction == other.direction &&\n this.tokens.length === other.tokens.length &&\n this.tokens.every((val, index) => val === other.tokens[index]));\n }\n}\n/**\n * The message pattern consisting of a message direction and some Noise tokens\n * All Noise tokens are allowed\n */\nclass MessagePattern {\n constructor(direction, tokens) {\n this.direction = direction;\n this.tokens = tokens;\n }\n /**\n * Check MessagePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return (this.direction == other.direction &&\n this.tokens.length === other.tokens.length &&\n this.tokens.every((val, index) => val === other.tokens[index]));\n }\n}\n/**\n * The handshake pattern object. It stores the handshake protocol name, the\n * handshake pre message patterns and the handshake message patterns\n */\nclass HandshakePattern {\n constructor(name, dhKeyType, cipherType, hash, preMessagePatterns, messagePatterns) {\n this.name = name;\n this.hash = hash;\n this.preMessagePatterns = preMessagePatterns;\n this.messagePatterns = messagePatterns;\n this.dhKey = new dhKeyType();\n this.cipher = new cipherType();\n }\n /**\n * Check HandshakePattern equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n if (this.preMessagePatterns.length != other.preMessagePatterns.length)\n return false;\n for (let i = 0; i < this.preMessagePatterns.length; i++) {\n if (!this.preMessagePatterns[i].equals(other.preMessagePatterns[i]))\n return false;\n }\n if (this.messagePatterns.length != other.messagePatterns.length)\n return false;\n for (let i = 0; i < this.messagePatterns.length; i++) {\n if (!this.messagePatterns[i].equals(other.messagePatterns[i]))\n return false;\n }\n return this.name == other.name;\n }\n}\n/**\n * Supported Noise handshake patterns as defined in https://rfc.vac.dev/spec/35/#specification\n */\nconst NoiseHandshakePatterns = {\n Noise_K1K1_25519_ChaChaPoly_SHA256: new HandshakePattern(\"Noise_K1K1_25519_ChaChaPoly_SHA256\", _dh25519_js__WEBPACK_IMPORTED_MODULE_2__.DH25519, _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__.ChaChaPoly, _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.SHA256, [\n new PreMessagePattern(MessageDirection.r, [NoiseTokens.s]),\n new PreMessagePattern(MessageDirection.l, [NoiseTokens.s]),\n ], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.se]),\n ]),\n Noise_XK1_25519_ChaChaPoly_SHA256: new HandshakePattern(\"Noise_XK1_25519_ChaChaPoly_SHA256\", _dh25519_js__WEBPACK_IMPORTED_MODULE_2__.DH25519, _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__.ChaChaPoly, _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.SHA256, [new PreMessagePattern(MessageDirection.l, [NoiseTokens.s])], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n Noise_XX_25519_ChaChaPoly_SHA256: new HandshakePattern(\"Noise_XX_25519_ChaChaPoly_SHA256\", _dh25519_js__WEBPACK_IMPORTED_MODULE_2__.DH25519, _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__.ChaChaPoly, _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.SHA256, [], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n Noise_XXpsk0_25519_ChaChaPoly_SHA256: new HandshakePattern(\"Noise_XXpsk0_25519_ChaChaPoly_SHA256\", _dh25519_js__WEBPACK_IMPORTED_MODULE_2__.DH25519, _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__.ChaChaPoly, _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.SHA256, [], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.psk, NoiseTokens.e]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.e, NoiseTokens.ee, NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se]),\n ]),\n Noise_WakuPairing_25519_ChaChaPoly_SHA256: new HandshakePattern(\"Noise_WakuPairing_25519_ChaChaPoly_SHA256\", _dh25519_js__WEBPACK_IMPORTED_MODULE_2__.DH25519, _chachapoly_js__WEBPACK_IMPORTED_MODULE_1__.ChaChaPoly, _stablelib_sha256__WEBPACK_IMPORTED_MODULE_0__.SHA256, [new PreMessagePattern(MessageDirection.l, [NoiseTokens.e])], [\n new MessagePattern(MessageDirection.r, [NoiseTokens.e, NoiseTokens.ee]),\n new MessagePattern(MessageDirection.l, [NoiseTokens.s, NoiseTokens.es]),\n new MessagePattern(MessageDirection.r, [NoiseTokens.s, NoiseTokens.se, NoiseTokens.ss]),\n ]),\n};\n/**\n * Supported Protocol ID for PayloadV2 objects\n * Protocol IDs are defined according to https://rfc.vac.dev/spec/35/#specification\n */\nconst PayloadV2ProtocolIDs = {\n \"\": 0,\n Noise_K1K1_25519_ChaChaPoly_SHA256: 10,\n Noise_XK1_25519_ChaChaPoly_SHA256: 11,\n Noise_XX_25519_ChaChaPoly_SHA256: 12,\n Noise_XXpsk0_25519_ChaChaPoly_SHA256: 13,\n Noise_WakuPairing_25519_ChaChaPoly_SHA256: 14,\n ChaChaPoly: 30,\n};\n//# sourceMappingURL=patterns.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/patterns.js?"); /***/ }), @@ -4971,7 +5913,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PayloadV2: () => (/* binding */ PayloadV2)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/noise/dist/utils.js\");\n\n\n\n\n\n\n\n/**\n * PayloadV2 defines an object for Waku payloads with version 2 as in\n * https://rfc.vac.dev/spec/35/#public-keys-serialization\n * It contains a message nametag, protocol ID field, the handshake message (for Noise handshakes)\n * and the transport message\n */\nclass PayloadV2 {\n constructor(messageNametag = new Uint8Array(_messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagLength), protocolId = 0, handshakeMessage = [], transportMessage = new Uint8Array()) {\n this.messageNametag = messageNametag;\n this.protocolId = protocolId;\n this.handshakeMessage = handshakeMessage;\n this.transportMessage = transportMessage;\n }\n /**\n * Create a copy of the PayloadV2\n * @returns a copy of the PayloadV2\n */\n clone() {\n const r = new PayloadV2();\n r.protocolId = this.protocolId;\n r.transportMessage = new Uint8Array(this.transportMessage);\n r.messageNametag = new Uint8Array(this.messageNametag);\n for (let i = 0; i < this.handshakeMessage.length; i++) {\n r.handshakeMessage.push(this.handshakeMessage[i].clone());\n }\n return r;\n }\n /**\n * Check PayloadV2 equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n let pkEquals = true;\n if (this.handshakeMessage.length != other.handshakeMessage.length) {\n pkEquals = false;\n }\n for (let i = 0; i < this.handshakeMessage.length; i++) {\n if (!this.handshakeMessage[i].equals(other.handshakeMessage[i])) {\n pkEquals = false;\n break;\n }\n }\n return ((0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.messageNametag, other.messageNametag) &&\n this.protocolId == other.protocolId &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.transportMessage, other.transportMessage) &&\n pkEquals);\n }\n /**\n * Serializes a PayloadV2 object to a byte sequences according to https://rfc.vac.dev/spec/35/.\n * The output serialized payload concatenates the input PayloadV2 object fields as\n * payload = ( protocolId || serializedHandshakeMessageLen || serializedHandshakeMessage || transportMessageLen || transportMessage)\n * The output can be then passed to the payload field of a WakuMessage https://rfc.vac.dev/spec/14/\n * @returns serialized payload\n */\n serialize() {\n // We collect public keys contained in the handshake message\n // According to https://rfc.vac.dev/spec/35/, the maximum size for the handshake message is 256 bytes, that is\n // the handshake message length can be represented with 1 byte only. (its length can be stored in 1 byte)\n // However, to ease public keys length addition operation, we declare it as int and later cast to uit8\n let serializedHandshakeMessageLen = 0;\n // This variables will store the concatenation of the serializations of all public keys in the handshake message\n let serializedHandshakeMessage = new Uint8Array();\n // For each public key in the handshake message\n for (const pk of this.handshakeMessage) {\n // We serialize the public key\n const serializedPk = pk.serialize();\n // We sum its serialized length to the total\n serializedHandshakeMessageLen += serializedPk.length;\n // We add its serialization to the concatenation of all serialized public keys in the handshake message\n serializedHandshakeMessage = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([serializedHandshakeMessage, serializedPk]);\n // If we are processing more than 256 byte, we return an error\n if (serializedHandshakeMessageLen > 255) {\n console.debug(\"PayloadV2 malformed: too many public keys contained in the handshake message\");\n throw new Error(\"too many public keys in handshake message\");\n }\n }\n // The output payload as in https://rfc.vac.dev/spec/35/. We concatenate all the PayloadV2 fields as\n // payload = ( protocolId || serializedHandshakeMessageLen || serializedHandshakeMessage || transportMessageLen || transportMessage)\n // We concatenate all the data\n // The protocol ID (1 byte) and handshake message length (1 byte) can be directly casted to byte to allow direct copy to the payload byte sequence\n const payload = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([\n this.messageNametag,\n new Uint8Array([this.protocolId]),\n new Uint8Array([serializedHandshakeMessageLen]),\n serializedHandshakeMessage,\n // The transport message length is converted from uint64 to bytes in Little-Endian\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_6__.writeUIntLE)(new Uint8Array(8), this.transportMessage.length, 0, 8),\n this.transportMessage,\n ]);\n return payload;\n }\n /**\n * Deserializes a byte sequence to a PayloadV2 object according to https://rfc.vac.dev/spec/35/.\n * @param payload input serialized payload\n * @returns PayloadV2\n */\n static deserialize(payload) {\n // i is the read input buffer position index\n let i = 0;\n // We start by reading the messageNametag\n const messageNametag = new Uint8Array(_messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagLength);\n for (let j = 0; j < _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagLength; j++) {\n messageNametag[j] = payload[i + j];\n }\n i += _messagenametag_js__WEBPACK_IMPORTED_MODULE_3__.MessageNametagLength;\n // We read the Protocol ID\n const protocolId = payload[i];\n const protocolName = Object.keys(_patterns_js__WEBPACK_IMPORTED_MODULE_4__.PayloadV2ProtocolIDs).find((key) => _patterns_js__WEBPACK_IMPORTED_MODULE_4__.PayloadV2ProtocolIDs[key] === protocolId);\n if (protocolName === undefined) {\n throw new Error(\"protocolId not found\");\n }\n i++;\n // We read the Handshake Message length (1 byte)\n const handshakeMessageLen = payload[i];\n if (handshakeMessageLen > 255) {\n console.debug(\"payload malformed: too many public keys contained in the handshake message\");\n throw new Error(\"too many public keys in handshake message\");\n }\n i++;\n // We now read for handshakeMessageLen bytes the buffer and we deserialize each (encrypted/unencrypted) public key read\n // In handshakeMessage we accumulate the read deserialized Noise Public keys\n const handshakeMessage = new Array();\n let written = 0;\n // We read the buffer until handshakeMessageLen are read\n while (written != handshakeMessageLen) {\n // We obtain the current Noise Public key encryption flag\n const flag = payload[i];\n // If the key is unencrypted, we only read the X coordinate of the EC public key and we deserialize into a Noise Public Key\n if (flag === 0) {\n const pkLen = 1 + _crypto_js__WEBPACK_IMPORTED_MODULE_2__.Curve25519KeySize;\n handshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_5__.NoisePublicKey.deserialize(payload.subarray(i, i + pkLen)));\n i += pkLen;\n written += pkLen;\n // If the key is encrypted, we only read the encrypted X coordinate and the authorization tag, and we deserialize into a Noise Public Key\n }\n else if (flag === 1) {\n const pkLen = 1 + _crypto_js__WEBPACK_IMPORTED_MODULE_2__.Curve25519KeySize + _crypto_js__WEBPACK_IMPORTED_MODULE_2__.ChachaPolyTagLen;\n handshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_5__.NoisePublicKey.deserialize(payload.subarray(i, i + pkLen)));\n i += pkLen;\n written += pkLen;\n }\n else {\n throw new Error(\"invalid flag for Noise public key\");\n }\n }\n // We read the transport message length (8 bytes) and we convert to uint64 in Little Endian\n const transportMessageLen = (0,_utils_js__WEBPACK_IMPORTED_MODULE_6__.readUIntLE)(payload, i, i + 8 - 1);\n i += 8;\n // We read the transport message (handshakeMessage bytes)\n const transportMessage = payload.subarray(i, i + transportMessageLen);\n i += transportMessageLen;\n return new PayloadV2(messageNametag, protocolId, handshakeMessage, transportMessage);\n }\n}\n//# sourceMappingURL=payload.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/payload.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PayloadV2: () => (/* binding */ PayloadV2)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _messagenametag_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./messagenametag.js */ \"./node_modules/@waku/noise/dist/messagenametag.js\");\n/* harmony import */ var _patterns_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./patterns.js */ \"./node_modules/@waku/noise/dist/patterns.js\");\n/* harmony import */ var _publickey_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./publickey.js */ \"./node_modules/@waku/noise/dist/publickey.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/noise/dist/utils.js\");\n\n\n\n\n\n\nconst authDataLen = 16;\n/**\n * PayloadV2 defines an object for Waku payloads with version 2 as in\n * https://rfc.vac.dev/spec/35/#public-keys-serialization\n * It contains a message nametag, protocol ID field, the handshake message (for Noise handshakes)\n * and the transport message\n */\nclass PayloadV2 {\n constructor(messageNametag = new Uint8Array(_messagenametag_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagLength), protocolId = 0, handshakeMessage = [], transportMessage = new Uint8Array()) {\n this.messageNametag = messageNametag;\n this.protocolId = protocolId;\n this.handshakeMessage = handshakeMessage;\n this.transportMessage = transportMessage;\n }\n /**\n * Create a copy of the PayloadV2\n * @returns a copy of the PayloadV2\n */\n clone() {\n const r = new PayloadV2();\n r.protocolId = this.protocolId;\n r.transportMessage = new Uint8Array(this.transportMessage);\n r.messageNametag = new Uint8Array(this.messageNametag);\n for (let i = 0; i < this.handshakeMessage.length; i++) {\n r.handshakeMessage.push(this.handshakeMessage[i].clone());\n }\n return r;\n }\n /**\n * Check PayloadV2 equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n let pkEquals = true;\n if (this.handshakeMessage.length != other.handshakeMessage.length) {\n pkEquals = false;\n }\n for (let i = 0; i < this.handshakeMessage.length; i++) {\n if (!this.handshakeMessage[i].equals(other.handshakeMessage[i])) {\n pkEquals = false;\n break;\n }\n }\n return ((0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.messageNametag, other.messageNametag) &&\n this.protocolId == other.protocolId &&\n (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.transportMessage, other.transportMessage) &&\n pkEquals);\n }\n /**\n * Serializes a PayloadV2 object to a byte sequences according to https://rfc.vac.dev/spec/35/.\n * The output serialized payload concatenates the input PayloadV2 object fields as\n * payload = ( protocolId || serializedHandshakeMessageLen || serializedHandshakeMessage || transportMessageLen || transportMessage)\n * The output can be then passed to the payload field of a WakuMessage https://rfc.vac.dev/spec/14/\n * @returns serialized payload\n */\n serialize() {\n // We collect public keys contained in the handshake message\n // According to https://rfc.vac.dev/spec/35/, the maximum size for the handshake message is 256 bytes, that is\n // the handshake message length can be represented with 1 byte only. (its length can be stored in 1 byte)\n // However, to ease public keys length addition operation, we declare it as int and later cast to uit8\n let serializedHandshakeMessageLen = 0;\n // This variables will store the concatenation of the serializations of all public keys in the handshake message\n let serializedHandshakeMessage = new Uint8Array();\n // For each public key in the handshake message\n for (const pk of this.handshakeMessage) {\n // We serialize the public key\n const serializedPk = pk.serialize();\n // We sum its serialized length to the total\n serializedHandshakeMessageLen += serializedPk.length;\n // We add its serialization to the concatenation of all serialized public keys in the handshake message\n serializedHandshakeMessage = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([serializedHandshakeMessage, serializedPk]);\n // If we are processing more than 256 byte, we return an error\n if (serializedHandshakeMessageLen > 255) {\n console.debug(\"PayloadV2 malformed: too many public keys contained in the handshake message\");\n throw new Error(\"too many public keys in handshake message\");\n }\n }\n // The output payload as in https://rfc.vac.dev/spec/35/. We concatenate all the PayloadV2 fields as\n // payload = ( protocolId || serializedHandshakeMessageLen || serializedHandshakeMessage || transportMessageLen || transportMessage)\n // We concatenate all the data\n // The protocol ID (1 byte) and handshake message length (1 byte) can be directly casted to byte to allow direct copy to the payload byte sequence\n const payload = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([\n this.messageNametag,\n new Uint8Array([this.protocolId]),\n new Uint8Array([serializedHandshakeMessageLen]),\n serializedHandshakeMessage,\n // The transport message length is converted from uint64 to bytes in Little-Endian\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.writeUIntLE)(new Uint8Array(8), this.transportMessage.length, 0, 8),\n this.transportMessage,\n ]);\n return payload;\n }\n /**\n * Deserializes a byte sequence to a PayloadV2 object according to https://rfc.vac.dev/spec/35/.\n * @param payload input serialized payload\n * @returns PayloadV2\n */\n static deserialize(payload) {\n // i is the read input buffer position index\n let i = 0;\n // We start by reading the messageNametag\n const messageNametag = new Uint8Array(_messagenametag_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagLength);\n for (let j = 0; j < _messagenametag_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagLength; j++) {\n messageNametag[j] = payload[i + j];\n }\n i += _messagenametag_js__WEBPACK_IMPORTED_MODULE_2__.MessageNametagLength;\n // We read the Protocol ID\n const protocolId = payload[i];\n const protocolName = Object.keys(_patterns_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2ProtocolIDs).find((key) => _patterns_js__WEBPACK_IMPORTED_MODULE_3__.PayloadV2ProtocolIDs[key] === protocolId);\n if (protocolName === undefined) {\n throw new Error(\"protocolId not found\");\n }\n const pattern = _patterns_js__WEBPACK_IMPORTED_MODULE_3__.NoiseHandshakePatterns[protocolName];\n const keySize = pattern ? pattern.dhKey.DHLen() : 0;\n i++;\n // We read the Handshake Message length (1 byte)\n const handshakeMessageLen = payload[i];\n if (handshakeMessageLen > 255) {\n console.debug(\"payload malformed: too many public keys contained in the handshake message\");\n throw new Error(\"too many public keys in handshake message\");\n }\n i++;\n // We now read for handshakeMessageLen bytes the buffer and we deserialize each (encrypted/unencrypted) public key read\n // In handshakeMessage we accumulate the read deserialized Noise Public keys\n const handshakeMessage = new Array();\n let written = 0;\n // We read the buffer until handshakeMessageLen are read\n while (written != handshakeMessageLen) {\n // We obtain the current Noise Public key encryption flag\n const flag = payload[i];\n // If the key is unencrypted, we only read the X coordinate of the EC public key and we deserialize into a Noise Public Key\n if (flag === 0) {\n const pkLen = 1 + keySize;\n handshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_4__.NoisePublicKey.deserialize(payload.subarray(i, i + pkLen)));\n i += pkLen;\n written += pkLen;\n // If the key is encrypted, we only read the encrypted X coordinate and the authorization tag, and we deserialize into a Noise Public Key\n }\n else if (flag === 1) {\n const pkLen = 1 + keySize + authDataLen;\n handshakeMessage.push(_publickey_js__WEBPACK_IMPORTED_MODULE_4__.NoisePublicKey.deserialize(payload.subarray(i, i + pkLen)));\n i += pkLen;\n written += pkLen;\n }\n else {\n throw new Error(\"invalid flag for Noise public key\");\n }\n }\n // We read the transport message length (8 bytes) and we convert to uint64 in Little Endian\n const transportMessageLen = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.readUIntLE)(payload, i, i + 8 - 1);\n i += 8;\n // We read the transport message (handshakeMessage bytes)\n const transportMessage = payload.subarray(i, i + transportMessageLen);\n i += transportMessageLen;\n return new PayloadV2(messageNametag, protocolId, handshakeMessage, transportMessage);\n }\n}\n//# sourceMappingURL=payload.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/payload.js?"); /***/ }), @@ -4982,7 +5924,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChaChaPolyCipherState: () => (/* binding */ ChaChaPolyCipherState),\n/* harmony export */ NoisePublicKey: () => (/* binding */ NoisePublicKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/noise/dist/crypto.js\");\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@waku/noise/dist/noise.js\");\n\n\n\n\n/**\n * A ChaChaPoly Cipher State containing key (k), nonce (nonce) and associated data (ad)\n */\nclass ChaChaPolyCipherState {\n /**\n * @param k 32-byte key\n * @param nonce 12 byte little-endian nonce\n * @param ad associated data\n */\n constructor(k = new Uint8Array(), nonce = new Uint8Array(), ad = new Uint8Array()) {\n this.k = k;\n this.nonce = nonce;\n this.ad = ad;\n }\n /**\n * Takes a Cipher State (with key, nonce, and associated data) and encrypts a plaintext.\n * The cipher state in not changed\n * @param plaintext data to encrypt\n * @returns sealed ciphertext including authentication tag\n */\n encrypt(plaintext) {\n // If plaintext is empty, we raise an error\n if (plaintext.length == 0) {\n throw new Error(\"tried to encrypt empty plaintext\");\n }\n return (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.chaCha20Poly1305Encrypt)(plaintext, this.nonce, this.ad, this.k);\n }\n /**\n * Takes a Cipher State (with key, nonce, and associated data) and decrypts a ciphertext\n * The cipher state is not changed\n * @param ciphertext data to decrypt\n * @returns plaintext\n */\n decrypt(ciphertext) {\n // If ciphertext is empty, we raise an error\n if (ciphertext.length == 0) {\n throw new Error(\"tried to decrypt empty ciphertext\");\n }\n const plaintext = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_2__.chaCha20Poly1305Decrypt)(ciphertext, this.nonce, this.ad, this.k);\n if (!plaintext) {\n throw new Error(\"decryptWithAd failed\");\n }\n return plaintext;\n }\n}\n/**\n * A Noise public key is a public key exchanged during Noise handshakes (no private part)\n * This follows https://rfc.vac.dev/spec/35/#public-keys-serialization\n */\nclass NoisePublicKey {\n /**\n * @param flag 1 to indicate that the public key is encrypted, 0 for unencrypted.\n * Note: besides encryption, flag can be used to distinguish among multiple supported Elliptic Curves\n * @param pk contains the X coordinate of the public key, if unencrypted\n * or the encryption of the X coordinate concatenated with the authorization tag, if encrypted\n */\n constructor(flag, pk) {\n this.flag = flag;\n this.pk = pk;\n }\n /**\n * Create a copy of the NoisePublicKey\n * @returns a copy of the NoisePublicKey\n */\n clone() {\n return new NoisePublicKey(this.flag, new Uint8Array(this.pk));\n }\n /**\n * Check NoisePublicKey equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return this.flag == other.flag && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.pk, other.pk);\n }\n /**\n * Converts a public Elliptic Curve key to an unencrypted Noise public key\n * @param publicKey 32-byte public key\n * @returns NoisePublicKey\n */\n static fromPublicKey(publicKey) {\n return new NoisePublicKey(0, publicKey);\n }\n /**\n * Converts a Noise public key to a stream of bytes as in https://rfc.vac.dev/spec/35/#public-keys-serialization\n * @returns Serialized NoisePublicKey\n */\n serialize() {\n // Public key is serialized as (flag || pk)\n // Note that pk contains the X coordinate of the public key if unencrypted\n // or the encryption concatenated with the authorization tag if encrypted\n const serializedNoisePublicKey = new Uint8Array((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([new Uint8Array([this.flag ? 1 : 0]), this.pk]));\n return serializedNoisePublicKey;\n }\n /**\n * Converts a serialized Noise public key to a NoisePublicKey object as in https://rfc.vac.dev/spec/35/#public-keys-serialization\n * @param serializedPK Serialized NoisePublicKey\n * @returns NoisePublicKey\n */\n static deserialize(serializedPK) {\n if (serializedPK.length == 0)\n throw new Error(\"invalid serialized key\");\n // We retrieve the encryption flag\n const flag = serializedPK[0];\n if (!(flag == 0 || flag == 1))\n throw new Error(\"invalid flag in serialized public key\");\n const pk = serializedPK.subarray(1);\n return new NoisePublicKey(flag, pk);\n }\n /**\n * Encrypt a NoisePublicKey using a ChaChaPolyCipherState\n * @param pk NoisePublicKey to encrypt\n * @param cs ChaChaPolyCipherState used to encrypt\n * @returns encrypted NoisePublicKey\n */\n static encrypt(pk, cs) {\n // We proceed with encryption only if\n // - a key is set in the cipher state\n // - the public key is unencrypted\n if (!(0,_noise_js__WEBPACK_IMPORTED_MODULE_3__.isEmptyKey)(cs.k) && pk.flag == 0) {\n const encPk = cs.encrypt(pk.pk);\n return new NoisePublicKey(1, encPk);\n }\n // Otherwise we return the public key as it is\n return pk.clone();\n }\n /**\n * Decrypts a Noise public key using a ChaChaPoly Cipher State\n * @param pk NoisePublicKey to decrypt\n * @param cs ChaChaPolyCipherState used to decrypt\n * @returns decrypted NoisePublicKey\n */\n static decrypt(pk, cs) {\n // We proceed with decryption only if\n // - a key is set in the cipher state\n // - the public key is encrypted\n if (!(0,_noise_js__WEBPACK_IMPORTED_MODULE_3__.isEmptyKey)(cs.k) && pk.flag == 1) {\n const decrypted = cs.decrypt(pk.pk);\n return new NoisePublicKey(0, decrypted);\n }\n // Otherwise we return the public key as it is\n return pk.clone();\n }\n}\n//# sourceMappingURL=publickey.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/publickey.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoisePublicKey: () => (/* binding */ NoisePublicKey)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n/**\n * A Noise public key is a public key exchanged during Noise handshakes (no private part)\n * This follows https://rfc.vac.dev/spec/35/#public-keys-serialization\n */\nclass NoisePublicKey {\n /**\n * @param flag 1 to indicate that the public key is encrypted, 0 for unencrypted.\n * Note: besides encryption, flag can be used to distinguish among multiple supported Elliptic Curves\n * @param pk contains the X coordinate of the public key, if unencrypted\n * or the encryption of the X coordinate concatenated with the authorization tag, if encrypted\n */\n constructor(flag, pk) {\n this.flag = flag;\n this.pk = pk;\n }\n /**\n * Create a copy of the NoisePublicKey\n * @returns a copy of the NoisePublicKey\n */\n clone() {\n return new NoisePublicKey(this.flag, new Uint8Array(this.pk));\n }\n /**\n * Check NoisePublicKey equality\n * @param other object to compare against\n * @returns true if equal, false otherwise\n */\n equals(other) {\n return this.flag == other.flag && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(this.pk, other.pk);\n }\n /**\n * Converts a public Elliptic Curve key to an unencrypted Noise public key\n * @param publicKey 32-byte public key\n * @returns NoisePublicKey\n */\n static fromPublicKey(publicKey) {\n return new NoisePublicKey(0, publicKey);\n }\n /**\n * Converts a Noise public key to a stream of bytes as in https://rfc.vac.dev/spec/35/#public-keys-serialization\n * @returns Serialized NoisePublicKey\n */\n serialize() {\n // Public key is serialized as (flag || pk)\n // Note that pk contains the X coordinate of the public key if unencrypted\n // or the encryption concatenated with the authorization tag if encrypted\n const serializedNoisePublicKey = new Uint8Array((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([new Uint8Array([this.flag ? 1 : 0]), this.pk]));\n return serializedNoisePublicKey;\n }\n /**\n * Converts a serialized Noise public key to a NoisePublicKey object as in https://rfc.vac.dev/spec/35/#public-keys-serialization\n * @param serializedPK Serialized NoisePublicKey\n * @returns NoisePublicKey\n */\n static deserialize(serializedPK) {\n if (serializedPK.length == 0)\n throw new Error(\"invalid serialized key\");\n // We retrieve the encryption flag\n const flag = serializedPK[0];\n if (!(flag == 0 || flag == 1))\n throw new Error(\"invalid flag in serialized public key\");\n const pk = serializedPK.subarray(1);\n return new NoisePublicKey(flag, pk);\n }\n}\n//# sourceMappingURL=publickey.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/noise/dist/publickey.js?"); /***/ }), @@ -5015,7 +5957,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_3__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _lib_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _lib_store_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _lib_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/message.js */ \"./node_modules/@waku/proto/dist/lib/message.js\");\n/* harmony import */ var _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/filter.js */ \"./node_modules/@waku/proto/dist/lib/filter.js\");\n/* harmony import */ var _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/topic_only_message.js */ \"./node_modules/@waku/proto/dist/lib/topic_only_message.js\");\n/* harmony import */ var _lib_light_push_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/light_push.js */ \"./node_modules/@waku/proto/dist/lib/light_push.js\");\n/* harmony import */ var _lib_store_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/store.js */ \"./node_modules/@waku/proto/dist/lib/store.js\");\n/* harmony import */ var _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/peer_exchange.js */ \"./node_modules/@waku/proto/dist/lib/peer_exchange.js\");\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _lib_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_metadata: () => (/* reexport module object */ _lib_metadata_js__WEBPACK_IMPORTED_MODULE_7__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _lib_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _lib_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/message.js */ \"./node_modules/@waku/proto/dist/lib/message.js\");\n/* harmony import */ var _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/filter.js */ \"./node_modules/@waku/proto/dist/lib/filter.js\");\n/* harmony import */ var _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/topic_only_message.js */ \"./node_modules/@waku/proto/dist/lib/topic_only_message.js\");\n/* harmony import */ var _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/filter_v2.js */ \"./node_modules/@waku/proto/dist/lib/filter_v2.js\");\n/* harmony import */ var _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/light_push.js */ \"./node_modules/@waku/proto/dist/lib/light_push.js\");\n/* harmony import */ var _lib_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/store.js */ \"./node_modules/@waku/proto/dist/lib/store.js\");\n/* harmony import */ var _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/peer_exchange.js */ \"./node_modules/@waku/proto/dist/lib/peer_exchange.js\");\n/* harmony import */ var _lib_metadata_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/metadata.js */ \"./node_modules/@waku/proto/dist/lib/metadata.js\");\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/index.js?"); /***/ }), @@ -5026,7 +5968,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.subscribe != null && obj.subscribe !== false) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if (obj.topic != null && obj.topic !== \"\") {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n subscribe: false,\n topic: \"\",\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.subscribe = reader.bool();\n break;\n case 2:\n obj.topic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec());\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = FilterRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.push = MessagePush.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec());\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/filter.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.subscribe != null && obj.subscribe !== false)) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if ((obj.topic != null && obj.topic !== '')) {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n subscribe: false,\n topic: '',\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.subscribe = reader.bool();\n break;\n case 2:\n obj.topic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec());\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = FilterRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.push = MessagePush.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec());\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/proto/dist/lib/filter_v2.js": +/*!********************************************************!*\ + !*** ./node_modules/@waku/proto/dist/lib/filter_v2.js ***! + \********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null && __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: '',\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.filterSubscribeType = FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n case 10:\n obj.pubsubTopic = reader.string();\n break;\n case 11:\n obj.contentTopics.push(reader.string());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec());\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if ((obj.statusCode != null && obj.statusCode !== 0)) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: '',\n statusCode: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 10:\n obj.statusCode = reader.uint32();\n break;\n case 11:\n obj.statusDesc = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec());\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/filter_v2.js?"); /***/ }), @@ -5037,7 +5990,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pubsubTopic = reader.string();\n break;\n case 2:\n obj.message = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec());\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.isSuccess != null && obj.isSuccess !== false) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n isSuccess: false,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.isSuccess = reader.bool();\n break;\n case 2:\n obj.info = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec());\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = PushRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = PushResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec());\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/light_push.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pubsubTopic = reader.string();\n break;\n case 2:\n obj.message = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec());\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.isSuccess != null && obj.isSuccess !== false)) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n isSuccess: false\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.isSuccess = reader.bool();\n break;\n case 2:\n obj.info = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec());\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = PushRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = PushResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec());\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), @@ -5048,7 +6001,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/message.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/proto/dist/lib/metadata.js": +/*!*******************************************************!*\ + !*** ./node_modules/@waku/proto/dist/lib/metadata.js ***! + \*******************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ WakuMetadataRequest: () => (/* binding */ WakuMetadataRequest),\n/* harmony export */ WakuMetadataResponse: () => (/* binding */ WakuMetadataResponse)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar WakuMetadataRequest;\n(function (WakuMetadataRequest) {\n let _codec;\n WakuMetadataRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.clusterId = reader.uint32();\n break;\n case 2:\n obj.shards.push(reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataRequest.codec());\n };\n WakuMetadataRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataRequest.codec());\n };\n})(WakuMetadataRequest || (WakuMetadataRequest = {}));\nvar WakuMetadataResponse;\n(function (WakuMetadataResponse) {\n let _codec;\n WakuMetadataResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.clusterId = reader.uint32();\n break;\n case 2:\n obj.shards.push(reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataResponse.codec());\n };\n WakuMetadataResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataResponse.codec());\n };\n})(WakuMetadataResponse || (WakuMetadataResponse = {}));\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/metadata.js?"); /***/ }), @@ -5059,7 +6023,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.enr = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec());\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.numPeers = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec());\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerInfos: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec());\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec());\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/peer_exchange.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.enr = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec());\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.numPeers = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec());\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerInfos: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec());\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec());\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/peer_exchange.js?"); /***/ }), @@ -5070,7 +6034,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.digest != null && obj.digest.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if (obj.receiverTime != null && obj.receiverTime !== 0n) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if (obj.senderTime != null && obj.senderTime !== 0n) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n digest: new Uint8Array(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.digest = reader.bytes();\n break;\n case 2:\n obj.receiverTime = reader.sint64();\n break;\n case 3:\n obj.senderTime = reader.sint64();\n break;\n case 4:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec());\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pageSize = reader.uint64();\n break;\n case 2:\n obj.cursor = Index.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec());\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 5:\n obj.startTime = reader.sint64();\n break;\n case 6:\n obj.endTime = reader.sint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec());\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n case 3:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 4:\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec());\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec());\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/store.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.digest != null && obj.digest.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if ((obj.receiverTime != null && obj.receiverTime !== 0n)) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if ((obj.senderTime != null && obj.senderTime !== 0n)) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n digest: new Uint8Array(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.digest = reader.bytes();\n break;\n case 2:\n obj.receiverTime = reader.sint64();\n break;\n case 3:\n obj.senderTime = reader.sint64();\n break;\n case 4:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec());\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pageSize = reader.uint64();\n break;\n case 2:\n obj.cursor = Index.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec());\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 5:\n obj.startTime = reader.sint64();\n break;\n case 6:\n obj.endTime = reader.sint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec());\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n case 3:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 4:\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec());\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec());\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/store.js?"); /***/ }), @@ -5081,7 +6045,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec());\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/topic_only_message.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec());\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), @@ -5103,7 +6067,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ wakuGossipSub: () => (/* binding */ wakuGossipSub),\n/* harmony export */ wakuRelay: () => (/* binding */ wakuRelay)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_libp2p_gossipsub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/libp2p-gossipsub */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js\");\n/* harmony import */ var _chainsafe_libp2p_gossipsub_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @chainsafe/libp2p-gossipsub/types */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/dist/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/relay/dist/message_validator.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./topic_only_message.js */ \"./node_modules/@waku/relay/dist/topic_only_message.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_5__(\"waku:relay\");\n/**\n * Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).\n * Throws if libp2p.pubsub does not support Waku Relay\n */\nclass Relay {\n pubSubTopic;\n defaultDecoder;\n static multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_6__.RelayCodecs[0];\n gossipSub;\n /**\n * observers called when receiving new message.\n * Observers under key `\"\"` are always called.\n */\n observers;\n constructor(libp2p, options) {\n if (!this.isRelayPubSub(libp2p.services.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.services.pubsub;\n this.pubSubTopic = options?.pubSubTopic ?? _waku_core__WEBPACK_IMPORTED_MODULE_2__.DefaultPubSubTopic;\n if (this.gossipSub.isStarted()) {\n this.gossipSubSubscribe(this.pubSubTopic);\n }\n this.observers = new Map();\n // TODO: User might want to decide what decoder should be used (e.g. for RLN)\n this.defaultDecoder = new _topic_only_message_js__WEBPACK_IMPORTED_MODULE_8__.TopicOnlyDecoder();\n }\n /**\n * Mounts the gossipsub protocol onto the libp2p node\n * and subscribes to the default topic.\n *\n * @override\n * @returns {void}\n */\n async start() {\n if (this.gossipSub.isStarted()) {\n throw Error(\"GossipSub already started.\");\n }\n await this.gossipSub.start();\n this.gossipSubSubscribe(this.pubSubTopic);\n }\n /**\n * Send Waku message.\n */\n async send(encoder, message) {\n if (!(0,_waku_utils__WEBPACK_IMPORTED_MODULE_4__.isSizeValid)(message.payload)) {\n log(\"Failed to send waku relay: message is bigger that 1MB\");\n return {\n recipients: [],\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.SendError.SIZE_TOO_BIG,\n };\n }\n const msg = await encoder.toWire(message);\n if (!msg) {\n log(\"Failed to encode message, aborting publish\");\n return {\n recipients: [],\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.SendError.ENCODE_FAILED,\n };\n }\n return this.gossipSub.publish(this.pubSubTopic, msg);\n }\n /**\n * Add an observer and associated Decoder to process incoming messages on a given content topic.\n *\n * @returns Function to delete the observer\n */\n subscribe(decoders, callback) {\n const contentTopicToObservers = Array.isArray(decoders)\n ? toObservers(decoders, callback)\n : toObservers([decoders], callback);\n for (const contentTopic of contentTopicToObservers.keys()) {\n const currObservers = this.observers.get(contentTopic) || new Set();\n const newObservers = contentTopicToObservers.get(contentTopic) || new Set();\n this.observers.set(contentTopic, union(currObservers, newObservers));\n }\n return () => {\n for (const contentTopic of contentTopicToObservers.keys()) {\n const currentObservers = this.observers.get(contentTopic) || new Set();\n const observersToRemove = contentTopicToObservers.get(contentTopic) || new Set();\n const nextObservers = leftMinusJoin(currentObservers, observersToRemove);\n if (nextObservers.size) {\n this.observers.set(contentTopic, nextObservers);\n }\n else {\n this.observers.delete(contentTopic);\n }\n }\n };\n }\n toSubscriptionIterator(decoders, opts) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_4__.toAsyncIterator)(this, decoders, opts);\n }\n getActiveSubscriptions() {\n const map = new Map();\n map.set(this.pubSubTopic, this.observers.keys());\n return map;\n }\n getMeshPeers(topic) {\n return this.gossipSub.getMeshPeers(topic ?? this.pubSubTopic);\n }\n async processIncomingMessage(pubSubTopic, bytes) {\n const topicOnlyMsg = await this.defaultDecoder.fromWireToProtoObj(bytes);\n if (!topicOnlyMsg || !topicOnlyMsg.contentTopic) {\n log(\"Message does not have a content topic, skipping\");\n return;\n }\n const observers = this.observers.get(topicOnlyMsg.contentTopic);\n if (!observers) {\n return;\n }\n await Promise.all(Array.from(observers).map(({ decoder, callback }) => {\n return (async () => {\n try {\n const protoMsg = await decoder.fromWireToProtoObj(bytes);\n if (!protoMsg) {\n log(\"Internal error: message previously decoded failed on 2nd pass.\");\n return;\n }\n const msg = await decoder.fromProtoObj(pubSubTopic, protoMsg);\n if (msg) {\n await callback(msg);\n }\n else {\n log(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\n }\n }\n catch (error) {\n log(\"Error while decoding message:\", error);\n }\n })();\n }));\n }\n /**\n * Subscribe to a pubsub topic and start emitting Waku messages to observers.\n *\n * @override\n */\n gossipSubSubscribe(pubSubTopic) {\n this.gossipSub.addEventListener(\"gossipsub:message\", (event) => {\n if (event.detail.msg.topic !== pubSubTopic)\n return;\n log(`Message received on ${pubSubTopic}`);\n this.processIncomingMessage(event.detail.msg.topic, event.detail.msg.data).catch((e) => log(\"Failed to process incoming message\", e));\n });\n this.gossipSub.topicValidators.set(pubSubTopic, _message_validator_js__WEBPACK_IMPORTED_MODULE_7__.messageValidator);\n this.gossipSub.subscribe(pubSubTopic);\n }\n isRelayPubSub(pubsub) {\n return pubsub?.multicodecs?.includes(Relay.multicodec) || false;\n }\n}\nfunction wakuRelay(init = {}) {\n return (libp2p) => new Relay(libp2p, init);\n}\nfunction wakuGossipSub(init = {}) {\n return (components) => {\n init = {\n ...init,\n msgIdFn: ({ data }) => (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_9__.sha256)(data),\n // Ensure that no signature is included nor expected in the messages.\n globalSignaturePolicy: _chainsafe_libp2p_gossipsub_types__WEBPACK_IMPORTED_MODULE_1__.SignaturePolicy.StrictNoSign,\n fallbackToFloodsub: false,\n };\n const pubsub = new _chainsafe_libp2p_gossipsub__WEBPACK_IMPORTED_MODULE_0__.GossipSub(components, init);\n pubsub.multicodecs = _constants_js__WEBPACK_IMPORTED_MODULE_6__.RelayCodecs;\n return pubsub;\n };\n}\nfunction toObservers(decoders, callback) {\n const contentTopicToDecoders = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_4__.groupByContentTopic)(decoders).entries());\n const contentTopicToObserversEntries = contentTopicToDecoders.map(([contentTopic, decoders]) => [\n contentTopic,\n new Set(decoders.map((decoder) => ({\n decoder,\n callback,\n }))),\n ]);\n return new Map(contentTopicToObserversEntries);\n}\nfunction union(left, right) {\n for (const val of right.values()) {\n left.add(val);\n }\n return left;\n}\nfunction leftMinusJoin(left, right) {\n for (const val of right.values()) {\n if (left.has(val)) {\n left.delete(val);\n }\n }\n return left;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ wakuGossipSub: () => (/* binding */ wakuGossipSub),\n/* harmony export */ wakuRelay: () => (/* binding */ wakuRelay)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_libp2p_gossipsub__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @chainsafe/libp2p-gossipsub */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js\");\n/* harmony import */ var _chainsafe_libp2p_gossipsub_types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @chainsafe/libp2p-gossipsub/types */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/dist/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/relay/dist/message_validator.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./topic_only_message.js */ \"./node_modules/@waku/relay/dist/topic_only_message.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"relay\");\n/**\n * Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).\n * Throws if libp2p.pubsub does not support Waku Relay\n */\nclass Relay {\n pubsubTopics;\n defaultDecoder;\n static multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_2__.RelayCodecs[0];\n gossipSub;\n /**\n * observers called when receiving new message.\n * Observers under key `\"\"` are always called.\n */\n observers;\n constructor(libp2p, pubsubTopics) {\n if (!this.isRelayPubsub(libp2p.services.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.services.pubsub;\n this.pubsubTopics = new Set(pubsubTopics);\n if (this.gossipSub.isStarted()) {\n this.subscribeToAllTopics();\n }\n this.observers = new Map();\n // Default PubsubTopic decoder\n // TODO: User might want to decide what decoder should be used (e.g. for RLN)\n this.defaultDecoder = new _topic_only_message_js__WEBPACK_IMPORTED_MODULE_4__.TopicOnlyDecoder();\n }\n /**\n * Mounts the gossipsub protocol onto the libp2p node\n * and subscribes to all the topics.\n *\n * @override\n * @returns {void}\n */\n async start() {\n if (this.gossipSub.isStarted()) {\n throw Error(\"GossipSub already started.\");\n }\n await this.gossipSub.start();\n this.subscribeToAllTopics();\n }\n /**\n * Send Waku message.\n */\n async send(encoder, message) {\n const successes = [];\n const { pubsubTopic } = encoder;\n if (!this.pubsubTopics.has(pubsubTopic)) {\n log.error(\"Failed to send waku relay: topic not configured\");\n return {\n successes,\n failures: [\n {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.TOPIC_NOT_CONFIGURED\n }\n ]\n };\n }\n const msg = await encoder.toWire(message);\n if (!msg) {\n log.error(\"Failed to encode message, aborting publish\");\n return {\n successes,\n failures: [\n {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.ENCODE_FAILED\n }\n ]\n };\n }\n if (!(0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.isWireSizeUnderCap)(msg)) {\n log.error(\"Failed to send waku relay: message is bigger that 1MB\");\n return {\n successes,\n failures: [\n {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.SIZE_TOO_BIG\n }\n ]\n };\n }\n const { recipients } = await this.gossipSub.publish(pubsubTopic, msg);\n return {\n successes: recipients\n };\n }\n subscribe(decoders, callback) {\n const observers = [];\n for (const decoder of Array.isArray(decoders) ? decoders : [decoders]) {\n const { pubsubTopic } = decoder;\n const ctObs = this.observers.get(pubsubTopic) ?? new Map();\n const observer = { pubsubTopic, decoder, callback };\n (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.pushOrInitMapSet)(ctObs, decoder.contentTopic, observer);\n this.observers.set(pubsubTopic, ctObs);\n observers.push([pubsubTopic, observer]);\n }\n return () => {\n this.removeObservers(observers);\n };\n }\n removeObservers(observers) {\n for (const [pubsubTopic, observer] of observers) {\n const ctObs = this.observers.get(pubsubTopic);\n if (!ctObs)\n continue;\n const contentTopic = observer.decoder.contentTopic;\n const _obs = ctObs.get(contentTopic);\n if (!_obs)\n continue;\n _obs.delete(observer);\n ctObs.set(contentTopic, _obs);\n this.observers.set(pubsubTopic, ctObs);\n }\n }\n toSubscriptionIterator(decoders) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.toAsyncIterator)(this, decoders);\n }\n getActiveSubscriptions() {\n const map = new Map();\n for (const pubsubTopic of this.pubsubTopics) {\n map.set(pubsubTopic, Array.from(this.observers.keys()));\n }\n return map;\n }\n getMeshPeers(topic = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DefaultPubsubTopic) {\n return this.gossipSub.getMeshPeers(topic);\n }\n subscribeToAllTopics() {\n for (const pubsubTopic of this.pubsubTopics) {\n this.gossipSubSubscribe(pubsubTopic);\n }\n }\n async processIncomingMessage(pubsubTopic, bytes) {\n const topicOnlyMsg = await this.defaultDecoder.fromWireToProtoObj(bytes);\n if (!topicOnlyMsg || !topicOnlyMsg.contentTopic) {\n log.warn(\"Message does not have a content topic, skipping\");\n return;\n }\n // Retrieve the map of content topics for the given pubsubTopic\n const contentTopicMap = this.observers.get(pubsubTopic);\n if (!contentTopicMap) {\n return;\n }\n // Retrieve the set of observers for the given contentTopic\n const observers = contentTopicMap.get(topicOnlyMsg.contentTopic);\n if (!observers) {\n return;\n }\n await Promise.all(Array.from(observers).map(({ decoder, callback }) => {\n return (async () => {\n try {\n const protoMsg = await decoder.fromWireToProtoObj(bytes);\n if (!protoMsg) {\n log.error(\"Internal error: message previously decoded failed on 2nd pass.\");\n return;\n }\n const msg = await decoder.fromProtoObj(pubsubTopic, protoMsg);\n if (msg) {\n await callback(msg);\n }\n else {\n log.error(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\n }\n }\n catch (error) {\n log.error(\"Error while decoding message:\", error);\n }\n })();\n }));\n }\n /**\n * Subscribe to a pubsub topic and start emitting Waku messages to observers.\n *\n * @override\n */\n gossipSubSubscribe(pubsubTopic) {\n this.gossipSub.addEventListener(\"gossipsub:message\", (event) => {\n if (event.detail.msg.topic !== pubsubTopic)\n return;\n this.processIncomingMessage(event.detail.msg.topic, event.detail.msg.data).catch((e) => log.error(\"Failed to process incoming message\", e));\n });\n this.gossipSub.topicValidators.set(pubsubTopic, _message_validator_js__WEBPACK_IMPORTED_MODULE_3__.messageValidator);\n this.gossipSub.subscribe(pubsubTopic);\n }\n isRelayPubsub(pubsub) {\n return pubsub?.multicodecs?.includes(Relay.multicodec) ?? false;\n }\n}\nfunction wakuRelay(pubsubTopics) {\n return (libp2p) => new Relay(libp2p, pubsubTopics);\n}\nfunction wakuGossipSub(init = {}) {\n return (components) => {\n init = {\n ...init,\n msgIdFn: ({ data }) => (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_5__.sha256)(data),\n // Ensure that no signature is included nor expected in the messages.\n globalSignaturePolicy: _chainsafe_libp2p_gossipsub_types__WEBPACK_IMPORTED_MODULE_6__.SignaturePolicy.StrictNoSign,\n fallbackToFloodsub: false\n };\n const pubsub = new _chainsafe_libp2p_gossipsub__WEBPACK_IMPORTED_MODULE_7__.GossipSub(components, init);\n pubsub.multicodecs = _constants_js__WEBPACK_IMPORTED_MODULE_2__.RelayCodecs;\n return pubsub;\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/index.js?"); /***/ }), @@ -5114,7 +6078,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ messageValidator: () => (/* binding */ messageValidator)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:relay\");\nfunction messageValidator(peer, message) {\n const startTime = performance.now();\n log(`validating message from ${peer} received on ${message.topic}`);\n let result = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Accept;\n try {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.proto_message.WakuMessage.decode(message.data);\n if (!protoMessage.contentTopic ||\n !protoMessage.contentTopic.length ||\n !protoMessage.payload ||\n !protoMessage.payload.length) {\n result = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Reject;\n }\n }\n catch (e) {\n result = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Reject;\n }\n const endTime = performance.now();\n log(`Validation time (must be <100ms): ${endTime - startTime}ms`);\n return result;\n}\n//# sourceMappingURL=message_validator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/message_validator.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ messageValidator: () => (/* binding */ messageValidator)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/pubsub/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"relay\");\nfunction messageValidator(peer, message) {\n const startTime = performance.now();\n log.info(`validating message from ${peer} received on ${message.topic}`);\n let result = _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.TopicValidatorResult.Accept;\n try {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(message.data);\n if (!protoMessage.contentTopic ||\n !protoMessage.contentTopic.length ||\n !protoMessage.payload ||\n !protoMessage.payload.length) {\n result = _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.TopicValidatorResult.Reject;\n }\n }\n catch (e) {\n result = _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.TopicValidatorResult.Reject;\n }\n const endTime = performance.now();\n const timeTakenMs = endTime - startTime;\n if (timeTakenMs > 100) {\n log.warn(`message validation took ${timeTakenMs}ms for peer ${peer} on topic ${message.topic}. This should be less than 100ms.`);\n }\n else {\n log.info(`message validation took ${timeTakenMs}ms for peer ${peer} on topic ${message.topic}`);\n }\n return result;\n}\n//# sourceMappingURL=message_validator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/message_validator.js?"); /***/ }), @@ -5125,502 +6089,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyDecoder: () => (/* binding */ TopicOnlyDecoder),\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:message:topic-only\");\nclass TopicOnlyMessage {\n pubSubTopic;\n proto;\n payload = new Uint8Array();\n rateLimitProof;\n timestamp;\n meta;\n ephemeral;\n constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n}\nclass TopicOnlyDecoder {\n contentTopic = \"\";\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.TopicOnlyMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve({\n contentTopic: protoMessage.contentTopic,\n payload: new Uint8Array(),\n rateLimitProof: undefined,\n timestamp: undefined,\n meta: undefined,\n version: undefined,\n ephemeral: undefined,\n });\n }\n async fromProtoObj(pubSubTopic, proto) {\n return new TopicOnlyMessage(pubSubTopic, proto);\n }\n}\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/topic_only_message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ACCEPT_FROM_WHITELIST_DURATION_MS: () => (/* binding */ ACCEPT_FROM_WHITELIST_DURATION_MS),\n/* harmony export */ ACCEPT_FROM_WHITELIST_MAX_MESSAGES: () => (/* binding */ ACCEPT_FROM_WHITELIST_MAX_MESSAGES),\n/* harmony export */ ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE: () => (/* binding */ ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE),\n/* harmony export */ BACKOFF_SLACK: () => (/* binding */ BACKOFF_SLACK),\n/* harmony export */ DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS: () => (/* binding */ DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS),\n/* harmony export */ ERR_TOPIC_VALIDATOR_IGNORE: () => (/* binding */ ERR_TOPIC_VALIDATOR_IGNORE),\n/* harmony export */ ERR_TOPIC_VALIDATOR_REJECT: () => (/* binding */ ERR_TOPIC_VALIDATOR_REJECT),\n/* harmony export */ FloodsubID: () => (/* binding */ FloodsubID),\n/* harmony export */ GossipsubConnectionTimeout: () => (/* binding */ GossipsubConnectionTimeout),\n/* harmony export */ GossipsubConnectors: () => (/* binding */ GossipsubConnectors),\n/* harmony export */ GossipsubD: () => (/* binding */ GossipsubD),\n/* harmony export */ GossipsubDhi: () => (/* binding */ GossipsubDhi),\n/* harmony export */ GossipsubDirectConnectInitialDelay: () => (/* binding */ GossipsubDirectConnectInitialDelay),\n/* harmony export */ GossipsubDirectConnectTicks: () => (/* binding */ GossipsubDirectConnectTicks),\n/* harmony export */ GossipsubDlazy: () => (/* binding */ GossipsubDlazy),\n/* harmony export */ GossipsubDlo: () => (/* binding */ GossipsubDlo),\n/* harmony export */ GossipsubDout: () => (/* binding */ GossipsubDout),\n/* harmony export */ GossipsubDscore: () => (/* binding */ GossipsubDscore),\n/* harmony export */ GossipsubFanoutTTL: () => (/* binding */ GossipsubFanoutTTL),\n/* harmony export */ GossipsubGossipFactor: () => (/* binding */ GossipsubGossipFactor),\n/* harmony export */ GossipsubGossipRetransmission: () => (/* binding */ GossipsubGossipRetransmission),\n/* harmony export */ GossipsubGraftFloodThreshold: () => (/* binding */ GossipsubGraftFloodThreshold),\n/* harmony export */ GossipsubHeartbeatInitialDelay: () => (/* binding */ GossipsubHeartbeatInitialDelay),\n/* harmony export */ GossipsubHeartbeatInterval: () => (/* binding */ GossipsubHeartbeatInterval),\n/* harmony export */ GossipsubHistoryGossip: () => (/* binding */ GossipsubHistoryGossip),\n/* harmony export */ GossipsubHistoryLength: () => (/* binding */ GossipsubHistoryLength),\n/* harmony export */ GossipsubIDv10: () => (/* binding */ GossipsubIDv10),\n/* harmony export */ GossipsubIDv11: () => (/* binding */ GossipsubIDv11),\n/* harmony export */ GossipsubIWantFollowupTime: () => (/* binding */ GossipsubIWantFollowupTime),\n/* harmony export */ GossipsubMaxIHaveLength: () => (/* binding */ GossipsubMaxIHaveLength),\n/* harmony export */ GossipsubMaxIHaveMessages: () => (/* binding */ GossipsubMaxIHaveMessages),\n/* harmony export */ GossipsubMaxPendingConnections: () => (/* binding */ GossipsubMaxPendingConnections),\n/* harmony export */ GossipsubOpportunisticGraftPeers: () => (/* binding */ GossipsubOpportunisticGraftPeers),\n/* harmony export */ GossipsubOpportunisticGraftTicks: () => (/* binding */ GossipsubOpportunisticGraftTicks),\n/* harmony export */ GossipsubPruneBackoff: () => (/* binding */ GossipsubPruneBackoff),\n/* harmony export */ GossipsubPruneBackoffTicks: () => (/* binding */ GossipsubPruneBackoffTicks),\n/* harmony export */ GossipsubPrunePeers: () => (/* binding */ GossipsubPrunePeers),\n/* harmony export */ GossipsubSeenTTL: () => (/* binding */ GossipsubSeenTTL),\n/* harmony export */ GossipsubUnsubscribeBackoff: () => (/* binding */ GossipsubUnsubscribeBackoff),\n/* harmony export */ TimeCacheDuration: () => (/* binding */ TimeCacheDuration),\n/* harmony export */ minute: () => (/* binding */ minute),\n/* harmony export */ second: () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n// Protocol identifiers\nconst FloodsubID = '/floodsub/1.0.0';\n/**\n * The protocol ID for version 1.0.0 of the Gossipsub protocol\n * It is advertised along with GossipsubIDv11 for backwards compatability\n */\nconst GossipsubIDv10 = '/meshsub/1.0.0';\n/**\n * The protocol ID for version 1.1.0 of the Gossipsub protocol\n * See the spec for details about how v1.1.0 compares to v1.0.0:\n * https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md\n */\nconst GossipsubIDv11 = '/meshsub/1.1.0';\n// Overlay parameters\n/**\n * GossipsubD sets the optimal degree for a Gossipsub topic mesh. For example, if GossipsubD == 6,\n * each peer will want to have about six peers in their mesh for each topic they're subscribed to.\n * GossipsubD should be set somewhere between GossipsubDlo and GossipsubDhi.\n */\nconst GossipsubD = 6;\n/**\n * GossipsubDlo sets the lower bound on the number of peers we keep in a Gossipsub topic mesh.\n * If we have fewer than GossipsubDlo peers, we will attempt to graft some more into the mesh at\n * the next heartbeat.\n */\nconst GossipsubDlo = 4;\n/**\n * GossipsubDhi sets the upper bound on the number of peers we keep in a Gossipsub topic mesh.\n * If we have more than GossipsubDhi peers, we will select some to prune from the mesh at the next heartbeat.\n */\nconst GossipsubDhi = 12;\n/**\n * GossipsubDscore affects how peers are selected when pruning a mesh due to over subscription.\n * At least GossipsubDscore of the retained peers will be high-scoring, while the remainder are\n * chosen randomly.\n */\nconst GossipsubDscore = 4;\n/**\n * GossipsubDout sets the quota for the number of outbound connections to maintain in a topic mesh.\n * When the mesh is pruned due to over subscription, we make sure that we have outbound connections\n * to at least GossipsubDout of the survivor peers. This prevents sybil attackers from overwhelming\n * our mesh with incoming connections.\n *\n * GossipsubDout must be set below GossipsubDlo, and must not exceed GossipsubD / 2.\n */\nconst GossipsubDout = 2;\n// Gossip parameters\n/**\n * GossipsubHistoryLength controls the size of the message cache used for gossip.\n * The message cache will remember messages for GossipsubHistoryLength heartbeats.\n */\nconst GossipsubHistoryLength = 5;\n/**\n * GossipsubHistoryGossip controls how many cached message ids we will advertise in\n * IHAVE gossip messages. When asked for our seen message IDs, we will return\n * only those from the most recent GossipsubHistoryGossip heartbeats. The slack between\n * GossipsubHistoryGossip and GossipsubHistoryLength allows us to avoid advertising messages\n * that will be expired by the time they're requested.\n *\n * GossipsubHistoryGossip must be less than or equal to GossipsubHistoryLength to\n * avoid a runtime panic.\n */\nconst GossipsubHistoryGossip = 3;\n/**\n * GossipsubDlazy affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to at least GossipsubDlazy peers outside our mesh. The actual\n * number may be more, depending on GossipsubGossipFactor and how many peers we're\n * connected to.\n */\nconst GossipsubDlazy = 6;\n/**\n * GossipsubGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to GossipsubGossipFactor * (total number of non-mesh peers), or\n * GossipsubDlazy, whichever is greater.\n */\nconst GossipsubGossipFactor = 0.25;\n/**\n * GossipsubGossipRetransmission controls how many times we will allow a peer to request\n * the same message id through IWANT gossip before we start ignoring them. This is designed\n * to prevent peers from spamming us with requests and wasting our resources.\n */\nconst GossipsubGossipRetransmission = 3;\n// Heartbeat interval\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst GossipsubHeartbeatInitialDelay = 100;\n/**\n * GossipsubHeartbeatInterval controls the time between heartbeats.\n */\nconst GossipsubHeartbeatInterval = second;\n/**\n * GossipsubFanoutTTL controls how long we keep track of the fanout state. If it's been\n * GossipsubFanoutTTL since we've published to a topic that we're not subscribed to,\n * we'll delete the fanout map for that topic.\n */\nconst GossipsubFanoutTTL = minute;\n/**\n * GossipsubPrunePeers controls the number of peers to include in prune Peer eXchange.\n * When we prune a peer that's eligible for PX (has a good score, etc), we will try to\n * send them signed peer records for up to GossipsubPrunePeers other peers that we\n * know of.\n */\nconst GossipsubPrunePeers = 16;\n/**\n * GossipsubPruneBackoff controls the backoff time for pruned peers. This is how long\n * a peer must wait before attempting to graft into our mesh again after being pruned.\n * When pruning a peer, we send them our value of GossipsubPruneBackoff so they know\n * the minimum time to wait. Peers running older versions may not send a backoff time,\n * so if we receive a prune message without one, we will wait at least GossipsubPruneBackoff\n * before attempting to re-graft.\n */\nconst GossipsubPruneBackoff = minute;\n/**\n * Backoff to use when unsuscribing from a topic. Should not resubscribe to this topic before it expired.\n */\nconst GossipsubUnsubscribeBackoff = 10 * second;\n/**\n * GossipsubPruneBackoffTicks is the number of heartbeat ticks for attempting to prune expired\n * backoff timers.\n */\nconst GossipsubPruneBackoffTicks = 15;\n/**\n * GossipsubConnectors controls the number of active connection attempts for peers obtained through PX.\n */\nconst GossipsubConnectors = 8;\n/**\n * GossipsubMaxPendingConnections sets the maximum number of pending connections for peers attempted through px.\n */\nconst GossipsubMaxPendingConnections = 128;\n/**\n * GossipsubConnectionTimeout controls the timeout for connection attempts.\n */\nconst GossipsubConnectionTimeout = 30 * second;\n/**\n * GossipsubDirectConnectTicks is the number of heartbeat ticks for attempting to reconnect direct peers\n * that are not currently connected.\n */\nconst GossipsubDirectConnectTicks = 300;\n/**\n * GossipsubDirectConnectInitialDelay is the initial delay before opening connections to direct peers\n */\nconst GossipsubDirectConnectInitialDelay = second;\n/**\n * GossipsubOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every GossipsubOpportunisticGraftTicks we will attempt to select some\n * high-scoring mesh peers to replace lower-scoring ones, if the median score of our mesh peers falls\n * below a threshold\n */\nconst GossipsubOpportunisticGraftTicks = 60;\n/**\n * GossipsubOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst GossipsubOpportunisticGraftPeers = 2;\n/**\n * If a GRAFT comes before GossipsubGraftFloodThreshold has elapsed since the last PRUNE,\n * then there is an extra score penalty applied to the peer through P7.\n */\nconst GossipsubGraftFloodThreshold = 10 * second;\n/**\n * GossipsubMaxIHaveLength is the maximum number of messages to include in an IHAVE message.\n * Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a\n * peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the\n * default if your system is pushing more than 5000 messages in GossipsubHistoryGossip heartbeats;\n * with the defaults this is 1666 messages/s.\n */\nconst GossipsubMaxIHaveLength = 5000;\n/**\n * GossipsubMaxIHaveMessages is the maximum number of IHAVE messages to accept from a peer within a heartbeat.\n */\nconst GossipsubMaxIHaveMessages = 10;\n/**\n * Time to wait for a message requested through IWANT following an IHAVE advertisement.\n * If the message is not received within this window, a broken promise is declared and\n * the router may apply bahavioural penalties.\n */\nconst GossipsubIWantFollowupTime = 3 * second;\n/**\n * Time in milliseconds to keep message ids in the seen cache\n */\nconst GossipsubSeenTTL = 2 * minute;\nconst TimeCacheDuration = 120 * 1000;\nconst ERR_TOPIC_VALIDATOR_REJECT = 'ERR_TOPIC_VALIDATOR_REJECT';\nconst ERR_TOPIC_VALIDATOR_IGNORE = 'ERR_TOPIC_VALIDATOR_IGNORE';\n/**\n * If peer score is better than this, we accept messages from this peer\n * within ACCEPT_FROM_WHITELIST_DURATION_MS from the last time computing score.\n **/\nconst ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE = 0;\n/**\n * If peer score >= ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE, accept up to this\n * number of messages from that peer.\n */\nconst ACCEPT_FROM_WHITELIST_MAX_MESSAGES = 128;\n/**\n * If peer score >= ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE, accept messages from\n * this peer up to this time duration.\n */\nconst ACCEPT_FROM_WHITELIST_DURATION_MS = 1000;\n/**\n * The default MeshMessageDeliveriesWindow to be used in metrics.\n */\nconst DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS = 1000;\n/** Wait for 1 more heartbeats before clearing a backoff */\nconst BACKOFF_SLACK = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ GossipSub: () => (/* binding */ GossipSub),\n/* harmony export */ gossipsub: () => (/* binding */ gossipsub),\n/* harmony export */ multicodec: () => (/* binding */ multicodec)\n/* harmony export */ });\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_topology__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/topology */ \"./node_modules/@libp2p/topology/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIDv11;\nvar GossipStatusCode;\n(function (GossipStatusCode) {\n GossipStatusCode[GossipStatusCode[\"started\"] = 0] = \"started\";\n GossipStatusCode[GossipStatusCode[\"stopped\"] = 1] = \"stopped\";\n})(GossipStatusCode || (GossipStatusCode = {}));\nclass GossipSub extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.EventEmitter {\n constructor(components, options = {}) {\n super();\n this.multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIDv10];\n // State\n this.peers = new Set();\n this.streamsInbound = new Map();\n this.streamsOutbound = new Map();\n /** Ensures outbound streams are created sequentially */\n this.outboundInflightQueue = (0,it_pushable__WEBPACK_IMPORTED_MODULE_20__.pushable)({ objectMode: true });\n /** Direct peers */\n this.direct = new Set();\n /** Floodsub peers */\n this.floodsubPeers = new Set();\n /**\n * Map of peer id and AcceptRequestWhileListEntry\n */\n this.acceptFromWhitelist = new Map();\n /**\n * Map of topics to which peers are subscribed to\n */\n this.topics = new Map();\n /**\n * List of our subscriptions\n */\n this.subscriptions = new Set();\n /**\n * Map of topic meshes\n * topic => peer id set\n */\n this.mesh = new Map();\n /**\n * Map of topics to set of peers. These mesh peers are the ones to which we are publishing without a topic membership\n * topic => peer id set\n */\n this.fanout = new Map();\n /**\n * Map of last publish time for fanout topics\n * topic => last publish time\n */\n this.fanoutLastpub = new Map();\n /**\n * Map of pending messages to gossip\n * peer id => control messages\n */\n this.gossip = new Map();\n /**\n * Map of control messages\n * peer id => control message\n */\n this.control = new Map();\n /**\n * Number of IHAVEs received from peer in the last heartbeat\n */\n this.peerhave = new Map();\n /** Number of messages we have asked from peer in the last heartbeat */\n this.iasked = new Map();\n /** Prune backoff map */\n this.backoff = new Map();\n /**\n * Connection direction cache, marks peers with outbound connections\n * peer id => direction\n */\n this.outbound = new Map();\n /**\n * Custom validator function per topic.\n * Must return or resolve quickly (< 100ms) to prevent causing penalties for late messages.\n * If you need to apply validation that may require longer times use `asyncValidation` option and callback the\n * validation result through `Gossipsub.reportValidationResult`\n */\n this.topicValidators = new Map();\n /**\n * Number of heartbeats since the beginning of time\n * This allows us to amortize some resource cleanup -- eg: backoff cleanup\n */\n this.heartbeatTicks = 0;\n this.directPeerInitial = null;\n this.status = { code: GossipStatusCode.stopped };\n this.heartbeatTimer = null;\n this.runHeartbeat = () => {\n const timer = this.metrics?.heartbeatDuration.startTimer();\n this.heartbeat()\n .catch((err) => {\n this.log('Error running heartbeat', err);\n })\n .finally(() => {\n if (timer != null) {\n timer();\n }\n // Schedule the next run if still in started status\n if (this.status.code === GossipStatusCode.started) {\n // Clear previous timeout before overwriting `status.heartbeatTimeout`, it should be completed tho.\n clearTimeout(this.status.heartbeatTimeout);\n // NodeJS setInterval function is innexact, calls drift by a few miliseconds on each call.\n // To run the heartbeat precisely setTimeout() must be used recomputing the delay on every loop.\n let msToNextHeartbeat = this.opts.heartbeatInterval - ((Date.now() - this.status.hearbeatStartMs) % this.opts.heartbeatInterval);\n // If too close to next heartbeat, skip one\n if (msToNextHeartbeat < this.opts.heartbeatInterval * 0.25) {\n msToNextHeartbeat += this.opts.heartbeatInterval;\n this.metrics?.heartbeatSkipped.inc();\n }\n this.status.heartbeatTimeout = setTimeout(this.runHeartbeat, msToNextHeartbeat);\n }\n });\n };\n const opts = {\n fallbackToFloodsub: true,\n floodPublish: true,\n doPX: false,\n directPeers: [],\n D: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubPruneBackoff,\n unsubcribeBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubUnsubscribeBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_9__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_9__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_22__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.StrictSign;\n // Also wants to get notified of peers connected using floodsub\n if (opts.fallbackToFloodsub) {\n this.multicodecs.push(_constants_js__WEBPACK_IMPORTED_MODULE_7__.FloodsubID);\n }\n // From pubsub\n this.log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)(opts.debugName ?? 'libp2p:gossipsub');\n // Gossipsub\n this.opts = opts;\n this.direct = new Set(opts.directPeers.map((p) => p.id.toString()));\n this.seenCache = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_11__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_11__.SimpleTimeCache({ validityMs: opts.seenTTL });\n if (options.msgIdFn) {\n // Use custom function\n this.msgIdFn = options.msgIdFn;\n }\n else {\n switch (this.globalSignaturePolicy) {\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_15__.msgIdFnStrictSign;\n break;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_15__.msgIdFnStrictNoSign;\n break;\n }\n }\n if (options.fastMsgIdFn) {\n this.fastMsgIdFn = options.fastMsgIdFn;\n this.fastMsgIdCache = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_11__.SimpleTimeCache({ validityMs: opts.seenTTL });\n }\n // By default, gossipsub only provide a browser friendly function to convert Uint8Array message id to string.\n this.msgIdToStrFn = options.msgIdToStrFn ?? _utils_index_js__WEBPACK_IMPORTED_MODULE_8__.messageIdToString;\n this.mcache = options.messageCache || new _message_cache_js__WEBPACK_IMPORTED_MODULE_5__.MessageCache(opts.mcacheGossip, opts.mcacheLength, this.msgIdToStrFn);\n if (options.dataTransform) {\n this.dataTransform = options.dataTransform;\n }\n if (options.metricsRegister) {\n if (!options.metricsTopicStrToLabel) {\n throw Error('Must set metricsTopicStrToLabel with metrics');\n }\n // in theory, each topic has its own meshMessageDeliveriesWindow param\n // however in lodestar, we configure it mostly the same so just pick the max of positive ones\n // (some topics have meshMessageDeliveriesWindow as 0)\n const maxMeshMessageDeliveriesWindowMs = Math.max(...Object.values(opts.scoreParams.topics).map((topicParam) => topicParam.meshMessageDeliveriesWindow), _constants_js__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_METRIC_MESH_MESSAGE_DELIVERIES_WINDOWS);\n const metrics = (0,_metrics_js__WEBPACK_IMPORTED_MODULE_12__.getMetrics)(options.metricsRegister, options.metricsTopicStrToLabel, {\n gossipPromiseExpireSec: this.opts.gossipsubIWantFollowupMs / 1000,\n behaviourPenaltyThreshold: opts.scoreParams.behaviourPenaltyThreshold,\n maxMeshMessageDeliveriesWindowSec: maxMeshMessageDeliveriesWindowMs / 1000\n });\n metrics.mcacheSize.addCollect(() => this.onScrapeMetrics(metrics));\n for (const protocol of this.multicodecs) {\n metrics.protocolsEnabled.set({ protocol }, 1);\n }\n this.metrics = metrics;\n }\n else {\n this.metrics = null;\n }\n this.gossipTracer = new _tracer_js__WEBPACK_IMPORTED_MODULE_10__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_9__.PeerScore(this.opts.scoreParams, this.metrics, {\n scoreCacheValidityMs: opts.heartbeatInterval\n });\n this.maxInboundStreams = options.maxInboundStreams;\n this.maxOutboundStreams = options.maxOutboundStreams;\n this.allowedTopics = opts.allowedTopics ? new Set(opts.allowedTopics) : null;\n }\n getPeers() {\n return [...this.peers.keys()].map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(str));\n }\n isStarted() {\n return this.status.code === GossipStatusCode.started;\n }\n // LIFECYCLE METHODS\n /**\n * Mounts the gossipsub protocol onto the libp2p node and sends our\n * our subscriptions to every peer connected\n */\n async start() {\n // From pubsub\n if (this.isStarted()) {\n return;\n }\n this.log('starting');\n this.publishConfig = await (0,_utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_17__.getPublishConfigFromPeerId)(this.globalSignaturePolicy, this.components.peerId);\n // Create the outbound inflight queue\n // This ensures that outbound stream creation happens sequentially\n this.outboundInflightQueue = (0,it_pushable__WEBPACK_IMPORTED_MODULE_20__.pushable)({ objectMode: true });\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_0__.pipe)(this.outboundInflightQueue, async (source) => {\n for await (const { peerId, connection } of source) {\n await this.createOutboundStream(peerId, connection);\n }\n }).catch((e) => this.log.error('outbound inflight queue error', e));\n // set direct peer addresses in the address book\n await Promise.all(this.opts.directPeers.map(async (p) => {\n await this.components.peerStore.merge(p.id, {\n multiaddrs: p.addrs\n });\n }));\n const registrar = this.components.registrar;\n // Incoming streams\n // Called after a peer dials us\n await Promise.all(this.multicodecs.map((multicodec) => registrar.handle(multicodec, this.onIncomingStream.bind(this), {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams\n })));\n // # How does Gossipsub interact with libp2p? Rough guide from Mar 2022\n //\n // ## Setup:\n // Gossipsub requests libp2p to callback, TBD\n //\n // `this.libp2p.handle()` registers a handler for `/meshsub/1.1.0` and other Gossipsub protocols\n // The handler callback is registered in libp2p Upgrader.protocols map.\n //\n // Upgrader receives an inbound connection from some transport and (`Upgrader.upgradeInbound`):\n // - Adds encryption (NOISE in our case)\n // - Multiplex stream\n // - Create a muxer and register that for each new stream call Upgrader.protocols handler\n //\n // ## Topology\n // - new instance of Topology (unlinked to libp2p) with handlers\n // - registar.register(topology)\n // register protocol with topology\n // Topology callbacks called on connection manager changes\n const topology = (0,_libp2p_topology__WEBPACK_IMPORTED_MODULE_3__.createTopology)({\n onConnect: this.onPeerConnected.bind(this),\n onDisconnect: this.onPeerDisconnected.bind(this)\n });\n const registrarTopologyIds = await Promise.all(this.multicodecs.map((multicodec) => registrar.register(multicodec, topology)));\n // Schedule to start heartbeat after `GossipsubHeartbeatInitialDelay`\n const heartbeatTimeout = setTimeout(this.runHeartbeat, _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubHeartbeatInitialDelay);\n // Then, run heartbeat every `heartbeatInterval` offset by `GossipsubHeartbeatInitialDelay`\n this.status = {\n code: GossipStatusCode.started,\n registrarTopologyIds,\n heartbeatTimeout: heartbeatTimeout,\n hearbeatStartMs: Date.now() + _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubHeartbeatInitialDelay\n };\n this.score.start();\n // connect to direct peers\n this.directPeerInitial = setTimeout(() => {\n Promise.resolve()\n .then(async () => {\n await Promise.all(Array.from(this.direct).map(async (id) => await this.connect(id)));\n })\n .catch((err) => {\n this.log(err);\n });\n }, _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubDirectConnectInitialDelay);\n this.log('started');\n }\n /**\n * Unmounts the gossipsub protocol and shuts down every connection\n */\n async stop() {\n this.log('stopping');\n // From pubsub\n if (this.status.code !== GossipStatusCode.started) {\n return;\n }\n const { registrarTopologyIds } = this.status;\n this.status = { code: GossipStatusCode.stopped };\n // unregister protocol and handlers\n const registrar = this.components.registrar;\n await Promise.all(this.multicodecs.map((multicodec) => registrar.unhandle(multicodec)));\n registrarTopologyIds.forEach((id) => registrar.unregister(id));\n this.outboundInflightQueue.end();\n for (const outboundStream of this.streamsOutbound.values()) {\n outboundStream.close();\n }\n this.streamsOutbound.clear();\n for (const inboundStream of this.streamsInbound.values()) {\n inboundStream.close();\n }\n this.streamsInbound.clear();\n this.peers.clear();\n this.subscriptions.clear();\n // Gossipsub\n if (this.heartbeatTimer) {\n this.heartbeatTimer.cancel();\n this.heartbeatTimer = null;\n }\n this.score.stop();\n this.mesh.clear();\n this.fanout.clear();\n this.fanoutLastpub.clear();\n this.gossip.clear();\n this.control.clear();\n this.peerhave.clear();\n this.iasked.clear();\n this.backoff.clear();\n this.outbound.clear();\n this.gossipTracer.clear();\n this.seenCache.clear();\n if (this.fastMsgIdCache)\n this.fastMsgIdCache.clear();\n if (this.directPeerInitial)\n clearTimeout(this.directPeerInitial);\n this.log('stopped');\n }\n /** FOR DEBUG ONLY - Dump peer stats for all peers. Data is cloned, safe to mutate */\n dumpPeerScoreStats() {\n return this.score.dumpPeerScoreStats();\n }\n /**\n * On an inbound stream opened\n */\n onIncomingStream({ stream, connection }) {\n if (!this.isStarted()) {\n return;\n }\n const peerId = connection.remotePeer;\n // add peer to router\n this.addPeer(peerId, connection.stat.direction, connection.remoteAddr);\n // create inbound stream\n this.createInboundStream(peerId, stream);\n // attempt to create outbound stream\n this.outboundInflightQueue.push({ peerId, connection });\n }\n /**\n * Registrar notifies an established connection with pubsub protocol\n */\n onPeerConnected(peerId, connection) {\n this.metrics?.newConnectionCount.inc({ status: connection.stat.status });\n // libp2p may emit a closed connection and never issue peer:disconnect event\n // see https://github.com/ChainSafe/js-libp2p-gossipsub/issues/398\n if (!this.isStarted() || connection.stat.status !== 'OPEN') {\n return;\n }\n this.addPeer(peerId, connection.stat.direction, connection.remoteAddr);\n this.outboundInflightQueue.push({ peerId, connection });\n }\n /**\n * Registrar notifies a closing connection with pubsub protocol\n */\n onPeerDisconnected(peerId) {\n this.log('connection ended %p', peerId);\n this.removePeer(peerId);\n }\n async createOutboundStream(peerId, connection) {\n if (!this.isStarted()) {\n return;\n }\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // TODO make this behavior more robust\n // This behavior is different than for inbound streams\n // If an outbound stream already exists, don't create a new stream\n if (this.streamsOutbound.has(id)) {\n return;\n }\n try {\n const stream = new _stream_js__WEBPACK_IMPORTED_MODULE_21__.OutboundStream(await connection.newStream(this.multicodecs), (e) => this.log.error('outbound pipe error', e), { maxBufferSize: this.opts.maxOutboundBufferSize });\n this.log('create outbound stream %p', peerId);\n this.streamsOutbound.set(id, stream);\n const protocol = stream.protocol;\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_7__.FloodsubID) {\n this.floodsubPeers.add(id);\n }\n this.metrics?.peersPerProtocol.inc({ protocol }, 1);\n // Immediately send own subscriptions via the newly attached stream\n if (this.subscriptions.size > 0) {\n this.log('send subscriptions to', id);\n this.sendSubscriptions(id, Array.from(this.subscriptions), true);\n }\n }\n catch (e) {\n this.log.error('createOutboundStream error', e);\n }\n }\n async createInboundStream(peerId, stream) {\n if (!this.isStarted()) {\n return;\n }\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // TODO make this behavior more robust\n // This behavior is different than for outbound streams\n // If a peer initiates a new inbound connection\n // we assume that one is the new canonical inbound stream\n const priorInboundStream = this.streamsInbound.get(id);\n if (priorInboundStream !== undefined) {\n this.log('replacing existing inbound steam %s', id);\n priorInboundStream.close();\n }\n this.log('create inbound stream %s', id);\n const inboundStream = new _stream_js__WEBPACK_IMPORTED_MODULE_21__.InboundStream(stream, { maxDataLength: this.opts.maxInboundDataLength });\n this.streamsInbound.set(id, inboundStream);\n this.pipePeerReadStream(peerId, inboundStream.source).catch((err) => this.log(err));\n }\n /**\n * Add a peer to the router\n */\n addPeer(peerId, direction, addr) {\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n this.log('new peer %p', peerId);\n this.peers.add(id);\n // Add to peer scoring\n this.score.addPeer(id);\n const currentIP = (0,_utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_23__.multiaddrToIPStr)(addr);\n if (currentIP !== null) {\n this.score.addIP(id, currentIP);\n }\n else {\n this.log('Added peer has no IP in current address %s %s', id, addr.toString());\n }\n // track the connection direction. Don't allow to unset outbound\n if (!this.outbound.has(id)) {\n this.outbound.set(id, direction === 'outbound');\n }\n }\n }\n /**\n * Removes a peer from the router\n */\n removePeer(peerId) {\n const id = peerId.toString();\n if (!this.peers.has(id)) {\n return;\n }\n // delete peer\n this.log('delete peer %p', peerId);\n this.peers.delete(id);\n const outboundStream = this.streamsOutbound.get(id);\n const inboundStream = this.streamsInbound.get(id);\n if (outboundStream) {\n this.metrics?.peersPerProtocol.inc({ protocol: outboundStream.protocol }, -1);\n }\n // close streams\n outboundStream?.close();\n inboundStream?.close();\n // remove streams\n this.streamsOutbound.delete(id);\n this.streamsInbound.delete(id);\n // remove peer from topics map\n for (const peers of this.topics.values()) {\n peers.delete(id);\n }\n // Remove this peer from the mesh\n for (const [topicStr, peers] of this.mesh) {\n if (peers.delete(id) === true) {\n this.metrics?.onRemoveFromMesh(topicStr, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ChurnReason.Dc, 1);\n }\n }\n // Remove this peer from the fanout\n for (const peers of this.fanout.values()) {\n peers.delete(id);\n }\n // Remove from floodsubPeers\n this.floodsubPeers.delete(id);\n // Remove from gossip mapping\n this.gossip.delete(id);\n // Remove from control mapping\n this.control.delete(id);\n // Remove from backoff mapping\n this.outbound.delete(id);\n // Remove from peer scoring\n this.score.removePeer(id);\n this.acceptFromWhitelist.delete(id);\n }\n // API METHODS\n get started() {\n return this.status.code === GossipStatusCode.started;\n }\n /**\n * Get a the peer-ids in a topic mesh\n */\n getMeshPeers(topic) {\n const peersInTopic = this.mesh.get(topic);\n return peersInTopic ? Array.from(peersInTopic) : [];\n }\n /**\n * Get a list of the peer-ids that are subscribed to one topic.\n */\n getSubscribers(topic) {\n const peersInTopic = this.topics.get(topic);\n return (peersInTopic ? Array.from(peersInTopic) : []).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(str));\n }\n /**\n * Get the list of topics which the peer is subscribed to.\n */\n getTopics() {\n return Array.from(this.subscriptions);\n }\n // TODO: Reviewing Pubsub API\n // MESSAGE METHODS\n /**\n * Responsible for processing each RPC message received by other peers.\n */\n async pipePeerReadStream(peerId, stream) {\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_0__.pipe)(stream, async (source) => {\n for await (const data of source) {\n try {\n // TODO: Check max gossip message size, before decodeRpc()\n const rpcBytes = data.subarray();\n // Note: This function may throw, it must be wrapped in a try {} catch {} to prevent closing the stream.\n // TODO: What should we do if the entire RPC is invalid?\n const rpc = (0,_message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_22__.decodeRpc)(rpcBytes, this.decodeRpcLimits);\n this.metrics?.onRpcRecv(rpc, rpcBytes.length);\n // Since processRpc may be overridden entirely in unsafe ways,\n // the simplest/safest option here is to wrap in a function and capture all errors\n // to prevent a top-level unhandled exception\n // This processing of rpc messages should happen without awaiting full validation/execution of prior messages\n if (this.opts.awaitRpcHandler) {\n try {\n await this.handleReceivedRpc(peerId, rpc);\n }\n catch (err) {\n this.metrics?.onRpcRecvError();\n this.log(err);\n }\n }\n else {\n this.handleReceivedRpc(peerId, rpc).catch((err) => {\n this.metrics?.onRpcRecvError();\n this.log(err);\n });\n }\n }\n catch (e) {\n this.metrics?.onRpcDataError();\n this.log(e);\n }\n }\n });\n }\n catch (err) {\n this.metrics?.onPeerReadStreamError();\n this.handlePeerReadStreamError(err, peerId);\n }\n }\n /**\n * Handle error when read stream pipe throws, less of the functional use but more\n * to for testing purposes to spy on the error handling\n * */\n handlePeerReadStreamError(err, peerId) {\n this.log.error(err);\n this.onPeerDisconnected(peerId);\n }\n /**\n * Handles an rpc request from a peer\n */\n async handleReceivedRpc(from, rpc) {\n // Check if peer is graylisted in which case we ignore the event\n if (!this.acceptFrom(from.toString())) {\n this.log('received message from unacceptable peer %p', from);\n this.metrics?.rpcRecvNotAccepted.inc();\n return;\n }\n const subscriptions = rpc.subscriptions ? rpc.subscriptions.length : 0;\n const messages = rpc.messages ? rpc.messages.length : 0;\n let ihave = 0;\n let iwant = 0;\n let graft = 0;\n let prune = 0;\n if (rpc.control) {\n if (rpc.control.ihave)\n ihave = rpc.control.ihave.length;\n if (rpc.control.iwant)\n iwant = rpc.control.iwant.length;\n if (rpc.control.graft)\n graft = rpc.control.graft.length;\n if (rpc.control.prune)\n prune = rpc.control.prune.length;\n }\n this.log(`rpc.from ${from.toString()} subscriptions ${subscriptions} messages ${messages} ihave ${ihave} iwant ${iwant} graft ${graft} prune ${prune}`);\n // Handle received subscriptions\n if (rpc.subscriptions && rpc.subscriptions.length > 0) {\n // update peer subscriptions\n const subscriptions = [];\n rpc.subscriptions.forEach((subOpt) => {\n const topic = subOpt.topic;\n const subscribe = subOpt.subscribe === true;\n if (topic != null) {\n if (this.allowedTopics && !this.allowedTopics.has(topic)) {\n // Not allowed: subscription data-structures are not bounded by topic count\n // TODO: Should apply behaviour penalties?\n return;\n }\n this.handleReceivedSubscription(from, topic, subscribe);\n subscriptions.push({ topic, subscribe });\n }\n });\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('subscription-change', {\n detail: { peerId: from, subscriptions }\n }));\n }\n // Handle messages\n // TODO: (up to limit)\n if (rpc.messages) {\n for (const message of rpc.messages) {\n if (this.allowedTopics && !this.allowedTopics.has(message.topic)) {\n // Not allowed: message cache data-structures are not bounded by topic count\n // TODO: Should apply behaviour penalties?\n continue;\n }\n const handleReceivedMessagePromise = this.handleReceivedMessage(from, message)\n // Should never throw, but handle just in case\n .catch((err) => {\n this.metrics?.onMsgRecvError(message.topic);\n this.log(err);\n });\n if (this.opts.awaitRpcMessageHandler) {\n await handleReceivedMessagePromise;\n }\n }\n }\n // Handle control messages\n if (rpc.control) {\n await this.handleControlMessage(from.toString(), rpc.control);\n }\n }\n /**\n * Handles a subscription change from a peer\n */\n handleReceivedSubscription(from, topic, subscribe) {\n this.log('subscription update from %p topic %s', from, topic);\n let topicSet = this.topics.get(topic);\n if (topicSet == null) {\n topicSet = new Set();\n this.topics.set(topic, topicSet);\n }\n if (subscribe) {\n // subscribe peer to new topic\n topicSet.add(from.toString());\n }\n else {\n // unsubscribe from existing topic\n topicSet.delete(from.toString());\n }\n // TODO: rust-libp2p has A LOT more logic here\n }\n /**\n * Handles a newly received message from an RPC.\n * May forward to all peers in the mesh.\n */\n async handleReceivedMessage(from, rpcMsg) {\n this.metrics?.onMsgRecvPreValidation(rpcMsg.topic);\n const validationResult = await this.validateReceivedMessage(from, rpcMsg);\n this.metrics?.onMsgRecvResult(rpcMsg.topic, validationResult.code);\n switch (validationResult.code) {\n case _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.duplicate:\n // Report the duplicate\n this.score.duplicateMessage(from.toString(), validationResult.msgIdStr, rpcMsg.topic);\n // due to the collision of fastMsgIdFn, 2 different messages may end up the same fastMsgId\n // so we need to also mark the duplicate message as delivered or the promise is not resolved\n // and peer gets penalized. See https://github.com/ChainSafe/js-libp2p-gossipsub/pull/385\n this.gossipTracer.deliverMessage(validationResult.msgIdStr, true);\n this.mcache.observeDuplicate(validationResult.msgIdStr, from.toString());\n return;\n case _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.invalid:\n // invalid messages received\n // metrics.register_invalid_message(&raw_message.topic)\n // Tell peer_score about reject\n // Reject the original source, and any duplicates we've seen from other peers.\n if (validationResult.msgIdStr) {\n const msgIdStr = validationResult.msgIdStr;\n this.score.rejectMessage(from.toString(), msgIdStr, rpcMsg.topic, validationResult.reason);\n this.gossipTracer.rejectMessage(msgIdStr, validationResult.reason);\n }\n else {\n this.score.rejectInvalidMessage(from.toString(), rpcMsg.topic);\n }\n this.metrics?.onMsgRecvInvalid(rpcMsg.topic, validationResult);\n return;\n case _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.valid:\n // Tells score that message arrived (but is maybe not fully validated yet).\n // Consider the message as delivered for gossip promises.\n this.score.validateMessage(validationResult.messageId.msgIdStr);\n this.gossipTracer.deliverMessage(validationResult.messageId.msgIdStr);\n // Add the message to our memcache\n // if no validation is required, mark the message as validated\n this.mcache.put(validationResult.messageId, rpcMsg, !this.opts.asyncValidation);\n // Dispatch the message to the user if we are subscribed to the topic\n if (this.subscriptions.has(rpcMsg.topic)) {\n const isFromSelf = this.components.peerId.equals(from);\n if (!isFromSelf || this.opts.emitSelf) {\n super.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:message', {\n detail: {\n propagationSource: from,\n msgId: validationResult.messageId.msgIdStr,\n msg: validationResult.msg\n }\n }));\n // TODO: Add option to switch between emit per topic or all messages in one\n super.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('message', { detail: validationResult.msg }));\n }\n }\n // Forward the message to mesh peers, if no validation is required\n // If asyncValidation is ON, expect the app layer to call reportMessageValidationResult(), then forward\n if (!this.opts.asyncValidation) {\n // TODO: in rust-libp2p\n // .forward_msg(&msg_id, raw_message, Some(propagation_source))\n this.forwardMessage(validationResult.messageId.msgIdStr, rpcMsg, from.toString());\n }\n }\n }\n /**\n * Handles a newly received message from an RPC.\n * May forward to all peers in the mesh.\n */\n async validateReceivedMessage(propagationSource, rpcMsg) {\n // Fast message ID stuff\n const fastMsgIdStr = this.fastMsgIdFn?.(rpcMsg);\n const msgIdCached = fastMsgIdStr !== undefined ? this.fastMsgIdCache?.get(fastMsgIdStr) : undefined;\n if (msgIdCached) {\n // This message has been seen previously. Ignore it\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.duplicate, msgIdStr: msgIdCached };\n }\n // Perform basic validation on message and convert to RawGossipsubMessage for fastMsgIdFn()\n const validationResult = await (0,_utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_14__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_13__.RejectReason.Error, error: validationResult.error };\n }\n const msg = validationResult.message;\n // Try and perform the data transform to the message. If it fails, consider it invalid.\n try {\n if (this.dataTransform) {\n msg.data = this.dataTransform.inboundTransform(rpcMsg.topic, msg.data);\n }\n }\n catch (e) {\n this.log('Invalid message, transform failed', e);\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_13__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_13__.ValidateError.TransformFailed };\n }\n // TODO: Check if message is from a blacklisted source or propagation origin\n // - Reject any message from a blacklisted peer\n // - Also reject any message that originated from a blacklisted peer\n // - reject messages claiming to be from ourselves but not locally published\n // Calculate the message id on the transformed data.\n const msgId = await this.msgIdFn(msg);\n const msgIdStr = this.msgIdToStrFn(msgId);\n const messageId = { msgId, msgIdStr };\n // Add the message to the duplicate caches\n if (fastMsgIdStr !== undefined && this.fastMsgIdCache) {\n const collision = this.fastMsgIdCache.put(fastMsgIdStr, msgIdStr);\n if (collision) {\n this.metrics?.fastMsgIdCacheCollision.inc();\n }\n }\n if (this.seenCache.has(msgIdStr)) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.duplicate, msgIdStr };\n }\n else {\n this.seenCache.put(msgIdStr);\n }\n // (Optional) Provide custom validation here with dynamic validators per topic\n // NOTE: This custom topicValidator() must resolve fast (< 100ms) to allow scores\n // to not penalize peers for long validation times.\n const topicValidator = this.topicValidators.get(rpcMsg.topic);\n if (topicValidator != null) {\n let acceptance;\n // Use try {} catch {} in case topicValidator() is synchronous\n try {\n acceptance = await topicValidator(propagationSource, msg);\n }\n catch (e) {\n const errCode = e.code;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_7__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_7__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_13__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_13__.MessageStatus.valid, messageId, msg };\n }\n /**\n * Return score of a peer.\n */\n getScore(peerId) {\n return this.score.score(peerId);\n }\n /**\n * Send an rpc object to a peer with subscriptions\n */\n sendSubscriptions(toPeer, topics, subscribe) {\n this.sendRpc(toPeer, {\n subscriptions: topics.map((topic) => ({ topic, subscribe }))\n });\n }\n /**\n * Handles an rpc control message from a peer\n */\n async handleControlMessage(id, controlMsg) {\n if (controlMsg === undefined) {\n return;\n }\n const iwant = controlMsg.ihave ? this.handleIHave(id, controlMsg.ihave) : [];\n const ihave = controlMsg.iwant ? this.handleIWant(id, controlMsg.iwant) : [];\n const prune = controlMsg.graft ? await this.handleGraft(id, controlMsg.graft) : [];\n controlMsg.prune && (await this.handlePrune(id, controlMsg.prune));\n if (!iwant.length && !ihave.length && !prune.length) {\n return;\n }\n const sent = this.sendRpc(id, { messages: ihave, control: { iwant, prune } });\n const iwantMessageIds = iwant[0]?.messageIDs;\n if (iwantMessageIds) {\n if (sent) {\n this.gossipTracer.addPromise(id, iwantMessageIds);\n }\n else {\n this.metrics?.iwantPromiseUntracked.inc(1);\n }\n }\n }\n /**\n * Whether to accept a message from a peer\n */\n acceptFrom(id) {\n if (this.direct.has(id)) {\n return true;\n }\n const now = Date.now();\n const entry = this.acceptFromWhitelist.get(id);\n if (entry && entry.messagesAccepted < _constants_js__WEBPACK_IMPORTED_MODULE_7__.ACCEPT_FROM_WHITELIST_MAX_MESSAGES && entry.acceptUntil >= now) {\n entry.messagesAccepted += 1;\n return true;\n }\n const score = this.score.score(id);\n if (score >= _constants_js__WEBPACK_IMPORTED_MODULE_7__.ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE) {\n // peer is unlikely to be able to drop its score to `graylistThreshold`\n // after 128 messages or 1s\n this.acceptFromWhitelist.set(id, {\n messagesAccepted: 0,\n acceptUntil: now + _constants_js__WEBPACK_IMPORTED_MODULE_7__.ACCEPT_FROM_WHITELIST_DURATION_MS\n });\n }\n else {\n this.acceptFromWhitelist.delete(id);\n }\n return score >= this.opts.scoreThresholds.graylistThreshold;\n }\n /**\n * Handles IHAVE messages\n */\n handleIHave(id, ihave) {\n if (!ihave.length) {\n return [];\n }\n // we ignore IHAVE gossip from any peer whose score is below the gossips threshold\n const score = this.score.score(id);\n if (score < this.opts.scoreThresholds.gossipThreshold) {\n this.log('IHAVE: ignoring peer %s with score below threshold [ score = %d ]', id, score);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_12__.IHaveIgnoreReason.LowScore });\n return [];\n }\n // IHAVE flood protection\n const peerhave = (this.peerhave.get(id) ?? 0) + 1;\n this.peerhave.set(id, peerhave);\n if (peerhave > _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveMessages) {\n this.log('IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring', id, peerhave);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_12__.IHaveIgnoreReason.MaxIhave });\n return [];\n }\n const iasked = this.iasked.get(id) ?? 0;\n if (iasked >= _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength) {\n this.log('IHAVE: peer %s has already advertised too many messages (%d); ignoring', id, iasked);\n this.metrics?.ihaveRcvIgnored.inc({ reason: _metrics_js__WEBPACK_IMPORTED_MODULE_12__.IHaveIgnoreReason.MaxIasked });\n return [];\n }\n // string msgId => msgId\n const iwant = new Map();\n ihave.forEach(({ topicID, messageIDs }) => {\n if (!topicID || !messageIDs || !this.mesh.has(topicID)) {\n return;\n }\n let idonthave = 0;\n messageIDs.forEach((msgId) => {\n const msgIdStr = this.msgIdToStrFn(msgId);\n if (!this.seenCache.has(msgIdStr)) {\n iwant.set(msgIdStr, msgId);\n idonthave++;\n }\n });\n this.metrics?.onIhaveRcv(topicID, messageIDs.length, idonthave);\n });\n if (!iwant.size) {\n return [];\n }\n let iask = iwant.size;\n if (iask + iasked > _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength - iasked;\n }\n this.log('IHAVE: Asking for %d out of %d messages from %s', iask, iwant.size, id);\n let iwantList = Array.from(iwant.values());\n // ask in random order\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(iwantList);\n // truncate to the messages we are actually asking for and update the iasked counter\n iwantList = iwantList.slice(0, iask);\n this.iasked.set(id, iasked + iask);\n // do not add gossipTracer promise here until a successful sendRpc()\n return [\n {\n messageIDs: iwantList\n }\n ];\n }\n /**\n * Handles IWANT messages\n * Returns messages to send back to peer\n */\n handleIWant(id, iwant) {\n if (!iwant.length) {\n return [];\n }\n // we don't respond to IWANT requests from any per whose score is below the gossip threshold\n const score = this.score.score(id);\n if (score < this.opts.scoreThresholds.gossipThreshold) {\n this.log('IWANT: ignoring peer %s with score below threshold [score = %d]', id, score);\n return [];\n }\n const ihave = new Map();\n const iwantByTopic = new Map();\n let iwantDonthave = 0;\n iwant.forEach(({ messageIDs }) => {\n messageIDs &&\n messageIDs.forEach((msgId) => {\n const msgIdStr = this.msgIdToStrFn(msgId);\n const entry = this.mcache.getWithIWantCount(msgIdStr, id);\n if (entry == null) {\n iwantDonthave++;\n return;\n }\n iwantByTopic.set(entry.msg.topic, 1 + (iwantByTopic.get(entry.msg.topic) ?? 0));\n if (entry.count > _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubGossipRetransmission) {\n this.log('IWANT: Peer %s has asked for message %s too many times: ignoring request', id, msgId);\n return;\n }\n ihave.set(msgIdStr, entry.msg);\n });\n });\n this.metrics?.onIwantRcv(iwantByTopic, iwantDonthave);\n if (!ihave.size) {\n this.log('IWANT: Could not provide any wanted messages to %s', id);\n return [];\n }\n this.log('IWANT: Sending %d messages to %s', ihave.size, id);\n return Array.from(ihave.values());\n }\n /**\n * Handles Graft messages\n */\n async handleGraft(id, graft) {\n const prune = [];\n const score = this.score.score(id);\n const now = Date.now();\n let doPX = this.opts.doPX;\n graft.forEach(({ topicID }) => {\n if (!topicID) {\n return;\n }\n const peersInMesh = this.mesh.get(topicID);\n if (!peersInMesh) {\n // don't do PX when there is an unknown topic to avoid leaking our peers\n doPX = false;\n // spam hardening: ignore GRAFTs for unknown topics\n return;\n }\n // check if peer is already in the mesh; if so do nothing\n if (peersInMesh.has(id)) {\n return;\n }\n // we don't GRAFT to/from direct peers; complain loudly if this happens\n if (this.direct.has(id)) {\n this.log('GRAFT: ignoring request from direct peer %s', id);\n // this is possibly a bug from a non-reciprical configuration; send a PRUNE\n prune.push(topicID);\n // but don't px\n doPX = false;\n return;\n }\n // make sure we are not backing off that peer\n const expire = this.backoff.get(topicID)?.get(id);\n if (typeof expire === 'number' && now < expire) {\n this.log('GRAFT: ignoring backed off peer %s', id);\n // add behavioral penalty\n this.score.addPenalty(id, 1, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ScorePenalty.GraftBackoff);\n // no PX\n doPX = false;\n // check the flood cutoff -- is the GRAFT coming too fast?\n const floodCutoff = expire + this.opts.graftFloodThreshold - this.opts.pruneBackoff;\n if (now < floodCutoff) {\n // extra penalty\n this.score.addPenalty(id, 1, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ScorePenalty.GraftBackoff);\n }\n // refresh the backoff\n this.addBackoff(id, topicID);\n prune.push(topicID);\n return;\n }\n // check the score\n if (score < 0) {\n // we don't GRAFT peers with negative score\n this.log('GRAFT: ignoring peer %s with negative score: score=%d, topic=%s', id, score, topicID);\n // we do send them PRUNE however, because it's a matter of protocol correctness\n prune.push(topicID);\n // but we won't PX to them\n doPX = false;\n // add/refresh backoff so that we don't reGRAFT too early even if the score decays\n this.addBackoff(id, topicID);\n return;\n }\n // check the number of mesh peers; if it is at (or over) Dhi, we only accept grafts\n // from peers with outbound connections; this is a defensive check to restrict potential\n // mesh takeover attacks combined with love bombing\n if (peersInMesh.size >= this.opts.Dhi && !this.outbound.get(id)) {\n prune.push(topicID);\n this.addBackoff(id, topicID);\n return;\n }\n this.log('GRAFT: Add mesh link from %s in %s', id, topicID);\n this.score.graft(id, topicID);\n peersInMesh.add(id);\n this.metrics?.onAddToMesh(topicID, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.Subscribed, 1);\n });\n if (!prune.length) {\n return [];\n }\n const onUnsubscribe = false;\n return await Promise.all(prune.map((topic) => this.makePrune(id, topic, doPX, onUnsubscribe)));\n }\n /**\n * Handles Prune messages\n */\n async handlePrune(id, prune) {\n const score = this.score.score(id);\n for (const { topicID, backoff, peers } of prune) {\n if (topicID == null) {\n continue;\n }\n const peersInMesh = this.mesh.get(topicID);\n if (!peersInMesh) {\n return;\n }\n this.log('PRUNE: Remove mesh link to %s in %s', id, topicID);\n this.score.prune(id, topicID);\n if (peersInMesh.has(id)) {\n peersInMesh.delete(id);\n this.metrics?.onRemoveFromMesh(topicID, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ChurnReason.Prune, 1);\n }\n // is there a backoff specified by the peer? if so obey it\n if (typeof backoff === 'number' && backoff > 0) {\n this.doAddBackoff(id, topicID, backoff * 1000);\n }\n else {\n this.addBackoff(id, topicID);\n }\n // PX\n if (peers && peers.length) {\n // we ignore PX from peers with insufficient scores\n if (score < this.opts.scoreThresholds.acceptPXThreshold) {\n this.log('PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]', id, score, topicID);\n continue;\n }\n await this.pxConnect(peers);\n }\n }\n }\n /**\n * Add standard backoff log for a peer in a topic\n */\n addBackoff(id, topic) {\n this.doAddBackoff(id, topic, this.opts.pruneBackoff);\n }\n /**\n * Add backoff expiry interval for a peer in a topic\n *\n * @param id\n * @param topic\n * @param intervalMs - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, intervalMs) {\n let backoff = this.backoff.get(topic);\n if (!backoff) {\n backoff = new Map();\n this.backoff.set(topic, backoff);\n }\n const expire = Date.now() + intervalMs;\n const existingExpire = backoff.get(id) ?? 0;\n if (existingExpire < expire) {\n backoff.set(id, expire);\n }\n }\n /**\n * Apply penalties from broken IHAVE/IWANT promises\n */\n applyIwantPenalties() {\n this.gossipTracer.getBrokenPromises().forEach((count, p) => {\n this.log(\"peer %s didn't follow up in %d IWANT requests; adding penalty\", p, count);\n this.score.addPenalty(p, count, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ScorePenalty.BrokenPromise);\n });\n }\n /**\n * Clear expired backoff expiries\n */\n clearBackoff() {\n // we only clear once every GossipsubPruneBackoffTicks ticks to avoid iterating over the maps too much\n if (this.heartbeatTicks % _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n // add some slack time to the expiration, see https://github.com/libp2p/specs/pull/289\n if (expire + _constants_js__WEBPACK_IMPORTED_MODULE_7__.BACKOFF_SLACK * this.opts.heartbeatInterval < now) {\n backoff.delete(id);\n }\n });\n if (backoff.size === 0) {\n this.backoff.delete(topic);\n }\n });\n }\n /**\n * Maybe reconnect to direct peers\n */\n async directConnect() {\n const toconnect = [];\n this.direct.forEach((id) => {\n if (!this.streamsOutbound.has(id)) {\n toconnect.push(id);\n }\n });\n await Promise.all(toconnect.map(async (id) => await this.connect(id)));\n }\n /**\n * Maybe attempt connection given signed peer records\n */\n async pxConnect(peers) {\n if (peers.length > this.opts.prunePeers) {\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(peers);\n peers = peers.slice(0, this.opts.prunePeers);\n }\n const toconnect = [];\n await Promise.all(peers.map(async (pi) => {\n if (!pi.peerID) {\n return;\n }\n const peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(pi.peerID);\n const p = peer.toString();\n if (this.peers.has(p)) {\n return;\n }\n if (!pi.signedPeerRecord) {\n toconnect.push(p);\n return;\n }\n // The peer sent us a signed record\n // This is not a record from the peer who sent the record, but another peer who is connected with it\n // Ensure that it is valid\n try {\n if (!(await this.components.peerStore.consumePeerRecord(pi.signedPeerRecord, peer))) {\n this.log('bogus peer record obtained through px: could not add peer record to address book');\n return;\n }\n toconnect.push(p);\n }\n catch (e) {\n this.log('bogus peer record obtained through px: invalid signature or not a peer record');\n }\n }));\n if (!toconnect.length) {\n return;\n }\n await Promise.all(toconnect.map(async (id) => await this.connect(id)));\n }\n /**\n * Connect to a peer using the gossipsub protocol\n */\n async connect(id) {\n this.log('Initiating connection with %s', id);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(id);\n const connection = await this.components.connectionManager.openConnection(peerId);\n for (const multicodec of this.multicodecs) {\n for (const topology of this.components.registrar.getTopologies(multicodec)) {\n topology.onConnect(peerId, connection);\n }\n }\n }\n /**\n * Subscribes to a topic\n */\n subscribe(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Pubsub has not started');\n }\n if (!this.subscriptions.has(topic)) {\n this.subscriptions.add(topic);\n for (const peerId of this.peers.keys()) {\n this.sendSubscriptions(peerId, [topic], true);\n }\n }\n this.join(topic);\n }\n /**\n * Unsubscribe to a topic\n */\n unsubscribe(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Pubsub is not started');\n }\n const wasSubscribed = this.subscriptions.delete(topic);\n this.log('unsubscribe from %s - am subscribed %s', topic, wasSubscribed);\n if (wasSubscribed) {\n for (const peerId of this.peers.keys()) {\n this.sendSubscriptions(peerId, [topic], false);\n }\n }\n this.leave(topic);\n }\n /**\n * Join topic\n */\n join(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Gossipsub has not started');\n }\n // if we are already in the mesh, return\n if (this.mesh.has(topic)) {\n return;\n }\n this.log('JOIN %s', topic);\n this.metrics?.onJoin(topic);\n const toAdd = new Set();\n const backoff = this.backoff.get(topic);\n // check if we have mesh_n peers in fanout[topic] and add them to the mesh if we do,\n // removing the fanout entry.\n const fanoutPeers = this.fanout.get(topic);\n if (fanoutPeers) {\n // Remove fanout entry and the last published time\n this.fanout.delete(topic);\n this.fanoutLastpub.delete(topic);\n // remove explicit peers, peers with negative scores, and backoffed peers\n fanoutPeers.forEach((id) => {\n if (!this.direct.has(id) && this.score.score(id) >= 0 && (!backoff || !backoff.has(id))) {\n toAdd.add(id);\n }\n });\n this.metrics?.onAddToMesh(topic, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.Fanout, toAdd.size);\n }\n // check if we need to get more peers, which we randomly select\n if (toAdd.size < this.opts.D) {\n const fanoutCount = toAdd.size;\n const newPeers = this.getRandomGossipPeers(topic, this.opts.D, (id) => \n // filter direct peers and peers with negative score\n !toAdd.has(id) && !this.direct.has(id) && this.score.score(id) >= 0 && (!backoff || !backoff.has(id)));\n newPeers.forEach((peer) => {\n toAdd.add(peer);\n });\n this.metrics?.onAddToMesh(topic, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.Random, toAdd.size - fanoutCount);\n }\n this.mesh.set(topic, toAdd);\n toAdd.forEach((id) => {\n this.log('JOIN: Add mesh link to %s in %s', id, topic);\n this.sendGraft(id, topic);\n // rust-libp2p\n // - peer_score.graft()\n // - Self::control_pool_add()\n // - peer_added_to_mesh()\n });\n }\n /**\n * Leave topic\n */\n leave(topic) {\n if (this.status.code !== GossipStatusCode.started) {\n throw new Error('Gossipsub has not started');\n }\n this.log('LEAVE %s', topic);\n this.metrics?.onLeave(topic);\n // Send PRUNE to mesh peers\n const meshPeers = this.mesh.get(topic);\n if (meshPeers) {\n Promise.all(Array.from(meshPeers).map(async (id) => {\n this.log('LEAVE: Remove mesh link to %s in %s', id, topic);\n return await this.sendPrune(id, topic);\n })).catch((err) => {\n this.log('Error sending prunes to mesh peers', err);\n });\n this.mesh.delete(topic);\n }\n }\n selectPeersToForward(topic, propagationSource, excludePeers) {\n const tosend = new Set();\n // Add explicit peers\n const peersInTopic = this.topics.get(topic);\n if (peersInTopic) {\n this.direct.forEach((peer) => {\n if (peersInTopic.has(peer) && propagationSource !== peer && !excludePeers?.has(peer)) {\n tosend.add(peer);\n }\n });\n // As of Mar 2022, spec + golang-libp2p include this while rust-libp2p does not\n // rust-libp2p: https://github.com/libp2p/rust-libp2p/blob/6cc3b4ec52c922bfcf562a29b5805c3150e37c75/protocols/gossipsub/src/behaviour.rs#L2693\n // spec: https://github.com/libp2p/specs/blob/10712c55ab309086a52eec7d25f294df4fa96528/pubsub/gossipsub/gossipsub-v1.0.md?plain=1#L361\n this.floodsubPeers.forEach((peer) => {\n if (peersInTopic.has(peer) &&\n propagationSource !== peer &&\n !excludePeers?.has(peer) &&\n this.score.score(peer) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(peer);\n }\n });\n }\n // add mesh peers\n const meshPeers = this.mesh.get(topic);\n if (meshPeers && meshPeers.size > 0) {\n meshPeers.forEach((peer) => {\n if (propagationSource !== peer && !excludePeers?.has(peer)) {\n tosend.add(peer);\n }\n });\n }\n return tosend;\n }\n selectPeersToPublish(topic) {\n const tosend = new Set();\n const tosendCount = {\n direct: 0,\n floodsub: 0,\n mesh: 0,\n fanout: 0\n };\n const peersInTopic = this.topics.get(topic);\n if (peersInTopic) {\n // flood-publish behavior\n // send to direct peers and _all_ peers meeting the publishThreshold\n if (this.opts.floodPublish) {\n peersInTopic.forEach((id) => {\n if (this.direct.has(id)) {\n tosend.add(id);\n tosendCount.direct++;\n }\n else if (this.score.score(id) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(id);\n tosendCount.floodsub++;\n }\n });\n }\n else {\n // non-flood-publish behavior\n // send to direct peers, subscribed floodsub peers\n // and some mesh peers above publishThreshold\n // direct peers (if subscribed)\n this.direct.forEach((id) => {\n if (peersInTopic.has(id)) {\n tosend.add(id);\n tosendCount.direct++;\n }\n });\n // floodsub peers\n // Note: if there are no floodsub peers, we save a loop through peersInTopic Map\n this.floodsubPeers.forEach((id) => {\n if (peersInTopic.has(id) && this.score.score(id) >= this.opts.scoreThresholds.publishThreshold) {\n tosend.add(id);\n tosendCount.floodsub++;\n }\n });\n // Gossipsub peers handling\n const meshPeers = this.mesh.get(topic);\n if (meshPeers && meshPeers.size > 0) {\n meshPeers.forEach((peer) => {\n tosend.add(peer);\n tosendCount.mesh++;\n });\n }\n // We are not in the mesh for topic, use fanout peers\n else {\n const fanoutPeers = this.fanout.get(topic);\n if (fanoutPeers && fanoutPeers.size > 0) {\n fanoutPeers.forEach((peer) => {\n tosend.add(peer);\n tosendCount.fanout++;\n });\n }\n // We have no fanout peers, select mesh_n of them and add them to the fanout\n else {\n // If we are not in the fanout, then pick peers in topic above the publishThreshold\n const newFanoutPeers = this.getRandomGossipPeers(topic, this.opts.D, (id) => {\n return this.score.score(id) >= this.opts.scoreThresholds.publishThreshold;\n });\n if (newFanoutPeers.size > 0) {\n // eslint-disable-line max-depth\n this.fanout.set(topic, newFanoutPeers);\n newFanoutPeers.forEach((peer) => {\n // eslint-disable-line max-depth\n tosend.add(peer);\n tosendCount.fanout++;\n });\n }\n }\n // We are publishing to fanout peers - update the time we published\n this.fanoutLastpub.set(topic, Date.now());\n }\n }\n }\n return { tosend, tosendCount };\n }\n /**\n * Forwards a message from our peers.\n *\n * For messages published by us (the app layer), this class uses `publish`\n */\n forwardMessage(msgIdStr, rawMsg, propagationSource, excludePeers) {\n // message is fully validated inform peer_score\n if (propagationSource) {\n this.score.deliverMessage(propagationSource, msgIdStr, rawMsg.topic);\n }\n const tosend = this.selectPeersToForward(rawMsg.topic, propagationSource, excludePeers);\n // Note: Don't throw if tosend is empty, we can have a mesh with a single peer\n // forward the message to peers\n tosend.forEach((id) => {\n // sendRpc may mutate RPC message on piggyback, create a new message for each peer\n this.sendRpc(id, { messages: [rawMsg] });\n });\n this.metrics?.onForwardMsg(rawMsg.topic, tosend.size);\n }\n /**\n * App layer publishes a message to peers, return number of peers this message is published to\n * Note: `async` due to crypto only if `StrictSign`, otherwise it's a sync fn.\n *\n * For messages not from us, this class uses `forwardMessage`.\n */\n async publish(topic, data, opts) {\n const transformedData = this.dataTransform ? this.dataTransform.outboundTransform(topic, data) : data;\n if (this.publishConfig == null) {\n throw Error('PublishError.Uninitialized');\n }\n // Prepare raw message with user's publishConfig\n const { raw: rawMsg, msg } = await (0,_utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_14__.buildRawMessage)(this.publishConfig, topic, data, transformedData);\n // calculate the message id from the un-transformed data\n const msgId = await this.msgIdFn(msg);\n const msgIdStr = this.msgIdToStrFn(msgId);\n // Current publish opt takes precedence global opts, while preserving false value\n const ignoreDuplicatePublishError = opts?.ignoreDuplicatePublishError ?? this.opts.ignoreDuplicatePublishError;\n if (this.seenCache.has(msgIdStr)) {\n // This message has already been seen. We don't re-publish messages that have already\n // been published on the network.\n if (ignoreDuplicatePublishError) {\n this.metrics?.onPublishDuplicateMsg(topic);\n return { recipients: [] };\n }\n throw Error('PublishError.Duplicate');\n }\n const { tosend, tosendCount } = this.selectPeersToPublish(topic);\n const willSendToSelf = this.opts.emitSelf === true && this.subscriptions.has(topic);\n // Current publish opt takes precedence global opts, while preserving false value\n const allowPublishToZeroPeers = opts?.allowPublishToZeroPeers ?? this.opts.allowPublishToZeroPeers;\n if (tosend.size === 0 && !allowPublishToZeroPeers && !willSendToSelf) {\n throw Error('PublishError.InsufficientPeers');\n }\n // If the message isn't a duplicate and we have sent it to some peers add it to the\n // duplicate cache and memcache.\n this.seenCache.put(msgIdStr);\n // all published messages are valid\n this.mcache.put({ msgId, msgIdStr }, rawMsg, true);\n // If the message is anonymous or has a random author add it to the published message ids cache.\n this.publishedMessageIds.put(msgIdStr);\n // Send to set of peers aggregated from direct, mesh, fanout\n for (const id of tosend) {\n // sendRpc may mutate RPC message on piggyback, create a new message for each peer\n const sent = this.sendRpc(id, { messages: [rawMsg] });\n // did not actually send the message\n if (!sent) {\n tosend.delete(id);\n }\n }\n this.metrics?.onPublishMsg(topic, tosendCount, tosend.size, rawMsg.data != null ? rawMsg.data.length : 0);\n // Dispatch the message to the user if we are subscribed to the topic\n if (willSendToSelf) {\n tosend.add(this.components.peerId.toString());\n super.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:message', {\n detail: {\n propagationSource: this.components.peerId,\n msgId: msgIdStr,\n msg\n }\n }));\n // TODO: Add option to switch between emit per topic or all messages in one\n super.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(str))\n };\n }\n /**\n * This function should be called when `asyncValidation` is `true` after\n * the message got validated by the caller. Messages are stored in the `mcache` and\n * validation is expected to be fast enough that the messages should still exist in the cache.\n * There are three possible validation outcomes and the outcome is given in acceptance.\n *\n * If acceptance = `MessageAcceptance.Accept` the message will get propagated to the\n * network. The `propagation_source` parameter indicates who the message was received by and\n * will not be forwarded back to that peer.\n *\n * If acceptance = `MessageAcceptance.Reject` the message will be deleted from the memcache\n * and the P₄ penalty will be applied to the `propagationSource`.\n *\n * If acceptance = `MessageAcceptance.Ignore` the message will be deleted from the memcache\n * but no P₄ penalty will be applied.\n *\n * This function will return true if the message was found in the cache and false if was not\n * in the cache anymore.\n *\n * This should only be called once per message.\n */\n reportMessageValidationResult(msgId, propagationSource, acceptance) {\n let cacheEntry;\n if (acceptance === _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_18__.TopicValidatorResult.Accept) {\n cacheEntry = this.mcache.validate(msgId);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource, msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource, originatingPeers);\n }\n // else, Message not in cache. Ignoring forwarding\n }\n // Not valid\n else {\n cacheEntry = this.mcache.remove(msgId);\n if (cacheEntry) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_13__.rejectReasonFromAcceptance)(acceptance);\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // Tell peer_score about reject\n // Reject the original source, and any duplicates we've seen from other peers.\n this.score.rejectMessage(propagationSource, msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n }\n // else, Message not in cache. Ignoring forwarding\n }\n const firstSeenTimestampMs = this.score.messageFirstSeenTimestampMs(msgId);\n this.metrics?.onReportValidation(cacheEntry, acceptance, firstSeenTimestampMs);\n }\n /**\n * Sends a GRAFT message to a peer\n */\n sendGraft(id, topic) {\n const graft = [\n {\n topicID: topic\n }\n ];\n this.sendRpc(id, { control: { graft } });\n }\n /**\n * Sends a PRUNE message to a peer\n */\n async sendPrune(id, topic) {\n // this is only called from leave() function\n const onUnsubscribe = true;\n const prune = [await this.makePrune(id, topic, this.opts.doPX, onUnsubscribe)];\n this.sendRpc(id, { control: { prune } });\n }\n /**\n * Send an rpc object to a peer\n */\n sendRpc(id, rpc) {\n const outboundStream = this.streamsOutbound.get(id);\n if (!outboundStream) {\n this.log(`Cannot send RPC to ${id} as there is no open stream to it available`);\n return false;\n }\n // piggyback control message retries\n const ctrl = this.control.get(id);\n if (ctrl) {\n this.piggybackControl(id, rpc, ctrl);\n this.control.delete(id);\n }\n // piggyback gossip\n const ihave = this.gossip.get(id);\n if (ihave) {\n this.piggybackGossip(id, rpc, ihave);\n this.gossip.delete(id);\n }\n const rpcBytes = _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__.RPC.encode(rpc).finish();\n try {\n outboundStream.push(rpcBytes);\n }\n catch (e) {\n this.log.error(`Cannot send rpc to ${id}`, e);\n // if the peer had control messages or gossip, re-attach\n if (ctrl) {\n this.control.set(id, ctrl);\n }\n if (ihave) {\n this.gossip.set(id, ihave);\n }\n return false;\n }\n this.metrics?.onRpcSent(rpc, rpcBytes.length);\n return true;\n }\n /** Mutates `outRpc` adding graft and prune control messages */\n piggybackControl(id, outRpc, ctrl) {\n if (ctrl.graft) {\n if (!outRpc.control)\n outRpc.control = {};\n if (!outRpc.control.graft)\n outRpc.control.graft = [];\n for (const graft of ctrl.graft) {\n if (graft.topicID && this.mesh.get(graft.topicID)?.has(id)) {\n outRpc.control.graft.push(graft);\n }\n }\n }\n if (ctrl.prune) {\n if (!outRpc.control)\n outRpc.control = {};\n if (!outRpc.control.prune)\n outRpc.control.prune = [];\n for (const prune of ctrl.prune) {\n if (prune.topicID && !this.mesh.get(prune.topicID)?.has(id)) {\n outRpc.control.prune.push(prune);\n }\n }\n }\n }\n /** Mutates `outRpc` adding ihave control messages */\n piggybackGossip(id, outRpc, ihave) {\n if (!outRpc.control)\n outRpc.control = {};\n outRpc.control.ihave = ihave;\n }\n /**\n * Send graft and prune messages\n *\n * @param tograft - peer id => topic[]\n * @param toprune - peer id => topic[]\n */\n async sendGraftPrune(tograft, toprune, noPX) {\n const doPX = this.opts.doPX;\n const onUnsubscribe = false;\n for (const [id, topics] of tograft) {\n const graft = topics.map((topicID) => ({ topicID }));\n let prune = [];\n // If a peer also has prunes, process them now\n const pruning = toprune.get(id);\n if (pruning) {\n prune = await Promise.all(pruning.map(async (topicID) => await this.makePrune(id, topicID, doPX && !(noPX.get(id) ?? false), onUnsubscribe)));\n toprune.delete(id);\n }\n this.sendRpc(id, { control: { graft, prune } });\n }\n for (const [id, topics] of toprune) {\n const prune = await Promise.all(topics.map(async (topicID) => await this.makePrune(id, topicID, doPX && !(noPX.get(id) ?? false), onUnsubscribe)));\n this.sendRpc(id, { control: { prune } });\n }\n }\n /**\n * Emits gossip - Send IHAVE messages to a random set of gossip peers\n */\n emitGossip(peersToGossipByTopic) {\n const gossipIDsByTopic = this.mcache.getGossipIDs(new Set(peersToGossipByTopic.keys()));\n for (const [topic, peersToGossip] of peersToGossipByTopic) {\n this.doEmitGossip(topic, peersToGossip, gossipIDsByTopic.get(topic) ?? []);\n }\n }\n /**\n * Send gossip messages to GossipFactor peers above threshold with a minimum of D_lazy\n * Peers are randomly selected from the heartbeat which exclude mesh + fanout peers\n * We also exclude direct peers, as there is no reason to emit gossip to them\n * @param topic\n * @param candidateToGossip - peers to gossip\n * @param messageIDs - message ids to gossip\n */\n doEmitGossip(topic, candidateToGossip, messageIDs) {\n if (!messageIDs.length) {\n return;\n }\n // shuffle to emit in random order\n (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength) {\n // we do the truncation (with shuffling) per peer below\n this.log('too many messages for gossip; will truncate IHAVE list (%d messages)', messageIDs.length);\n }\n if (!candidateToGossip.size)\n return;\n let target = this.opts.Dlazy;\n const factor = _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubGossipFactor * candidateToGossip.size;\n let peersToGossip = candidateToGossip;\n if (factor > target) {\n target = factor;\n }\n if (target > peersToGossip.size) {\n target = peersToGossip.size;\n }\n else {\n // only shuffle if needed\n peersToGossip = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(Array.from(peersToGossip)).slice(0, target);\n }\n // Emit the IHAVE gossip to the selected peers up to the target\n peersToGossip.forEach((id) => {\n let peerMessageIDs = messageIDs;\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength) {\n // shuffle and slice message IDs per peer so that we emit a different set for each peer\n // we have enough reduncancy in the system that this will significantly increase the message\n // coverage when we do truncate\n peerMessageIDs = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubMaxIHaveLength);\n }\n this.pushGossip(id, {\n topicID: topic,\n messageIDs: peerMessageIDs\n });\n });\n }\n /**\n * Flush gossip and control messages\n */\n flush() {\n // send gossip first, which will also piggyback control\n for (const [peer, ihave] of this.gossip.entries()) {\n this.gossip.delete(peer);\n this.sendRpc(peer, { control: { ihave } });\n }\n // send the remaining control messages\n for (const [peer, control] of this.control.entries()) {\n this.control.delete(peer);\n this.sendRpc(peer, { control: { graft: control.graft, prune: control.prune } });\n }\n }\n /**\n * Adds new IHAVE messages to pending gossip\n */\n pushGossip(id, controlIHaveMsgs) {\n this.log('Add gossip to %s', id);\n const gossip = this.gossip.get(id) || [];\n this.gossip.set(id, gossip.concat(controlIHaveMsgs));\n }\n /**\n * Make a PRUNE control message for a peer in a topic\n */\n async makePrune(id, topic, doPX, onUnsubscribe) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id).protocol === _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIDv10) {\n // Gossipsub v1.0 -- no backoff, the peer won't be able to parse it anyway\n return {\n topicID: topic,\n peers: []\n };\n }\n // backoff is measured in seconds\n // GossipsubPruneBackoff and GossipsubUnsubscribeBackoff are measured in milliseconds\n // The protobuf has it as a uint64\n const backoffMs = onUnsubscribe ? this.opts.unsubcribeBackoff : this.opts.pruneBackoff;\n const backoff = backoffMs / 1000;\n this.doAddBackoff(id, topic, backoffMs);\n if (!doPX) {\n return {\n topicID: topic,\n peers: [],\n backoff: backoff\n };\n }\n // select peers for Peer eXchange\n const peers = this.getRandomGossipPeers(topic, this.opts.prunePeers, (xid) => {\n return xid !== id && this.score.score(xid) >= 0;\n });\n const px = await Promise.all(Array.from(peers).map(async (peerId) => {\n // see if we have a signed record to send back; if we don't, just send\n // the peer ID and let the pruned peer find them in the DHT -- we can't trust\n // unsigned address records through PX anyways\n // Finding signed records in the DHT is not supported at the time of writing in js-libp2p\n const id = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(peerId);\n let peerInfo;\n try {\n peerInfo = await this.components.peerStore.get(id);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n return {\n peerID: id.toBytes(),\n signedPeerRecord: peerInfo?.peerRecordEnvelope\n };\n }));\n return {\n topicID: topic,\n peers: px,\n backoff: backoff\n };\n }\n /**\n * Maintains the mesh and fanout maps in gossipsub.\n */\n async heartbeat() {\n const { D, Dlo, Dhi, Dscore, Dout, fanoutTTL } = this.opts;\n this.heartbeatTicks++;\n // cache scores throught the heartbeat\n const scores = new Map();\n const getScore = (id) => {\n let s = scores.get(id);\n if (s === undefined) {\n s = this.score.score(id);\n scores.set(id, s);\n }\n return s;\n };\n // peer id => topic[]\n const tograft = new Map();\n // peer id => topic[]\n const toprune = new Map();\n // peer id => don't px\n const noPX = new Map();\n // clean up expired backoffs\n this.clearBackoff();\n // clean up peerhave/iasked counters\n this.peerhave.clear();\n this.metrics?.cacheSize.set({ cache: 'iasked' }, this.iasked.size);\n this.iasked.clear();\n // apply IWANT request penalties\n this.applyIwantPenalties();\n // ensure direct peers are connected\n if (this.heartbeatTicks % this.opts.directConnectTicks === 0) {\n // we only do this every few ticks to allow pending connections to complete and account for restarts/downtime\n await this.directConnect();\n }\n // EXTRA: Prune caches\n this.fastMsgIdCache?.prune();\n this.seenCache.prune();\n this.gossipTracer.prune();\n this.publishedMessageIds.prune();\n /**\n * Instead of calling getRandomGossipPeers multiple times to:\n * + get more mesh peers\n * + more outbound peers\n * + oppportunistic grafting\n * + emitGossip\n *\n * We want to loop through the topic peers only a single time and prepare gossip peers for all topics to improve the performance\n */\n const peersToGossipByTopic = new Map();\n // maintain the mesh for topics we have joined\n this.mesh.forEach((peers, topic) => {\n const peersInTopic = this.topics.get(topic);\n const candidateMeshPeers = new Set();\n const peersToGossip = new Set();\n peersToGossipByTopic.set(topic, peersToGossip);\n if (peersInTopic) {\n const shuffledPeers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(Array.from(peersInTopic));\n const backoff = this.backoff.get(topic);\n for (const id of shuffledPeers) {\n const peerStreams = this.streamsOutbound.get(id);\n if (peerStreams &&\n this.multicodecs.includes(peerStreams.protocol) &&\n !peers.has(id) &&\n !this.direct.has(id)) {\n const score = getScore(id);\n if ((!backoff || !backoff.has(id)) && score >= 0)\n candidateMeshPeers.add(id);\n // instead of having to find gossip peers after heartbeat which require another loop\n // we prepare peers to gossip in a topic within heartbeat to improve performance\n if (score >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n }\n }\n }\n // prune/graft helper functions (defined per topic)\n const prunePeer = (id, reason) => {\n this.log('HEARTBEAT: Remove mesh link to %s in %s', id, topic);\n // no need to update peer score here as we do it in makePrune\n // add prune backoff record\n this.addBackoff(id, topic);\n // remove peer from mesh\n peers.delete(id);\n // after pruning a peer from mesh, we want to gossip topic to it if its score meet the gossip threshold\n if (getScore(id) >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n this.metrics?.onRemoveFromMesh(topic, reason, 1);\n // add to toprune\n const topics = toprune.get(id);\n if (!topics) {\n toprune.set(id, [topic]);\n }\n else {\n topics.push(topic);\n }\n };\n const graftPeer = (id, reason) => {\n this.log('HEARTBEAT: Add mesh link to %s in %s', id, topic);\n // update peer score\n this.score.graft(id, topic);\n // add peer to mesh\n peers.add(id);\n // when we add a new mesh peer, we don't want to gossip messages to it\n peersToGossip.delete(id);\n this.metrics?.onAddToMesh(topic, reason, 1);\n // add to tograft\n const topics = tograft.get(id);\n if (!topics) {\n tograft.set(id, [topic]);\n }\n else {\n topics.push(topic);\n }\n };\n // drop all peers with negative score, without PX\n peers.forEach((id) => {\n const score = getScore(id);\n // Record the score\n if (score < 0) {\n this.log('HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s', id, score, topic);\n prunePeer(id, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ChurnReason.BadScore);\n noPX.set(id, true);\n }\n });\n // do we have enough peers?\n if (peers.size < Dlo) {\n const ineed = D - peers.size;\n // slice up to first `ineed` items and remove them from candidateMeshPeers\n // same to `const newMeshPeers = candidateMeshPeers.slice(0, ineed)`\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_19__.removeFirstNItemsFromSet)(candidateMeshPeers, ineed);\n newMeshPeers.forEach((p) => {\n graftPeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.NotEnough);\n });\n }\n // do we have to many peers?\n if (peers.size > Dhi) {\n let peersArray = Array.from(peers);\n // sort by score\n peersArray.sort((a, b) => getScore(b) - getScore(a));\n // We keep the first D_score peers by score and the remaining up to D randomly\n // under the constraint that we keep D_out peers in the mesh (if we have that many)\n peersArray = peersArray.slice(0, Dscore).concat((0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(peersArray.slice(Dscore)));\n // count the outbound peers we are keeping\n let outbound = 0;\n peersArray.slice(0, D).forEach((p) => {\n if (this.outbound.get(p)) {\n outbound++;\n }\n });\n // if it's less than D_out, bubble up some outbound peers from the random selection\n if (outbound < Dout) {\n const rotate = (i) => {\n // rotate the peersArray to the right and put the ith peer in the front\n const p = peersArray[i];\n for (let j = i; j > 0; j--) {\n peersArray[j] = peersArray[j - 1];\n }\n peersArray[0] = p;\n };\n // first bubble up all outbound peers already in the selection to the front\n if (outbound > 0) {\n let ihave = outbound;\n for (let i = 1; i < D && ihave > 0; i++) {\n if (this.outbound.get(peersArray[i])) {\n rotate(i);\n ihave--;\n }\n }\n }\n // now bubble up enough outbound peers outside the selection to the front\n let ineed = D - outbound;\n for (let i = D; i < peersArray.length && ineed > 0; i++) {\n if (this.outbound.get(peersArray[i])) {\n rotate(i);\n ineed--;\n }\n }\n }\n // prune the excess peers\n peersArray.slice(D).forEach((p) => {\n prunePeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.ChurnReason.Excess);\n });\n }\n // do we have enough outbound peers?\n if (peers.size >= Dlo) {\n // count the outbound peers we have\n let outbound = 0;\n peers.forEach((p) => {\n if (this.outbound.get(p)) {\n outbound++;\n }\n });\n // if it's less than D_out, select some peers with outbound connections and graft them\n if (outbound < Dout) {\n const ineed = Dout - outbound;\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_19__.removeItemsFromSet)(candidateMeshPeers, ineed, (id) => this.outbound.get(id) === true);\n newMeshPeers.forEach((p) => {\n graftPeer(p, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.Outbound);\n });\n }\n }\n // should we try to improve the mesh with opportunistic grafting?\n if (this.heartbeatTicks % this.opts.opportunisticGraftTicks === 0 && peers.size > 1) {\n // Opportunistic grafting works as follows: we check the median score of peers in the\n // mesh; if this score is below the opportunisticGraftThreshold, we select a few peers at\n // random with score over the median.\n // The intention is to (slowly) improve an underperforming mesh by introducing good\n // scoring peers that may have been gossiping at us. This allows us to get out of sticky\n // situations where we are stuck with poor peers and also recover from churn of good peers.\n // now compute the median peer score in the mesh\n const peersList = Array.from(peers).sort((a, b) => getScore(a) - getScore(b));\n const medianIndex = Math.floor(peers.size / 2);\n const medianScore = getScore(peersList[medianIndex]);\n // if the median score is below the threshold, select a better peer (if any) and GRAFT\n if (medianScore < this.opts.scoreThresholds.opportunisticGraftThreshold) {\n const ineed = this.opts.opportunisticGraftPeers;\n const newMeshPeers = (0,_utils_set_js__WEBPACK_IMPORTED_MODULE_19__.removeItemsFromSet)(candidateMeshPeers, ineed, (id) => getScore(id) > medianScore);\n for (const id of newMeshPeers) {\n this.log('HEARTBEAT: Opportunistically graft peer %s on topic %s', id, topic);\n graftPeer(id, _metrics_js__WEBPACK_IMPORTED_MODULE_12__.InclusionReason.Opportunistic);\n }\n }\n }\n });\n // expire fanout for topics we haven't published to in a while\n const now = Date.now();\n this.fanoutLastpub.forEach((lastpb, topic) => {\n if (lastpb + fanoutTTL < now) {\n this.fanout.delete(topic);\n this.fanoutLastpub.delete(topic);\n }\n });\n // maintain our fanout for topics we are publishing but we have not joined\n this.fanout.forEach((fanoutPeers, topic) => {\n // checks whether our peers are still in the topic and have a score above the publish threshold\n const topicPeers = this.topics.get(topic);\n fanoutPeers.forEach((id) => {\n if (!topicPeers.has(id) || getScore(id) < this.opts.scoreThresholds.publishThreshold) {\n fanoutPeers.delete(id);\n }\n });\n const peersInTopic = this.topics.get(topic);\n const candidateFanoutPeers = [];\n // the fanout map contains topics to which we are not subscribed.\n const peersToGossip = new Set();\n peersToGossipByTopic.set(topic, peersToGossip);\n if (peersInTopic) {\n const shuffledPeers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(Array.from(peersInTopic));\n for (const id of shuffledPeers) {\n const peerStreams = this.streamsOutbound.get(id);\n if (peerStreams &&\n this.multicodecs.includes(peerStreams.protocol) &&\n !fanoutPeers.has(id) &&\n !this.direct.has(id)) {\n const score = getScore(id);\n if (score >= this.opts.scoreThresholds.publishThreshold)\n candidateFanoutPeers.push(id);\n // instead of having to find gossip peers after heartbeat which require another loop\n // we prepare peers to gossip in a topic within heartbeat to improve performance\n if (score >= this.opts.scoreThresholds.gossipThreshold)\n peersToGossip.add(id);\n }\n }\n }\n // do we need more peers?\n if (fanoutPeers.size < D) {\n const ineed = D - fanoutPeers.size;\n candidateFanoutPeers.slice(0, ineed).forEach((id) => {\n fanoutPeers.add(id);\n peersToGossip?.delete(id);\n });\n }\n });\n this.emitGossip(peersToGossipByTopic);\n // send coalesced GRAFT/PRUNE messages (will piggyback gossip)\n await this.sendGraftPrune(tograft, toprune, noPX);\n // flush pending gossip that wasn't piggybacked above\n this.flush();\n // advance the message history window\n this.mcache.shift();\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('gossipsub:heartbeat'));\n }\n /**\n * Given a topic, returns up to count peers subscribed to that topic\n * that pass an optional filter function\n *\n * @param topic\n * @param count\n * @param filter - a function to filter acceptable peers\n */\n getRandomGossipPeers(topic, count, filter = () => true) {\n const peersInTopic = this.topics.get(topic);\n if (!peersInTopic) {\n return new Set();\n }\n // Adds all peers using our protocol\n // that also pass the filter function\n let peers = [];\n peersInTopic.forEach((id) => {\n const peerStreams = this.streamsOutbound.get(id);\n if (!peerStreams) {\n return;\n }\n if (this.multicodecs.includes(peerStreams.protocol) && filter(id)) {\n peers.push(id);\n }\n });\n // Pseudo-randomly shuffles peers\n peers = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_8__.shuffle)(peers);\n if (count > 0 && peers.length > count) {\n peers = peers.slice(0, count);\n }\n return new Set(peers);\n }\n onScrapeMetrics(metrics) {\n /* Data structure sizes */\n metrics.mcacheSize.set(this.mcache.size);\n metrics.mcacheNotValidatedCount.set(this.mcache.notValidatedCount);\n // Arbitrary size\n metrics.cacheSize.set({ cache: 'direct' }, this.direct.size);\n metrics.cacheSize.set({ cache: 'seenCache' }, this.seenCache.size);\n metrics.cacheSize.set({ cache: 'fastMsgIdCache' }, this.fastMsgIdCache?.size ?? 0);\n metrics.cacheSize.set({ cache: 'publishedMessageIds' }, this.publishedMessageIds.size);\n metrics.cacheSize.set({ cache: 'mcache' }, this.mcache.size);\n metrics.cacheSize.set({ cache: 'score' }, this.score.size);\n metrics.cacheSize.set({ cache: 'gossipTracer.promises' }, this.gossipTracer.size);\n metrics.cacheSize.set({ cache: 'gossipTracer.requests' }, this.gossipTracer.requestMsByMsgSize);\n // Bounded by topic\n metrics.cacheSize.set({ cache: 'topics' }, this.topics.size);\n metrics.cacheSize.set({ cache: 'subscriptions' }, this.subscriptions.size);\n metrics.cacheSize.set({ cache: 'mesh' }, this.mesh.size);\n metrics.cacheSize.set({ cache: 'fanout' }, this.fanout.size);\n // Bounded by peer\n metrics.cacheSize.set({ cache: 'peers' }, this.peers.size);\n metrics.cacheSize.set({ cache: 'streamsOutbound' }, this.streamsOutbound.size);\n metrics.cacheSize.set({ cache: 'streamsInbound' }, this.streamsInbound.size);\n metrics.cacheSize.set({ cache: 'acceptFromWhitelist' }, this.acceptFromWhitelist.size);\n metrics.cacheSize.set({ cache: 'gossip' }, this.gossip.size);\n metrics.cacheSize.set({ cache: 'control' }, this.control.size);\n metrics.cacheSize.set({ cache: 'peerhave' }, this.peerhave.size);\n metrics.cacheSize.set({ cache: 'outbound' }, this.outbound.size);\n // 2D nested data structure\n let backoffSize = 0;\n const now = Date.now();\n metrics.connectedPeersBackoffSec.reset();\n for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\n for (const [peer, expiredMs] of backoff.entries()) {\n if (this.peers.has(peer)) {\n metrics.connectedPeersBackoffSec.observe(Math.max(0, expiredMs - now) / 1000);\n }\n }\n }\n metrics.cacheSize.set({ cache: 'backoff' }, backoffSize);\n // Peer counts\n for (const [topicStr, peers] of this.topics) {\n metrics.topicPeersCount.set({ topicStr }, peers.size);\n }\n for (const [topicStr, peers] of this.mesh) {\n metrics.meshPeerCounts.set({ topicStr }, peers.size);\n }\n // Peer scores\n const scores = [];\n const scoreByPeer = new Map();\n metrics.behaviourPenalty.reset();\n for (const peerIdStr of this.peers.keys()) {\n const score = this.score.score(peerIdStr);\n scores.push(score);\n scoreByPeer.set(peerIdStr, score);\n metrics.behaviourPenalty.observe(this.score.peerStats.get(peerIdStr)?.behaviourPenalty ?? 0);\n }\n metrics.registerScores(scores, this.opts.scoreThresholds);\n // Breakdown score per mesh topicLabel\n metrics.registerScorePerMesh(this.mesh, scoreByPeer);\n // Breakdown on each score weight\n const sw = (0,_score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_16__.computeAllPeersScoreWeights)(this.peers.keys(), this.score.peerStats, this.score.params, this.score.peerIPs, metrics.topicStrToLabel);\n metrics.registerScoreWeights(sw);\n }\n}\nGossipSub.multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_7__.GossipsubIDv11;\nfunction gossipsub(init = {}) {\n return (components) => new GossipSub(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageCache: () => (/* binding */ MessageCache)\n/* harmony export */ });\nclass MessageCache {\n /**\n * Holds history of messages in timebounded history arrays\n */\n constructor(\n /**\n * The number of indices in the cache history used for gossiping. That means that a message\n * won't get gossiped anymore when shift got called `gossip` many times after inserting the\n * message in the cache.\n */\n gossip, historyCapacity, msgIdToStrFn) {\n this.gossip = gossip;\n this.msgs = new Map();\n this.history = [];\n /** Track with accounting of messages in the mcache that are not yet validated */\n this.notValidatedCount = 0;\n this.msgIdToStrFn = msgIdToStrFn;\n for (let i = 0; i < historyCapacity; i++) {\n this.history[i] = [];\n }\n }\n get size() {\n return this.msgs.size;\n }\n /**\n * Adds a message to the current window and the cache\n * Returns true if the message is not known and is inserted in the cache\n */\n put(messageId, msg, validated = false) {\n const { msgIdStr } = messageId;\n // Don't add duplicate entries to the cache.\n if (this.msgs.has(msgIdStr)) {\n return false;\n }\n this.msgs.set(msgIdStr, {\n message: msg,\n validated,\n originatingPeers: new Set(),\n iwantCounts: new Map()\n });\n this.history[0].push({ ...messageId, topic: msg.topic });\n if (!validated) {\n this.notValidatedCount++;\n }\n return true;\n }\n observeDuplicate(msgId, fromPeerIdStr) {\n const entry = this.msgs.get(msgId);\n if (entry &&\n // if the message is already validated, we don't need to store extra peers sending us\n // duplicates as the message has already been forwarded\n !entry.validated) {\n entry.originatingPeers.add(fromPeerIdStr);\n }\n }\n /**\n * Retrieves a message from the cache by its ID, if it is still present\n */\n get(msgId) {\n return this.msgs.get(this.msgIdToStrFn(msgId))?.message;\n }\n /**\n * Increases the iwant count for the given message by one and returns the message together\n * with the iwant if the message exists.\n */\n getWithIWantCount(msgIdStr, p) {\n const msg = this.msgs.get(msgIdStr);\n if (!msg) {\n return null;\n }\n const count = (msg.iwantCounts.get(p) ?? 0) + 1;\n msg.iwantCounts.set(p, count);\n return { msg: msg.message, count };\n }\n /**\n * Retrieves a list of message IDs for a set of topics\n */\n getGossipIDs(topics) {\n const msgIdsByTopic = new Map();\n for (let i = 0; i < this.gossip; i++) {\n this.history[i].forEach((entry) => {\n const msg = this.msgs.get(entry.msgIdStr);\n if (msg && msg.validated && topics.has(entry.topic)) {\n let msgIds = msgIdsByTopic.get(entry.topic);\n if (!msgIds) {\n msgIds = [];\n msgIdsByTopic.set(entry.topic, msgIds);\n }\n msgIds.push(entry.msgId);\n }\n });\n }\n return msgIdsByTopic;\n }\n /**\n * Gets a message with msgId and tags it as validated.\n * This function also returns the known peers that have sent us this message. This is used to\n * prevent us sending redundant messages to peers who have already propagated it.\n */\n validate(msgId) {\n const entry = this.msgs.get(msgId);\n if (!entry) {\n return null;\n }\n if (!entry.validated) {\n this.notValidatedCount--;\n }\n const { message, originatingPeers } = entry;\n entry.validated = true;\n // Clear the known peers list (after a message is validated, it is forwarded and we no\n // longer need to store the originating peers).\n entry.originatingPeers = new Set();\n return { message, originatingPeers };\n }\n /**\n * Shifts the current window, discarding messages older than this.history.length of the cache\n */\n shift() {\n const lastCacheEntries = this.history[this.history.length - 1];\n lastCacheEntries.forEach((cacheEntry) => {\n const entry = this.msgs.get(cacheEntry.msgIdStr);\n if (entry) {\n this.msgs.delete(cacheEntry.msgIdStr);\n if (!entry.validated) {\n this.notValidatedCount--;\n }\n }\n });\n this.history.pop();\n this.history.unshift([]);\n }\n remove(msgId) {\n const entry = this.msgs.get(msgId);\n if (!entry) {\n return null;\n }\n // Keep the message on the history vector, it will be dropped on a shift()\n this.msgs.delete(msgId);\n return entry;\n }\n}\n//# sourceMappingURL=message-cache.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js ***! - \*********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeRpc: () => (/* binding */ decodeRpc),\n/* harmony export */ defaultDecodeRpcLimits: () => (/* binding */ defaultDecodeRpcLimits)\n/* harmony export */ });\n/* harmony import */ var protobufjs_minimal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/minimal.js */ \"./node_modules/@waku/relay/node_modules/protobufjs/minimal.js\");\n\nconst defaultDecodeRpcLimits = {\n maxSubscriptions: Infinity,\n maxMessages: Infinity,\n maxIhaveMessageIDs: Infinity,\n maxIwantMessageIDs: Infinity,\n maxControlMessages: Infinity,\n maxPeerInfos: Infinity\n};\n/**\n * Copied code from src/message/rpc.cjs but with decode limits to prevent OOM attacks\n */\nfunction decodeRpc(bytes, opts) {\n // Mutate to use the option as stateful counter. Must limit the total count of messageIDs across all IWANT, IHAVE\n // else one count put 100 messageIDs into each 100 IWANT and \"get around\" the limit\n opts = { ...opts };\n const r = protobufjs_minimal_js__WEBPACK_IMPORTED_MODULE_0__.Reader.create(bytes);\n const l = bytes.length;\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.subscriptions && m.subscriptions.length))\n m.subscriptions = [];\n if (m.subscriptions.length < opts.maxSubscriptions)\n m.subscriptions.push(decodeSubOpts(r, r.uint32()));\n else\n r.skipType(t & 7);\n break;\n case 2:\n if (!(m.messages && m.messages.length))\n m.messages = [];\n if (m.messages.length < opts.maxMessages)\n m.messages.push(decodeMessage(r, r.uint32()));\n else\n r.skipType(t & 7);\n break;\n case 3:\n m.control = decodeControlMessage(r, r.uint32(), opts);\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeSubOpts(r, l) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.subscribe = r.bool();\n break;\n case 2:\n m.topic = r.string();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeMessage(r, l) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.from = r.bytes();\n break;\n case 2:\n m.data = r.bytes();\n break;\n case 3:\n m.seqno = r.bytes();\n break;\n case 4:\n m.topic = r.string();\n break;\n case 5:\n m.signature = r.bytes();\n break;\n case 6:\n m.key = r.bytes();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n if (!m.topic)\n throw Error(\"missing required 'topic'\");\n return m;\n}\nfunction decodeControlMessage(r, l, opts) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.ihave && m.ihave.length))\n m.ihave = [];\n if (m.ihave.length < opts.maxControlMessages)\n m.ihave.push(decodeControlIHave(r, r.uint32(), opts));\n else\n r.skipType(t & 7);\n break;\n case 2:\n if (!(m.iwant && m.iwant.length))\n m.iwant = [];\n if (m.iwant.length < opts.maxControlMessages)\n m.iwant.push(decodeControlIWant(r, r.uint32(), opts));\n else\n r.skipType(t & 7);\n break;\n case 3:\n if (!(m.graft && m.graft.length))\n m.graft = [];\n if (m.graft.length < opts.maxControlMessages)\n m.graft.push(decodeControlGraft(r, r.uint32()));\n else\n r.skipType(t & 7);\n break;\n case 4:\n if (!(m.prune && m.prune.length))\n m.prune = [];\n if (m.prune.length < opts.maxControlMessages)\n m.prune.push(decodeControlPrune(r, r.uint32(), opts));\n else\n r.skipType(t & 7);\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeControlIHave(r, l, opts) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n case 2:\n if (!(m.messageIDs && m.messageIDs.length))\n m.messageIDs = [];\n if (opts.maxIhaveMessageIDs-- > 0)\n m.messageIDs.push(r.bytes());\n else\n r.skipType(t & 7);\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeControlIWant(r, l, opts) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n if (!(m.messageIDs && m.messageIDs.length))\n m.messageIDs = [];\n if (opts.maxIwantMessageIDs-- > 0)\n m.messageIDs.push(r.bytes());\n else\n r.skipType(t & 7);\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeControlGraft(r, l) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodeControlPrune(r, l, opts) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.topicID = r.string();\n break;\n case 2:\n if (!(m.peers && m.peers.length))\n m.peers = [];\n if (opts.maxPeerInfos-- > 0)\n m.peers.push(decodePeerInfo(r, r.uint32()));\n else\n r.skipType(t & 7);\n break;\n case 3:\n m.backoff = r.uint64();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\nfunction decodePeerInfo(r, l) {\n const c = l === undefined ? r.len : r.pos + l;\n const m = {};\n while (r.pos < c) {\n const t = r.uint32();\n switch (t >>> 3) {\n case 1:\n m.peerID = r.bytes();\n break;\n case 2:\n m.signedPeerRecord = r.bytes();\n break;\n default:\n r.skipType(t & 7);\n break;\n }\n }\n return m;\n}\n//# sourceMappingURL=decodeRpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RPC: () => (/* binding */ RPC)\n/* harmony export */ });\n/* harmony import */ var _rpc_cjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.cjs */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs\");\n\n\nconst {RPC} = _rpc_cjs__WEBPACK_IMPORTED_MODULE_0__\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ChurnReason: () => (/* binding */ ChurnReason),\n/* harmony export */ IHaveIgnoreReason: () => (/* binding */ IHaveIgnoreReason),\n/* harmony export */ InclusionReason: () => (/* binding */ InclusionReason),\n/* harmony export */ MessageSource: () => (/* binding */ MessageSource),\n/* harmony export */ ScorePenalty: () => (/* binding */ ScorePenalty),\n/* harmony export */ ScoreThreshold: () => (/* binding */ ScoreThreshold),\n/* harmony export */ getMetrics: () => (/* binding */ getMetrics)\n/* harmony export */ });\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\nvar MessageSource;\n(function (MessageSource) {\n MessageSource[\"forward\"] = \"forward\";\n MessageSource[\"publish\"] = \"publish\";\n})(MessageSource || (MessageSource = {}));\nvar InclusionReason;\n(function (InclusionReason) {\n /** Peer was a fanaout peer. */\n InclusionReason[\"Fanout\"] = \"fanout\";\n /** Included from random selection. */\n InclusionReason[\"Random\"] = \"random\";\n /** Peer subscribed. */\n InclusionReason[\"Subscribed\"] = \"subscribed\";\n /** On heartbeat, peer was included to fill the outbound quota. */\n InclusionReason[\"Outbound\"] = \"outbound\";\n /** On heartbeat, not enough peers in mesh */\n InclusionReason[\"NotEnough\"] = \"not_enough\";\n /** On heartbeat opportunistic grafting due to low mesh score */\n InclusionReason[\"Opportunistic\"] = \"opportunistic\";\n})(InclusionReason || (InclusionReason = {}));\n/// Reasons why a peer was removed from the mesh.\nvar ChurnReason;\n(function (ChurnReason) {\n /// Peer disconnected.\n ChurnReason[\"Dc\"] = \"disconnected\";\n /// Peer had a bad score.\n ChurnReason[\"BadScore\"] = \"bad_score\";\n /// Peer sent a PRUNE.\n ChurnReason[\"Prune\"] = \"prune\";\n /// Too many peers.\n ChurnReason[\"Excess\"] = \"excess\";\n})(ChurnReason || (ChurnReason = {}));\n/// Kinds of reasons a peer's score has been penalized\nvar ScorePenalty;\n(function (ScorePenalty) {\n /// A peer grafted before waiting the back-off time.\n ScorePenalty[\"GraftBackoff\"] = \"graft_backoff\";\n /// A Peer did not respond to an IWANT request in time.\n ScorePenalty[\"BrokenPromise\"] = \"broken_promise\";\n /// A Peer did not send enough messages as expected.\n ScorePenalty[\"MessageDeficit\"] = \"message_deficit\";\n /// Too many peers under one IP address.\n ScorePenalty[\"IPColocation\"] = \"IP_colocation\";\n})(ScorePenalty || (ScorePenalty = {}));\nvar IHaveIgnoreReason;\n(function (IHaveIgnoreReason) {\n IHaveIgnoreReason[\"LowScore\"] = \"low_score\";\n IHaveIgnoreReason[\"MaxIhave\"] = \"max_ihave\";\n IHaveIgnoreReason[\"MaxIasked\"] = \"max_iasked\";\n})(IHaveIgnoreReason || (IHaveIgnoreReason = {}));\nvar ScoreThreshold;\n(function (ScoreThreshold) {\n ScoreThreshold[\"graylist\"] = \"graylist\";\n ScoreThreshold[\"publish\"] = \"publish\";\n ScoreThreshold[\"gossip\"] = \"gossip\";\n ScoreThreshold[\"mesh\"] = \"mesh\";\n})(ScoreThreshold || (ScoreThreshold = {}));\n/**\n * A collection of metrics used throughout the Gossipsub behaviour.\n * NOTE: except for special reasons, do not add more than 1 label for frequent metrics,\n * there's a performance penalty as of June 2023.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nfunction getMetrics(register, topicStrToLabel, opts) {\n // Using function style instead of class to prevent having to re-declare all MetricsPrometheus types.\n return {\n /* Metrics for static config */\n protocolsEnabled: register.gauge({\n name: 'gossipsub_protocol',\n help: 'Status of enabled protocols',\n labelNames: ['protocol']\n }),\n /* Metrics per known topic */\n /** Status of our subscription to this topic. This metric allows analyzing other topic metrics\n * filtered by our current subscription status.\n * = rust-libp2p `topic_subscription_status` */\n topicSubscriptionStatus: register.gauge({\n name: 'gossipsub_topic_subscription_status',\n help: 'Status of our subscription to this topic',\n labelNames: ['topicStr']\n }),\n /** Number of peers subscribed to each topic. This allows us to analyze a topic's behaviour\n * regardless of our subscription status. */\n topicPeersCount: register.gauge({\n name: 'gossipsub_topic_peer_count',\n help: 'Number of peers subscribed to each topic',\n labelNames: ['topicStr']\n }),\n /* Metrics regarding mesh state */\n /** Number of peers in our mesh. This metric should be updated with the count of peers for a\n * topic in the mesh regardless of inclusion and churn events.\n * = rust-libp2p `mesh_peer_counts` */\n meshPeerCounts: register.gauge({\n name: 'gossipsub_mesh_peer_count',\n help: 'Number of peers in our mesh',\n labelNames: ['topicStr']\n }),\n /** Number of times we include peers in a topic mesh for different reasons.\n * = rust-libp2p `mesh_peer_inclusion_events` */\n meshPeerInclusionEvents: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_total',\n help: 'Number of times we include peers in a topic mesh for different reasons',\n labelNames: ['reason']\n }),\n meshPeerInclusionEventsByTopic: register.gauge({\n name: 'gossipsub_mesh_peer_inclusion_events_by_topic_total',\n help: 'Number of times we include peers in a topic',\n labelNames: ['topic']\n }),\n /** Number of times we remove peers in a topic mesh for different reasons.\n * = rust-libp2p `mesh_peer_churn_events` */\n meshPeerChurnEvents: register.gauge({\n name: 'gossipsub_peer_churn_events_total',\n help: 'Number of times we remove peers in a topic mesh for different reasons',\n labelNames: ['reason']\n }),\n meshPeerChurnEventsByTopic: register.gauge({\n name: 'gossipsub_peer_churn_events_by_topic_total',\n help: 'Number of times we remove peers in a topic',\n labelNames: ['topic']\n }),\n /* General Metrics */\n /** Gossipsub supports floodsub, gossipsub v1.0 and gossipsub v1.1. Peers are classified based\n * on which protocol they support. This metric keeps track of the number of peers that are\n * connected of each type. */\n peersPerProtocol: register.gauge({\n name: 'gossipsub_peers_per_protocol_count',\n help: 'Peers connected for each topic',\n labelNames: ['protocol']\n }),\n /** The time it takes to complete one iteration of the heartbeat. */\n heartbeatDuration: register.histogram({\n name: 'gossipsub_heartbeat_duration_seconds',\n help: 'The time it takes to complete one iteration of the heartbeat',\n // Should take <10ms, over 1s it's a huge issue that needs debugging, since a heartbeat will be cancelled\n buckets: [0.01, 0.1, 1]\n }),\n /** Heartbeat run took longer than heartbeat interval so next is skipped */\n heartbeatSkipped: register.gauge({\n name: 'gossipsub_heartbeat_skipped',\n help: 'Heartbeat run took longer than heartbeat interval so next is skipped'\n }),\n /** Message validation results for each topic.\n * Invalid == Reject?\n * = rust-libp2p `invalid_messages`, `accepted_messages`, `ignored_messages`, `rejected_messages` */\n asyncValidationResult: register.gauge({\n name: 'gossipsub_async_validation_result_total',\n help: 'Message validation result',\n labelNames: ['acceptance']\n }),\n asyncValidationResultByTopic: register.gauge({\n name: 'gossipsub_async_validation_result_by_topic_total',\n help: 'Message validation result for each topic',\n labelNames: ['topic']\n }),\n /** When the user validates a message, it tries to re propagate it to its mesh peers. If the\n * message expires from the memcache before it can be validated, we count this a cache miss\n * and it is an indicator that the memcache size should be increased.\n * = rust-libp2p `mcache_misses` */\n asyncValidationMcacheHit: register.gauge({\n name: 'gossipsub_async_validation_mcache_hit_total',\n help: 'Async validation result reported by the user layer',\n labelNames: ['hit']\n }),\n asyncValidationDelayFromFirstSeenSec: register.histogram({\n name: 'gossipsub_async_validation_delay_from_first_seen',\n help: 'Async validation report delay from first seen in second',\n labelNames: ['topic'],\n buckets: [0.01, 0.03, 0.1, 0.3, 1, 3, 10]\n }),\n asyncValidationUnknownFirstSeen: register.gauge({\n name: 'gossipsub_async_validation_unknown_first_seen_count_total',\n help: 'Async validation report unknown first seen value for message'\n }),\n // peer stream\n peerReadStreamError: register.gauge({\n name: 'gossipsub_peer_read_stream_err_count_total',\n help: 'Peer read stream error'\n }),\n // RPC outgoing. Track byte length + data structure sizes\n rpcRecvBytes: register.gauge({ name: 'gossipsub_rpc_recv_bytes_total', help: 'RPC recv' }),\n rpcRecvCount: register.gauge({ name: 'gossipsub_rpc_recv_count_total', help: 'RPC recv' }),\n rpcRecvSubscription: register.gauge({ name: 'gossipsub_rpc_recv_subscription_total', help: 'RPC recv' }),\n rpcRecvMessage: register.gauge({ name: 'gossipsub_rpc_recv_message_total', help: 'RPC recv' }),\n rpcRecvControl: register.gauge({ name: 'gossipsub_rpc_recv_control_total', help: 'RPC recv' }),\n rpcRecvIHave: register.gauge({ name: 'gossipsub_rpc_recv_ihave_total', help: 'RPC recv' }),\n rpcRecvIWant: register.gauge({ name: 'gossipsub_rpc_recv_iwant_total', help: 'RPC recv' }),\n rpcRecvGraft: register.gauge({ name: 'gossipsub_rpc_recv_graft_total', help: 'RPC recv' }),\n rpcRecvPrune: register.gauge({ name: 'gossipsub_rpc_recv_prune_total', help: 'RPC recv' }),\n rpcDataError: register.gauge({ name: 'gossipsub_rpc_data_err_count_total', help: 'RPC data error' }),\n rpcRecvError: register.gauge({ name: 'gossipsub_rpc_recv_err_count_total', help: 'RPC recv error' }),\n /** Total count of RPC dropped because acceptFrom() == false */\n rpcRecvNotAccepted: register.gauge({\n name: 'gossipsub_rpc_rcv_not_accepted_total',\n help: 'Total count of RPC dropped because acceptFrom() == false'\n }),\n // RPC incoming. Track byte length + data structure sizes\n rpcSentBytes: register.gauge({ name: 'gossipsub_rpc_sent_bytes_total', help: 'RPC sent' }),\n rpcSentCount: register.gauge({ name: 'gossipsub_rpc_sent_count_total', help: 'RPC sent' }),\n rpcSentSubscription: register.gauge({ name: 'gossipsub_rpc_sent_subscription_total', help: 'RPC sent' }),\n rpcSentMessage: register.gauge({ name: 'gossipsub_rpc_sent_message_total', help: 'RPC sent' }),\n rpcSentControl: register.gauge({ name: 'gossipsub_rpc_sent_control_total', help: 'RPC sent' }),\n rpcSentIHave: register.gauge({ name: 'gossipsub_rpc_sent_ihave_total', help: 'RPC sent' }),\n rpcSentIWant: register.gauge({ name: 'gossipsub_rpc_sent_iwant_total', help: 'RPC sent' }),\n rpcSentGraft: register.gauge({ name: 'gossipsub_rpc_sent_graft_total', help: 'RPC sent' }),\n rpcSentPrune: register.gauge({ name: 'gossipsub_rpc_sent_prune_total', help: 'RPC sent' }),\n // publish message. Track peers sent to and bytes\n /** Total count of msg published by topic */\n msgPublishCount: register.gauge({\n name: 'gossipsub_msg_publish_count_total',\n help: 'Total count of msg published by topic',\n labelNames: ['topic']\n }),\n /** Total count of peers that we publish a msg to */\n msgPublishPeersByTopic: register.gauge({\n name: 'gossipsub_msg_publish_peers_total',\n help: 'Total count of peers that we publish a msg to',\n labelNames: ['topic']\n }),\n /** Total count of peers (by group) that we publish a msg to */\n // NOTE: Do not use 'group' label since it's a generic already used by Prometheus to group instances\n msgPublishPeersByGroup: register.gauge({\n name: 'gossipsub_msg_publish_peers_by_group',\n help: 'Total count of peers (by group) that we publish a msg to',\n labelNames: ['peerGroup']\n }),\n /** Total count of msg publish data.length bytes */\n msgPublishBytes: register.gauge({\n name: 'gossipsub_msg_publish_bytes_total',\n help: 'Total count of msg publish data.length bytes',\n labelNames: ['topic']\n }),\n /** Total count of msg forwarded by topic */\n msgForwardCount: register.gauge({\n name: 'gossipsub_msg_forward_count_total',\n help: 'Total count of msg forwarded by topic',\n labelNames: ['topic']\n }),\n /** Total count of peers that we forward a msg to */\n msgForwardPeers: register.gauge({\n name: 'gossipsub_msg_forward_peers_total',\n help: 'Total count of peers that we forward a msg to',\n labelNames: ['topic']\n }),\n /** Total count of recv msgs before any validation */\n msgReceivedPreValidation: register.gauge({\n name: 'gossipsub_msg_received_prevalidation_total',\n help: 'Total count of recv msgs before any validation',\n labelNames: ['topic']\n }),\n /** Total count of recv msgs error */\n msgReceivedError: register.gauge({\n name: 'gossipsub_msg_received_error_total',\n help: 'Total count of recv msgs error',\n labelNames: ['topic']\n }),\n /** Tracks distribution of recv msgs by duplicate, invalid, valid */\n msgReceivedStatus: register.gauge({\n name: 'gossipsub_msg_received_status_total',\n help: 'Tracks distribution of recv msgs by duplicate, invalid, valid',\n labelNames: ['status']\n }),\n msgReceivedTopic: register.gauge({\n name: 'gossipsub_msg_received_topic_total',\n help: 'Tracks distribution of recv msgs by topic label',\n labelNames: ['topic']\n }),\n /** Tracks specific reason of invalid */\n msgReceivedInvalid: register.gauge({\n name: 'gossipsub_msg_received_invalid_total',\n help: 'Tracks specific reason of invalid',\n labelNames: ['error']\n }),\n msgReceivedInvalidByTopic: register.gauge({\n name: 'gossipsub_msg_received_invalid_by_topic_total',\n help: 'Tracks specific invalid message by topic',\n labelNames: ['topic']\n }),\n /** Track duplicate message delivery time */\n duplicateMsgDeliveryDelay: register.histogram({\n name: 'gossisub_duplicate_msg_delivery_delay_seconds',\n help: 'Time since the 1st duplicated message validated',\n labelNames: ['topic'],\n buckets: [\n 0.25 * opts.maxMeshMessageDeliveriesWindowSec,\n 0.5 * opts.maxMeshMessageDeliveriesWindowSec,\n 1 * opts.maxMeshMessageDeliveriesWindowSec,\n 2 * opts.maxMeshMessageDeliveriesWindowSec,\n 4 * opts.maxMeshMessageDeliveriesWindowSec\n ]\n }),\n /** Total count of late msg delivery total by topic */\n duplicateMsgLateDelivery: register.gauge({\n name: 'gossisub_duplicate_msg_late_delivery_total',\n help: 'Total count of late duplicate message delivery by topic, which triggers P3 penalty',\n labelNames: ['topic']\n }),\n duplicateMsgIgnored: register.gauge({\n name: 'gossisub_ignored_published_duplicate_msgs_total',\n help: 'Total count of published duplicate message ignored by topic',\n labelNames: ['topic']\n }),\n /* Metrics related to scoring */\n /** Total times score() is called */\n scoreFnCalls: register.gauge({\n name: 'gossipsub_score_fn_calls_total',\n help: 'Total times score() is called'\n }),\n /** Total times score() call actually computed computeScore(), no cache */\n scoreFnRuns: register.gauge({\n name: 'gossipsub_score_fn_runs_total',\n help: 'Total times score() call actually computed computeScore(), no cache'\n }),\n scoreCachedDelta: register.histogram({\n name: 'gossipsub_score_cache_delta',\n help: 'Delta of score between cached values that expired',\n buckets: [10, 100, 1000]\n }),\n /** Current count of peers by score threshold */\n peersByScoreThreshold: register.gauge({\n name: 'gossipsub_peers_by_score_threshold_count',\n help: 'Current count of peers by score threshold',\n labelNames: ['threshold']\n }),\n score: register.avgMinMax({\n name: 'gossipsub_score',\n help: 'Avg min max of gossip scores'\n }),\n /**\n * Separate score weights\n * Need to use 2-label metrics in this case to debug the score weights\n **/\n scoreWeights: register.avgMinMax({\n name: 'gossipsub_score_weights',\n help: 'Separate score weights',\n labelNames: ['topic', 'p']\n }),\n /** Histogram of the scores for each mesh topic. */\n // TODO: Not implemented\n scorePerMesh: register.avgMinMax({\n name: 'gossipsub_score_per_mesh',\n help: 'Histogram of the scores for each mesh topic',\n labelNames: ['topic']\n }),\n /** A counter of the kind of penalties being applied to peers. */\n // TODO: Not fully implemented\n scoringPenalties: register.gauge({\n name: 'gossipsub_scoring_penalties_total',\n help: 'A counter of the kind of penalties being applied to peers',\n labelNames: ['penalty']\n }),\n behaviourPenalty: register.histogram({\n name: 'gossipsub_peer_stat_behaviour_penalty',\n help: 'Current peer stat behaviour_penalty at each scrape',\n buckets: [\n 0.25 * opts.behaviourPenaltyThreshold,\n 0.5 * opts.behaviourPenaltyThreshold,\n 1 * opts.behaviourPenaltyThreshold,\n 2 * opts.behaviourPenaltyThreshold,\n 4 * opts.behaviourPenaltyThreshold\n ]\n }),\n // TODO:\n // - iasked per peer (on heartbeat)\n // - when promise is resolved, track messages from promises\n /** Total received IHAVE messages that we ignore for some reason */\n ihaveRcvIgnored: register.gauge({\n name: 'gossipsub_ihave_rcv_ignored_total',\n help: 'Total received IHAVE messages that we ignore for some reason',\n labelNames: ['reason']\n }),\n /** Total received IHAVE messages by topic */\n ihaveRcvMsgids: register.gauge({\n name: 'gossipsub_ihave_rcv_msgids_total',\n help: 'Total received IHAVE messages by topic',\n labelNames: ['topic']\n }),\n /** Total messages per topic we don't have. Not actual requests.\n * The number of times we have decided that an IWANT control message is required for this\n * topic. A very high metric might indicate an underperforming network.\n * = rust-libp2p `topic_iwant_msgs` */\n ihaveRcvNotSeenMsgids: register.gauge({\n name: 'gossipsub_ihave_rcv_not_seen_msgids_total',\n help: 'Total messages per topic we do not have, not actual requests',\n labelNames: ['topic']\n }),\n /** Total received IWANT messages by topic */\n iwantRcvMsgids: register.gauge({\n name: 'gossipsub_iwant_rcv_msgids_total',\n help: 'Total received IWANT messages by topic',\n labelNames: ['topic']\n }),\n /** Total requested messageIDs that we don't have */\n iwantRcvDonthaveMsgids: register.gauge({\n name: 'gossipsub_iwant_rcv_dont_have_msgids_total',\n help: 'Total requested messageIDs that we do not have'\n }),\n iwantPromiseStarted: register.gauge({\n name: 'gossipsub_iwant_promise_sent_total',\n help: 'Total count of started IWANT promises'\n }),\n /** Total count of resolved IWANT promises */\n iwantPromiseResolved: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_total',\n help: 'Total count of resolved IWANT promises'\n }),\n /** Total count of resolved IWANT promises from duplicate messages */\n iwantPromiseResolvedFromDuplicate: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_from_duplicate_total',\n help: 'Total count of resolved IWANT promises from duplicate messages'\n }),\n /** Total count of peers we have asked IWANT promises that are resolved */\n iwantPromiseResolvedPeers: register.gauge({\n name: 'gossipsub_iwant_promise_resolved_peers',\n help: 'Total count of peers we have asked IWANT promises that are resolved'\n }),\n iwantPromiseBroken: register.gauge({\n name: 'gossipsub_iwant_promise_broken',\n help: 'Total count of broken IWANT promises'\n }),\n iwantMessagePruned: register.gauge({\n name: 'gossipsub_iwant_message_pruned',\n help: 'Total count of pruned IWANT messages'\n }),\n /** Histogram of delivery time of resolved IWANT promises */\n iwantPromiseDeliveryTime: register.histogram({\n name: 'gossipsub_iwant_promise_delivery_seconds',\n help: 'Histogram of delivery time of resolved IWANT promises',\n buckets: [\n 0.5 * opts.gossipPromiseExpireSec,\n 1 * opts.gossipPromiseExpireSec,\n 2 * opts.gossipPromiseExpireSec,\n 4 * opts.gossipPromiseExpireSec\n ]\n }),\n iwantPromiseUntracked: register.gauge({\n name: 'gossip_iwant_promise_untracked',\n help: 'Total count of untracked IWANT promise'\n }),\n /** Backoff time */\n connectedPeersBackoffSec: register.histogram({\n name: 'gossipsub_connected_peers_backoff_seconds',\n help: 'Backoff time in seconds',\n // Using 1 seconds as minimum as that's close to the heartbeat duration, no need for more resolution.\n // As per spec, backoff times are 10 seconds for UnsubscribeBackoff and 60 seconds for PruneBackoff.\n // Higher values of 60 seconds should not occur, but we add 120 seconds just in case\n // https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#overview-of-new-parameters\n buckets: [1, 2, 4, 10, 20, 60, 120]\n }),\n /* Data structure sizes */\n /** Unbounded cache sizes */\n cacheSize: register.gauge({\n name: 'gossipsub_cache_size',\n help: 'Unbounded cache sizes',\n labelNames: ['cache']\n }),\n /** Current mcache msg count */\n mcacheSize: register.gauge({\n name: 'gossipsub_mcache_size',\n help: 'Current mcache msg count'\n }),\n mcacheNotValidatedCount: register.gauge({\n name: 'gossipsub_mcache_not_validated_count',\n help: 'Current mcache msg count not validated'\n }),\n fastMsgIdCacheCollision: register.gauge({\n name: 'gossipsub_fastmsgid_cache_collision_total',\n help: 'Total count of key collisions on fastmsgid cache put'\n }),\n newConnectionCount: register.gauge({\n name: 'gossipsub_new_connection_total',\n help: 'Total new connection by status',\n labelNames: ['status']\n }),\n topicStrToLabel: topicStrToLabel,\n toTopic(topicStr) {\n return this.topicStrToLabel.get(topicStr) ?? topicStr;\n },\n /** We joined a topic */\n onJoin(topicStr) {\n this.topicSubscriptionStatus.set({ topicStr }, 1);\n this.meshPeerCounts.set({ topicStr }, 0); // Reset count\n },\n /** We left a topic */\n onLeave(topicStr) {\n this.topicSubscriptionStatus.set({ topicStr }, 0);\n this.meshPeerCounts.set({ topicStr }, 0); // Reset count\n },\n /** Register the inclusion of peers in our mesh due to some reason. */\n onAddToMesh(topicStr, reason, count) {\n const topic = this.toTopic(topicStr);\n this.meshPeerInclusionEvents.inc({ reason }, count);\n this.meshPeerInclusionEventsByTopic.inc({ topic }, count);\n },\n /** Register the removal of peers in our mesh due to some reason */\n // - remove_peer_from_mesh()\n // - heartbeat() Churn::BadScore\n // - heartbeat() Churn::Excess\n // - on_disconnect() Churn::Ds\n onRemoveFromMesh(topicStr, reason, count) {\n const topic = this.toTopic(topicStr);\n this.meshPeerChurnEvents.inc({ reason }, count);\n this.meshPeerChurnEventsByTopic.inc({ topic }, count);\n },\n /**\n * Update validation result to metrics\n * @param messageRecord null means the message's mcache record was not known at the time of acceptance report\n */\n onReportValidation(messageRecord, acceptance, firstSeenTimestampMs) {\n this.asyncValidationMcacheHit.inc({ hit: messageRecord != null ? 'hit' : 'miss' });\n if (messageRecord != null) {\n const topic = this.toTopic(messageRecord.message.topic);\n this.asyncValidationResult.inc({ acceptance });\n this.asyncValidationResultByTopic.inc({ topic });\n }\n if (firstSeenTimestampMs != null) {\n this.asyncValidationDelayFromFirstSeenSec.observe((Date.now() - firstSeenTimestampMs) / 1000);\n }\n else {\n this.asyncValidationUnknownFirstSeen.inc();\n }\n },\n /**\n * - in handle_graft() Penalty::GraftBackoff\n * - in apply_iwant_penalties() Penalty::BrokenPromise\n * - in metric_score() P3 Penalty::MessageDeficit\n * - in metric_score() P6 Penalty::IPColocation\n */\n onScorePenalty(penalty) {\n // Can this be labeled by topic too?\n this.scoringPenalties.inc({ penalty }, 1);\n },\n onIhaveRcv(topicStr, ihave, idonthave) {\n const topic = this.toTopic(topicStr);\n this.ihaveRcvMsgids.inc({ topic }, ihave);\n this.ihaveRcvNotSeenMsgids.inc({ topic }, idonthave);\n },\n onIwantRcv(iwantByTopic, iwantDonthave) {\n for (const [topicStr, iwant] of iwantByTopic) {\n const topic = this.toTopic(topicStr);\n this.iwantRcvMsgids.inc({ topic }, iwant);\n }\n this.iwantRcvDonthaveMsgids.inc(iwantDonthave);\n },\n onForwardMsg(topicStr, tosendCount) {\n const topic = this.toTopic(topicStr);\n this.msgForwardCount.inc({ topic }, 1);\n this.msgForwardPeers.inc({ topic }, tosendCount);\n },\n onPublishMsg(topicStr, tosendGroupCount, tosendCount, dataLen) {\n const topic = this.toTopic(topicStr);\n this.msgPublishCount.inc({ topic }, 1);\n this.msgPublishBytes.inc({ topic }, tosendCount * dataLen);\n this.msgPublishPeersByTopic.inc({ topic }, tosendCount);\n this.msgPublishPeersByGroup.inc({ peerGroup: 'direct' }, tosendGroupCount.direct);\n this.msgPublishPeersByGroup.inc({ peerGroup: 'floodsub' }, tosendGroupCount.floodsub);\n this.msgPublishPeersByGroup.inc({ peerGroup: 'mesh' }, tosendGroupCount.mesh);\n this.msgPublishPeersByGroup.inc({ peerGroup: 'fanout' }, tosendGroupCount.fanout);\n },\n onMsgRecvPreValidation(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedPreValidation.inc({ topic }, 1);\n },\n onMsgRecvError(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedError.inc({ topic }, 1);\n },\n onMsgRecvResult(topicStr, status) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedTopic.inc({ topic });\n this.msgReceivedStatus.inc({ status });\n },\n onMsgRecvInvalid(topicStr, reason) {\n const topic = this.toTopic(topicStr);\n const error = reason.reason === _types_js__WEBPACK_IMPORTED_MODULE_0__.RejectReason.Error ? reason.error : reason.reason;\n this.msgReceivedInvalid.inc({ error }, 1);\n this.msgReceivedInvalidByTopic.inc({ topic }, 1);\n },\n onDuplicateMsgDelivery(topicStr, deliveryDelayMs, isLateDelivery) {\n this.duplicateMsgDeliveryDelay.observe(deliveryDelayMs / 1000);\n if (isLateDelivery) {\n const topic = this.toTopic(topicStr);\n this.duplicateMsgLateDelivery.inc({ topic }, 1);\n }\n },\n onPublishDuplicateMsg(topicStr) {\n const topic = this.toTopic(topicStr);\n this.duplicateMsgIgnored.inc({ topic }, 1);\n },\n onPeerReadStreamError() {\n this.peerReadStreamError.inc(1);\n },\n onRpcRecvError() {\n this.rpcRecvError.inc(1);\n },\n onRpcDataError() {\n this.rpcDataError.inc(1);\n },\n onRpcRecv(rpc, rpcBytes) {\n this.rpcRecvBytes.inc(rpcBytes);\n this.rpcRecvCount.inc(1);\n if (rpc.subscriptions)\n this.rpcRecvSubscription.inc(rpc.subscriptions.length);\n if (rpc.messages)\n this.rpcRecvMessage.inc(rpc.messages.length);\n if (rpc.control) {\n this.rpcRecvControl.inc(1);\n if (rpc.control.ihave)\n this.rpcRecvIHave.inc(rpc.control.ihave.length);\n if (rpc.control.iwant)\n this.rpcRecvIWant.inc(rpc.control.iwant.length);\n if (rpc.control.graft)\n this.rpcRecvGraft.inc(rpc.control.graft.length);\n if (rpc.control.prune)\n this.rpcRecvPrune.inc(rpc.control.prune.length);\n }\n },\n onRpcSent(rpc, rpcBytes) {\n this.rpcSentBytes.inc(rpcBytes);\n this.rpcSentCount.inc(1);\n if (rpc.subscriptions)\n this.rpcSentSubscription.inc(rpc.subscriptions.length);\n if (rpc.messages)\n this.rpcSentMessage.inc(rpc.messages.length);\n if (rpc.control) {\n const ihave = rpc.control.ihave?.length ?? 0;\n const iwant = rpc.control.iwant?.length ?? 0;\n const graft = rpc.control.graft?.length ?? 0;\n const prune = rpc.control.prune?.length ?? 0;\n if (ihave > 0)\n this.rpcSentIHave.inc(ihave);\n if (iwant > 0)\n this.rpcSentIWant.inc(iwant);\n if (graft > 0)\n this.rpcSentGraft.inc(graft);\n if (prune > 0)\n this.rpcSentPrune.inc(prune);\n if (ihave > 0 || iwant > 0 || graft > 0 || prune > 0)\n this.rpcSentControl.inc(1);\n }\n },\n registerScores(scores, scoreThresholds) {\n let graylist = 0;\n let publish = 0;\n let gossip = 0;\n let mesh = 0;\n for (const score of scores) {\n if (score >= scoreThresholds.graylistThreshold)\n graylist++;\n if (score >= scoreThresholds.publishThreshold)\n publish++;\n if (score >= scoreThresholds.gossipThreshold)\n gossip++;\n if (score >= 0)\n mesh++;\n }\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.graylist }, graylist);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.publish }, publish);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.gossip }, gossip);\n this.peersByScoreThreshold.set({ threshold: ScoreThreshold.mesh }, mesh);\n // Register full score too\n this.score.set(scores);\n },\n registerScoreWeights(sw) {\n for (const [topic, wsTopic] of sw.byTopic) {\n this.scoreWeights.set({ topic, p: 'p1' }, wsTopic.p1w);\n this.scoreWeights.set({ topic, p: 'p2' }, wsTopic.p2w);\n this.scoreWeights.set({ topic, p: 'p3' }, wsTopic.p3w);\n this.scoreWeights.set({ topic, p: 'p3b' }, wsTopic.p3bw);\n this.scoreWeights.set({ topic, p: 'p4' }, wsTopic.p4w);\n }\n this.scoreWeights.set({ p: 'p5' }, sw.p5w);\n this.scoreWeights.set({ p: 'p6' }, sw.p6w);\n this.scoreWeights.set({ p: 'p7' }, sw.p7w);\n },\n registerScorePerMesh(mesh, scoreByPeer) {\n const peersPerTopicLabel = new Map();\n mesh.forEach((peers, topicStr) => {\n // Aggregate by known topicLabel or throw to 'unknown'. This prevent too high cardinality\n const topicLabel = this.topicStrToLabel.get(topicStr) ?? 'unknown';\n let peersInMesh = peersPerTopicLabel.get(topicLabel);\n if (!peersInMesh) {\n peersInMesh = new Set();\n peersPerTopicLabel.set(topicLabel, peersInMesh);\n }\n peers.forEach((p) => peersInMesh?.add(p));\n });\n for (const [topic, peers] of peersPerTopicLabel) {\n const meshScores = [];\n peers.forEach((peer) => {\n meshScores.push(scoreByPeer.get(peer) ?? 0);\n });\n this.scorePerMesh.set({ topic }, meshScores);\n }\n }\n };\n}\n//# sourceMappingURL=metrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js ***! - \***********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ computeScore: () => (/* binding */ computeScore)\n/* harmony export */ });\nfunction computeScore(peer, pstats, params, peerIPs) {\n let score = 0;\n // topic stores\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n // the topic parameters\n const topicParams = params.topics[topic];\n if (topicParams === undefined) {\n // we are not scoring this topic\n return;\n }\n let topicScore = 0;\n // P1: time in Mesh\n if (tstats.inMesh) {\n let p1 = tstats.meshTime / topicParams.timeInMeshQuantum;\n if (p1 > topicParams.timeInMeshCap) {\n p1 = topicParams.timeInMeshCap;\n }\n topicScore += p1 * topicParams.timeInMeshWeight;\n }\n // P2: first message deliveries\n let p2 = tstats.firstMessageDeliveries;\n if (p2 > topicParams.firstMessageDeliveriesCap) {\n p2 = topicParams.firstMessageDeliveriesCap;\n }\n topicScore += p2 * topicParams.firstMessageDeliveriesWeight;\n // P3: mesh message deliveries\n if (tstats.meshMessageDeliveriesActive &&\n tstats.meshMessageDeliveries < topicParams.meshMessageDeliveriesThreshold) {\n const deficit = topicParams.meshMessageDeliveriesThreshold - tstats.meshMessageDeliveries;\n const p3 = deficit * deficit;\n topicScore += p3 * topicParams.meshMessageDeliveriesWeight;\n }\n // P3b:\n // NOTE: the weight of P3b is negative (validated in validateTopicScoreParams) so this detracts\n const p3b = tstats.meshFailurePenalty;\n topicScore += p3b * topicParams.meshFailurePenaltyWeight;\n // P4: invalid messages\n // NOTE: the weight of P4 is negative (validated in validateTopicScoreParams) so this detracts\n const p4 = tstats.invalidMessageDeliveries * tstats.invalidMessageDeliveries;\n topicScore += p4 * topicParams.invalidMessageDeliveriesWeight;\n // update score, mixing with topic weight\n score += topicScore * topicParams.topicWeight;\n });\n // apply the topic score cap, if any\n if (params.topicScoreCap > 0 && score > params.topicScoreCap) {\n score = params.topicScoreCap;\n }\n // P5: application-specific score\n const p5 = params.appSpecificScore(peer);\n score += p5 * params.appSpecificWeight;\n // P6: IP colocation factor\n pstats.knownIPs.forEach((ip) => {\n if (params.IPColocationFactorWhitelist.has(ip)) {\n return;\n }\n // P6 has a cliff (IPColocationFactorThreshold)\n // It's only applied if at least that many peers are connected to us from that source IP addr.\n // It is quadratic, and the weight is negative (validated in validatePeerScoreParams)\n const peersInIP = peerIPs.get(ip);\n const numPeersInIP = peersInIP ? peersInIP.size : 0;\n if (numPeersInIP > params.IPColocationFactorThreshold) {\n const surplus = numPeersInIP - params.IPColocationFactorThreshold;\n const p6 = surplus * surplus;\n score += p6 * params.IPColocationFactorWeight;\n }\n });\n // P7: behavioural pattern penalty\n if (pstats.behaviourPenalty > params.behaviourPenaltyThreshold) {\n const excess = pstats.behaviourPenalty - params.behaviourPenaltyThreshold;\n const p7 = excess * excess;\n score += p7 * params.behaviourPenaltyWeight;\n }\n return score;\n}\n//# sourceMappingURL=compute-score.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js ***! - \*******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ERR_INVALID_PEER_SCORE_PARAMS: () => (/* binding */ ERR_INVALID_PEER_SCORE_PARAMS),\n/* harmony export */ ERR_INVALID_PEER_SCORE_THRESHOLDS: () => (/* binding */ ERR_INVALID_PEER_SCORE_THRESHOLDS)\n/* harmony export */ });\nconst ERR_INVALID_PEER_SCORE_PARAMS = 'ERR_INVALID_PEER_SCORE_PARAMS';\nconst ERR_INVALID_PEER_SCORE_THRESHOLDS = 'ERR_INVALID_PEER_SCORE_THRESHOLDS';\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerScore: () => (/* reexport safe */ _peer_score_js__WEBPACK_IMPORTED_MODULE_2__.PeerScore),\n/* harmony export */ createPeerScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.createPeerScoreParams),\n/* harmony export */ createPeerScoreThresholds: () => (/* reexport safe */ _peer_score_thresholds_js__WEBPACK_IMPORTED_MODULE_1__.createPeerScoreThresholds),\n/* harmony export */ createTopicScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.createTopicScoreParams),\n/* harmony export */ defaultPeerScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.defaultPeerScoreParams),\n/* harmony export */ defaultPeerScoreThresholds: () => (/* reexport safe */ _peer_score_thresholds_js__WEBPACK_IMPORTED_MODULE_1__.defaultPeerScoreThresholds),\n/* harmony export */ defaultTopicScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.defaultTopicScoreParams),\n/* harmony export */ validatePeerScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.validatePeerScoreParams),\n/* harmony export */ validatePeerScoreThresholds: () => (/* reexport safe */ _peer_score_thresholds_js__WEBPACK_IMPORTED_MODULE_1__.validatePeerScoreThresholds),\n/* harmony export */ validateTopicScoreParams: () => (/* reexport safe */ _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.validateTopicScoreParams)\n/* harmony export */ });\n/* harmony import */ var _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./peer-score-params.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js\");\n/* harmony import */ var _peer_score_thresholds_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./peer-score-thresholds.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js\");\n/* harmony import */ var _peer_score_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./peer-score.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js": -/*!****************************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js ***! - \****************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DeliveryRecordStatus: () => (/* binding */ DeliveryRecordStatus),\n/* harmony export */ MessageDeliveries: () => (/* binding */ MessageDeliveries)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var denque__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! denque */ \"./node_modules/denque/index.js\");\n\n\nvar DeliveryRecordStatus;\n(function (DeliveryRecordStatus) {\n /**\n * we don't know (yet) if the message is valid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"unknown\"] = 0] = \"unknown\";\n /**\n * we know the message is valid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"valid\"] = 1] = \"valid\";\n /**\n * we know the message is invalid\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"invalid\"] = 2] = \"invalid\";\n /**\n * we were instructed by the validator to ignore the message\n */\n DeliveryRecordStatus[DeliveryRecordStatus[\"ignored\"] = 3] = \"ignored\";\n})(DeliveryRecordStatus || (DeliveryRecordStatus = {}));\n/**\n * Map of canonical message ID to DeliveryRecord\n *\n * Maintains an internal queue for efficient gc of old messages\n */\nclass MessageDeliveries {\n constructor() {\n this.records = new Map();\n this.queue = new denque__WEBPACK_IMPORTED_MODULE_1__();\n }\n getRecord(msgIdStr) {\n return this.records.get(msgIdStr);\n }\n ensureRecord(msgIdStr) {\n let drec = this.records.get(msgIdStr);\n if (drec) {\n return drec;\n }\n // record doesn't exist yet\n // create record\n drec = {\n status: DeliveryRecordStatus.unknown,\n firstSeenTsMs: Date.now(),\n validated: 0,\n peers: new Set()\n };\n this.records.set(msgIdStr, drec);\n // and add msgId to the queue\n const entry = {\n msgId: msgIdStr,\n expire: Date.now() + _constants_js__WEBPACK_IMPORTED_MODULE_0__.TimeCacheDuration\n };\n this.queue.push(entry);\n return drec;\n }\n gc() {\n const now = Date.now();\n // queue is sorted by expiry time\n // remove expired messages, remove from queue until first un-expired message found\n let head = this.queue.peekFront();\n while (head && head.expire < now) {\n this.records.delete(head.msgId);\n this.queue.shift();\n head = this.queue.peekFront();\n }\n }\n clear() {\n this.records.clear();\n this.queue.clear();\n }\n}\n//# sourceMappingURL=message-deliveries.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js": -/*!***************************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js ***! - \***************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerScoreParams: () => (/* binding */ createPeerScoreParams),\n/* harmony export */ createTopicScoreParams: () => (/* binding */ createTopicScoreParams),\n/* harmony export */ defaultPeerScoreParams: () => (/* binding */ defaultPeerScoreParams),\n/* harmony export */ defaultTopicScoreParams: () => (/* binding */ defaultTopicScoreParams),\n/* harmony export */ validatePeerScoreParams: () => (/* binding */ validatePeerScoreParams),\n/* harmony export */ validateTopicScoreParams: () => (/* binding */ validateTopicScoreParams)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\nconst defaultPeerScoreParams = {\n topics: {},\n topicScoreCap: 10.0,\n appSpecificScore: () => 0.0,\n appSpecificWeight: 10.0,\n IPColocationFactorWeight: -5.0,\n IPColocationFactorThreshold: 10.0,\n IPColocationFactorWhitelist: new Set(),\n behaviourPenaltyWeight: -10.0,\n behaviourPenaltyThreshold: 0.0,\n behaviourPenaltyDecay: 0.2,\n decayInterval: 1000.0,\n decayToZero: 0.1,\n retainScore: 3600 * 1000\n};\nconst defaultTopicScoreParams = {\n topicWeight: 0.5,\n timeInMeshWeight: 1,\n timeInMeshQuantum: 1,\n timeInMeshCap: 3600,\n firstMessageDeliveriesWeight: 1,\n firstMessageDeliveriesDecay: 0.5,\n firstMessageDeliveriesCap: 2000,\n meshMessageDeliveriesWeight: -1,\n meshMessageDeliveriesDecay: 0.5,\n meshMessageDeliveriesCap: 100,\n meshMessageDeliveriesThreshold: 20,\n meshMessageDeliveriesWindow: 10,\n meshMessageDeliveriesActivation: 5000,\n meshFailurePenaltyWeight: -1,\n meshFailurePenaltyDecay: 0.5,\n invalidMessageDeliveriesWeight: -1,\n invalidMessageDeliveriesDecay: 0.3\n};\nfunction createPeerScoreParams(p = {}) {\n return {\n ...defaultPeerScoreParams,\n ...p,\n topics: p.topics\n ? Object.entries(p.topics).reduce((topics, [topic, topicScoreParams]) => {\n topics[topic] = createTopicScoreParams(topicScoreParams);\n return topics;\n }, {})\n : {}\n };\n}\nfunction createTopicScoreParams(p = {}) {\n return {\n ...defaultTopicScoreParams,\n ...p\n };\n}\n// peer score parameter validation\nfunction validatePeerScoreParams(p) {\n for (const [topic, params] of Object.entries(p.topics)) {\n try {\n validateTopicScoreParams(params);\n }\n catch (e) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`invalid score parameters for topic ${topic}: ${e.message}`, _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n }\n // check that the topic score is 0 or something positive\n if (p.topicScoreCap < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid topic score cap; must be positive (or 0 for no cap)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check that we have an app specific score; the weight can be anything (but expected positive)\n if (p.appSpecificScore === null || p.appSpecificScore === undefined) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('missing application specific score function', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the IP colocation factor\n if (p.IPColocationFactorWeight > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid IPColocationFactorWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.IPColocationFactorWeight !== 0 && p.IPColocationFactorThreshold < 1) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid IPColocationFactorThreshold; must be at least 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the behaviour penalty\n if (p.behaviourPenaltyWeight > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.behaviourPenaltyWeight !== 0 && (p.behaviourPenaltyDecay <= 0 || p.behaviourPenaltyDecay >= 1)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid BehaviourPenaltyDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check the decay parameters\n if (p.decayInterval < 1000) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid DecayInterval; must be at least 1s', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.decayToZero <= 0 || p.decayToZero >= 1) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid DecayToZero; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // no need to check the score retention; a value of 0 means that we don't retain scores\n}\nfunction validateTopicScoreParams(p) {\n // make sure we have a sane topic weight\n if (p.topicWeight < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid topic weight; must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P1\n if (p.timeInMeshQuantum === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid TimeInMeshQuantum; must be non zero', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid TimeInMeshWeight; must be positive (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight !== 0 && p.timeInMeshQuantum <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid TimeInMeshQuantum; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.timeInMeshWeight !== 0 && p.timeInMeshCap <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid TimeInMeshCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P2\n if (p.firstMessageDeliveriesWeight < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.firstMessageDeliveriesWeight !== 0 &&\n (p.firstMessageDeliveriesDecay <= 0 || p.firstMessageDeliveriesDecay >= 1)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid FirstMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.firstMessageDeliveriesWeight !== 0 && p.firstMessageDeliveriesCap <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid FirstMessageDeliveriesCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P3\n if (p.meshMessageDeliveriesWeight > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && (p.meshMessageDeliveriesDecay <= 0 || p.meshMessageDeliveriesDecay >= 1)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesCap <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesCap; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesThreshold <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesThreshold; must be positive', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWindow < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesWindow; must be non-negative', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshMessageDeliveriesWeight !== 0 && p.meshMessageDeliveriesActivation < 1000) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshMessageDeliveriesActivation; must be at least 1s', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P3b\n if (p.meshFailurePenaltyWeight > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.meshFailurePenaltyWeight !== 0 && (p.meshFailurePenaltyDecay <= 0 || p.meshFailurePenaltyDecay >= 1)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid MeshFailurePenaltyDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n // check P4\n if (p.invalidMessageDeliveriesWeight > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n if (p.invalidMessageDeliveriesDecay <= 0 || p.invalidMessageDeliveriesDecay >= 1) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid InvalidMessageDeliveriesDecay; must be between 0 and 1', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_PARAMS);\n }\n}\n//# sourceMappingURL=peer-score-params.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js": -/*!*******************************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js ***! - \*******************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPeerScoreThresholds: () => (/* binding */ createPeerScoreThresholds),\n/* harmony export */ defaultPeerScoreThresholds: () => (/* binding */ defaultPeerScoreThresholds),\n/* harmony export */ validatePeerScoreThresholds: () => (/* binding */ validatePeerScoreThresholds)\n/* harmony export */ });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\nconst defaultPeerScoreThresholds = {\n gossipThreshold: -10,\n publishThreshold: -50,\n graylistThreshold: -80,\n acceptPXThreshold: 10,\n opportunisticGraftThreshold: 20\n};\nfunction createPeerScoreThresholds(p = {}) {\n return {\n ...defaultPeerScoreThresholds,\n ...p\n };\n}\nfunction validatePeerScoreThresholds(p) {\n if (p.gossipThreshold > 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid gossip threshold; it must be <= 0', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.publishThreshold > 0 || p.publishThreshold > p.gossipThreshold) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid publish threshold; it must be <= 0 and <= gossip threshold', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.graylistThreshold > 0 || p.graylistThreshold > p.publishThreshold) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid graylist threshold; it must be <= 0 and <= publish threshold', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.acceptPXThreshold < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid accept PX threshold; it must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n if (p.opportunisticGraftThreshold < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid opportunistic grafting threshold; it must be >= 0', _constants_js__WEBPACK_IMPORTED_MODULE_0__.ERR_INVALID_PEER_SCORE_THRESHOLDS);\n }\n}\n//# sourceMappingURL=peer-score-thresholds.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js ***! - \********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerScore: () => (/* binding */ PeerScore)\n/* harmony export */ });\n/* harmony import */ var _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./peer-score-params.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js\");\n/* harmony import */ var _compute_score_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compute-score.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js\");\n/* harmony import */ var _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./message-deliveries.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/set.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.logger)('libp2p:gossipsub:score');\nclass PeerScore {\n constructor(params, metrics, opts) {\n this.params = params;\n this.metrics = metrics;\n /**\n * Per-peer stats for score calculation\n */\n this.peerStats = new Map();\n /**\n * IP colocation tracking; maps IP => set of peers.\n */\n this.peerIPs = new _utils_set_js__WEBPACK_IMPORTED_MODULE_5__.MapDef(() => new Set());\n /**\n * Cache score up to decayInterval if topic stats are unchanged.\n */\n this.scoreCache = new Map();\n /**\n * Recent message delivery timing/participants\n */\n this.deliveryRecords = new _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.MessageDeliveries();\n (0,_peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__.validatePeerScoreParams)(params);\n this.scoreCacheValidityMs = opts.scoreCacheValidityMs;\n this.computeScore = opts.computeScore ?? _compute_score_js__WEBPACK_IMPORTED_MODULE_1__.computeScore;\n }\n get size() {\n return this.peerStats.size;\n }\n /**\n * Start PeerScore instance\n */\n start() {\n if (this._backgroundInterval) {\n log('Peer score already running');\n return;\n }\n this._backgroundInterval = setInterval(() => this.background(), this.params.decayInterval);\n log('started');\n }\n /**\n * Stop PeerScore instance\n */\n stop() {\n if (!this._backgroundInterval) {\n log('Peer score already stopped');\n return;\n }\n clearInterval(this._backgroundInterval);\n delete this._backgroundInterval;\n this.peerIPs.clear();\n this.peerStats.clear();\n this.deliveryRecords.clear();\n log('stopped');\n }\n /**\n * Periodic maintenance\n */\n background() {\n this.refreshScores();\n this.deliveryRecords.gc();\n }\n dumpPeerScoreStats() {\n return Object.fromEntries(Array.from(this.peerStats.entries()).map(([peer, stats]) => [peer, stats]));\n }\n messageFirstSeenTimestampMs(msgIdStr) {\n const drec = this.deliveryRecords.getRecord(msgIdStr);\n return drec ? drec.firstSeenTsMs : null;\n }\n /**\n * Decays scores, and purges score records for disconnected peers once their expiry has elapsed.\n */\n refreshScores() {\n const now = Date.now();\n const decayToZero = this.params.decayToZero;\n this.peerStats.forEach((pstats, id) => {\n if (!pstats.connected) {\n // has the retention period expired?\n if (now > pstats.expire) {\n // yes, throw it away (but clean up the IP tracking first)\n this.removeIPsForPeer(id, pstats.knownIPs);\n this.peerStats.delete(id);\n this.scoreCache.delete(id);\n }\n // we don't decay retained scores, as the peer is not active.\n // this way the peer cannot reset a negative score by simply disconnecting and reconnecting,\n // unless the retention period has elapsed.\n // similarly, a well behaved peer does not lose its score by getting disconnected.\n return;\n }\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n const tparams = this.params.topics[topic];\n if (tparams === undefined) {\n // we are not scoring this topic\n // should be unreachable, we only add scored topics to pstats\n return;\n }\n // decay counters\n tstats.firstMessageDeliveries *= tparams.firstMessageDeliveriesDecay;\n if (tstats.firstMessageDeliveries < decayToZero) {\n tstats.firstMessageDeliveries = 0;\n }\n tstats.meshMessageDeliveries *= tparams.meshMessageDeliveriesDecay;\n if (tstats.meshMessageDeliveries < decayToZero) {\n tstats.meshMessageDeliveries = 0;\n }\n tstats.meshFailurePenalty *= tparams.meshFailurePenaltyDecay;\n if (tstats.meshFailurePenalty < decayToZero) {\n tstats.meshFailurePenalty = 0;\n }\n tstats.invalidMessageDeliveries *= tparams.invalidMessageDeliveriesDecay;\n if (tstats.invalidMessageDeliveries < decayToZero) {\n tstats.invalidMessageDeliveries = 0;\n }\n // update mesh time and activate mesh message delivery parameter if need be\n if (tstats.inMesh) {\n tstats.meshTime = now - tstats.graftTime;\n if (tstats.meshTime > tparams.meshMessageDeliveriesActivation) {\n tstats.meshMessageDeliveriesActive = true;\n }\n }\n });\n // decay P7 counter\n pstats.behaviourPenalty *= this.params.behaviourPenaltyDecay;\n if (pstats.behaviourPenalty < decayToZero) {\n pstats.behaviourPenalty = 0;\n }\n });\n }\n /**\n * Return the score for a peer\n */\n score(id) {\n this.metrics?.scoreFnCalls.inc();\n const pstats = this.peerStats.get(id);\n if (!pstats) {\n return 0;\n }\n const now = Date.now();\n const cacheEntry = this.scoreCache.get(id);\n // Found cached score within validity period\n if (cacheEntry && cacheEntry.cacheUntil > now) {\n return cacheEntry.score;\n }\n this.metrics?.scoreFnRuns.inc();\n const score = this.computeScore(id, pstats, this.params, this.peerIPs);\n const cacheUntil = now + this.scoreCacheValidityMs;\n if (cacheEntry) {\n this.metrics?.scoreCachedDelta.observe(Math.abs(score - cacheEntry.score));\n cacheEntry.score = score;\n cacheEntry.cacheUntil = cacheUntil;\n }\n else {\n this.scoreCache.set(id, { score, cacheUntil });\n }\n return score;\n }\n /**\n * Apply a behavioural penalty to a peer\n */\n addPenalty(id, penalty, penaltyLabel) {\n const pstats = this.peerStats.get(id);\n if (pstats) {\n pstats.behaviourPenalty += penalty;\n this.metrics?.onScorePenalty(penaltyLabel);\n }\n }\n addPeer(id) {\n // create peer stats (not including topic stats for each topic to be scored)\n // topic stats will be added as needed\n const pstats = {\n connected: true,\n expire: 0,\n topics: {},\n knownIPs: new Set(),\n behaviourPenalty: 0\n };\n this.peerStats.set(id, pstats);\n }\n /** Adds a new IP to a peer, if the peer is not known the update is ignored */\n addIP(id, ip) {\n const pstats = this.peerStats.get(id);\n if (pstats) {\n pstats.knownIPs.add(ip);\n }\n this.peerIPs.getOrDefault(ip).add(id);\n }\n /** Remove peer association with IP */\n removeIP(id, ip) {\n const pstats = this.peerStats.get(id);\n if (pstats) {\n pstats.knownIPs.delete(ip);\n }\n const peersWithIP = this.peerIPs.get(ip);\n if (peersWithIP) {\n peersWithIP.delete(id);\n if (peersWithIP.size === 0) {\n this.peerIPs.delete(ip);\n }\n }\n }\n removePeer(id) {\n const pstats = this.peerStats.get(id);\n if (!pstats) {\n return;\n }\n // decide whether to retain the score; this currently only retains non-positive scores\n // to dissuade attacks on the score function.\n if (this.score(id) > 0) {\n this.removeIPsForPeer(id, pstats.knownIPs);\n this.peerStats.delete(id);\n return;\n }\n // furthermore, when we decide to retain the score, the firstMessageDelivery counters are\n // reset to 0 and mesh delivery penalties applied.\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n tstats.firstMessageDeliveries = 0;\n const threshold = this.params.topics[topic].meshMessageDeliveriesThreshold;\n if (tstats.inMesh && tstats.meshMessageDeliveriesActive && tstats.meshMessageDeliveries < threshold) {\n const deficit = threshold - tstats.meshMessageDeliveries;\n tstats.meshFailurePenalty += deficit * deficit;\n }\n tstats.inMesh = false;\n tstats.meshMessageDeliveriesActive = false;\n });\n pstats.connected = false;\n pstats.expire = Date.now() + this.params.retainScore;\n }\n /** Handles scoring functionality as a peer GRAFTs to a topic. */\n graft(id, topic) {\n const pstats = this.peerStats.get(id);\n if (pstats) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats) {\n // if we are scoring the topic, update the mesh status.\n tstats.inMesh = true;\n tstats.graftTime = Date.now();\n tstats.meshTime = 0;\n tstats.meshMessageDeliveriesActive = false;\n }\n }\n }\n /** Handles scoring functionality as a peer PRUNEs from a topic. */\n prune(id, topic) {\n const pstats = this.peerStats.get(id);\n if (pstats) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats) {\n // sticky mesh delivery rate failure penalty\n const threshold = this.params.topics[topic].meshMessageDeliveriesThreshold;\n if (tstats.meshMessageDeliveriesActive && tstats.meshMessageDeliveries < threshold) {\n const deficit = threshold - tstats.meshMessageDeliveries;\n tstats.meshFailurePenalty += deficit * deficit;\n }\n tstats.meshMessageDeliveriesActive = false;\n tstats.inMesh = false;\n // TODO: Consider clearing score cache on important penalties\n // this.scoreCache.delete(id)\n }\n }\n }\n validateMessage(msgIdStr) {\n this.deliveryRecords.ensureRecord(msgIdStr);\n }\n deliverMessage(from, msgIdStr, topic) {\n this.markFirstMessageDelivery(from, topic);\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n const now = Date.now();\n // defensive check that this is the first delivery trace -- delivery status should be unknown\n if (drec.status !== _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.unknown) {\n log('unexpected delivery: message from %s was first seen %s ago and has delivery status %s', from, now - drec.firstSeenTsMs, _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus[drec.status]);\n return;\n }\n // mark the message as valid and reward mesh peers that have already forwarded it to us\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.valid;\n drec.validated = now;\n drec.peers.forEach((p) => {\n // this check is to make sure a peer can't send us a message twice and get a double count\n // if it is a first delivery.\n if (p !== from.toString()) {\n this.markDuplicateMessageDelivery(p, topic);\n }\n });\n }\n /**\n * Similar to `rejectMessage` except does not require the message id or reason for an invalid message.\n */\n rejectInvalidMessage(from, topic) {\n this.markInvalidMessageDelivery(from, topic);\n }\n rejectMessage(from, msgIdStr, topic, reason) {\n switch (reason) {\n // these messages are not tracked, but the peer is penalized as they are invalid\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Error:\n this.markInvalidMessageDelivery(from, topic);\n return;\n // we ignore those messages, so do nothing.\n case _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Blacklisted:\n return;\n // the rest are handled after record creation\n }\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n // defensive check that this is the first rejection -- delivery status should be unknown\n if (drec.status !== _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.unknown) {\n log('unexpected rejection: message from %s was first seen %s ago and has delivery status %d', from, Date.now() - drec.firstSeenTsMs, _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus[drec.status]);\n return;\n }\n if (reason === _types_js__WEBPACK_IMPORTED_MODULE_4__.RejectReason.Ignore) {\n // we were explicitly instructed by the validator to ignore the message but not penalize the peer\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.ignored;\n drec.peers.clear();\n return;\n }\n // mark the message as invalid and penalize peers that have already forwarded it.\n drec.status = _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.invalid;\n this.markInvalidMessageDelivery(from, topic);\n drec.peers.forEach((p) => {\n this.markInvalidMessageDelivery(p, topic);\n });\n // release the delivery time tracking map to free some memory early\n drec.peers.clear();\n }\n duplicateMessage(from, msgIdStr, topic) {\n const drec = this.deliveryRecords.ensureRecord(msgIdStr);\n if (drec.peers.has(from)) {\n // we have already seen this duplicate\n return;\n }\n switch (drec.status) {\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.unknown:\n // the message is being validated; track the peer delivery and wait for\n // the Deliver/Reject/Ignore notification.\n drec.peers.add(from);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.valid:\n // mark the peer delivery time to only count a duplicate delivery once.\n drec.peers.add(from);\n this.markDuplicateMessageDelivery(from, topic, drec.validated);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.invalid:\n // we no longer track delivery time\n this.markInvalidMessageDelivery(from, topic);\n break;\n case _message_deliveries_js__WEBPACK_IMPORTED_MODULE_2__.DeliveryRecordStatus.ignored:\n // the message was ignored; do nothing (we don't know if it was valid)\n break;\n }\n }\n /**\n * Increments the \"invalid message deliveries\" counter for all scored topics the message is published in.\n */\n markInvalidMessageDelivery(from, topic) {\n const pstats = this.peerStats.get(from);\n if (pstats) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats) {\n tstats.invalidMessageDeliveries += 1;\n }\n }\n }\n /**\n * Increments the \"first message deliveries\" counter for all scored topics the message is published in,\n * as well as the \"mesh message deliveries\" counter, if the peer is in the mesh for the topic.\n * Messages already known (with the seenCache) are counted with markDuplicateMessageDelivery()\n */\n markFirstMessageDelivery(from, topic) {\n const pstats = this.peerStats.get(from);\n if (pstats) {\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats) {\n let cap = this.params.topics[topic].firstMessageDeliveriesCap;\n tstats.firstMessageDeliveries = Math.min(cap, tstats.firstMessageDeliveries + 1);\n if (tstats.inMesh) {\n cap = this.params.topics[topic].meshMessageDeliveriesCap;\n tstats.meshMessageDeliveries = Math.min(cap, tstats.meshMessageDeliveries + 1);\n }\n }\n }\n }\n /**\n * Increments the \"mesh message deliveries\" counter for messages we've seen before,\n * as long the message was received within the P3 window.\n */\n markDuplicateMessageDelivery(from, topic, validatedTime) {\n const pstats = this.peerStats.get(from);\n if (pstats) {\n const now = validatedTime !== undefined ? Date.now() : 0;\n const tstats = this.getPtopicStats(pstats, topic);\n if (tstats && tstats.inMesh) {\n const tparams = this.params.topics[topic];\n // check against the mesh delivery window -- if the validated time is passed as 0, then\n // the message was received before we finished validation and thus falls within the mesh\n // delivery window.\n if (validatedTime !== undefined) {\n const deliveryDelayMs = now - validatedTime;\n const isLateDelivery = deliveryDelayMs > tparams.meshMessageDeliveriesWindow;\n this.metrics?.onDuplicateMsgDelivery(topic, deliveryDelayMs, isLateDelivery);\n if (isLateDelivery) {\n return;\n }\n }\n const cap = tparams.meshMessageDeliveriesCap;\n tstats.meshMessageDeliveries = Math.min(cap, tstats.meshMessageDeliveries + 1);\n }\n }\n }\n /**\n * Removes an IP list from the tracking list for a peer.\n */\n removeIPsForPeer(id, ipsToRemove) {\n for (const ipToRemove of ipsToRemove) {\n const peerSet = this.peerIPs.get(ipToRemove);\n if (peerSet) {\n peerSet.delete(id);\n if (peerSet.size === 0) {\n this.peerIPs.delete(ipToRemove);\n }\n }\n }\n }\n /**\n * Returns topic stats if they exist, otherwise if the supplied parameters score the\n * topic, inserts the default stats and returns a reference to those. If neither apply, returns None.\n */\n getPtopicStats(pstats, topic) {\n let topicStats = pstats.topics[topic];\n if (topicStats !== undefined) {\n return topicStats;\n }\n if (this.params.topics[topic] !== undefined) {\n topicStats = {\n inMesh: false,\n graftTime: 0,\n meshTime: 0,\n firstMessageDeliveries: 0,\n meshMessageDeliveries: 0,\n meshMessageDeliveriesActive: false,\n meshFailurePenalty: 0,\n invalidMessageDeliveries: 0\n };\n pstats.topics[topic] = topicStats;\n return topicStats;\n }\n return null;\n }\n}\n//# sourceMappingURL=peer-score.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js ***! - \**********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ computeAllPeersScoreWeights: () => (/* binding */ computeAllPeersScoreWeights),\n/* harmony export */ computeScoreWeights: () => (/* binding */ computeScoreWeights)\n/* harmony export */ });\nfunction computeScoreWeights(peer, pstats, params, peerIPs, topicStrToLabel) {\n let score = 0;\n const byTopic = new Map();\n // topic stores\n Object.entries(pstats.topics).forEach(([topic, tstats]) => {\n // the topic parameters\n // Aggregate by known topicLabel or throw to 'unknown'. This prevent too high cardinality\n const topicLabel = topicStrToLabel.get(topic) ?? 'unknown';\n const topicParams = params.topics[topic];\n if (topicParams === undefined) {\n // we are not scoring this topic\n return;\n }\n let topicScores = byTopic.get(topicLabel);\n if (!topicScores) {\n topicScores = {\n p1w: 0,\n p2w: 0,\n p3w: 0,\n p3bw: 0,\n p4w: 0\n };\n byTopic.set(topicLabel, topicScores);\n }\n let p1w = 0;\n let p2w = 0;\n let p3w = 0;\n let p3bw = 0;\n let p4w = 0;\n // P1: time in Mesh\n if (tstats.inMesh) {\n const p1 = Math.max(tstats.meshTime / topicParams.timeInMeshQuantum, topicParams.timeInMeshCap);\n p1w += p1 * topicParams.timeInMeshWeight;\n }\n // P2: first message deliveries\n let p2 = tstats.firstMessageDeliveries;\n if (p2 > topicParams.firstMessageDeliveriesCap) {\n p2 = topicParams.firstMessageDeliveriesCap;\n }\n p2w += p2 * topicParams.firstMessageDeliveriesWeight;\n // P3: mesh message deliveries\n if (tstats.meshMessageDeliveriesActive &&\n tstats.meshMessageDeliveries < topicParams.meshMessageDeliveriesThreshold) {\n const deficit = topicParams.meshMessageDeliveriesThreshold - tstats.meshMessageDeliveries;\n const p3 = deficit * deficit;\n p3w += p3 * topicParams.meshMessageDeliveriesWeight;\n }\n // P3b:\n // NOTE: the weight of P3b is negative (validated in validateTopicScoreParams) so this detracts\n const p3b = tstats.meshFailurePenalty;\n p3bw += p3b * topicParams.meshFailurePenaltyWeight;\n // P4: invalid messages\n // NOTE: the weight of P4 is negative (validated in validateTopicScoreParams) so this detracts\n const p4 = tstats.invalidMessageDeliveries * tstats.invalidMessageDeliveries;\n p4w += p4 * topicParams.invalidMessageDeliveriesWeight;\n // update score, mixing with topic weight\n score += (p1w + p2w + p3w + p3bw + p4w) * topicParams.topicWeight;\n topicScores.p1w += p1w;\n topicScores.p2w += p2w;\n topicScores.p3w += p3w;\n topicScores.p3bw += p3bw;\n topicScores.p4w += p4w;\n });\n // apply the topic score cap, if any\n if (params.topicScoreCap > 0 && score > params.topicScoreCap) {\n score = params.topicScoreCap;\n // Proportionally apply cap to all individual contributions\n const capF = params.topicScoreCap / score;\n for (const ws of byTopic.values()) {\n ws.p1w *= capF;\n ws.p2w *= capF;\n ws.p3w *= capF;\n ws.p3bw *= capF;\n ws.p4w *= capF;\n }\n }\n let p5w = 0;\n let p6w = 0;\n let p7w = 0;\n // P5: application-specific score\n const p5 = params.appSpecificScore(peer);\n p5w += p5 * params.appSpecificWeight;\n // P6: IP colocation factor\n pstats.knownIPs.forEach((ip) => {\n if (params.IPColocationFactorWhitelist.has(ip)) {\n return;\n }\n // P6 has a cliff (IPColocationFactorThreshold)\n // It's only applied if at least that many peers are connected to us from that source IP addr.\n // It is quadratic, and the weight is negative (validated in validatePeerScoreParams)\n const peersInIP = peerIPs.get(ip);\n const numPeersInIP = peersInIP ? peersInIP.size : 0;\n if (numPeersInIP > params.IPColocationFactorThreshold) {\n const surplus = numPeersInIP - params.IPColocationFactorThreshold;\n const p6 = surplus * surplus;\n p6w += p6 * params.IPColocationFactorWeight;\n }\n });\n // P7: behavioural pattern penalty\n const p7 = pstats.behaviourPenalty * pstats.behaviourPenalty;\n p7w += p7 * params.behaviourPenaltyWeight;\n score += p5w + p6w + p7w;\n return {\n byTopic,\n p5w,\n p6w,\n p7w,\n score\n };\n}\nfunction computeAllPeersScoreWeights(peerIdStrs, peerStats, params, peerIPs, topicStrToLabel) {\n const sw = {\n byTopic: new Map(),\n p5w: [],\n p6w: [],\n p7w: [],\n score: []\n };\n for (const peerIdStr of peerIdStrs) {\n const pstats = peerStats.get(peerIdStr);\n if (pstats) {\n const swPeer = computeScoreWeights(peerIdStr, pstats, params, peerIPs, topicStrToLabel);\n for (const [topic, swPeerTopic] of swPeer.byTopic) {\n let swTopic = sw.byTopic.get(topic);\n if (!swTopic) {\n swTopic = {\n p1w: [],\n p2w: [],\n p3w: [],\n p3bw: [],\n p4w: []\n };\n sw.byTopic.set(topic, swTopic);\n }\n swTopic.p1w.push(swPeerTopic.p1w);\n swTopic.p2w.push(swPeerTopic.p2w);\n swTopic.p3w.push(swPeerTopic.p3w);\n swTopic.p3bw.push(swPeerTopic.p3bw);\n swTopic.p4w.push(swPeerTopic.p4w);\n }\n sw.p5w.push(swPeer.p5w);\n sw.p6w.push(swPeer.p6w);\n sw.p7w.push(swPeer.p7w);\n sw.score.push(swPeer.score);\n }\n else {\n sw.p5w.push(0);\n sw.p6w.push(0);\n sw.p7w.push(0);\n sw.score.push(0);\n }\n }\n return sw;\n}\n//# sourceMappingURL=scoreMetrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InboundStream: () => (/* binding */ InboundStream),\n/* harmony export */ OutboundStream: () => (/* binding */ OutboundStream)\n/* harmony export */ });\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n\n\n\n\nclass OutboundStream {\n constructor(rawStream, errCallback, opts) {\n this.rawStream = rawStream;\n this.pushable = (0,it_pushable__WEBPACK_IMPORTED_MODULE_2__.pushable)({ objectMode: false });\n this.closeController = new AbortController();\n this.maxBufferSize = opts.maxBufferSize ?? Infinity;\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)((0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(this.pushable, this.closeController.signal, { returnOnAbort: true }), (source) => (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode)(source), this.rawStream).catch(errCallback);\n }\n get protocol() {\n // TODO remove this non-nullish assertion after https://github.com/libp2p/js-libp2p-interfaces/pull/265 is incorporated\n return this.rawStream.stat.protocol;\n }\n push(data) {\n if (this.pushable.readableLength > this.maxBufferSize) {\n throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);\n }\n this.pushable.push(data);\n }\n close() {\n this.closeController.abort();\n // similar to pushable.end() but clear the internal buffer\n this.pushable.return();\n this.rawStream.close();\n }\n}\nclass InboundStream {\n constructor(rawStream, opts = {}) {\n this.rawStream = rawStream;\n this.closeController = new AbortController();\n this.source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)((0,it_pipe__WEBPACK_IMPORTED_MODULE_1__.pipe)(this.rawStream, (source) => (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)(source, opts)), this.closeController.signal, {\n returnOnAbort: true\n });\n }\n close() {\n this.closeController.abort();\n this.rawStream.close();\n }\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ IWantTracer: () => (/* binding */ IWantTracer)\n/* harmony export */ });\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n/**\n * IWantTracer is an internal tracer that tracks IWANT requests in order to penalize\n * peers who don't follow up on IWANT requests after an IHAVE advertisement.\n * The tracking of promises is probabilistic to avoid using too much memory.\n *\n * Note: Do not confuse these 'promises' with JS Promise objects.\n * These 'promises' are merely expectations of a peer's behavior.\n */\nclass IWantTracer {\n constructor(gossipsubIWantFollowupMs, msgIdToStrFn, metrics) {\n this.gossipsubIWantFollowupMs = gossipsubIWantFollowupMs;\n this.msgIdToStrFn = msgIdToStrFn;\n this.metrics = metrics;\n /**\n * Promises to deliver a message\n * Map per message id, per peer, promise expiration time\n */\n this.promises = new Map();\n /**\n * First request time by msgId. Used for metrics to track expire times.\n * Necessary to know if peers are actually breaking promises or simply sending them a bit later\n */\n this.requestMsByMsg = new Map();\n this.requestMsByMsgExpire = 10 * gossipsubIWantFollowupMs;\n }\n get size() {\n return this.promises.size;\n }\n get requestMsByMsgSize() {\n return this.requestMsByMsg.size;\n }\n /**\n * Track a promise to deliver a message from a list of msgIds we are requesting\n */\n addPromise(from, msgIds) {\n // pick msgId randomly from the list\n const ix = Math.floor(Math.random() * msgIds.length);\n const msgId = msgIds[ix];\n const msgIdStr = this.msgIdToStrFn(msgId);\n let expireByPeer = this.promises.get(msgIdStr);\n if (!expireByPeer) {\n expireByPeer = new Map();\n this.promises.set(msgIdStr, expireByPeer);\n }\n const now = Date.now();\n // If a promise for this message id and peer already exists we don't update the expiry\n if (!expireByPeer.has(from)) {\n expireByPeer.set(from, now + this.gossipsubIWantFollowupMs);\n if (this.metrics) {\n this.metrics.iwantPromiseStarted.inc(1);\n if (!this.requestMsByMsg.has(msgIdStr)) {\n this.requestMsByMsg.set(msgIdStr, now);\n }\n }\n }\n }\n /**\n * Returns the number of broken promises for each peer who didn't follow up on an IWANT request.\n *\n * This should be called not too often relative to the expire times, since it iterates over the whole data.\n */\n getBrokenPromises() {\n const now = Date.now();\n const result = new Map();\n let brokenPromises = 0;\n this.promises.forEach((expireByPeer, msgId) => {\n expireByPeer.forEach((expire, p) => {\n // the promise has been broken\n if (expire < now) {\n // add 1 to result\n result.set(p, (result.get(p) ?? 0) + 1);\n // delete from tracked promises\n expireByPeer.delete(p);\n // for metrics\n brokenPromises++;\n }\n });\n // clean up empty promises for a msgId\n if (!expireByPeer.size) {\n this.promises.delete(msgId);\n }\n });\n this.metrics?.iwantPromiseBroken.inc(brokenPromises);\n return result;\n }\n /**\n * Someone delivered a message, stop tracking promises for it\n */\n deliverMessage(msgIdStr, isDuplicate = false) {\n this.trackMessage(msgIdStr);\n const expireByPeer = this.promises.get(msgIdStr);\n // Expired promise, check requestMsByMsg\n if (expireByPeer) {\n this.promises.delete(msgIdStr);\n if (this.metrics) {\n this.metrics.iwantPromiseResolved.inc(1);\n if (isDuplicate)\n this.metrics.iwantPromiseResolvedFromDuplicate.inc(1);\n this.metrics.iwantPromiseResolvedPeers.inc(expireByPeer.size);\n }\n }\n }\n /**\n * A message got rejected, so we can stop tracking promises and let the score penalty apply from invalid message delivery,\n * unless its an obviously invalid message.\n */\n rejectMessage(msgIdStr, reason) {\n this.trackMessage(msgIdStr);\n // A message got rejected, so we can stop tracking promises and let the score penalty apply.\n // With the expection of obvious invalid messages\n switch (reason) {\n case _types_js__WEBPACK_IMPORTED_MODULE_0__.RejectReason.Error:\n return;\n }\n this.promises.delete(msgIdStr);\n }\n clear() {\n this.promises.clear();\n }\n prune() {\n const maxMs = Date.now() - this.requestMsByMsgExpire;\n let count = 0;\n for (const [k, v] of this.requestMsByMsg.entries()) {\n if (v < maxMs) {\n // messages that stay too long in the requestMsByMsg map, delete\n this.requestMsByMsg.delete(k);\n count++;\n }\n else {\n // recent messages, keep them\n // sort by insertion order\n break;\n }\n }\n this.metrics?.iwantMessagePruned.inc(count);\n }\n trackMessage(msgIdStr) {\n if (this.metrics) {\n const requestMs = this.requestMsByMsg.get(msgIdStr);\n if (requestMs !== undefined) {\n this.metrics.iwantPromiseDeliveryTime.observe((Date.now() - requestMs) / 1000);\n this.requestMsByMsg.delete(msgIdStr);\n }\n }\n }\n}\n//# sourceMappingURL=tracer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MessageStatus: () => (/* binding */ MessageStatus),\n/* harmony export */ PublishConfigType: () => (/* binding */ PublishConfigType),\n/* harmony export */ RejectReason: () => (/* binding */ RejectReason),\n/* harmony export */ SignaturePolicy: () => (/* binding */ SignaturePolicy),\n/* harmony export */ ValidateError: () => (/* binding */ ValidateError),\n/* harmony export */ rejectReasonFromAcceptance: () => (/* binding */ rejectReasonFromAcceptance)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n\nvar SignaturePolicy;\n(function (SignaturePolicy) {\n /**\n * On the producing side:\n * - Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.\n *\n * On the consuming side:\n * - Enforce the fields to be present, reject otherwise.\n * - Propagate only if the fields are valid and signature can be verified, reject otherwise.\n */\n SignaturePolicy[\"StrictSign\"] = \"StrictSign\";\n /**\n * On the producing side:\n * - Build messages without the signature, key, from and seqno fields.\n * - The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty.\n *\n * On the consuming side:\n * - Enforce the fields to be absent, reject otherwise.\n * - Propagate only if the fields are absent, reject otherwise.\n * - A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.\n */\n SignaturePolicy[\"StrictNoSign\"] = \"StrictNoSign\";\n})(SignaturePolicy || (SignaturePolicy = {}));\nvar PublishConfigType;\n(function (PublishConfigType) {\n PublishConfigType[PublishConfigType[\"Signing\"] = 0] = \"Signing\";\n PublishConfigType[PublishConfigType[\"Anonymous\"] = 1] = \"Anonymous\";\n})(PublishConfigType || (PublishConfigType = {}));\nvar RejectReason;\n(function (RejectReason) {\n /**\n * The message failed the configured validation during decoding.\n * SelfOrigin is considered a ValidationError\n */\n RejectReason[\"Error\"] = \"error\";\n /**\n * Custom validator fn reported status IGNORE.\n */\n RejectReason[\"Ignore\"] = \"ignore\";\n /**\n * Custom validator fn reported status REJECT.\n */\n RejectReason[\"Reject\"] = \"reject\";\n /**\n * The peer that sent the message OR the source from field is blacklisted.\n * Causes messages to be ignored, not penalized, neither do score record creation.\n */\n RejectReason[\"Blacklisted\"] = \"blacklisted\";\n})(RejectReason || (RejectReason = {}));\nvar ValidateError;\n(function (ValidateError) {\n /// The message has an invalid signature,\n ValidateError[\"InvalidSignature\"] = \"invalid_signature\";\n /// The sequence number was the incorrect size\n ValidateError[\"InvalidSeqno\"] = \"invalid_seqno\";\n /// The PeerId was invalid\n ValidateError[\"InvalidPeerId\"] = \"invalid_peerid\";\n /// Signature existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"SignaturePresent\"] = \"signature_present\";\n /// Sequence number existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"SeqnoPresent\"] = \"seqno_present\";\n /// Message source existed when validation has been sent to\n /// [`crate::behaviour::MessageAuthenticity::Anonymous`].\n ValidateError[\"FromPresent\"] = \"from_present\";\n /// The data transformation failed.\n ValidateError[\"TransformFailed\"] = \"transform_failed\";\n})(ValidateError || (ValidateError = {}));\nvar MessageStatus;\n(function (MessageStatus) {\n MessageStatus[\"duplicate\"] = \"duplicate\";\n MessageStatus[\"invalid\"] = \"invalid\";\n MessageStatus[\"valid\"] = \"valid\";\n})(MessageStatus || (MessageStatus = {}));\n/**\n * Typesafe conversion of MessageAcceptance -> RejectReason. TS ensures all values covered\n */\nfunction rejectReasonFromAcceptance(acceptance) {\n switch (acceptance) {\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Ignore:\n return RejectReason.Ignore;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_0__.TopicValidatorResult.Reject:\n return RejectReason.Reject;\n }\n}\n//# sourceMappingURL=types.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js ***! - \*************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SignPrefix: () => (/* binding */ SignPrefix),\n/* harmony export */ buildRawMessage: () => (/* binding */ buildRawMessage),\n/* harmony export */ validateToRawMessage: () => (/* binding */ validateToRawMessage)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../message/rpc.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n\n\n\n\n\nconst SignPrefix = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)('libp2p-pubsub:');\nasync function buildRawMessage(publishConfig, topic, originalData, transformedData) {\n switch (publishConfig.type) {\n case _types_js__WEBPACK_IMPORTED_MODULE_7__.PublishConfigType.Signing: {\n const rpcMsg = {\n from: publishConfig.author.toBytes(),\n data: transformedData,\n seqno: (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_3__.randomBytes)(8),\n topic,\n signature: undefined,\n key: undefined // Exclude key field for signing\n };\n // Get the message in bytes, and prepend with the pubsub prefix\n // the signature is over the bytes \"libp2p-pubsub:\"\n const bytes = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([SignPrefix, _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__.RPC.Message.encode(rpcMsg).finish()]);\n rpcMsg.signature = await publishConfig.privateKey.sign(bytes);\n rpcMsg.key = publishConfig.key;\n const msg = {\n type: 'signed',\n from: publishConfig.author,\n data: originalData,\n sequenceNumber: BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(rpcMsg.seqno, 'base16')}`),\n topic,\n signature: rpcMsg.signature,\n key: rpcMsg.key\n };\n return {\n raw: rpcMsg,\n msg: msg\n };\n }\n case _types_js__WEBPACK_IMPORTED_MODULE_7__.PublishConfigType.Anonymous: {\n return {\n raw: {\n from: undefined,\n data: transformedData,\n seqno: undefined,\n topic,\n signature: undefined,\n key: undefined\n },\n msg: {\n type: 'unsigned',\n data: originalData,\n topic\n }\n };\n }\n }\n}\nasync function validateToRawMessage(signaturePolicy, msg) {\n // If strict-sign, verify all\n // If anonymous (no-sign), ensure no preven\n switch (signaturePolicy) {\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_8__.StrictNoSign:\n if (msg.signature != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.SignaturePresent };\n if (msg.seqno != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.SeqnoPresent };\n if (msg.key != null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.FromPresent };\n return { valid: true, message: { type: 'unsigned', topic: msg.topic, data: msg.data ?? new Uint8Array(0) } };\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_8__.StrictSign: {\n // Verify seqno\n if (msg.seqno == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidSeqno };\n if (msg.seqno.length !== 8) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidSeqno };\n }\n if (msg.signature == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidSignature };\n if (msg.from == null)\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidPeerId };\n let fromPeerId;\n try {\n // TODO: Fix PeerId types\n fromPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromBytes)(msg.from);\n }\n catch (e) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidPeerId };\n }\n // - check from defined\n // - transform source to PeerId\n // - parse signature\n // - get .key, else from source\n // - check key == source if present\n // - verify sig\n let publicKey;\n if (msg.key) {\n publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_2__.unmarshalPublicKey)(msg.key);\n // TODO: Should `fromPeerId.pubKey` be optional?\n if (fromPeerId.publicKey !== undefined && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(publicKey.bytes, fromPeerId.publicKey)) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidPeerId };\n }\n }\n else {\n if (fromPeerId.publicKey == null) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidPeerId };\n }\n publicKey = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_2__.unmarshalPublicKey)(fromPeerId.publicKey);\n }\n const rpcMsgPreSign = {\n from: msg.from,\n data: msg.data,\n seqno: msg.seqno,\n topic: msg.topic,\n signature: undefined,\n key: undefined // Exclude key field for signing\n };\n // Get the message in bytes, and prepend with the pubsub prefix\n // the signature is over the bytes \"libp2p-pubsub:\"\n const bytes = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)([SignPrefix, _message_rpc_js__WEBPACK_IMPORTED_MODULE_6__.RPC.Message.encode(rpcMsgPreSign).finish()]);\n if (!(await publicKey.verify(bytes, msg.signature))) {\n return { valid: false, error: _types_js__WEBPACK_IMPORTED_MODULE_7__.ValidateError.InvalidSignature };\n }\n return {\n valid: true,\n message: {\n type: 'signed',\n from: fromPeerId,\n data: msg.data ?? new Uint8Array(0),\n sequenceNumber: BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_9__.toString)(msg.seqno, 'base16')}`),\n topic: msg.topic,\n signature: msg.signature,\n key: msg.key ?? (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_2__.marshalPublicKey)(publicKey)\n }\n };\n }\n }\n}\n//# sourceMappingURL=buildRawMessage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPublishConfigFromPeerId: () => (/* reexport safe */ _publishConfig_js__WEBPACK_IMPORTED_MODULE_2__.getPublishConfigFromPeerId),\n/* harmony export */ messageIdToString: () => (/* reexport safe */ _messageIdToString_js__WEBPACK_IMPORTED_MODULE_1__.messageIdToString),\n/* harmony export */ shuffle: () => (/* reexport safe */ _shuffle_js__WEBPACK_IMPORTED_MODULE_0__.shuffle)\n/* harmony export */ });\n/* harmony import */ var _shuffle_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shuffle.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js\");\n/* harmony import */ var _messageIdToString_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./messageIdToString.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js\");\n/* harmony import */ var _publishConfig_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./publishConfig.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js": -/*!***************************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js ***! - \***************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ messageIdToString: () => (/* binding */ messageIdToString)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n/**\n * Browser friendly function to convert Uint8Array message id to base64 string.\n */\nfunction messageIdToString(msgId) {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(msgId, 'base64');\n}\n//# sourceMappingURL=messageIdToString.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ msgIdFnStrictNoSign: () => (/* binding */ msgIdFnStrictNoSign),\n/* harmony export */ msgIdFnStrictSign: () => (/* binding */ msgIdFnStrictSign)\n/* harmony export */ });\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_pubsub_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/pubsub/utils */ \"./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/utils.js\");\n\n\n/**\n * Generate a message id, based on the `key` and `seqno`\n */\nfunction msgIdFnStrictSign(msg) {\n if (msg.type !== 'signed') {\n throw new Error('expected signed message type');\n }\n // Should never happen\n if (msg.sequenceNumber == null)\n throw Error('missing seqno field');\n // TODO: Should use .from here or key?\n return (0,_libp2p_pubsub_utils__WEBPACK_IMPORTED_MODULE_1__.msgId)(msg.from.toBytes(), msg.sequenceNumber);\n}\n/**\n * Generate a message id, based on message `data`\n */\nasync function msgIdFnStrictNoSign(msg) {\n return await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.sha256.encode(msg.data);\n}\n//# sourceMappingURL=msgIdFn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js ***! - \*******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ multiaddrToIPStr: () => (/* binding */ multiaddrToIPStr)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr/convert */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n\n// Protocols https://github.com/multiformats/multiaddr/blob/master/protocols.csv\n// code size name\n// 4 32 ip4\n// 41 128 ip6\nvar Protocol;\n(function (Protocol) {\n Protocol[Protocol[\"ip4\"] = 4] = \"ip4\";\n Protocol[Protocol[\"ip6\"] = 41] = \"ip6\";\n})(Protocol || (Protocol = {}));\nfunction multiaddrToIPStr(multiaddr) {\n for (const tuple of multiaddr.tuples()) {\n switch (tuple[0]) {\n case Protocol.ip4:\n case Protocol.ip6:\n return (0,_multiformats_multiaddr_convert__WEBPACK_IMPORTED_MODULE_0__.convertToString)(tuple[0], tuple[1]);\n }\n }\n return null;\n}\n//# sourceMappingURL=multiaddr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js ***! - \***********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPublishConfigFromPeerId: () => (/* binding */ getPublishConfigFromPeerId)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../types.js */ \"./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n\n\n\n/**\n * Prepare a PublishConfig object from a PeerId.\n */\nasync function getPublishConfigFromPeerId(signaturePolicy, peerId) {\n switch (signaturePolicy) {\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_1__.StrictSign: {\n if (!peerId) {\n throw Error('Must provide PeerId');\n }\n if (peerId.privateKey == null) {\n throw Error('Cannot sign message, no private key present');\n }\n if (peerId.publicKey == null) {\n throw Error('Cannot sign message, no public key present');\n }\n // Transform privateKey once at initialization time instead of once per message\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPrivateKey)(peerId.privateKey);\n return {\n type: _types_js__WEBPACK_IMPORTED_MODULE_2__.PublishConfigType.Signing,\n author: peerId,\n key: peerId.publicKey,\n privateKey\n };\n }\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_1__.StrictNoSign:\n return {\n type: _types_js__WEBPACK_IMPORTED_MODULE_2__.PublishConfigType.Anonymous\n };\n default:\n throw new Error(`Unknown signature policy \"${signaturePolicy}\"`);\n }\n}\n//# sourceMappingURL=publishConfig.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MapDef: () => (/* binding */ MapDef),\n/* harmony export */ removeFirstNItemsFromSet: () => (/* binding */ removeFirstNItemsFromSet),\n/* harmony export */ removeItemsFromSet: () => (/* binding */ removeItemsFromSet)\n/* harmony export */ });\n/**\n * Exclude up to `ineed` items from a set if item meets condition `cond`\n */\nfunction removeItemsFromSet(superSet, ineed, cond = () => true) {\n const subset = new Set();\n if (ineed <= 0)\n return subset;\n for (const id of superSet) {\n if (subset.size >= ineed)\n break;\n if (cond(id)) {\n subset.add(id);\n superSet.delete(id);\n }\n }\n return subset;\n}\n/**\n * Exclude up to `ineed` items from a set\n */\nfunction removeFirstNItemsFromSet(superSet, ineed) {\n return removeItemsFromSet(superSet, ineed, () => true);\n}\nclass MapDef extends Map {\n constructor(getDefault) {\n super();\n this.getDefault = getDefault;\n }\n getOrDefault(key) {\n let value = super.get(key);\n if (value === undefined) {\n value = this.getDefault();\n this.set(key, value);\n }\n return value;\n }\n}\n//# sourceMappingURL=set.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ shuffle: () => (/* binding */ shuffle)\n/* harmony export */ });\n/**\n * Pseudo-randomly shuffles an array\n *\n * Mutates the input array\n */\nfunction shuffle(arr) {\n if (arr.length <= 1) {\n return arr;\n }\n const randInt = () => {\n return Math.floor(Math.random() * Math.floor(arr.length));\n };\n for (let i = 0; i < arr.length; i++) {\n const j = randInt();\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n }\n return arr;\n}\n//# sourceMappingURL=shuffle.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js ***! - \********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SimpleTimeCache: () => (/* binding */ SimpleTimeCache)\n/* harmony export */ });\n/**\n * This is similar to https://github.com/daviddias/time-cache/blob/master/src/index.js\n * for our own need, we don't use lodash throttle to improve performance.\n * This gives 4x - 5x performance gain compared to npm TimeCache\n */\nclass SimpleTimeCache {\n constructor(opts) {\n this.entries = new Map();\n this.validityMs = opts.validityMs;\n // allow negative validityMs so that this does not cache anything, spec test compliance.spec.js\n // sends duplicate messages and expect peer to receive all. Application likely uses positive validityMs\n }\n get size() {\n return this.entries.size;\n }\n /** Returns true if there was a key collision and the entry is dropped */\n put(key, value) {\n if (this.entries.has(key)) {\n // Key collisions break insertion order in the entries cache, which break prune logic.\n // prune relies on each iterated entry to have strictly ascending validUntilMs, else it\n // won't prune expired entries and SimpleTimeCache will grow unexpectedly.\n // As of Oct 2022 NodeJS v16, inserting the same key twice with different value does not\n // change the key position in the iterator stream. A unit test asserts this behaviour.\n return true;\n }\n this.entries.set(key, { value, validUntilMs: Date.now() + this.validityMs });\n return false;\n }\n prune() {\n const now = Date.now();\n for (const [k, v] of this.entries.entries()) {\n if (v.validUntilMs < now) {\n this.entries.delete(k);\n }\n else {\n // Entries are inserted with strictly ascending validUntilMs.\n // Stop early to save iterations\n break;\n }\n }\n }\n has(key) {\n return this.entries.has(key);\n }\n get(key) {\n const value = this.entries.get(key);\n return value && value.validUntilMs >= Date.now() ? value.value : undefined;\n }\n clear() {\n this.entries.clear();\n }\n}\n//# sourceMappingURL=time-cache.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StrictNoSign: () => (/* binding */ StrictNoSign),\n/* harmony export */ StrictSign: () => (/* binding */ StrictSign),\n/* harmony export */ TopicValidatorResult: () => (/* binding */ TopicValidatorResult)\n/* harmony export */ });\n/**\n * On the producing side:\n * * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.\n *\n * On the consuming side:\n * * Enforce the fields to be present, reject otherwise.\n * * Propagate only if the fields are valid and signature can be verified, reject otherwise.\n */\nconst StrictSign = 'StrictSign';\n/**\n * On the producing side:\n * * Build messages without the signature, key, from and seqno fields.\n * * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty.\n *\n * On the consuming side:\n * * Enforce the fields to be absent, reject otherwise.\n * * Propagate only if the fields are absent, reject otherwise.\n * * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.\n */\nconst StrictNoSign = 'StrictNoSign';\nvar TopicValidatorResult;\n(function (TopicValidatorResult) {\n /**\n * The message is considered valid, and it should be delivered and forwarded to the network\n */\n TopicValidatorResult[\"Accept\"] = \"accept\";\n /**\n * The message is neither delivered nor forwarded to the network\n */\n TopicValidatorResult[\"Ignore\"] = \"ignore\";\n /**\n * The message is considered invalid, and it should be rejected\n */\n TopicValidatorResult[\"Reject\"] = \"reject\";\n})(TopicValidatorResult || (TopicValidatorResult = {}));\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@libp2p/interface-pubsub/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/errors.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/errors.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes)\n/* harmony export */ });\nconst codes = {\n /**\n * Signature policy is invalid\n */\n ERR_INVALID_SIGNATURE_POLICY: 'ERR_INVALID_SIGNATURE_POLICY',\n /**\n * Signature policy is unhandled\n */\n ERR_UNHANDLED_SIGNATURE_POLICY: 'ERR_UNHANDLED_SIGNATURE_POLICY',\n // Strict signing codes\n /**\n * Message expected to have a `signature`, but doesn't\n */\n ERR_MISSING_SIGNATURE: 'ERR_MISSING_SIGNATURE',\n /**\n * Message expected to have a `seqno`, but doesn't\n */\n ERR_MISSING_SEQNO: 'ERR_MISSING_SEQNO',\n /**\n * Message expected to have a `key`, but doesn't\n */\n ERR_MISSING_KEY: 'ERR_MISSING_KEY',\n /**\n * Message `signature` is invalid\n */\n ERR_INVALID_SIGNATURE: 'ERR_INVALID_SIGNATURE',\n /**\n * Message expected to have a `from`, but doesn't\n */\n ERR_MISSING_FROM: 'ERR_MISSING_FROM',\n // Strict no-signing codes\n /**\n * Message expected to not have a `from`, but does\n */\n ERR_UNEXPECTED_FROM: 'ERR_UNEXPECTED_FROM',\n /**\n * Message expected to not have a `signature`, but does\n */\n ERR_UNEXPECTED_SIGNATURE: 'ERR_UNEXPECTED_SIGNATURE',\n /**\n * Message expected to not have a `key`, but does\n */\n ERR_UNEXPECTED_KEY: 'ERR_UNEXPECTED_KEY',\n /**\n * Message expected to not have a `seqno`, but does\n */\n ERR_UNEXPECTED_SEQNO: 'ERR_UNEXPECTED_SEQNO',\n /**\n * Message failed topic validator\n */\n ERR_TOPIC_VALIDATOR_REJECT: 'ERR_TOPIC_VALIDATOR_REJECT'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/utils.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/utils.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ anyMatch: () => (/* binding */ anyMatch),\n/* harmony export */ bigIntFromBytes: () => (/* binding */ bigIntFromBytes),\n/* harmony export */ bigIntToBytes: () => (/* binding */ bigIntToBytes),\n/* harmony export */ ensureArray: () => (/* binding */ ensureArray),\n/* harmony export */ msgId: () => (/* binding */ msgId),\n/* harmony export */ noSignMsgId: () => (/* binding */ noSignMsgId),\n/* harmony export */ randomSeqno: () => (/* binding */ randomSeqno),\n/* harmony export */ toMessage: () => (/* binding */ toMessage),\n/* harmony export */ toRpcMessage: () => (/* binding */ toRpcMessage)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/errors.js\");\n\n\n\n\n\n\n\n/**\n * Generate a random sequence number\n */\nfunction randomSeqno() {\n return BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_0__.randomBytes)(8), 'base16')}`);\n}\n/**\n * Generate a message id, based on the `key` and `seqno`\n */\nconst msgId = (key, seqno) => {\n const seqnoBytes = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(seqno.toString(16).padStart(16, '0'), 'base16');\n const msgId = new Uint8Array(key.length + seqnoBytes.length);\n msgId.set(key, 0);\n msgId.set(seqnoBytes, key.length);\n return msgId;\n};\n/**\n * Generate a message id, based on message `data`\n */\nconst noSignMsgId = (data) => {\n return multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__.sha256.encode(data);\n};\n/**\n * Check if any member of the first set is also a member\n * of the second set\n */\nconst anyMatch = (a, b) => {\n let bHas;\n if (Array.isArray(b)) {\n bHas = (val) => b.includes(val);\n }\n else {\n bHas = (val) => b.has(val);\n }\n for (const val of a) {\n if (bHas(val)) {\n return true;\n }\n }\n return false;\n};\n/**\n * Make everything an array\n */\nconst ensureArray = function (maybeArray) {\n if (!Array.isArray(maybeArray)) {\n return [maybeArray];\n }\n return maybeArray;\n};\nconst isSigned = async (message) => {\n if ((message.sequenceNumber == null) || (message.from == null) || (message.signature == null)) {\n return false;\n }\n // if a public key is present in the `from` field, the message should be signed\n const fromID = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(message.from);\n if (fromID.publicKey != null) {\n return true;\n }\n if (message.key != null) {\n const signingID = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)(message.key);\n return signingID.equals(fromID);\n }\n return false;\n};\nconst toMessage = async (message) => {\n if (message.from == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_FROM);\n }\n if (!await isSigned(message)) {\n return {\n type: 'unsigned',\n topic: message.topic ?? '',\n data: message.data ?? new Uint8Array(0)\n };\n }\n const from = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(message.from);\n const msg = {\n type: 'signed',\n from: (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(message.from),\n topic: message.topic ?? '',\n sequenceNumber: bigIntFromBytes(message.sequenceNumber ?? new Uint8Array(0)),\n data: message.data ?? new Uint8Array(0),\n signature: message.signature ?? new Uint8Array(0),\n key: message.key ?? from.publicKey ?? new Uint8Array(0)\n };\n if (msg.key.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_KEY);\n }\n return msg;\n};\nconst toRpcMessage = (message) => {\n if (message.type === 'signed') {\n return {\n from: message.from.multihash.bytes,\n data: message.data,\n sequenceNumber: bigIntToBytes(message.sequenceNumber),\n topic: message.topic,\n signature: message.signature,\n key: message.key\n };\n }\n return {\n data: message.data,\n topic: message.topic\n };\n};\nconst bigIntToBytes = (num) => {\n let str = num.toString(16);\n if (str.length % 2 !== 0) {\n str = `0${str}`;\n }\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(str, 'base16');\n};\nconst bigIntFromBytes = (num) => {\n return BigInt(`0x${(0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_5__.toString)(num, 'base16')}`);\n};\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@libp2p/pubsub/dist/src/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/index.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* reexport safe */ _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_8__.ConnectionManager),\n/* harmony export */ DefaultPubSubTopic: () => (/* reexport safe */ _lib_constants_js__WEBPACK_IMPORTED_MODULE_1__.DefaultPubSubTopic),\n/* harmony export */ DefaultUserAgent: () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__.DefaultUserAgent),\n/* harmony export */ KeepAliveManager: () => (/* reexport safe */ _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_9__.KeepAliveManager),\n/* harmony export */ LightPushCodec: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.LightPushCodec),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.PageDirection),\n/* harmony export */ StoreCodec: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.StoreCodec),\n/* harmony export */ WakuNode: () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__.WakuNode),\n/* harmony export */ createCursor: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.createCursor),\n/* harmony export */ createDecoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__.createDecoder),\n/* harmony export */ createEncoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__.createEncoder),\n/* harmony export */ message: () => (/* reexport module object */ _lib_message_index_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ waitForRemotePeer: () => (/* reexport safe */ _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_7__.waitForRemotePeer),\n/* harmony export */ waku: () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ wakuFilter: () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ wakuLightPush: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuLightPush),\n/* harmony export */ wakuStore: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuStore),\n/* harmony export */ waku_filter: () => (/* reexport module object */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ waku_light_push: () => (/* reexport module object */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ waku_store: () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__)\n/* harmony export */ });\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/waku.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/waku.js\");\n/* harmony import */ var _lib_constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/constants.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/message/version_0.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _lib_message_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/message/index.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/index.js\");\n/* harmony import */ var _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/filter/index.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/index.js\");\n/* harmony import */ var _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/light_push/index.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseProtocol: () => (/* binding */ BaseProtocol)\n/* harmony export */ });\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n\n/**\n * A class with predefined helpers, to be used as a base to implement Waku\n * Protocols.\n */\nclass BaseProtocol {\n multicodec;\n components;\n addLibp2pEventListener;\n removeLibp2pEventListener;\n constructor(multicodec, components) {\n this.multicodec = multicodec;\n this.components = components;\n this.addLibp2pEventListener = components.events.addEventListener.bind(components.events);\n this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);\n }\n get peerStore() {\n return this.components.peerStore;\n }\n /**\n * Returns known peers from the address book (`libp2p.peerStore`) that support\n * the class protocol. Waku may or may not be currently connected to these\n * peers.\n */\n async peers() {\n return (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.getPeersForProtocol)(this.peerStore, [this.multicodec]);\n }\n async getPeer(peerId) {\n const { peer } = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.selectPeerForProtocol)(this.peerStore, [this.multicodec], peerId);\n return peer;\n }\n async newStream(peer) {\n const connections = this.components.connectionManager.getConnections(peer.id);\n const connection = (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.selectConnection)(connections);\n if (!connection) {\n throw new Error(\"Failed to get a connection to the peer\");\n }\n return connection.newStream(this.multicodec);\n }\n}\n//# sourceMappingURL=base_protocol.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/connection_manager.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/connection_manager.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* binding */ ConnectionManager),\n/* harmony export */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED: () => (/* binding */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED),\n/* harmony export */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER: () => (/* binding */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER),\n/* harmony export */ DEFAULT_MAX_PARALLEL_DIALS: () => (/* binding */ DEFAULT_MAX_PARALLEL_DIALS)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nconst DEFAULT_MAX_PARALLEL_DIALS = 3;\nclass ConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n static instances = new Map();\n keepAliveManager;\n options;\n libp2p;\n dialAttemptsForPeer = new Map();\n dialErrorsForPeer = new Map();\n currentActiveDialCount = 0;\n pendingPeerDialQueue = [];\n static create(peerId, libp2p, keepAliveOptions, relay, options) {\n let instance = ConnectionManager.instances.get(peerId);\n if (!instance) {\n instance = new ConnectionManager(libp2p, keepAliveOptions, relay, options);\n ConnectionManager.instances.set(peerId, instance);\n }\n return instance;\n }\n async getPeersByDiscovery() {\n const peersDiscovered = await this.libp2p.peerStore.all();\n const peersConnected = this.libp2p\n .getConnections()\n .map((conn) => conn.remotePeer);\n const peersDiscoveredByBootstrap = [];\n const peersDiscoveredByPeerExchange = [];\n const peersConnectedByBootstrap = [];\n const peersConnectedByPeerExchange = [];\n for (const peer of peersDiscovered) {\n const tags = await this.getTagNamesForPeer(peer.id);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP)) {\n peersDiscoveredByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE)) {\n peersDiscoveredByPeerExchange.push(peer);\n }\n }\n for (const peerId of peersConnected) {\n const peer = await this.libp2p.peerStore.get(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP)) {\n peersConnectedByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE)) {\n peersConnectedByPeerExchange.push(peer);\n }\n }\n return {\n DISCOVERED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP]: peersDiscoveredByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE]: peersDiscoveredByPeerExchange,\n },\n CONNECTED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP]: peersConnectedByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE]: peersConnectedByPeerExchange,\n },\n };\n }\n constructor(libp2p, keepAliveOptions, relay, options) {\n super();\n this.libp2p = libp2p;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n maxParallelDials: DEFAULT_MAX_PARALLEL_DIALS,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_3__.KeepAliveManager(keepAliveOptions, relay);\n this.run()\n .then(() => log(`Connection Manager is now running`))\n .catch((error) => log(`Unexpected error while running service`, error));\n // libp2p emits `peer:discovery` events during its initialization\n // which means that before the ConnectionManager is initialized, some peers may have been discovered\n // we will dial the peers in peerStore ONCE before we start to listen to the `peer:discovery` events within the ConnectionManager\n this.dialPeerStorePeers().catch((error) => log(`Unexpected error while dialing peer store peers`, error));\n }\n async dialPeerStorePeers() {\n const peerInfos = await this.libp2p.peerStore.all();\n const dialPromises = [];\n for (const peerInfo of peerInfos) {\n if (this.libp2p.getConnections().find((c) => c.remotePeer === peerInfo.id))\n continue;\n dialPromises.push(this.attemptDial(peerInfo.id));\n }\n try {\n await Promise.all(dialPromises);\n }\n catch (error) {\n log(`Unexpected error while dialing peer store peers`, error);\n }\n }\n async run() {\n // start event listeners\n this.startPeerDiscoveryListener();\n this.startPeerConnectionListener();\n this.startPeerDisconnectionListener();\n }\n stop() {\n this.keepAliveManager.stopAll();\n this.libp2p.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2p.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2p.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n this.currentActiveDialCount += 1;\n let dialAttempt = 0;\n while (dialAttempt < this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()} on attempt ${dialAttempt + 1}`);\n await this.libp2p.dial(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n // add tag to connection describing discovery mechanism\n // don't add duplicate tags\n this.libp2p.getConnections(peerId).forEach((conn) => {\n conn.tags = Array.from(new Set([...conn.tags, ...tags]));\n });\n this.dialAttemptsForPeer.delete(peerId.toString());\n // Dialing succeeded, break the loop\n break;\n }\n catch (error) {\n if (error instanceof AggregateError) {\n // Handle AggregateError\n log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);\n }\n else {\n // Handle generic error\n log(`Error dialing peer ${peerId.toString()} - ${error.message}`);\n }\n this.dialErrorsForPeer.set(peerId.toString(), error);\n dialAttempt++;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt);\n }\n }\n // Always decrease the active dial count and process the dial queue\n this.currentActiveDialCount--;\n this.processDialQueue();\n // If max dial attempts reached and dialing failed, delete the peer\n if (dialAttempt === this.options.maxDialAttemptsForPeer) {\n try {\n const error = this.dialErrorsForPeer.get(peerId.toString());\n let errorMessage;\n if (error instanceof AggregateError) {\n errorMessage = JSON.stringify(error.errors[0]);\n }\n else {\n errorMessage = error.message;\n }\n log(`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`);\n this.dialErrorsForPeer.delete(peerId.toString());\n await this.libp2p.peerStore.delete(peerId);\n }\n catch (error) {\n throw new Error(`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`);\n }\n }\n }\n async dropConnection(peerId) {\n try {\n this.keepAliveManager.stop(peerId);\n await this.libp2p.hangUp(peerId);\n log(`Dropped connection with peer ${peerId.toString()}`);\n }\n catch (error) {\n log(`Error dropping connection with peer ${peerId.toString()} - ${error}`);\n }\n }\n processDialQueue() {\n if (this.pendingPeerDialQueue.length > 0 &&\n this.currentActiveDialCount < this.options.maxParallelDials) {\n const peerId = this.pendingPeerDialQueue.shift();\n if (!peerId)\n return;\n this.attemptDial(peerId).catch((error) => {\n log(error);\n });\n }\n }\n startPeerDiscoveryListener() {\n this.libp2p.addEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2p.addEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n }\n startPeerDisconnectionListener() {\n // TODO: ensure that these following issues are updated and confirmed\n /**\n * NOTE: Event is not being emitted on closing nor losing a connection.\n * @see https://github.com/libp2p/js-libp2p/issues/939\n * @see https://github.com/status-im/js-waku/issues/252\n *\n * >This event will be triggered anytime we are disconnected from another peer,\n * >regardless of the circumstances of that disconnection.\n * >If we happen to have multiple connections to a peer,\n * >this event will **only** be triggered when the last connection is closed.\n * @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100\n */\n this.libp2p.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n }\n async attemptDial(peerId) {\n if (this.currentActiveDialCount >= this.options.maxParallelDials) {\n this.pendingPeerDialQueue.push(peerId);\n return;\n }\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => {\n throw `Error dialing peer ${peerId.toString()} : ${err}`;\n });\n }\n onEventHandlers = {\n \"peer:discovery\": (evt) => {\n void (async () => {\n const { id: peerId } = evt.detail;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(isBootstrap\n ? _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP\n : _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE, {\n detail: peerId,\n }));\n try {\n await this.attemptDial(peerId);\n }\n catch (error) {\n log(`Error dialing peer ${peerId.toString()} : ${error}`);\n }\n })();\n },\n \"peer:connect\": (evt) => {\n void (async () => {\n const peerId = evt.detail;\n this.keepAliveManager.start(peerId, this.libp2p.services.ping);\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const bootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => conn.tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP));\n // If we have too many bootstrap connections, drop one\n if (bootstrapConnections.length > this.options.maxBootstrapPeersAllowed) {\n await this.dropConnection(peerId);\n }\n else {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP, {\n detail: peerId,\n }));\n }\n }\n else {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE, {\n detail: peerId,\n }));\n }\n })();\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail);\n };\n },\n };\n /**\n * Checks if the peer is dialable based on the following conditions:\n * 1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.\n * 2. If the peer is not a bootstrap peer\n */\n async shouldDialPeer(peerId) {\n const isConnected = this.libp2p.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const tagNames = await this.getTagNamesForPeer(peerId);\n const isBootstrap = tagNames.some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => {\n return conn.tags.find((name) => name === _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n }).length;\n if (currentBootstrapConnections < this.options.maxBootstrapPeersAllowed)\n return true;\n }\n else {\n return true;\n }\n return false;\n }\n /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n try {\n const peer = await this.libp2p.peerStore.get(peerId);\n return Array.from(peer.tags.keys());\n }\n catch (error) {\n log(`Failed to get peer ${peerId}, error: ${error}`);\n return [];\n }\n }\n}\n\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/connection_manager.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPubSubTopic: () => (/* binding */ DefaultPubSubTopic)\n/* harmony export */ });\n/**\n * DefaultPubSubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubSubTopic = \"/waku/2/default-waku/proto\";\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/filter_rpc.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/filter_rpc.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterPushRpc: () => (/* binding */ FilterPushRpc),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ FilterSubscribeRpc: () => (/* binding */ FilterSubscribeRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterPushRPC represents a message conforming to the Waku FilterPush protocol.\n * Protocol documentation: https://rfc.vac.dev/spec/12/\n */\nclass FilterPushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.decode(bytes);\n return new FilterPushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.encode(this.proto);\n }\n get wakuMessage() {\n return this.proto.wakuMessage;\n }\n /**\n * Get the pubsub topic from the FilterPushRpc object.\n * @returns string\n */\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n}\nclass FilterSubscribeRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createSubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBE,\n pubsubTopic,\n contentTopics,\n });\n }\n static createUnsubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE,\n pubsubTopic,\n contentTopics,\n });\n }\n static createUnsubscribeAllRequest(pubsubTopic) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE_ALL,\n pubsubTopic,\n contentTopics: [],\n });\n }\n static createSubscriberPingRequest() {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBER_PING,\n pubsubTopic: \"\",\n contentTopics: [],\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.decode(bytes);\n return new FilterSubscribeRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.encode(this.proto);\n }\n get filterSubscribeType() {\n return this.proto.filterSubscribeType;\n }\n get requestId() {\n return this.proto.requestId;\n }\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n get contentTopics() {\n return this.proto.contentTopics;\n }\n}\nclass FilterSubscribeResponse {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.decode(bytes);\n return new FilterSubscribeResponse(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.encode(this.proto);\n }\n get statusCode() {\n return this.proto.statusCode;\n }\n get statusDesc() {\n return this.proto.statusDesc;\n }\n get requestId() {\n return this.proto.requestId;\n }\n}\n//# sourceMappingURL=filter_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/filter_rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/index.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/index.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ wakuFilter: () => (/* binding */ wakuFilter)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/filter_rpc.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter:v2\");\nconst FilterCodecs = {\n SUBSCRIBE: \"/vac/waku/filter-subscribe/2.0.0-beta1\",\n PUSH: \"/vac/waku/filter-push/2.0.0-beta1\",\n};\nclass Subscription {\n peer;\n pubSubTopic;\n newStream;\n subscriptionCallbacks;\n constructor(pubSubTopic, remotePeer, newStream) {\n this.peer = remotePeer;\n this.pubSubTopic = pubSubTopic;\n this.newStream = newStream;\n this.subscriptionCallbacks = new Map();\n }\n async subscribe(decoders, callback) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const decodersGroupedByCT = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(decodersArray);\n const contentTopics = Array.from(decodersGroupedByCT.keys());\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscribeRequest(this.pubSubTopic, contentTopics);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter subscribe request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log(\"Subscribed to peer \", this.peer.id.toString(), \"for content topics\", contentTopics);\n }\n catch (e) {\n throw new Error(\"Error subscribing to peer: \" +\n this.peer.id.toString() +\n \" for content topics: \" +\n contentTopics +\n \": \" +\n e);\n }\n // Save the callback functions by content topics so they\n // can easily be removed (reciprocally replaced) if `unsubscribe` (reciprocally `subscribe`)\n // is called for those content topics\n decodersGroupedByCT.forEach((decoders, contentTopic) => {\n // Cast the type because a given `subscriptionCallbacks` map may hold\n // Decoder that decode to different implementations of `IDecodedMessage`\n const subscriptionCallback = {\n decoders,\n callback,\n };\n // The callback and decoder may override previous values, this is on\n // purpose as the user may call `subscribe` to refresh the subscription\n this.subscriptionCallbacks.set(contentTopic, subscriptionCallback);\n });\n }\n async unsubscribe(contentTopics) {\n const stream = await this.newStream(this.peer);\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeRequest(this.pubSubTopic, contentTopics);\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([unsubscribeRequest.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream.sink);\n }\n catch (error) {\n throw new Error(\"Error subscribing: \" + error);\n }\n contentTopics.forEach((contentTopic) => {\n this.subscriptionCallbacks.delete(contentTopic);\n });\n }\n async ping() {\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscriberPingRequest();\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter ping request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log(\"Ping successful\");\n }\n catch (error) {\n log(\"Error pinging: \", error);\n throw new Error(\"Error pinging: \" + error);\n }\n }\n async unsubscribeAll() {\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeAllRequest(this.pubSubTopic);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter unsubscribe all request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n this.subscriptionCallbacks.clear();\n log(\"Unsubscribed from all content topics\");\n }\n catch (error) {\n throw new Error(\"Error unsubscribing from all content topics: \" + error);\n }\n }\n async processMessage(message) {\n const contentTopic = message.contentTopic;\n const subscriptionCallback = this.subscriptionCallbacks.get(contentTopic);\n if (!subscriptionCallback) {\n log(\"No subscription callback available for \", contentTopic);\n return;\n }\n await pushMessage(subscriptionCallback, this.pubSubTopic, message);\n }\n}\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n options;\n activeSubscriptions = new Map();\n getActiveSubscription(pubSubTopic, peerIdStr) {\n return this.activeSubscriptions.get(`${pubSubTopic}_${peerIdStr}`);\n }\n setActiveSubscription(pubSubTopic, peerIdStr, subscription) {\n this.activeSubscriptions.set(`${pubSubTopic}_${peerIdStr}`, subscription);\n return subscription;\n }\n constructor(libp2p, options) {\n super(FilterCodecs.SUBSCRIBE, libp2p.components);\n libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {\n log(\"Failed to register \", FilterCodecs.PUSH, e);\n });\n this.activeSubscriptions = new Map();\n this.options = options ?? {};\n }\n async createSubscription(pubSubTopic, peerId) {\n const _pubSubTopic = pubSubTopic ?? this.options.pubSubTopic ?? _constants_js__WEBPACK_IMPORTED_MODULE_6__.DefaultPubSubTopic;\n const peer = await this.getPeer(peerId);\n const subscription = this.getActiveSubscription(_pubSubTopic, peer.id.toString()) ??\n this.setActiveSubscription(_pubSubTopic, peer.id.toString(), new Subscription(_pubSubTopic, peer, this.newStream.bind(this, peer)));\n return subscription;\n }\n toSubscriptionIterator(decoders, opts) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)(this, decoders, opts);\n }\n /**\n * This method is used to satisfy the `IReceiver` interface.\n *\n * @hidden\n *\n * @param decoders The decoders to use for the subscription.\n * @param callback The callback function to use for the subscription.\n * @param opts Optional protocol options for the subscription.\n *\n * @returns A Promise that resolves to a function that unsubscribes from the subscription.\n *\n * @remarks\n * This method should not be used directly.\n * Instead, use `createSubscription` to create a new subscription.\n */\n async subscribe(decoders, callback, opts) {\n const subscription = await this.createSubscription(undefined, opts?.peerId);\n await subscription.subscribe(decoders, callback);\n const contentTopics = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(Array.isArray(decoders) ? decoders : [decoders]).keys());\n return async () => {\n await subscription.unsubscribe(contentTopics);\n };\n }\n onRequest(streamData) {\n log(\"Receiving message push\");\n try {\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)(streamData.stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => {\n for await (const bytes of source) {\n const response = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterPushRpc.decode(bytes.slice());\n const { pubsubTopic, wakuMessage } = response;\n if (!wakuMessage) {\n log(\"Received empty message\");\n return;\n }\n if (!pubsubTopic) {\n log(\"PubSub topic missing from push message\");\n return;\n }\n const peerIdStr = streamData.connection.remotePeer.toString();\n const subscription = this.getActiveSubscription(pubsubTopic, peerIdStr);\n if (!subscription) {\n log(`No subscription locally registered for topic ${pubsubTopic}`);\n return;\n }\n await subscription.processMessage(wakuMessage);\n }\n }).then(() => {\n log(\"Receiving pipe closed.\");\n }, (e) => {\n log(\"Error with receiving pipe\", e);\n });\n }\n catch (e) {\n log(\"Error decoding message\", e);\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\nasync function pushMessage(subscriptionCallback, pubSubTopic, message) {\n const { decoders, callback } = subscriptionCallback;\n const { contentTopic } = message;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n try {\n const decodePromises = decoders.map((dec) => dec\n .fromProtoObj(pubSubTopic, message)\n .then((decoded) => decoded || Promise.reject(\"Decoding failed\")));\n const decodedMessage = await Promise.any(decodePromises);\n await callback(decodedMessage);\n }\n catch (e) {\n log(\"Error decoding message\", e);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/filter/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/keep_alive_manager.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/keep_alive_manager.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KeepAliveManager: () => (/* binding */ KeepAliveManager),\n/* harmony export */ RelayPingContentTopic: () => (/* binding */ RelayPingContentTopic)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/index.js\");\n\n\nconst RelayPingContentTopic = \"/relay-ping/1/ping/null\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:keep-alive\");\nclass KeepAliveManager {\n pingKeepAliveTimers;\n relayKeepAliveTimers;\n options;\n relay;\n constructor(options, relay) {\n this.pingKeepAliveTimers = new Map();\n this.relayKeepAliveTimers = new Map();\n this.options = options;\n this.relay = relay;\n }\n start(peerId, libp2pPing) {\n // Just in case a timer already exist for this peer\n this.stop(peerId);\n const { pingKeepAlive: pingPeriodSecs, relayKeepAlive: relayPeriodSecs } = this.options;\n const peerIdStr = peerId.toString();\n if (pingPeriodSecs !== 0) {\n const interval = setInterval(() => {\n libp2pPing.ping(peerId).catch((e) => {\n log(`Ping failed (${peerIdStr})`, e);\n });\n }, pingPeriodSecs * 1000);\n this.pingKeepAliveTimers.set(peerIdStr, interval);\n }\n const relay = this.relay;\n if (relay && relayPeriodSecs !== 0) {\n const encoder = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.createEncoder)({\n contentTopic: RelayPingContentTopic,\n ephemeral: true,\n });\n const interval = setInterval(() => {\n log(\"Sending Waku Relay ping message\");\n relay\n .send(encoder, { payload: new Uint8Array([1]) })\n .catch((e) => log(\"Failed to send relay ping\", e));\n }, relayPeriodSecs * 1000);\n this.relayKeepAliveTimers.set(peerId, interval);\n }\n }\n stop(peerId) {\n const peerIdStr = peerId.toString();\n if (this.pingKeepAliveTimers.has(peerIdStr)) {\n clearInterval(this.pingKeepAliveTimers.get(peerIdStr));\n this.pingKeepAliveTimers.delete(peerIdStr);\n }\n if (this.relayKeepAliveTimers.has(peerId)) {\n clearInterval(this.relayKeepAliveTimers.get(peerId));\n this.relayKeepAliveTimers.delete(peerId);\n }\n }\n stopAll() {\n for (const timer of [\n ...Object.values(this.pingKeepAliveTimers),\n ...Object.values(this.relayKeepAliveTimers),\n ]) {\n clearInterval(timer);\n }\n this.pingKeepAliveTimers.clear();\n this.relayKeepAliveTimers.clear();\n }\n}\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/keep_alive_manager.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/index.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/index.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LightPushCodec: () => (/* binding */ LightPushCodec),\n/* harmony export */ PushResponse: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_1__.PushResponse),\n/* harmony export */ wakuLightPush: () => (/* binding */ wakuLightPush)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./push_rpc.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/push_rpc.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:light-push\");\nconst LightPushCodec = \"/vac/waku/lightpush/2.0.0-beta1\";\n\n/**\n * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).\n */\nclass LightPush extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__.BaseProtocol {\n options;\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.components);\n this.options = options || {};\n }\n async send(encoder, message, opts) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic } = this.options;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n const recipients = [];\n let error = undefined;\n try {\n if (!(0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.isSizeValid)(message.payload)) {\n log(\"Failed to send waku light push: message is bigger that 1MB\");\n return {\n recipients,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.SIZE_TOO_BIG,\n };\n }\n const protoMessage = await encoder.toProtoObj(message);\n if (!protoMessage) {\n log(\"Failed to encode to protoMessage, aborting push\");\n return {\n recipients,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.ENCODE_FAILED,\n };\n }\n const query = _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__.PushRpc.createRequest(protoMessage, pubSubTopic);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)([query.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n try {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const response = _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__.PushRpc.decode(bytes).response;\n if (response?.isSuccess) {\n recipients.push(peer.id);\n }\n else {\n log(\"No response in PushRPC\");\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.NO_RPC_RESPONSE;\n }\n }\n catch (err) {\n log(\"Failed to decode push reply\", err);\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.DECODE_FAILED;\n }\n }\n catch (err) {\n log(\"Failed to send waku light push request\", err);\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.GENERIC_FAIL;\n }\n return {\n error,\n recipients,\n };\n }\n}\nfunction wakuLightPush(init = {}) {\n return (libp2p) => new LightPush(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/push_rpc.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/push_rpc.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nclass PushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(message, pubSubTopic) {\n return new PushRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n message: message,\n pubsubTopic: pubSubTopic,\n },\n response: undefined,\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.decode(bytes);\n return new PushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.encode(this.proto);\n }\n get query() {\n return this.proto.request;\n }\n get response() {\n return this.proto.response;\n }\n}\n//# sourceMappingURL=push_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/light_push/push_rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/index.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/index.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ version_0: () => (/* reexport module object */ _version_0_js__WEBPACK_IMPORTED_MODULE_0__)\n/* harmony export */ });\n/* harmony import */ var _version_0_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./version_0.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/version_0.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/version_0.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/version_0.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* binding */ DecodedMessage),\n/* harmony export */ Decoder: () => (/* binding */ Decoder),\n/* harmony export */ Encoder: () => (/* binding */ Encoder),\n/* harmony export */ Version: () => (/* binding */ Version),\n/* harmony export */ createDecoder: () => (/* binding */ createDecoder),\n/* harmony export */ createEncoder: () => (/* binding */ createEncoder),\n/* harmony export */ proto: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:message:version-0\");\nconst OneMillion = BigInt(1000000);\nconst Version = 0;\n\nclass DecodedMessage {\n pubSubTopic;\n proto;\n constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n }\n get ephemeral() {\n return Boolean(this.proto.ephemeral);\n }\n get payload() {\n return this.proto.payload;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n get _rawTimestamp() {\n return this.proto.timestamp;\n }\n get timestamp() {\n // In the case we receive a value that is bigger than JS's max number,\n // we catch the error and return undefined.\n try {\n if (this.proto.timestamp) {\n // nanoseconds 10^-9 to milliseconds 10^-3\n const timestamp = this.proto.timestamp / OneMillion;\n return new Date(Number(timestamp));\n }\n return;\n }\n catch (e) {\n return;\n }\n }\n get meta() {\n return this.proto.meta;\n }\n get version() {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n return this.proto.version ?? 0;\n }\n get rateLimitProof() {\n return this.proto.rateLimitProof;\n }\n}\nclass Encoder {\n contentTopic;\n ephemeral;\n metaSetter;\n constructor(contentTopic, ephemeral = false, metaSetter) {\n this.contentTopic = contentTopic;\n this.ephemeral = ephemeral;\n this.metaSetter = metaSetter;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n async toWire(message) {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.encode(await this.toProtoObj(message));\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n const protoMessage = {\n payload: message.payload,\n version: Version,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n meta: undefined,\n rateLimitProof: message.rateLimitProof,\n ephemeral: this.ephemeral,\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * Creates an encoder that encode messages without Waku level encryption or signature.\n *\n * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format to be sent over the Waku network. The resulting encoder can then be\n * pass to { @link @waku/interfaces.LightPush.push } or\n * { @link @waku/interfaces.Relay.send } to automatically encode outgoing\n * messages.\n */\nfunction createEncoder({ contentTopic, ephemeral, metaSetter, }) {\n return new Encoder(contentTopic, ephemeral, metaSetter);\n}\nclass Decoder {\n contentTopic;\n constructor(contentTopic) {\n this.contentTopic = contentTopic;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve({\n payload: protoMessage.payload,\n contentTopic: protoMessage.contentTopic,\n version: protoMessage.version ?? undefined,\n timestamp: protoMessage.timestamp ?? undefined,\n meta: protoMessage.meta ?? undefined,\n rateLimitProof: protoMessage.rateLimitProof ?? undefined,\n ephemeral: protoMessage.ephemeral ?? false,\n });\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n if (proto.version ?? 0 !== Version) {\n log(\"Failed to decode due to incorrect version, expected:\", Version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n return new DecodedMessage(pubSubTopic, proto);\n }\n}\n/**\n * Creates a decoder that decode messages without Waku level encryption.\n *\n * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format when received from the Waku network. The resulting decoder can then be\n * pass to { @link @waku/interfaces.Filter.subscribe } or\n * { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming\n * messages.\n *\n * @param contentTopic The resulting decoder will only decode messages with this content topic.\n */\nfunction createDecoder(contentTopic) {\n return new Decoder(contentTopic);\n}\n//# sourceMappingURL=version_0.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/message/version_0.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/history_rpc.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/history_rpc.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nconst OneMillion = BigInt(1000000);\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\nclass HistoryRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n get query() {\n return this.proto.query;\n }\n get response() {\n return this.proto.response;\n }\n /**\n * Create History Query.\n */\n static createQuery(params) {\n const contentFilters = params.contentTopics.map((contentTopic) => {\n return { contentTopic };\n });\n const direction = directionToProto(params.pageDirection);\n const pagingInfo = {\n pageSize: BigInt(params.pageSize),\n cursor: params.cursor,\n direction,\n };\n let startTime, endTime;\n if (params.startTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n startTime = BigInt(params.startTime.valueOf()) * OneMillion;\n }\n if (params.endTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n endTime = BigInt(params.endTime.valueOf()) * OneMillion;\n }\n return new HistoryRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n query: {\n pubsubTopic: params.pubSubTopic,\n contentFilters,\n pagingInfo,\n startTime,\n endTime,\n },\n response: undefined,\n });\n }\n decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.decode(bytes);\n return new HistoryRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.encode(this.proto);\n }\n}\nfunction directionToProto(pageDirection) {\n switch (pageDirection) {\n case PageDirection.BACKWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n case PageDirection.FORWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.FORWARD;\n default:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n }\n}\n//# sourceMappingURL=history_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/history_rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/index.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPageSize: () => (/* binding */ DefaultPageSize),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection),\n/* harmony export */ StoreCodec: () => (/* binding */ StoreCodec),\n/* harmony export */ createCursor: () => (/* binding */ createCursor),\n/* harmony export */ wakuStore: () => (/* binding */ wakuStore)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./history_rpc.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/history_rpc.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar HistoryError = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:store\");\nconst StoreCodec = \"/vac/waku/store/2.0.0-beta4\";\nconst DefaultPageSize = 10;\n\n/**\n * Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).\n *\n * The Waku Store protocol can be used to retrieved historical messages.\n */\nclass Store extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__.BaseProtocol {\n options;\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.components);\n this.options = options ?? {};\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * The callback function takes a `WakuMessage` in input,\n * messages are processed in order:\n * - oldest to latest if `options.pageDirection` == { @link PageDirection.FORWARD }\n * - latest to oldest if `options.pageDirection` == { @link PageDirection.BACKWARD }\n *\n * The ordering may affect performance.\n * The ordering depends on the behavior of the remote store node.\n * If strong ordering is needed, you may need to handle this at application level\n * and set your own timestamps too (the WakuMessage timestamps are not certified).\n *\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n */\n async queryOrderedCallback(decoders, callback, options) {\n let abort = false;\n for await (const promises of this.queryGenerator(decoders, options)) {\n if (abort)\n break;\n const messagesOrUndef = await Promise.all(promises);\n let messages = messagesOrUndef.filter(_waku_utils__WEBPACK_IMPORTED_MODULE_1__.isDefined);\n // Messages in pages are ordered from oldest (first) to most recent (last).\n // https://github.com/vacp2p/rfc/issues/533\n if (typeof options?.pageDirection === \"undefined\" ||\n options?.pageDirection === _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection.BACKWARD) {\n messages = messages.reverse();\n }\n await Promise.all(messages.map(async (msg) => {\n if (msg && !abort) {\n abort = Boolean(await callback(msg));\n }\n }));\n }\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * The callback function takes a `Promise` in input,\n * useful if messages needs to be decrypted and performance matters.\n *\n * The order of the messages passed to the callback is as follows:\n * - within a page, messages are expected to be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n *\n * Do note that the resolution of the `Promise {\n if (!abort) {\n abort = Boolean(await callback(msg));\n }\n });\n promises = promises.concat(_promises);\n }\n await Promise.all(promises);\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * This is a generator, useful if you want most control on how messages\n * are processed.\n *\n * The order of the messages returned by the remote Waku node SHOULD BE\n * as follows:\n * - within a page, messages SHOULD be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n *\n * However, there is no way to guarantee the behavior of the remote node.\n *\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n */\n async *queryGenerator(decoders, options) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic } = this.options;\n let startTime, endTime;\n if (options?.timeFilter) {\n startTime = options.timeFilter.startTime;\n endTime = options.timeFilter.endTime;\n }\n const decodersAsMap = new Map();\n decoders.forEach((dec) => {\n if (decodersAsMap.has(dec.contentTopic)) {\n throw new Error(\"API does not support different decoder per content topic\");\n }\n decodersAsMap.set(dec.contentTopic, dec);\n });\n const contentTopics = decoders.map((dec) => dec.contentTopic);\n const queryOpts = Object.assign({\n pubSubTopic: pubSubTopic,\n pageDirection: _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection.BACKWARD,\n pageSize: DefaultPageSize,\n }, options, { contentTopics, startTime, endTime });\n log(\"Querying history with the following options\", {\n ...options,\n peerId: options?.peerId?.toString(),\n });\n const peer = await this.getPeer(options?.peerId);\n for await (const messages of paginate(this.newStream.bind(this, peer), queryOpts, decodersAsMap, options?.cursor)) {\n yield messages;\n }\n }\n}\nasync function* paginate(streamFactory, queryOpts, decoders, cursor) {\n if (queryOpts.contentTopics.toString() !==\n Array.from(decoders.keys()).toString()) {\n throw new Error(\"Internal error, the decoders should match the query's content topics\");\n }\n let currentCursor = cursor;\n while (true) {\n queryOpts.cursor = currentCursor;\n const historyRpcQuery = _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.HistoryRpc.createQuery(queryOpts);\n log(\"Querying store peer\", `for (${queryOpts.pubSubTopic})`, queryOpts.contentTopics);\n const stream = await streamFactory();\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const reply = historyRpcQuery.decode(bytes);\n if (!reply.response) {\n log(\"Stopping pagination due to store `response` field missing\");\n break;\n }\n const response = reply.response;\n if (response.error && response.error !== HistoryError.NONE) {\n throw \"History response contains an Error: \" + response.error;\n }\n if (!response.messages || !response.messages.length) {\n log(\"Stopping pagination due to store `response.messages` field missing or empty\");\n break;\n }\n log(`${response.messages.length} messages retrieved from store`);\n yield response.messages.map((protoMsg) => {\n const contentTopic = protoMsg.contentTopic;\n if (typeof contentTopic !== \"undefined\") {\n const decoder = decoders.get(contentTopic);\n if (decoder) {\n return decoder.fromProtoObj(queryOpts.pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_10__.toProtoMessage)(protoMsg));\n }\n }\n return Promise.resolve(undefined);\n });\n const nextCursor = response.pagingInfo?.cursor;\n if (typeof nextCursor === \"undefined\") {\n // If the server does not return cursor then there is an issue,\n // Need to abort, or we end up in an infinite loop\n log(\"Stopping pagination due to `response.pagingInfo.cursor` missing from store response\");\n break;\n }\n currentCursor = nextCursor;\n const responsePageSize = response.pagingInfo?.pageSize;\n const queryPageSize = historyRpcQuery.query?.pagingInfo?.pageSize;\n if (\n // Response page size smaller than query, meaning this is the last page\n responsePageSize &&\n queryPageSize &&\n responsePageSize < queryPageSize) {\n break;\n }\n }\n}\nasync function createCursor(message, pubsubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic) {\n if (!message ||\n !message.timestamp ||\n !message.payload ||\n !message.contentTopic) {\n throw new Error(\"Message is missing required fields\");\n }\n const contentTopicBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_12__.sha256)((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.concat)([contentTopicBytes, message.payload]));\n const messageTime = BigInt(message.timestamp.getTime()) * BigInt(1000000);\n return {\n digest,\n pubsubTopic,\n senderTime: messageTime,\n receiverTime: messageTime,\n };\n}\nfunction wakuStore(init = {}) {\n return (libp2p) => new Store(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/store/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/to_proto_message.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/to_proto_message.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toProtoMessage: () => (/* binding */ toProtoMessage)\n/* harmony export */ });\nconst EmptyMessage = {\n payload: new Uint8Array(),\n contentTopic: \"\",\n version: undefined,\n timestamp: undefined,\n meta: undefined,\n rateLimitProof: undefined,\n ephemeral: undefined,\n};\nfunction toProtoMessage(wire) {\n return { ...EmptyMessage, ...wire };\n}\n//# sourceMappingURL=to_proto_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/to_proto_message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ waitForRemotePeer: () => (/* binding */ waitForRemotePeer)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var p_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-event */ \"./node_modules/p-event/index.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:wait-for-remote-peer\");\n/**\n * Wait for a remote peer to be ready given the passed protocols.\n * Must be used after attempting to connect to nodes, using\n * {@link @waku/core.WakuNode.dial} or a bootstrap method with\n * {@link @waku/sdk.createLightNode}.\n *\n * If the passed protocols is a GossipSub protocol, then it resolves only once\n * a peer is in a mesh, to help ensure that other peers will send and receive\n * message to us.\n *\n * @param waku The Waku Node\n * @param protocols The protocols that need to be enabled by remote peers.\n * @param timeoutMs A timeout value in milliseconds..\n *\n * @returns A promise that **resolves** if all desired protocols are fulfilled by\n * remote nodes, **rejects** if the timeoutMs is reached.\n * @throws If passing a protocol that is not mounted\n * @default Wait for remote peers with protocols enabled locally and no time out is applied.\n */\nasync function waitForRemotePeer(waku, protocols, timeoutMs) {\n protocols = protocols ?? getEnabledProtocols(waku);\n if (!waku.isStarted())\n return Promise.reject(\"Waku node is not started\");\n const promises = [];\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay)) {\n if (!waku.relay)\n throw new Error(\"Cannot wait for Relay peer: protocol not mounted\");\n promises.push(waitForGossipSubPeerInMesh(waku.relay));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store)) {\n if (!waku.store)\n throw new Error(\"Cannot wait for Store peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.store));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush)) {\n if (!waku.lightPush)\n throw new Error(\"Cannot wait for LightPush peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.lightPush));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter)) {\n if (!waku.filter)\n throw new Error(\"Cannot wait for Filter peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.filter));\n }\n if (timeoutMs) {\n await rejectOnTimeout(Promise.all(promises), timeoutMs, \"Timed out waiting for a remote peer.\");\n }\n else {\n await Promise.all(promises);\n }\n}\n/**\n * Wait for a peer with the given protocol to be connected.\n */\nasync function waitForConnectedPeer(protocol) {\n const codec = protocol.multicodec;\n const peers = await protocol.peers();\n if (peers.length) {\n log(`${codec} peer found: `, peers[0].id.toString());\n return;\n }\n await new Promise((resolve) => {\n const cb = (evt) => {\n if (evt.detail?.protocols?.includes(codec)) {\n log(\"Resolving for\", codec, evt.detail.protocols);\n protocol.removeLibp2pEventListener(\"peer:identify\", cb);\n resolve();\n }\n };\n protocol.addLibp2pEventListener(\"peer:identify\", cb);\n });\n}\n/**\n * Wait for a peer with the given protocol to be connected and in the gossipsub\n * mesh.\n */\nasync function waitForGossipSubPeerInMesh(waku) {\n let peers = waku.getMeshPeers();\n while (peers.length == 0) {\n await (0,p_event__WEBPACK_IMPORTED_MODULE_2__.pEvent)(waku.gossipSub, \"gossipsub:heartbeat\");\n peers = waku.getMeshPeers();\n }\n}\nconst awaitTimeout = (ms, rejectReason) => new Promise((_resolve, reject) => setTimeout(() => reject(rejectReason), ms));\nasync function rejectOnTimeout(promise, timeoutMs, rejectReason) {\n await Promise.race([promise, awaitTimeout(timeoutMs, rejectReason)]);\n}\nfunction getEnabledProtocols(waku) {\n const protocols = [];\n if (waku.relay) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay);\n }\n if (waku.filter) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter);\n }\n if (waku.store) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store);\n }\n if (waku.lightPush) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush);\n }\n return protocols;\n}\n//# sourceMappingURL=wait_for_remote_peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/waku.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/waku.js ***! - \***************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPingKeepAliveValueSecs: () => (/* binding */ DefaultPingKeepAliveValueSecs),\n/* harmony export */ DefaultRelayKeepAliveValueSecs: () => (/* binding */ DefaultRelayKeepAliveValueSecs),\n/* harmony export */ DefaultUserAgent: () => (/* binding */ DefaultUserAgent),\n/* harmony export */ WakuNode: () => (/* binding */ WakuNode)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/connection_manager.js\");\n\n\n\n\n\nconst DefaultPingKeepAliveValueSecs = 0;\nconst DefaultRelayKeepAliveValueSecs = 5 * 60;\nconst DefaultUserAgent = \"js-waku\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:waku\");\nclass WakuNode {\n libp2p;\n relay;\n store;\n filter;\n lightPush;\n connectionManager;\n constructor(options, libp2p, store, lightPush, filter, relay) {\n this.libp2p = libp2p;\n if (store) {\n this.store = store(libp2p);\n }\n if (filter) {\n this.filter = filter(libp2p);\n }\n if (lightPush) {\n this.lightPush = lightPush(libp2p);\n }\n if (relay) {\n this.relay = relay(libp2p);\n }\n const pingKeepAlive = options.pingKeepAlive || DefaultPingKeepAliveValueSecs;\n const relayKeepAlive = this.relay\n ? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs\n : 0;\n const peerId = this.libp2p.peerId.toString();\n this.connectionManager = _connection_manager_js__WEBPACK_IMPORTED_MODULE_4__.ConnectionManager.create(peerId, libp2p, { pingKeepAlive, relayKeepAlive }, this.relay);\n log(\"Waku node created\", peerId, `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this\n .lightPush}, filter: ${!!this.filter}`);\n }\n /**\n * Dials to the provided peer.\n *\n * @param peer The peer to dial\n * @param protocols Waku protocols we expect from the peer; Defaults to mounted protocols\n */\n async dial(peer, protocols) {\n const _protocols = protocols ?? [];\n const peerId = mapToPeerIdOrMultiaddr(peer);\n if (typeof protocols === \"undefined\") {\n this.relay && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay);\n this.store && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store);\n this.filter && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter);\n this.lightPush && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush);\n }\n const codecs = [];\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay)) {\n if (this.relay) {\n this.relay.gossipSub.multicodecs.forEach((codec) => codecs.push(codec));\n }\n else {\n log(\"Relay codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store)) {\n if (this.store) {\n codecs.push(this.store.multicodec);\n }\n else {\n log(\"Store codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush)) {\n if (this.lightPush) {\n codecs.push(this.lightPush.multicodec);\n }\n else {\n log(\"Light Push codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter)) {\n if (this.filter) {\n codecs.push(this.filter.multicodec);\n }\n else {\n log(\"Filter codec not included in dial codec: protocol not mounted locally\");\n }\n }\n log(`Dialing to ${peerId.toString()} with protocols ${_protocols}`);\n return this.libp2p.dialProtocol(peerId, codecs);\n }\n async start() {\n await this.libp2p.start();\n }\n async stop() {\n this.connectionManager.stop();\n await this.libp2p.stop();\n }\n isStarted() {\n return this.libp2p.isStarted();\n }\n /**\n * Return the local multiaddr with peer id on which libp2p is listening.\n *\n * @throws if libp2p is not listening on localhost.\n */\n getLocalMultiaddrWithID() {\n const localMultiaddr = this.libp2p\n .getMultiaddrs()\n .find((addr) => addr.toString().match(/127\\.0\\.0\\.1/));\n if (!localMultiaddr || localMultiaddr.toString() === \"\") {\n throw \"Not listening on localhost\";\n }\n return localMultiaddr + \"/p2p/\" + this.libp2p.peerId.toString();\n }\n}\nfunction mapToPeerIdOrMultiaddr(peerId) {\n return (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__.isPeerId)(peerId) ? peerId : (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(peerId);\n}\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/core/dist/lib/waku.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyDecoder: () => (/* binding */ TopicOnlyDecoder),\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js\");\n\n\nclass TopicOnlyMessage {\n pubsubTopic;\n proto;\n payload = new Uint8Array();\n rateLimitProof;\n timestamp;\n meta;\n ephemeral;\n constructor(pubsubTopic, proto) {\n this.pubsubTopic = pubsubTopic;\n this.proto = proto;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n}\nclass TopicOnlyDecoder {\n pubsubTopic = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DefaultPubsubTopic;\n contentTopic = \"\";\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.TopicOnlyMessage.decode(bytes);\n return Promise.resolve({\n contentTopic: protoMessage.contentTopic,\n payload: new Uint8Array(),\n rateLimitProof: undefined,\n timestamp: undefined,\n meta: undefined,\n version: undefined,\n ephemeral: undefined\n });\n }\n async fromProtoObj(pubsubTopic, proto) {\n return new TopicOnlyMessage(pubsubTopic, proto);\n }\n}\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/topic_only_message.js?"); /***/ }), @@ -5631,7 +6100,29 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/connection_manager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EConnectionStateEvents: () => (/* binding */ EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n Tags[\"LOCAL\"] = \"local-peer-cache\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\nvar EConnectionStateEvents;\n(function (EConnectionStateEvents) {\n EConnectionStateEvents[\"CONNECTION_STATUS\"] = \"waku:connection\";\n})(EConnectionStateEvents || (EConnectionStateEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/connection_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/constants.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/constants.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* binding */ DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* binding */ DefaultPubsubTopic)\n/* harmony export */ });\n/**\n * DefaultPubsubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubsubTopic = \"/waku/2/default-waku/proto\";\n/**\n * The default cluster ID for The Waku Network\n */\nconst DEFAULT_CLUSTER_ID = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/dns_discovery.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/dns_discovery.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/dns_discovery.js?"); /***/ }), @@ -5664,7 +6155,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=filter /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ SendError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.SendError),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DefaultPubsubTopic),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n/* harmony import */ var _dns_discovery_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./dns_discovery.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/dns_discovery.js\");\n/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./metadata.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/metadata.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/constants.js\");\n/* harmony import */ var _local_storage_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./local_storage.js */ \"./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/local_storage.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/index.js?"); /***/ }), @@ -5701,6 +6192,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=light_ /***/ }), +/***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/local_storage.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/local_storage.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=local_storage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/local_storage.js?"); + +/***/ }), + /***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/message.js": /*!********************************************************************************!*\ !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/message.js ***! @@ -5712,6 +6214,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=messag /***/ }), +/***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/metadata.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/metadata.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/metadata.js?"); + +/***/ }), + /***/ "./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/misc.js": /*!*****************************************************************************!*\ !*** ./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/misc.js ***! @@ -5741,7 +6254,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=peer_e /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Protocols: () => (/* binding */ Protocols),\n/* harmony export */ SendError: () => (/* binding */ SendError)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar SendError;\n(function (SendError) {\n SendError[\"GENERIC_FAIL\"] = \"Generic error\";\n SendError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n SendError[\"DECODE_FAILED\"] = \"Failed to decode\";\n SendError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n SendError[\"NO_RPC_RESPONSE\"] = \"No RPC response\";\n})(SendError || (SendError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/protocols.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ProtocolError: () => (/* binding */ ProtocolError),\n/* harmony export */ Protocols: () => (/* binding */ Protocols)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar ProtocolError;\n(function (ProtocolError) {\n /** Could not determine the origin of the fault. Best to check connectivity and try again */\n ProtocolError[\"GENERIC_FAIL\"] = \"Generic error\";\n /**\n * Failure to protobuf encode the message. This is not recoverable and needs\n * further investigation.\n */\n ProtocolError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n /**\n * Failure to protobuf decode the message. May be due to a remote peer issue,\n * ensuring that messages are sent via several peer enable mitigation of this error.\n */\n ProtocolError[\"DECODE_FAILED\"] = \"Failed to decode\";\n /**\n * The message payload is empty, making the message invalid. Ensure that a non-empty\n * payload is set on the outgoing message.\n */\n ProtocolError[\"EMPTY_PAYLOAD\"] = \"Payload is empty\";\n /**\n * The message size is above the maximum message size allowed on the Waku Network.\n * Compressing the message or using an alternative strategy for large messages is recommended.\n */\n ProtocolError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n /**\n * The PubsubTopic passed to the send function is not configured on the Waku node.\n * Please ensure that the PubsubTopic is used when initializing the Waku node.\n */\n ProtocolError[\"TOPIC_NOT_CONFIGURED\"] = \"Topic not configured\";\n /**\n * Failure to find a peer with suitable protocols. This may due to a connection issue.\n * Mitigation can be: retrying after a given time period, display connectivity issue\n * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`\n * on the connection manager before retrying.\n */\n ProtocolError[\"NO_PEER_AVAILABLE\"] = \"No peer available\";\n /**\n * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_FAULT\"] = \"Remote peer fault\";\n /**\n * The remote peer rejected the message. Information provided by the remote peer\n * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_REJECTED\"] = \"Remote peer rejected\";\n /**\n * The protocol request timed out without a response. This may be due to a connection issue.\n * Mitigation can be: retrying after a given time period\n */\n ProtocolError[\"REQUEST_TIMEOUT\"] = \"Request timeout\";\n})(ProtocolError || (ProtocolError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/interfaces/dist/protocols.js?"); /***/ }), @@ -5800,6 +6313,94 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.j /***/ }), +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.subscribe != null && obj.subscribe !== false)) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if ((obj.topic != null && obj.topic !== '')) {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n subscribe: false,\n topic: '',\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.subscribe = reader.bool();\n break;\n }\n case 2: {\n obj.topic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec(), opts);\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = FilterRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.push = MessagePush.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.push\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec(), opts);\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter_v2.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter_v2.js ***! + \***************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null && __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.filterSubscribeType = FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n }\n case 10: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 11: {\n if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentTopics\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentTopics.push(reader.string());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec(), opts);\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if ((obj.statusCode != null && obj.statusCode !== 0)) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n statusCode: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 10: {\n obj.statusCode = reader.uint32();\n break;\n }\n case 11: {\n obj.statusDesc = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec(), opts);\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.wakuMessage\n });\n break;\n }\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter_v2.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/light_push.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/light_push.js ***! + \****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 2: {\n obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.message\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec(), opts);\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.isSuccess != null && obj.isSuccess !== false)) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n isSuccess: false\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.isSuccess = reader.bool();\n break;\n }\n case 2: {\n obj.info = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec(), opts);\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = PushRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.response = PushResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec(), opts);\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/message.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/message.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/metadata.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/metadata.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ WakuMetadataRequest: () => (/* binding */ WakuMetadataRequest),\n/* harmony export */ WakuMetadataResponse: () => (/* binding */ WakuMetadataResponse)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar WakuMetadataRequest;\n(function (WakuMetadataRequest) {\n let _codec;\n WakuMetadataRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataRequest.codec());\n };\n WakuMetadataRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataRequest.codec(), opts);\n };\n})(WakuMetadataRequest || (WakuMetadataRequest = {}));\nvar WakuMetadataResponse;\n(function (WakuMetadataResponse) {\n let _codec;\n WakuMetadataResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataResponse.codec());\n };\n WakuMetadataResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataResponse.codec(), opts);\n };\n})(WakuMetadataResponse || (WakuMetadataResponse = {}));\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/peer_exchange.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/peer_exchange.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.enr = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec(), opts);\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.numPeers = reader.uint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec(), opts);\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n peerInfos: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"peerInfos\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.peerInfos$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec(), opts);\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 2: {\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec(), opts);\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/store.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/store.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.digest != null && obj.digest.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if ((obj.receiverTime != null && obj.receiverTime !== 0n)) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if ((obj.senderTime != null && obj.senderTime !== 0n)) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n digest: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.digest = reader.bytes();\n break;\n }\n case 2: {\n obj.receiverTime = reader.sint64();\n break;\n }\n case 3: {\n obj.senderTime = reader.sint64();\n break;\n }\n case 4: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec(), opts);\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pageSize = reader.uint64();\n break;\n }\n case 2: {\n obj.cursor = Index.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.cursor\n });\n break;\n }\n case 3: {\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec(), opts);\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n case 4: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 5: {\n obj.startTime = reader.sint64();\n break;\n }\n case 6: {\n obj.endTime = reader.sint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec(), opts);\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n HistoryError[\"TOO_MANY_RESULTS\"] = \"TOO_MANY_RESULTS\";\n HistoryError[\"SERVICE_UNAVAILABLE\"] = \"SERVICE_UNAVAILABLE\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n __HistoryErrorValues[__HistoryErrorValues[\"TOO_MANY_RESULTS\"] = 429] = \"TOO_MANY_RESULTS\";\n __HistoryErrorValues[__HistoryErrorValues[\"SERVICE_UNAVAILABLE\"] = 503] = \"SERVICE_UNAVAILABLE\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n case 3: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 4: {\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec(), opts);\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 3: {\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec(), opts);\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/topic_only_message.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/topic_only_message.js ***! + \************************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec(), opts);\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/topic_only_message.js?"); + +/***/ }), + /***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js": /*!*************************************************************************!*\ !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js ***! @@ -5807,139 +6408,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.j /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _lib_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _lib_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _lib_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/message.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/message.js\");\n/* harmony import */ var _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/filter.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter.js\");\n/* harmony import */ var _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/topic_only_message.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js\");\n/* harmony import */ var _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/filter_v2.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter_v2.js\");\n/* harmony import */ var _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/light_push.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/light_push.js\");\n/* harmony import */ var _lib_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/store.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/store.js\");\n/* harmony import */ var _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/peer_exchange.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/peer_exchange.js\");\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter.js ***! - \******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.subscribe != null && obj.subscribe !== false) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if (obj.topic != null && obj.topic !== \"\") {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n subscribe: false,\n topic: \"\",\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.subscribe = reader.bool();\n break;\n case 2:\n obj.topic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec());\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = FilterRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.push = MessagePush.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec());\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter_v2.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter_v2.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null &&\n __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.filterSubscribeType =\n FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n case 10:\n obj.pubsubTopic = reader.string();\n break;\n case 11:\n obj.contentTopics.push(reader.string());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec());\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.statusCode != null && obj.statusCode !== 0) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n statusCode: 0,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 10:\n obj.statusCode = reader.uint32();\n break;\n case 11:\n obj.statusDesc = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec());\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter_v2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/light_push.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/light_push.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pubsubTopic = reader.string();\n break;\n case 2:\n obj.message = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec());\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.isSuccess != null && obj.isSuccess !== false) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n isSuccess: false,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.isSuccess = reader.bool();\n break;\n case 2:\n obj.info = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec());\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = PushRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = PushResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec());\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/light_push.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/message.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/message.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/peer_exchange.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/peer_exchange.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.enr = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec());\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.numPeers = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec());\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerInfos: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec());\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec());\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/peer_exchange.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/store.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/store.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.digest != null && obj.digest.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if (obj.receiverTime != null && obj.receiverTime !== 0n) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if (obj.senderTime != null && obj.senderTime !== 0n) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n digest: new Uint8Array(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.digest = reader.bytes();\n break;\n case 2:\n obj.receiverTime = reader.sint64();\n break;\n case 3:\n obj.senderTime = reader.sint64();\n break;\n case 4:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec());\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pageSize = reader.uint64();\n break;\n case 2:\n obj.cursor = Index.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec());\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 5:\n obj.startTime = reader.sint64();\n break;\n case 6:\n obj.endTime = reader.sint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec());\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n case 3:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 4:\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec());\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec());\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/store.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec());\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/abort-error.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/abort-error.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/abort-error.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/index.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/index.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/abortable-iterator/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/it-merge/dist/src/index.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/it-merge/dist/src/index.js ***! - \**************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Merge several (async)iterables into one, yield values as they arrive.\n *\n * Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.\n *\n * @example\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values1 = [0, 1, 2, 3, 4]\n * const values2 = [5, 6, 7, 8, 9]\n *\n * const arr = all(merge(values1, values2))\n *\n * console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const values1 = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n * const values2 = async function * () {\n * yield * [5, 6, 7, 8, 9]\n * }\n *\n * const arr = await all(merge(values1(), values2()))\n *\n * console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction merge(...sources) {\n const syncSources = [];\n for (const source of sources) {\n if (!isAsyncIterable(source)) {\n syncSources.push(source);\n }\n }\n if (syncSources.length === sources.length) {\n // all sources are synchronous\n return (function* () {\n for (const source of syncSources) {\n yield* source;\n }\n })();\n }\n return (async function* () {\n const output = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n void Promise.resolve().then(async () => {\n try {\n await Promise.all(sources.map(async (source) => {\n for await (const item of source) {\n output.push(item);\n }\n }));\n output.end();\n }\n catch (err) {\n output.end(err);\n }\n });\n yield* output;\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (merge);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/it-merge/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pipe: () => (/* binding */ pipe),\n/* harmony export */ rawPipe: () => (/* binding */ rawPipe)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/@waku/relay/node_modules/it-merge/dist/src/index.js\");\n\n\nfunction pipe(first, ...rest) {\n if (first == null) {\n throw new Error('Empty pipeline');\n }\n // Duplex at start: wrap in function and return duplex source\n if (isDuplex(first)) {\n const duplex = first;\n first = () => duplex.source;\n // Iterable at start: wrap in function\n }\n else if (isIterable(first) || isAsyncIterable(first)) {\n const source = first;\n first = () => source;\n }\n const fns = [first, ...rest];\n if (fns.length > 1) {\n // Duplex at end: use duplex sink\n if (isDuplex(fns[fns.length - 1])) {\n fns[fns.length - 1] = fns[fns.length - 1].sink;\n }\n }\n if (fns.length > 2) {\n // Duplex in the middle, consume source with duplex sink and return duplex source\n for (let i = 1; i < fns.length - 1; i++) {\n if (isDuplex(fns[i])) {\n fns[i] = duplexPipelineFn(fns[i]);\n }\n }\n }\n return rawPipe(...fns);\n}\nconst rawPipe = (...fns) => {\n let res;\n while (fns.length > 0) {\n res = fns.shift()(res);\n }\n return res;\n};\nconst isAsyncIterable = (obj) => {\n return obj?.[Symbol.asyncIterator] != null;\n};\nconst isIterable = (obj) => {\n return obj?.[Symbol.iterator] != null;\n};\nconst isDuplex = (obj) => {\n if (obj == null) {\n return false;\n }\n return obj.sink != null && obj.source != null;\n};\nconst duplexPipelineFn = (duplex) => {\n return (source) => {\n const p = duplex.sink(source);\n if (p?.then != null) {\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n p.then(() => {\n stream.end();\n }, (err) => {\n stream.end(err);\n });\n let sourceWrap;\n const source = duplex.source;\n if (isAsyncIterable(source)) {\n sourceWrap = async function* () {\n yield* source;\n stream.end();\n };\n }\n else if (isIterable(source)) {\n sourceWrap = function* () {\n yield* source;\n stream.end();\n };\n }\n else {\n throw new Error('Unknown duplex source type - must be Iterable or AsyncIterable');\n }\n return (0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(stream, sourceWrap());\n }\n return duplex.source;\n };\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/it-pipe/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/dist/create.js": -/*!***********************************************!*\ - !*** ./node_modules/@waku/sdk/dist/create.js ***! - \***********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createFullNode: () => (/* binding */ createFullNode),\n/* harmony export */ createLightNode: () => (/* binding */ createLightNode),\n/* harmony export */ createRelayNode: () => (/* binding */ createRelayNode),\n/* harmony export */ defaultLibp2p: () => (/* binding */ defaultLibp2p),\n/* harmony export */ defaultPeerDiscovery: () => (/* binding */ defaultPeerDiscovery)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_libp2p_noise__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/libp2p-noise */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/index.js\");\n/* harmony import */ var _libp2p_mplex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/mplex */ \"./node_modules/@libp2p/mplex/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/websockets */ \"./node_modules/@libp2p/websockets/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets_filters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/websockets/filters */ \"./node_modules/@libp2p/websockets/dist/src/filters.js\");\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_dns_discovery__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @waku/dns-discovery */ \"./node_modules/@waku/dns-discovery/dist/index.js\");\n/* harmony import */ var _waku_relay__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @waku/relay */ \"./node_modules/@waku/relay/dist/index.js\");\n/* harmony import */ var libp2p__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! libp2p */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/index.js\");\n/* harmony import */ var libp2p_identify__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! libp2p/identify */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/index.js\");\n/* harmony import */ var libp2p_ping__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! libp2p/ping */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst DEFAULT_NODE_REQUIREMENTS = {\n lightPush: 1,\n filter: 1,\n store: 1,\n};\n/**\n * Create a Waku node that uses Waku Light Push, Filter and Store to send and\n * receive messages, enabling low resource consumption.\n * Uses Waku Filter V2 by default.\n */\nasync function createLightNode(options) {\n const libp2pOptions = options?.libp2p ?? {};\n const peerDiscovery = libp2pOptions.peerDiscovery ?? [];\n if (options?.defaultBootstrap) {\n peerDiscovery.push(defaultPeerDiscovery());\n Object.assign(libp2pOptions, { peerDiscovery });\n }\n const libp2p = await defaultLibp2p(undefined, libp2pOptions, options?.userAgent);\n const store = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuStore)(options);\n const lightPush = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuLightPush)(options);\n const filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilter)(options);\n return new _waku_core__WEBPACK_IMPORTED_MODULE_4__.WakuNode(options ?? {}, libp2p, store, lightPush, filter);\n}\n/**\n * Create a Waku node that uses Waku Relay to send and receive messages,\n * enabling some privacy preserving properties.\n */\nasync function createRelayNode(options) {\n const libp2pOptions = options?.libp2p ?? {};\n const peerDiscovery = libp2pOptions.peerDiscovery ?? [];\n if (options?.defaultBootstrap) {\n peerDiscovery.push(defaultPeerDiscovery());\n Object.assign(libp2pOptions, { peerDiscovery });\n }\n const libp2p = await defaultLibp2p((0,_waku_relay__WEBPACK_IMPORTED_MODULE_6__.wakuGossipSub)(options), libp2pOptions, options?.userAgent);\n const relay = (0,_waku_relay__WEBPACK_IMPORTED_MODULE_6__.wakuRelay)(options);\n return new _waku_core__WEBPACK_IMPORTED_MODULE_4__.WakuNode(options ?? {}, libp2p, undefined, undefined, undefined, relay);\n}\n/**\n * Create a Waku node that uses all Waku protocols.\n *\n * This helper is not recommended except if:\n * - you are interfacing with nwaku v0.11 or below\n * - you are doing some form of testing\n *\n * If you are building a full node, it is recommended to use\n * [nwaku](github.com/status-im/nwaku) and its JSON RPC API or wip REST API.\n *\n * @see https://github.com/status-im/nwaku/issues/1085\n * @internal\n */\nasync function createFullNode(options) {\n const libp2pOptions = options?.libp2p ?? {};\n const peerDiscovery = libp2pOptions.peerDiscovery ?? [];\n if (options?.defaultBootstrap) {\n peerDiscovery.push(defaultPeerDiscovery());\n Object.assign(libp2pOptions, { peerDiscovery });\n }\n const libp2p = await defaultLibp2p((0,_waku_relay__WEBPACK_IMPORTED_MODULE_6__.wakuGossipSub)(options), libp2pOptions, options?.userAgent);\n const store = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuStore)(options);\n const lightPush = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuLightPush)(options);\n const filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilter)(options);\n const relay = (0,_waku_relay__WEBPACK_IMPORTED_MODULE_6__.wakuRelay)(options);\n return new _waku_core__WEBPACK_IMPORTED_MODULE_4__.WakuNode(options ?? {}, libp2p, store, lightPush, filter, relay);\n}\nfunction defaultPeerDiscovery() {\n return (0,_waku_dns_discovery__WEBPACK_IMPORTED_MODULE_5__.wakuDnsDiscovery)([_waku_dns_discovery__WEBPACK_IMPORTED_MODULE_5__.enrTree[\"PROD\"]], DEFAULT_NODE_REQUIREMENTS);\n}\nasync function defaultLibp2p(wakuGossipSub, options, userAgent) {\n const pubsubService = wakuGossipSub\n ? { pubsub: wakuGossipSub }\n : {};\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_7__.createLibp2p)({\n connectionManager: {\n minConnections: 1,\n },\n transports: [(0,_libp2p_websockets__WEBPACK_IMPORTED_MODULE_2__.webSockets)({ filter: _libp2p_websockets_filters__WEBPACK_IMPORTED_MODULE_3__.all })],\n streamMuxers: [(0,_libp2p_mplex__WEBPACK_IMPORTED_MODULE_1__.mplex)()],\n connectionEncryption: [(0,_chainsafe_libp2p_noise__WEBPACK_IMPORTED_MODULE_0__.noise)()],\n ...options,\n services: {\n identify: (0,libp2p_identify__WEBPACK_IMPORTED_MODULE_8__.identifyService)({\n agentVersion: userAgent ?? _waku_core__WEBPACK_IMPORTED_MODULE_4__.DefaultUserAgent,\n }),\n ping: (0,libp2p_ping__WEBPACK_IMPORTED_MODULE_9__.pingService)(),\n ...pubsubService,\n ...options?.services,\n },\n }); // TODO: make libp2p include it;\n}\n//# sourceMappingURL=create.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/create.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _generated_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_metadata: () => (/* reexport module object */ _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _generated_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _generated_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generated/message.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/message.js\");\n/* harmony import */ var _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./generated/filter.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter.js\");\n/* harmony import */ var _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./generated/topic_only_message.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/topic_only_message.js\");\n/* harmony import */ var _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./generated/filter_v2.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/filter_v2.js\");\n/* harmony import */ var _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generated/light_push.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/light_push.js\");\n/* harmony import */ var _generated_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./generated/store.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/store.js\");\n/* harmony import */ var _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./generated/peer_exchange.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/peer_exchange.js\");\n/* harmony import */ var _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./generated/metadata.js */ \"./node_modules/@waku/relay/node_modules/@waku/proto/dist/generated/metadata.js\");\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/proto/dist/index.js?"); /***/ }), @@ -5950,128 +6419,95 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.DecodedMessage),\n/* harmony export */ Decoder: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.Decoder),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__.EPeersByDiscoveryEvents),\n/* harmony export */ Encoder: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.Encoder),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__.PageDirection),\n/* harmony export */ Protocols: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ SendError: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__.SendError),\n/* harmony export */ Tags: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__.Tags),\n/* harmony export */ WakuNode: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.WakuNode),\n/* harmony export */ bytesToUtf8: () => (/* reexport safe */ _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.bytesToUtf8),\n/* harmony export */ createDecoder: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.createDecoder),\n/* harmony export */ createEncoder: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.createEncoder),\n/* harmony export */ createFullNode: () => (/* reexport safe */ _create_js__WEBPACK_IMPORTED_MODULE_3__.createFullNode),\n/* harmony export */ createLightNode: () => (/* reexport safe */ _create_js__WEBPACK_IMPORTED_MODULE_3__.createLightNode),\n/* harmony export */ createRelayNode: () => (/* reexport safe */ _create_js__WEBPACK_IMPORTED_MODULE_3__.createRelayNode),\n/* harmony export */ defaultLibp2p: () => (/* reexport safe */ _create_js__WEBPACK_IMPORTED_MODULE_3__.defaultLibp2p),\n/* harmony export */ defaultPeerDiscovery: () => (/* reexport safe */ _create_js__WEBPACK_IMPORTED_MODULE_3__.defaultPeerDiscovery),\n/* harmony export */ relay: () => (/* reexport module object */ _waku_relay__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ utf8ToBytes: () => (/* reexport safe */ _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.utf8ToBytes),\n/* harmony export */ utils: () => (/* reexport module object */ _waku_utils__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ waitForRemotePeer: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.waitForRemotePeer),\n/* harmony export */ waku: () => (/* reexport module object */ _waku_core__WEBPACK_IMPORTED_MODULE_0__)\n/* harmony export */ });\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/core/lib/message/version_0 */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _create_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./create.js */ \"./node_modules/@waku/sdk/dist/create.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_relay__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @waku/relay */ \"./node_modules/@waku/relay/dist/index.js\");\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DecodedMessage: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.DecodedMessage),\n/* harmony export */ Decoder: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.Decoder),\n/* harmony export */ DefaultPingKeepAliveValueSecs: () => (/* reexport safe */ _waku_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPingKeepAliveValueSecs),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.DefaultPubsubTopic),\n/* harmony export */ DefaultRelayKeepAliveValueSecs: () => (/* reexport safe */ _waku_js__WEBPACK_IMPORTED_MODULE_5__.DefaultRelayKeepAliveValueSecs),\n/* harmony export */ DefaultUserAgent: () => (/* reexport safe */ _waku_js__WEBPACK_IMPORTED_MODULE_5__.DefaultUserAgent),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.EPeersByDiscoveryEvents),\n/* harmony export */ Encoder: () => (/* reexport safe */ _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__.Encoder),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__.Tags),\n/* harmony export */ WakuNode: () => (/* reexport safe */ _waku_js__WEBPACK_IMPORTED_MODULE_5__.WakuNode),\n/* harmony export */ bytesToUtf8: () => (/* reexport safe */ _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.bytesToUtf8),\n/* harmony export */ createDecoder: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.createDecoder),\n/* harmony export */ createEncoder: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.createEncoder),\n/* harmony export */ createLightNode: () => (/* reexport safe */ _light_node_index_js__WEBPACK_IMPORTED_MODULE_6__.createLightNode),\n/* harmony export */ createNode: () => (/* reexport safe */ _light_node_index_js__WEBPACK_IMPORTED_MODULE_6__.createNode),\n/* harmony export */ defaultLibp2p: () => (/* reexport safe */ _utils_libp2p_js__WEBPACK_IMPORTED_MODULE_3__.defaultLibp2p),\n/* harmony export */ relay: () => (/* reexport module object */ _waku_relay__WEBPACK_IMPORTED_MODULE_11__),\n/* harmony export */ streamContentTopic: () => (/* reexport safe */ _utils_content_topic_js__WEBPACK_IMPORTED_MODULE_4__.streamContentTopic),\n/* harmony export */ subscribeToContentTopic: () => (/* reexport safe */ _utils_content_topic_js__WEBPACK_IMPORTED_MODULE_4__.subscribeToContentTopic),\n/* harmony export */ utf8ToBytes: () => (/* reexport safe */ _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.utf8ToBytes),\n/* harmony export */ utils: () => (/* reexport module object */ _waku_utils__WEBPACK_IMPORTED_MODULE_9__),\n/* harmony export */ waitForRemotePeer: () => (/* reexport safe */ _waku_core__WEBPACK_IMPORTED_MODULE_0__.waitForRemotePeer),\n/* harmony export */ waku: () => (/* reexport module object */ _waku_core__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ wakuLightPush: () => (/* reexport safe */ _protocols_light_push_js__WEBPACK_IMPORTED_MODULE_7__.wakuLightPush),\n/* harmony export */ wakuStore: () => (/* reexport safe */ _protocols_store_js__WEBPACK_IMPORTED_MODULE_8__.wakuStore)\n/* harmony export */ });\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_core_lib_message_version_0__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/core/lib/message/version_0 */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _utils_libp2p_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils/libp2p.js */ \"./node_modules/@waku/sdk/dist/utils/libp2p.js\");\n/* harmony import */ var _utils_content_topic_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/content_topic.js */ \"./node_modules/@waku/sdk/dist/utils/content_topic.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/sdk/dist/waku.js\");\n/* harmony import */ var _light_node_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./light-node/index.js */ \"./node_modules/@waku/sdk/dist/light-node/index.js\");\n/* harmony import */ var _protocols_light_push_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./protocols/light_push.js */ \"./node_modules/@waku/sdk/dist/protocols/light_push.js\");\n/* harmony import */ var _protocols_store_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./protocols/store.js */ \"./node_modules/@waku/sdk/dist/protocols/store.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_relay__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @waku/relay */ \"./node_modules/@waku/relay/dist/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/index.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/index.js ***! - \********************************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/light-node/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/light-node/index.js ***! + \*********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isConnection: () => (/* binding */ isConnection),\n/* harmony export */ symbol: () => (/* binding */ symbol)\n/* harmony export */ });\nconst symbol = Symbol.for('@libp2p/connection');\nfunction isConnection(other) {\n return other != null && Boolean(other[symbol]);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createLightNode: () => (/* binding */ createLightNode),\n/* harmony export */ createNode: () => (/* binding */ createNode)\n/* harmony export */ });\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _protocols_light_push_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../protocols/light_push.js */ \"./node_modules/@waku/sdk/dist/protocols/light_push.js\");\n/* harmony import */ var _protocols_store_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../protocols/store.js */ \"./node_modules/@waku/sdk/dist/protocols/store.js\");\n/* harmony import */ var _utils_libp2p_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/libp2p.js */ \"./node_modules/@waku/sdk/dist/utils/libp2p.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../waku.js */ \"./node_modules/@waku/sdk/dist/waku.js\");\n\n\n\n\n\n/**\n * Create a Waku node configured to use autosharding or static sharding.\n */\nasync function createNode(options = { pubsubTopics: [] }) {\n if (!options.shardInfo) {\n throw new Error(\"Shard info must be set\");\n }\n const libp2p = await (0,_utils_libp2p_js__WEBPACK_IMPORTED_MODULE_3__.createLibp2pAndUpdateOptions)(options);\n const store = (0,_protocols_store_js__WEBPACK_IMPORTED_MODULE_2__.wakuStore)(options);\n const lightPush = (0,_protocols_light_push_js__WEBPACK_IMPORTED_MODULE_1__.wakuLightPush)(options);\n const filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_0__.wakuFilter)(options);\n return new _waku_js__WEBPACK_IMPORTED_MODULE_4__.WakuNode(options, libp2p, store, lightPush, filter);\n}\n/**\n * Create a Waku node that uses Waku Light Push, Filter and Store to send and\n * receive messages, enabling low resource consumption.\n * Uses Waku Filter V2 by default.\n */\nasync function createLightNode(options = {}) {\n const libp2p = await (0,_utils_libp2p_js__WEBPACK_IMPORTED_MODULE_3__.createLibp2pAndUpdateOptions)(options);\n const store = (0,_protocols_store_js__WEBPACK_IMPORTED_MODULE_2__.wakuStore)(options);\n const lightPush = (0,_protocols_light_push_js__WEBPACK_IMPORTED_MODULE_1__.wakuLightPush)(options);\n const filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_0__.wakuFilter)(options);\n return new _waku_js__WEBPACK_IMPORTED_MODULE_4__.WakuNode(options, libp2p, store, lightPush, filter);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/light-node/index.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/status.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/status.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/protocols/base_protocol.js": +/*!****************************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/protocols/base_protocol.js ***! + \****************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CLOSED: () => (/* binding */ CLOSED),\n/* harmony export */ CLOSING: () => (/* binding */ CLOSING),\n/* harmony export */ OPEN: () => (/* binding */ OPEN)\n/* harmony export */ });\nconst OPEN = 'OPEN';\nconst CLOSING = 'CLOSING';\nconst CLOSED = 'CLOSED';\n//# sourceMappingURL=status.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/status.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseProtocolSDK: () => (/* binding */ BaseProtocolSDK)\n/* harmony export */ });\nconst DEFAULT_NUM_PEERS_TO_USE = 3;\nclass BaseProtocolSDK {\n numPeers;\n constructor(options) {\n this.numPeers = options?.numPeersToUse ?? DEFAULT_NUM_PEERS_TO_USE;\n }\n}\n//# sourceMappingURL=base_protocol.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/protocols/base_protocol.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/interface-peer-store/dist/src/tags.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/interface-peer-store/dist/src/tags.js ***! - \*******************************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/protocols/light_push.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/protocols/light_push.js ***! + \*************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KEEP_ALIVE: () => (/* binding */ KEEP_ALIVE)\n/* harmony export */ });\nconst KEEP_ALIVE = 'keep-alive';\n//# sourceMappingURL=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/interface-peer-store/dist/src/tags.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LightPushSDK: () => (/* binding */ LightPushSDK),\n/* harmony export */ wakuLightPush: () => (/* binding */ wakuLightPush)\n/* harmony export */ });\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base_protocol.js */ \"./node_modules/@waku/sdk/dist/protocols/base_protocol.js\");\n\n\n\n\nconst DEFAULT_NUM_PEERS = 3;\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"sdk:light-push\");\nclass LightPushSDK extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_3__.BaseProtocolSDK {\n protocol;\n constructor(libp2p, options) {\n super({ numPeersToUse: options?.numPeersToUse ?? DEFAULT_NUM_PEERS });\n this.protocol = new _waku_core__WEBPACK_IMPORTED_MODULE_0__.LightPushCore(libp2p, options);\n }\n async send(encoder, message) {\n const successes = [];\n const failures = [];\n const { pubsubTopic } = encoder;\n try {\n (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.ensurePubsubTopicIsConfigured)(pubsubTopic, this.protocol.pubsubTopics);\n }\n catch (error) {\n log.error(\"Failed to send waku light push: pubsub topic not configured\");\n return {\n failures: [\n {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.ProtocolError.TOPIC_NOT_CONFIGURED\n }\n ],\n successes: []\n };\n }\n const peers = await this.protocol.getPeers();\n if (!peers.length) {\n return {\n successes,\n failures: [{ error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.ProtocolError.NO_PEER_AVAILABLE }]\n };\n }\n const sendPromises = peers.map((peer) => this.protocol.send(encoder, message, peer));\n const results = await Promise.allSettled(sendPromises);\n for (const result of results) {\n if (result.status === \"fulfilled\") {\n const { failure, success } = result.value;\n if (success) {\n successes.push(success);\n }\n if (failure) {\n failures.push(failure);\n }\n }\n else {\n log.error(\"Failed to send message to peer\", result.reason);\n failures.push({ error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.ProtocolError.GENERIC_FAIL });\n // TODO: handle renewing faulty peers with new peers (https://github.com/waku-org/js-waku/issues/1463)\n }\n }\n return {\n successes,\n failures\n };\n }\n}\nfunction wakuLightPush(init = {}) {\n return (libp2p) => new LightPushSDK(libp2p, init);\n}\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/protocols/light_push.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js ***! - \***********************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/protocols/store.js": +/*!********************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/protocols/store.js ***! + \********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes)\n/* harmony export */ });\nconst codes = {\n ERR_INVALID_PARAMETERS: 'ERR_INVALID_PARAMETERS'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPageSize: () => (/* binding */ DefaultPageSize),\n/* harmony export */ StoreSDK: () => (/* binding */ StoreSDK),\n/* harmony export */ wakuStore: () => (/* binding */ wakuStore)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@waku/sdk/dist/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base_protocol.js */ \"./node_modules/@waku/sdk/dist/protocols/base_protocol.js\");\n\n\n\n\n\n\n\nconst DefaultPageSize = 10;\nconst DEFAULT_NUM_PEERS = 1;\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"waku:store:protocol\");\nclass StoreSDK extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocolSDK {\n protocol;\n constructor(libp2p, options) {\n // TODO: options.numPeersToUse is disregarded: https://github.com/waku-org/js-waku/issues/1685\n super({ numPeersToUse: DEFAULT_NUM_PEERS });\n this.protocol = new _waku_core__WEBPACK_IMPORTED_MODULE_0__.StoreCore(libp2p, options);\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * This is a generator, useful if you want most control on how messages\n * are processed.\n *\n * The order of the messages returned by the remote Waku node SHOULD BE\n * as follows:\n * - within a page, messages SHOULD be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n *\n * This API only supports querying a single pubsub topic at a time.\n * If multiple decoders are provided, they must all have the same pubsub topic.\n * @throws If multiple decoders with different pubsub topics are provided.\n * @throws If no decoders are provided.\n * @throws If no decoders are found for the provided pubsub topic.\n */\n async *queryGenerator(decoders, options) {\n const { pubsubTopic, contentTopics, decodersAsMap } = this.validateDecodersAndPubsubTopic(decoders, options);\n const queryOpts = this.constructOptions(pubsubTopic, contentTopics, options);\n const peer = (await this.protocol.getPeers({\n numPeers: this.numPeers,\n maxBootstrapPeers: 1\n }))[0];\n if (!peer)\n throw new Error(\"No peers available to query\");\n const responseGenerator = this.protocol.queryPerPage(queryOpts, decodersAsMap, peer);\n for await (const messages of responseGenerator) {\n yield messages;\n }\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * The callback function takes a `WakuMessage` in input,\n * messages are processed in order:\n * - oldest to latest if `options.pageDirection` == { @link PageDirection.FORWARD }\n * - latest to oldest if `options.pageDirection` == { @link PageDirection.BACKWARD }\n *\n * The ordering may affect performance.\n * The ordering depends on the behavior of the remote store node.\n * If strong ordering is needed, you may need to handle this at application level\n * and set your own timestamps too (the WakuMessage timestamps are not certified).\n *\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n */\n async queryWithOrderedCallback(decoders, callback, options) {\n for await (const promises of this.queryGenerator(decoders, options)) {\n if (await this.processMessages(promises, callback, options))\n break;\n }\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n * The callback function takes a `Promise` in input,\n * useful if messages need to be decrypted and performance matters.\n *\n * The order of the messages passed to the callback is as follows:\n * - within a page, messages are expected to be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n *\n * Do note that the resolution of the `Promise {\n if (abort)\n return;\n abort = Boolean(await callback(msgPromise));\n });\n await Promise.all(_promises);\n if (abort)\n break;\n }\n }\n createCursor(message) {\n if (!message ||\n !message.timestamp ||\n !message.payload ||\n !message.contentTopic) {\n throw new Error(\"Message is missing required fields\");\n }\n const contentTopicBytes = (0,_index_js__WEBPACK_IMPORTED_MODULE_4__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_6__.sha256)((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_3__.concat)([contentTopicBytes, message.payload]));\n const messageTime = BigInt(message.timestamp.getTime()) * BigInt(1000000);\n return {\n digest,\n pubsubTopic: message.pubsubTopic,\n senderTime: messageTime,\n receiverTime: messageTime\n };\n }\n validateDecodersAndPubsubTopic(decoders, options) {\n if (decoders.length === 0) {\n throw new Error(\"No decoders provided\");\n }\n // convert array to set to remove duplicates\n const uniquePubsubTopicsInQuery = Array.from(new Set(decoders.map((decoder) => decoder.pubsubTopic)));\n // If multiple pubsub topics are provided, throw an error\n if (uniquePubsubTopicsInQuery.length > 1) {\n throw new Error(\"API does not support querying multiple pubsub topics at once\");\n }\n // we can be certain that there is only one pubsub topic in the query\n const pubsubTopicForQuery = uniquePubsubTopicsInQuery[0];\n (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.ensurePubsubTopicIsConfigured)(pubsubTopicForQuery, this.protocol.pubsubTopics);\n // check that the pubsubTopic from the Cursor and Decoder match\n if (options?.cursor?.pubsubTopic &&\n options.cursor.pubsubTopic !== pubsubTopicForQuery) {\n throw new Error(`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubsubTopicForQuery})`);\n }\n const decodersAsMap = new Map();\n decoders.forEach((dec) => {\n if (decodersAsMap.has(dec.contentTopic)) {\n throw new Error(\"API does not support different decoder per content topic\");\n }\n decodersAsMap.set(dec.contentTopic, dec);\n });\n const contentTopics = decoders\n .filter((decoder) => decoder.pubsubTopic === pubsubTopicForQuery)\n .map((dec) => dec.contentTopic);\n if (contentTopics.length === 0) {\n throw new Error(\"No decoders found for topic \" + pubsubTopicForQuery);\n }\n return {\n pubsubTopic: pubsubTopicForQuery,\n contentTopics,\n decodersAsMap\n };\n }\n constructOptions(pubsubTopic, contentTopics, options = {}) {\n let startTime, endTime;\n if (options?.timeFilter) {\n startTime = options.timeFilter.startTime;\n endTime = options.timeFilter.endTime;\n }\n if (!startTime) {\n log.warn(\"No start time provided\");\n }\n if (!endTime) {\n log.warn(\"No end time provided\");\n }\n const queryOpts = Object.assign({\n pubsubTopic: pubsubTopic,\n pageDirection: _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.PageDirection.BACKWARD,\n pageSize: DefaultPageSize\n }, options, { contentTopics, startTime, endTime });\n return queryOpts;\n }\n /**\n * Processes messages based on the provided callback and options.\n * @private\n */\n async processMessages(messages, callback, options) {\n let abort = false;\n const messagesOrUndef = await Promise.all(messages);\n let processedMessages = messagesOrUndef.filter(_waku_utils__WEBPACK_IMPORTED_MODULE_2__.isDefined);\n if (this.shouldReverseOrder(options)) {\n processedMessages = processedMessages.reverse();\n }\n await Promise.all(processedMessages.map(async (msg) => {\n if (msg && !abort) {\n abort = Boolean(await callback(msg));\n }\n }));\n return abort;\n }\n /**\n * Determines whether to reverse the order of messages based on the provided options.\n *\n * Messages in pages are ordered from oldest (first) to most recent (last).\n * https://github.com/vacp2p/rfc/issues/533\n *\n * @private\n */\n shouldReverseOrder(options) {\n return (typeof options?.pageDirection === \"undefined\" ||\n options?.pageDirection === _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.PageDirection.BACKWARD);\n }\n}\nfunction wakuStore(init = {}) {\n return (libp2p) => new StoreSDK(libp2p, init);\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/protocols/store.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/index.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/utils/content_topic.js": +/*!************************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/utils/content_topic.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PersistentPeerStore: () => (/* binding */ PersistentPeerStore)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/store.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store');\n/**\n * An implementation of PeerStore that stores data in a Datastore\n */\nclass PersistentPeerStore {\n store;\n events;\n peerId;\n constructor(components, init = {}) {\n this.events = components.events;\n this.peerId = components.peerId;\n this.store = new _store_js__WEBPACK_IMPORTED_MODULE_3__.PersistentStore(components, init);\n }\n async forEach(fn, query) {\n log.trace('forEach await read lock');\n const release = await this.store.lock.readLock();\n log.trace('forEach got read lock');\n try {\n for await (const peer of this.store.all(query)) {\n fn(peer);\n }\n }\n finally {\n log.trace('forEach release read lock');\n release();\n }\n }\n async all(query) {\n log.trace('all await read lock');\n const release = await this.store.lock.readLock();\n log.trace('all got read lock');\n try {\n return await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(this.store.all(query));\n }\n finally {\n log.trace('all release read lock');\n release();\n }\n }\n async delete(peerId) {\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n try {\n await this.store.delete(peerId);\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n }\n async has(peerId) {\n log.trace('has await read lock');\n const release = await this.store.lock.readLock();\n log.trace('has got read lock');\n try {\n return await this.store.has(peerId);\n }\n finally {\n log.trace('has release read lock');\n release();\n }\n }\n async get(peerId) {\n log.trace('get await read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n return await this.store.load(peerId);\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n }\n async save(id, data) {\n log.trace('save await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('save got write lock');\n try {\n const result = await this.store.save(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n log.trace('save release write lock');\n release();\n }\n }\n async patch(id, data) {\n log.trace('patch await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('patch got write lock');\n try {\n const result = await this.store.patch(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n log.trace('patch release write lock');\n release();\n }\n }\n async merge(id, data) {\n log.trace('merge await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('merge got write lock');\n try {\n const result = await this.store.merge(id, data);\n this.#emitIfUpdated(id, result);\n return result.peer;\n }\n finally {\n log.trace('merge release write lock');\n release();\n }\n }\n async consumePeerRecord(buf, expectedPeer) {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.openAndCertify(buf, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.PeerRecord.DOMAIN);\n if (expectedPeer?.equals(envelope.peerId) === false) {\n log('envelope peer id was not the expected peer id - expected: %p received: %p', expectedPeer, envelope.peerId);\n return false;\n }\n const peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.PeerRecord.createFromProtobuf(envelope.payload);\n let peer;\n try {\n peer = await this.get(envelope.peerId);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n // ensure seq is greater than, or equal to, the last received\n if (peer?.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.createFromProtobuf(peer.peerRecordEnvelope);\n const storedRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.PeerRecord.createFromProtobuf(storedEnvelope.payload);\n if (storedRecord.seqNumber >= peerRecord.seqNumber) {\n log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);\n return false;\n }\n }\n await this.patch(peerRecord.peerId, {\n peerRecordEnvelope: buf,\n addresses: peerRecord.multiaddrs.map(multiaddr => ({\n isCertified: true,\n multiaddr\n }))\n });\n return true;\n }\n #emitIfUpdated(id, result) {\n if (!result.updated) {\n return;\n }\n if (this.peerId.equals(id)) {\n this.events.safeDispatchEvent('self:peer:update', { detail: result });\n }\n else {\n this.events.safeDispatchEvent('peer:update', { detail: result });\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ streamContentTopic: () => (/* binding */ streamContentTopic),\n/* harmony export */ subscribeToContentTopic: () => (/* binding */ subscribeToContentTopic)\n/* harmony export */ });\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _light_node_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../light-node/index.js */ \"./node_modules/@waku/sdk/dist/light-node/index.js\");\n\n\n\n\n// Given a Waku node, peer Multiaddr, and content topic, creates a decoder and\n// subscription for that content topic.\nasync function prepareSubscription(waku, contentTopic, peer) {\n // Validate that the Waku node matches assumptions\n if (!waku.filter) {\n throw new Error(\"Filter protocol missing from Waku node\");\n }\n const { shardInfo } = waku.libp2p.components.metadata;\n if (!shardInfo) {\n throw new Error(\"Shard info missing from Waku node.\");\n }\n // Validate content topic and ensure node is configured for its corresponding pubsub topic\n const pubsubTopics = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.shardInfoToPubsubTopics)(shardInfo);\n const pubsubTopic = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.contentTopicToPubsubTopic)(contentTopic);\n if (!pubsubTopics.includes(pubsubTopic))\n throw new Error(\"Content topic does not match any pubsub topic in shard info.\");\n await waku.dial(peer);\n await (0,_waku_core__WEBPACK_IMPORTED_MODULE_0__.waitForRemotePeer)(waku, [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Protocols.Filter]);\n // Create decoder and subscription\n let decoder = (0,_waku_core__WEBPACK_IMPORTED_MODULE_0__.createDecoder)(contentTopic, pubsubTopic);\n if (decoder)\n decoder = decoder ?? decoder;\n const subscription = await waku.filter.createSubscription(pubsubTopic);\n return { decoder, subscription };\n}\n/**\n * Creates a subscription and streams all new messages for a content topic.\n * Will create a light node configured for the content topic with default settings if a node is not provided in `opts`.\n * Assumes node is using autosharding.\n * @param contentTopic\n * @param opts\n */\nasync function streamContentTopic(contentTopic, opts) {\n opts.waku =\n opts.waku ??\n (await (0,_light_node_index_js__WEBPACK_IMPORTED_MODULE_3__.createLightNode)({\n shardInfo: { contentTopics: [contentTopic] }\n }));\n const { decoder, subscription } = await prepareSubscription(opts.waku, contentTopic, opts.peer);\n // Create a ReadableStream that receives any messages for the content topic\n const messageStream = new ReadableStream({\n async start(controller) {\n await subscription.subscribe(decoder, (message) => {\n controller.enqueue(message);\n });\n },\n cancel() {\n return subscription.unsubscribe([contentTopic]);\n }\n });\n return [messageStream, opts.waku];\n}\n/**\n * Subscribes to new messages for a content topic via callback function.\n * Will create a light node configured for the content topic with default settings if a node is not provided in `opts`.\n * Assumes node is using autosharding.\n * @param contentTopic\n * @param callback Called every time a new message is received on the content topic\n * @param opts\n */\nasync function subscribeToContentTopic(contentTopic, callback, opts) {\n opts.waku =\n opts.waku ??\n (await (0,_light_node_index_js__WEBPACK_IMPORTED_MODULE_3__.createLightNode)({\n shardInfo: { contentTopics: [contentTopic] }\n }));\n const { decoder, subscription } = await prepareSubscription(opts.waku, contentTopic, opts.peer);\n await subscription.subscribe(decoder, callback);\n return { subscription, waku: opts.waku };\n}\n//# sourceMappingURL=content_topic.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/utils/content_topic.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/pb/peer.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/pb/peer.js ***! - \************************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/utils/discovery.js": +/*!********************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/utils/discovery.js ***! + \********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Address: () => (/* binding */ Address),\n/* harmony export */ Peer: () => (/* binding */ Peer),\n/* harmony export */ Tag: () => (/* binding */ Tag)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Peer;\n(function (Peer) {\n let Peer$metadataEntry;\n (function (Peer$metadataEntry) {\n let _codec;\n Peer$metadataEntry.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.key != null && obj.key !== '')) {\n w.uint32(10);\n w.string(obj.key);\n }\n if ((obj.value != null && obj.value.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.value);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n key: '',\n value: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.key = reader.string();\n break;\n case 2:\n obj.value = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer$metadataEntry.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer$metadataEntry.codec());\n };\n Peer$metadataEntry.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer$metadataEntry.codec());\n };\n })(Peer$metadataEntry = Peer.Peer$metadataEntry || (Peer.Peer$metadataEntry = {}));\n let Peer$tagsEntry;\n (function (Peer$tagsEntry) {\n let _codec;\n Peer$tagsEntry.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.key != null && obj.key !== '')) {\n w.uint32(10);\n w.string(obj.key);\n }\n if (obj.value != null) {\n w.uint32(18);\n Tag.codec().encode(obj.value, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n key: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.key = reader.string();\n break;\n case 2:\n obj.value = Tag.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer$tagsEntry.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer$tagsEntry.codec());\n };\n Peer$tagsEntry.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer$tagsEntry.codec());\n };\n })(Peer$tagsEntry = Peer.Peer$tagsEntry || (Peer.Peer$tagsEntry = {}));\n let _codec;\n Peer.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(10);\n Address.codec().encode(value, w);\n }\n }\n if (obj.protocols != null) {\n for (const value of obj.protocols) {\n w.uint32(18);\n w.string(value);\n }\n }\n if (obj.publicKey != null) {\n w.uint32(34);\n w.bytes(obj.publicKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (obj.metadata != null && obj.metadata.size !== 0) {\n for (const [key, value] of obj.metadata.entries()) {\n w.uint32(50);\n Peer.Peer$metadataEntry.codec().encode({ key, value }, w);\n }\n }\n if (obj.tags != null && obj.tags.size !== 0) {\n for (const [key, value] of obj.tags.entries()) {\n w.uint32(58);\n Peer.Peer$tagsEntry.codec().encode({ key, value }, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: new Map(),\n tags: new Map()\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.addresses.push(Address.codec().decode(reader, reader.uint32()));\n break;\n case 2:\n obj.protocols.push(reader.string());\n break;\n case 4:\n obj.publicKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = reader.bytes();\n break;\n case 6: {\n const entry = Peer.Peer$metadataEntry.codec().decode(reader, reader.uint32());\n obj.metadata.set(entry.key, entry.value);\n break;\n }\n case 7: {\n const entry = Peer.Peer$tagsEntry.codec().decode(reader, reader.uint32());\n obj.tags.set(entry.key, entry.value);\n break;\n }\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Peer.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Peer.codec());\n };\n Peer.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Peer.codec());\n };\n})(Peer || (Peer = {}));\nvar Address;\n(function (Address) {\n let _codec;\n Address.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.multiaddr != null && obj.multiaddr.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.multiaddr);\n }\n if (obj.isCertified != null) {\n w.uint32(16);\n w.bool(obj.isCertified);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n multiaddr: new Uint8Array(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.multiaddr = reader.bytes();\n break;\n case 2:\n obj.isCertified = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Address.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Address.codec());\n };\n Address.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Address.codec());\n };\n})(Address || (Address = {}));\nvar Tag;\n(function (Tag) {\n let _codec;\n Tag.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.value != null && obj.value !== 0)) {\n w.uint32(8);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(16);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n value: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.value = reader.uint32();\n break;\n case 2:\n obj.expiry = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Tag.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tag.codec());\n };\n Tag.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tag.codec());\n };\n})(Tag || (Tag = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/pb/peer.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultPeerDiscoveries: () => (/* binding */ defaultPeerDiscoveries)\n/* harmony export */ });\n/* harmony import */ var _waku_discovery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/discovery */ \"./node_modules/@waku/discovery/dist/index.js\");\n\nconst DEFAULT_NODE_REQUIREMENTS = {\n lightPush: 1,\n filter: 1,\n store: 1\n};\nfunction defaultPeerDiscoveries(pubsubTopics) {\n const discoveries = [\n (0,_waku_discovery__WEBPACK_IMPORTED_MODULE_0__.wakuDnsDiscovery)([_waku_discovery__WEBPACK_IMPORTED_MODULE_0__.enrTree[\"SANDBOX\"]], DEFAULT_NODE_REQUIREMENTS),\n (0,_waku_discovery__WEBPACK_IMPORTED_MODULE_0__.wakuLocalPeerCacheDiscovery)(),\n (0,_waku_discovery__WEBPACK_IMPORTED_MODULE_0__.wakuPeerExchangeDiscovery)(pubsubTopics)\n ];\n return discoveries;\n}\n//# sourceMappingURL=discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/utils/discovery.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/store.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/store.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/utils/libp2p.js": +/*!*****************************************************!*\ + !*** ./node_modules/@waku/sdk/dist/utils/libp2p.js ***! + \*****************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PersistentStore: () => (/* binding */ PersistentStore)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var _utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils/bytes-to-peer.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js\");\n/* harmony import */ var _utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/peer-id-to-datastore-key.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js\");\n/* harmony import */ var _utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils/to-peer-pb.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js\");\n\n\n\n\n\n\n\n\n\n\n\nfunction decodePeer(key, value, cache) {\n // /peers/${peer-id-as-libp2p-key-cid-string-in-base-32}\n const base32Str = key.toString().split('/')[2];\n const buf = multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_4__.base32.decode(base32Str);\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(buf);\n const cached = cache.get(peerId);\n if (cached != null) {\n return cached;\n }\n const peer = (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__.bytesToPeer)(peerId, value);\n cache.set(peerId, peer);\n return peer;\n}\nfunction mapQuery(query, cache) {\n if (query == null) {\n return {};\n }\n return {\n prefix: _utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.NAMESPACE_COMMON,\n filters: (query.filters ?? []).map(fn => ({ key, value }) => {\n return fn(decodePeer(key, value, cache));\n }),\n orders: (query.orders ?? []).map(fn => (a, b) => {\n return fn(decodePeer(a.key, a.value, cache), decodePeer(b.key, b.value, cache));\n })\n };\n}\nclass PersistentStore {\n peerId;\n datastore;\n lock;\n addressFilter;\n constructor(components, init = {}) {\n this.peerId = components.peerId;\n this.datastore = components.datastore;\n this.addressFilter = init.addressFilter;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_3__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n async has(peerId) {\n return this.datastore.has((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.peerIdToDatastoreKey)(peerId));\n }\n async delete(peerId) {\n if (this.peerId.equals(peerId)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Cannot delete self peer', _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n await this.datastore.delete((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.peerIdToDatastoreKey)(peerId));\n }\n async load(peerId) {\n const buf = await this.datastore.get((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.peerIdToDatastoreKey)(peerId));\n return (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__.bytesToPeer)(peerId, buf);\n }\n async save(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_10__.toPeerPB)(peerId, data, 'patch', {\n addressFilter: this.addressFilter\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async patch(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_10__.toPeerPB)(peerId, data, 'patch', {\n addressFilter: this.addressFilter,\n existingPeer\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async merge(peerId, data) {\n const { existingBuf, existingPeer } = await this.#findExistingPeer(peerId);\n const peerPb = await (0,_utils_to_peer_pb_js__WEBPACK_IMPORTED_MODULE_10__.toPeerPB)(peerId, data, 'merge', {\n addressFilter: this.addressFilter,\n existingPeer\n });\n return this.#saveIfDifferent(peerId, peerPb, existingBuf, existingPeer);\n }\n async *all(query) {\n const peerCache = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__.PeerMap();\n for await (const { key, value } of this.datastore.query(mapQuery(query ?? {}, peerCache))) {\n const peer = decodePeer(key, value, peerCache);\n if (peer.id.equals(this.peerId)) {\n // Skip self peer if present\n continue;\n }\n yield peer;\n }\n }\n async #findExistingPeer(peerId) {\n try {\n const existingBuf = await this.datastore.get((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.peerIdToDatastoreKey)(peerId));\n const existingPeer = (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__.bytesToPeer)(peerId, existingBuf);\n return {\n existingBuf,\n existingPeer\n };\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n return {};\n }\n async #saveIfDifferent(peerId, peer, existingBuf, existingPeer) {\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.encode(peer);\n if (existingBuf != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__.equals)(buf, existingBuf)) {\n return {\n peer: (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__.bytesToPeer)(peerId, buf),\n previous: existingPeer,\n updated: false\n };\n }\n await this.datastore.put((0,_utils_peer_id_to_datastore_key_js__WEBPACK_IMPORTED_MODULE_9__.peerIdToDatastoreKey)(peerId), buf);\n return {\n peer: (0,_utils_bytes_to_peer_js__WEBPACK_IMPORTED_MODULE_8__.bytesToPeer)(peerId, buf),\n previous: existingPeer,\n updated: true\n };\n }\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/store.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createLibp2pAndUpdateOptions: () => (/* binding */ createLibp2pAndUpdateOptions),\n/* harmony export */ defaultLibp2p: () => (/* binding */ defaultLibp2p)\n/* harmony export */ });\n/* harmony import */ var _chainsafe_libp2p_noise__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @chainsafe/libp2p-noise */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/index.js\");\n/* harmony import */ var _libp2p_bootstrap__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @libp2p/bootstrap */ \"./node_modules/@libp2p/bootstrap/dist/src/index.js\");\n/* harmony import */ var _libp2p_identify__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/identify */ \"./node_modules/@libp2p/identify/dist/src/index.js\");\n/* harmony import */ var _libp2p_mplex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/mplex */ \"./node_modules/@libp2p/mplex/dist/src/index.js\");\n/* harmony import */ var _libp2p_ping__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/ping */ \"./node_modules/@libp2p/ping/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/websockets */ \"./node_modules/@libp2p/websockets/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets_filters__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/websockets/filters */ \"./node_modules/@libp2p/websockets/dist/src/filters.js\");\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_relay__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/relay */ \"./node_modules/@waku/relay/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var libp2p__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! libp2p */ \"./node_modules/libp2p/dist/src/index.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../waku.js */ \"./node_modules/@waku/sdk/dist/waku.js\");\n/* harmony import */ var _discovery_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./discovery.js */ \"./node_modules/@waku/sdk/dist/utils/discovery.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nasync function defaultLibp2p(shardInfo, wakuGossipSub, options, userAgent) {\n if (!options?.hideWebSocketInfo && \"development\" !== \"test\") {\n /* eslint-disable no-console */\n console.info(\"%cIgnore WebSocket connection failures\", \"background: gray; color: white; font-size: x-large\");\n console.info(\"%cWaku tries to discover peers and some of them are expected to fail\", \"background: gray; color: white; font-size: x-large\");\n /* eslint-enable no-console */\n }\n const pubsubService = wakuGossipSub\n ? { pubsub: wakuGossipSub }\n : {};\n const metadataService = shardInfo\n ? { metadata: (0,_waku_core__WEBPACK_IMPORTED_MODULE_1__.wakuMetadata)(shardInfo) }\n : {};\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_7__.createLibp2p)({\n connectionManager: {\n minConnections: 1\n },\n transports: [(0,_libp2p_websockets__WEBPACK_IMPORTED_MODULE_8__.webSockets)({ filter: _libp2p_websockets_filters__WEBPACK_IMPORTED_MODULE_9__.all })],\n streamMuxers: [(0,_libp2p_mplex__WEBPACK_IMPORTED_MODULE_10__.mplex)()],\n connectionEncryption: [(0,_chainsafe_libp2p_noise__WEBPACK_IMPORTED_MODULE_0__.noise)()],\n ...options,\n services: {\n identify: (0,_libp2p_identify__WEBPACK_IMPORTED_MODULE_11__.identify)({\n agentVersion: userAgent ?? _waku_js__WEBPACK_IMPORTED_MODULE_5__.DefaultUserAgent\n }),\n ping: (0,_libp2p_ping__WEBPACK_IMPORTED_MODULE_12__.ping)(),\n ...metadataService,\n ...pubsubService,\n ...options?.services\n }\n }); // TODO: make libp2p include it;\n}\nasync function createLibp2pAndUpdateOptions(options) {\n const shardInfo = options.shardInfo\n ? (0,_waku_utils__WEBPACK_IMPORTED_MODULE_4__.ensureShardingConfigured)(options.shardInfo)\n : undefined;\n options.pubsubTopics = shardInfo?.pubsubTopics ??\n options.pubsubTopics ?? [_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.DefaultPubsubTopic];\n const libp2pOptions = options?.libp2p ?? {};\n const peerDiscovery = libp2pOptions.peerDiscovery ?? [];\n if (options?.defaultBootstrap) {\n peerDiscovery.push(...(0,_discovery_js__WEBPACK_IMPORTED_MODULE_6__.defaultPeerDiscoveries)(options.pubsubTopics));\n }\n if (options?.bootstrapPeers) {\n peerDiscovery.push((0,_libp2p_bootstrap__WEBPACK_IMPORTED_MODULE_13__.bootstrap)({ list: options.bootstrapPeers }));\n }\n libp2pOptions.peerDiscovery = peerDiscovery;\n const libp2p = await defaultLibp2p(shardInfo?.shardInfo, (0,_waku_relay__WEBPACK_IMPORTED_MODULE_3__.wakuGossipSub)(options), libp2pOptions, options?.userAgent);\n return libp2p;\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/utils/libp2p.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js ***! - \************************************************************************************************/ +/***/ "./node_modules/@waku/sdk/dist/waku.js": +/*!*********************************************!*\ + !*** ./node_modules/@waku/sdk/dist/waku.js ***! + \*********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bytesToPeer: () => (/* binding */ bytesToPeer)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../pb/peer.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n\n\n\nfunction bytesToPeer(peerId, buf) {\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_2__.Peer.decode(buf);\n if (peer.publicKey != null && peerId.publicKey == null) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromPeerId)({\n ...peerId,\n publicKey: peerId.publicKey\n });\n }\n const tags = new Map();\n // remove any expired tags\n const now = BigInt(Date.now());\n for (const [key, tag] of peer.tags.entries()) {\n if (tag.expiry != null && tag.expiry < now) {\n continue;\n }\n tags.set(key, tag);\n }\n return {\n ...peer,\n id: peerId,\n addresses: peer.addresses.map(({ multiaddr: ma, isCertified }) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata: peer.metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined,\n tags\n };\n}\n//# sourceMappingURL=bytes-to-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/bytes-to-peer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ dedupeFilterAndSortAddresses: () => (/* binding */ dedupeFilterAndSortAddresses)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js\");\n\n\n\nasync function dedupeFilterAndSortAddresses(peerId, filter, addresses) {\n const addressMap = new Map();\n for (const addr of addresses) {\n if (addr == null) {\n continue;\n }\n if (addr.multiaddr instanceof Uint8Array) {\n addr.multiaddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(addr.multiaddr);\n }\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.isMultiaddr)(addr.multiaddr)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Multiaddr was invalid', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (!(await filter(peerId, addr.multiaddr))) {\n continue;\n }\n const isCertified = addr.isCertified ?? false;\n const maStr = addr.multiaddr.toString();\n const existingAddr = addressMap.get(maStr);\n if (existingAddr != null) {\n addr.isCertified = existingAddr.isCertified || isCertified;\n }\n else {\n addressMap.set(maStr, {\n multiaddr: addr.multiaddr,\n isCertified\n });\n }\n }\n return [...addressMap.values()]\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ isCertified, multiaddr }) => ({\n isCertified,\n multiaddr: multiaddr.bytes\n }));\n}\n//# sourceMappingURL=dedupe-addresses.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js ***! - \***********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NAMESPACE_COMMON: () => (/* binding */ NAMESPACE_COMMON),\n/* harmony export */ peerIdToDatastoreKey: () => (/* binding */ peerIdToDatastoreKey)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js\");\n\n\n\n\nconst NAMESPACE_COMMON = '/peers/';\nfunction peerIdToDatastoreKey(peerId) {\n if (!(0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__.isPeerId)(peerId) || peerId.type == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Invalid PeerId', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const b32key = peerId.toCID().toString();\n return new interface_datastore_key__WEBPACK_IMPORTED_MODULE_2__.Key(`${NAMESPACE_COMMON}${b32key}`);\n}\n//# sourceMappingURL=peer-id-to-datastore-key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/peer-id-to-datastore-key.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toPeerPB: () => (/* binding */ toPeerPB)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var _dedupe_addresses_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dedupe-addresses.js */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/dedupe-addresses.js\");\n\n\n\n\nasync function toPeerPB(peerId, data, strategy, options) {\n if (data == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Invalid PeerData', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (data.publicKey != null && peerId.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__.equals)(data.publicKey, peerId.publicKey)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n const existingPeer = options.existingPeer;\n if (existingPeer != null && !peerId.equals(existingPeer.id)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('peer id did not match existing peer id', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n let addresses = existingPeer?.addresses ?? [];\n let protocols = new Set(existingPeer?.protocols ?? []);\n let metadata = existingPeer?.metadata ?? new Map();\n let tags = existingPeer?.tags ?? new Map();\n let peerRecordEnvelope = existingPeer?.peerRecordEnvelope;\n // when patching, we replace the original fields with passed values\n if (strategy === 'patch') {\n if (data.multiaddrs != null || data.addresses != null) {\n addresses = [];\n if (data.multiaddrs != null) {\n addresses.push(...data.multiaddrs.map(multiaddr => ({\n isCertified: false,\n multiaddr\n })));\n }\n if (data.addresses != null) {\n addresses.push(...data.addresses);\n }\n }\n if (data.protocols != null) {\n protocols = new Set(data.protocols);\n }\n if (data.metadata != null) {\n const metadataEntries = data.metadata instanceof Map ? [...data.metadata.entries()] : Object.entries(data.metadata);\n metadata = createSortedMap(metadataEntries, {\n validate: validateMetadata\n });\n }\n if (data.tags != null) {\n const tagsEntries = data.tags instanceof Map ? [...data.tags.entries()] : Object.entries(data.tags);\n tags = createSortedMap(tagsEntries, {\n validate: validateTag,\n map: mapTag\n });\n }\n if (data.peerRecordEnvelope != null) {\n peerRecordEnvelope = data.peerRecordEnvelope;\n }\n }\n // when merging, we join the original fields with passed values\n if (strategy === 'merge') {\n if (data.multiaddrs != null) {\n addresses.push(...data.multiaddrs.map(multiaddr => ({\n isCertified: false,\n multiaddr\n })));\n }\n if (data.addresses != null) {\n addresses.push(...data.addresses);\n }\n if (data.protocols != null) {\n protocols = new Set([...protocols, ...data.protocols]);\n }\n if (data.metadata != null) {\n const metadataEntries = data.metadata instanceof Map ? [...data.metadata.entries()] : Object.entries(data.metadata);\n for (const [key, value] of metadataEntries) {\n if (value == null) {\n metadata.delete(key);\n }\n else {\n metadata.set(key, value);\n }\n }\n metadata = createSortedMap([...metadata.entries()], {\n validate: validateMetadata\n });\n }\n if (data.tags != null) {\n const tagsEntries = data.tags instanceof Map ? [...data.tags.entries()] : Object.entries(data.tags);\n const mergedTags = new Map(tags);\n for (const [key, value] of tagsEntries) {\n if (value == null) {\n mergedTags.delete(key);\n }\n else {\n mergedTags.set(key, value);\n }\n }\n tags = createSortedMap([...mergedTags.entries()], {\n validate: validateTag,\n map: mapTag\n });\n }\n if (data.peerRecordEnvelope != null) {\n peerRecordEnvelope = data.peerRecordEnvelope;\n }\n }\n const output = {\n addresses: await (0,_dedupe_addresses_js__WEBPACK_IMPORTED_MODULE_3__.dedupeFilterAndSortAddresses)(peerId, options.addressFilter ?? (async () => true), addresses),\n protocols: [...protocols.values()].sort((a, b) => {\n return a.localeCompare(b);\n }),\n metadata,\n tags,\n publicKey: existingPeer?.id.publicKey ?? data.publicKey ?? peerId.publicKey,\n peerRecordEnvelope\n };\n // Ed25519 and secp256k1 have their public key embedded in them so no need to duplicate it\n if (peerId.type !== 'RSA') {\n delete output.publicKey;\n }\n return output;\n}\n/**\n * In JS maps are ordered by insertion order so create a new map with the\n * keys inserted in alphabetical order.\n */\nfunction createSortedMap(entries, options) {\n const output = new Map();\n for (const [key, value] of entries) {\n if (value == null) {\n continue;\n }\n options.validate(key, value);\n }\n for (const [key, value] of entries.sort(([a], [b]) => {\n return a.localeCompare(b);\n })) {\n if (value != null) {\n output.set(key, options.map?.(key, value) ?? value);\n }\n }\n return output;\n}\nfunction validateMetadata(key, value) {\n if (typeof key !== 'string') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Metadata key must be a string', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (!(value instanceof Uint8Array)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Metadata value must be a Uint8Array', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n}\nfunction validateTag(key, tag) {\n if (typeof key !== 'string') {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Tag name must be a string', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.value != null) {\n if (parseInt(`${tag.value}`, 10) !== tag.value) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Tag value must be an integer', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.value < 0 || tag.value > 100) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Tag value must be between 0-100', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n if (tag.ttl != null) {\n if (parseInt(`${tag.ttl}`, 10) !== tag.ttl) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Tag ttl must be an integer', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n if (tag.ttl < 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Tag ttl must be between greater than 0', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n}\nfunction mapTag(key, tag) {\n let expiry;\n if (tag.expiry != null) {\n expiry = tag.expiry;\n }\n if (tag.ttl != null) {\n expiry = BigInt(Date.now() + Number(tag.ttl));\n }\n return {\n value: tag.value ?? 0,\n expiry\n };\n}\n//# sourceMappingURL=to-peer-pb.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/utils/to-peer-pb.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPingKeepAliveValueSecs: () => (/* binding */ DefaultPingKeepAliveValueSecs),\n/* harmony export */ DefaultRelayKeepAliveValueSecs: () => (/* binding */ DefaultRelayKeepAliveValueSecs),\n/* harmony export */ DefaultUserAgent: () => (/* binding */ DefaultUserAgent),\n/* harmony export */ WakuNode: () => (/* binding */ WakuNode)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-id/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _waku_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _utils_content_topic_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/content_topic.js */ \"./node_modules/@waku/sdk/dist/utils/content_topic.js\");\n\n\n\n\n\n\nconst DefaultPingKeepAliveValueSecs = 5 * 60;\nconst DefaultRelayKeepAliveValueSecs = 5 * 60;\nconst DefaultUserAgent = \"js-waku\";\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_3__.Logger(\"waku\");\nclass WakuNode {\n libp2p;\n relay;\n store;\n filter;\n lightPush;\n connectionManager;\n pubsubTopics;\n constructor(options, libp2p, store, lightPush, filter, relay) {\n if (options.pubsubTopics.length == 0) {\n throw new Error(\"At least one pubsub topic must be provided\");\n }\n this.pubsubTopics = options.pubsubTopics;\n this.libp2p = libp2p;\n if (store) {\n this.store = store(libp2p);\n }\n if (filter) {\n this.filter = filter(libp2p);\n }\n if (lightPush) {\n this.lightPush = lightPush(libp2p);\n }\n if (relay) {\n this.relay = relay(libp2p);\n }\n const pingKeepAlive = options.pingKeepAlive || DefaultPingKeepAliveValueSecs;\n const relayKeepAlive = this.relay\n ? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs\n : 0;\n const peerId = this.libp2p.peerId.toString();\n this.connectionManager = _waku_core__WEBPACK_IMPORTED_MODULE_1__.ConnectionManager.create(peerId, libp2p, { pingKeepAlive, relayKeepAlive }, this.pubsubTopics, this.relay);\n log.info(\"Waku node created\", peerId, `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this\n .lightPush}, filter: ${!!this.filter}`);\n }\n /**\n * Dials to the provided peer.\n *\n * @param peer The peer to dial\n * @param protocols Waku protocols we expect from the peer; Defaults to mounted protocols\n */\n async dial(peer, protocols) {\n const _protocols = protocols ?? [];\n const peerId = mapToPeerIdOrMultiaddr(peer);\n if (typeof protocols === \"undefined\") {\n this.relay && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay);\n this.store && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store);\n this.filter && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter);\n this.lightPush && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush);\n }\n const codecs = [];\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay)) {\n if (this.relay) {\n this.relay.gossipSub.multicodecs.forEach((codec) => codecs.push(codec));\n }\n else {\n log.error(\"Relay codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store)) {\n if (this.store) {\n codecs.push(this.store.protocol.multicodec);\n }\n else {\n log.error(\"Store codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush)) {\n if (this.lightPush) {\n codecs.push(this.lightPush.protocol.multicodec);\n }\n else {\n log.error(\"Light Push codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter)) {\n if (this.filter) {\n codecs.push(this.filter.multicodec);\n }\n else {\n log.error(\"Filter codec not included in dial codec: protocol not mounted locally\");\n }\n }\n log.info(`Dialing to ${peerId.toString()} with protocols ${_protocols}`);\n return this.libp2p.dialProtocol(peerId, codecs);\n }\n async start() {\n await this.libp2p.start();\n }\n async stop() {\n this.connectionManager.stop();\n await this.libp2p.stop();\n }\n async subscribeToContentTopic(contentTopic, peer, callback) {\n return (await (0,_utils_content_topic_js__WEBPACK_IMPORTED_MODULE_4__.subscribeToContentTopic)(contentTopic, callback, {\n waku: this,\n peer\n })).subscription;\n }\n isStarted() {\n return this.libp2p.status == \"started\";\n }\n isConnected() {\n return this.connectionManager.isConnected();\n }\n /**\n * Return the local multiaddr with peer id on which libp2p is listening.\n *\n * @throws if libp2p is not listening on localhost.\n */\n getLocalMultiaddrWithID() {\n const localMultiaddr = this.libp2p\n .getMultiaddrs()\n .find((addr) => addr.toString().match(/127\\.0\\.0\\.1/));\n if (!localMultiaddr || localMultiaddr.toString() === \"\") {\n throw \"Not listening on localhost\";\n }\n return localMultiaddr + \"/p2p/\" + this.libp2p.peerId.toString();\n }\n}\nfunction mapToPeerIdOrMultiaddr(peerId) {\n return (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.isPeerId)(peerId) ? peerId : (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(peerId);\n}\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/dist/waku.js?"); /***/ }), @@ -6082,7 +6518,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* reexport safe */ _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_8__.ConnectionManager),\n/* harmony export */ DefaultPubSubTopic: () => (/* reexport safe */ _lib_constants_js__WEBPACK_IMPORTED_MODULE_1__.DefaultPubSubTopic),\n/* harmony export */ DefaultUserAgent: () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__.DefaultUserAgent),\n/* harmony export */ KeepAliveManager: () => (/* reexport safe */ _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_9__.KeepAliveManager),\n/* harmony export */ LightPushCodec: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.LightPushCodec),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.PageDirection),\n/* harmony export */ StoreCodec: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.StoreCodec),\n/* harmony export */ WakuNode: () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__.WakuNode),\n/* harmony export */ createCursor: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.createCursor),\n/* harmony export */ createDecoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__.createDecoder),\n/* harmony export */ createEncoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__.createEncoder),\n/* harmony export */ message: () => (/* reexport module object */ _lib_message_index_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ waitForRemotePeer: () => (/* reexport safe */ _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_7__.waitForRemotePeer),\n/* harmony export */ waku: () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ wakuFilter: () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ wakuLightPush: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuLightPush),\n/* harmony export */ wakuStore: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuStore),\n/* harmony export */ waku_filter: () => (/* reexport module object */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ waku_light_push: () => (/* reexport module object */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ waku_store: () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__)\n/* harmony export */ });\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/waku.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/waku.js\");\n/* harmony import */ var _lib_constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/constants.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/message/version_0.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _lib_message_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/message/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/index.js\");\n/* harmony import */ var _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/filter/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/index.js\");\n/* harmony import */ var _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/light_push/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* reexport safe */ _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_6__.ConnectionManager),\n/* harmony export */ FilterCodecs: () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_2__.FilterCodecs),\n/* harmony export */ KeepAliveManager: () => (/* reexport safe */ _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_7__.KeepAliveManager),\n/* harmony export */ LightPushCodec: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_3__.LightPushCodec),\n/* harmony export */ LightPushCore: () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_3__.LightPushCore),\n/* harmony export */ MetadataCodec: () => (/* reexport safe */ _lib_metadata_index_js__WEBPACK_IMPORTED_MODULE_9__.MetadataCodec),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_4__.PageDirection),\n/* harmony export */ StoreCore: () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_4__.StoreCore),\n/* harmony export */ StreamManager: () => (/* reexport safe */ _lib_stream_manager_js__WEBPACK_IMPORTED_MODULE_8__.StreamManager),\n/* harmony export */ createDecoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_0__.createDecoder),\n/* harmony export */ createEncoder: () => (/* reexport safe */ _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_0__.createEncoder),\n/* harmony export */ message: () => (/* reexport module object */ _lib_message_index_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ waitForRemotePeer: () => (/* reexport safe */ _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_5__.waitForRemotePeer),\n/* harmony export */ wakuFilter: () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_2__.wakuFilter),\n/* harmony export */ wakuMetadata: () => (/* reexport safe */ _lib_metadata_index_js__WEBPACK_IMPORTED_MODULE_9__.wakuMetadata),\n/* harmony export */ waku_filter: () => (/* reexport module object */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ waku_light_push: () => (/* reexport module object */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ waku_store: () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/message/version_0.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _lib_message_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/message/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/index.js\");\n/* harmony import */ var _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/filter/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/index.js\");\n/* harmony import */ var _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/light_push/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n/* harmony import */ var _lib_stream_manager_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/stream_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/stream_manager.js\");\n/* harmony import */ var _lib_metadata_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/metadata/index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/metadata/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js?"); /***/ }), @@ -6093,7 +6529,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseProtocol: () => (/* binding */ BaseProtocol)\n/* harmony export */ });\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n\n/**\n * A class with predefined helpers, to be used as a base to implement Waku\n * Protocols.\n */\nclass BaseProtocol {\n multicodec;\n components;\n addLibp2pEventListener;\n removeLibp2pEventListener;\n constructor(multicodec, components) {\n this.multicodec = multicodec;\n this.components = components;\n this.addLibp2pEventListener = components.events.addEventListener.bind(components.events);\n this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);\n }\n get peerStore() {\n return this.components.peerStore;\n }\n /**\n * Returns known peers from the address book (`libp2p.peerStore`) that support\n * the class protocol. Waku may or may not be currently connected to these\n * peers.\n */\n async peers() {\n return (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.getPeersForProtocol)(this.peerStore, [this.multicodec]);\n }\n async getPeer(peerId) {\n const { peer } = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.selectPeerForProtocol)(this.peerStore, [this.multicodec], peerId);\n return peer;\n }\n async newStream(peer) {\n const connections = this.components.connectionManager.getConnections(peer.id);\n const connection = (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_0__.selectConnection)(connections);\n if (!connection) {\n throw new Error(\"Failed to get a connection to the peer\");\n }\n return connection.newStream(this.multicodec);\n }\n}\n//# sourceMappingURL=base_protocol.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseProtocol: () => (/* binding */ BaseProtocol)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n/* harmony import */ var _filterPeers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filterPeers.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filterPeers.js\");\n/* harmony import */ var _stream_manager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/stream_manager.js\");\n\n\n\n\n/**\n * A class with predefined helpers, to be used as a base to implement Waku\n * Protocols.\n */\nclass BaseProtocol {\n multicodec;\n components;\n log;\n pubsubTopics;\n options;\n addLibp2pEventListener;\n removeLibp2pEventListener;\n streamManager;\n constructor(multicodec, components, log, pubsubTopics, options) {\n this.multicodec = multicodec;\n this.components = components;\n this.log = log;\n this.pubsubTopics = pubsubTopics;\n this.options = options;\n this.addLibp2pEventListener = components.events.addEventListener.bind(components.events);\n this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);\n this.streamManager = new _stream_manager_js__WEBPACK_IMPORTED_MODULE_3__.StreamManager(multicodec, components.connectionManager.getConnections.bind(components.connectionManager), this.addLibp2pEventListener);\n }\n async getStream(peer) {\n return this.streamManager.getStream(peer);\n }\n get peerStore() {\n return this.components.peerStore;\n }\n /**\n * Returns known peers from the address book (`libp2p.peerStore`) that support\n * the class protocol. Waku may or may not be currently connected to these\n * peers.\n */\n async allPeers() {\n return (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.getPeersForProtocol)(this.peerStore, [this.multicodec]);\n }\n async connectedPeers() {\n const peers = await this.allPeers();\n return peers.filter((peer) => {\n return (this.components.connectionManager.getConnections(peer.id).length > 0);\n });\n }\n /**\n * Retrieves a list of connected peers that support the protocol. The list is sorted by latency.\n *\n * @param numPeers - The total number of peers to retrieve. If 0, all peers are returned.\n * @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.\n \n * @returns A list of peers that support the protocol sorted by latency.\n */\n async getPeers({ numPeers, maxBootstrapPeers } = {\n maxBootstrapPeers: 1,\n numPeers: 0\n }) {\n // Retrieve all connected peers that support the protocol & shard (if configured)\n const connectedPeersForProtocolAndShard = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.getConnectedPeersForProtocolAndShard)(this.components.connectionManager.getConnections(), this.peerStore, [this.multicodec], this.options?.shardInfo\n ? (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.ensureShardingConfigured)(this.options.shardInfo).shardInfo\n : undefined);\n // Filter the peers based on discovery & number of peers requested\n const filteredPeers = (0,_filterPeers_js__WEBPACK_IMPORTED_MODULE_2__.filterPeersByDiscovery)(connectedPeersForProtocolAndShard, numPeers, maxBootstrapPeers);\n // Sort the peers by latency\n const sortedFilteredPeers = await (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.sortPeersByLatency)(this.peerStore, filteredPeers);\n if (sortedFilteredPeers.length === 0) {\n this.log.warn(\"No peers found. Ensure you have a connection to the network.\");\n }\n if (sortedFilteredPeers.length < numPeers) {\n this.log.warn(`Only ${sortedFilteredPeers.length} peers found. Requested ${numPeers}.`);\n }\n return sortedFilteredPeers;\n }\n}\n//# sourceMappingURL=base_protocol.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js?"); /***/ }), @@ -6104,18 +6540,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* binding */ ConnectionManager),\n/* harmony export */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED: () => (/* binding */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED),\n/* harmony export */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER: () => (/* binding */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER),\n/* harmony export */ DEFAULT_MAX_PARALLEL_DIALS: () => (/* binding */ DEFAULT_MAX_PARALLEL_DIALS)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nconst DEFAULT_MAX_PARALLEL_DIALS = 3;\nclass ConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n static instances = new Map();\n keepAliveManager;\n options;\n libp2p;\n dialAttemptsForPeer = new Map();\n dialErrorsForPeer = new Map();\n currentActiveDialCount = 0;\n pendingPeerDialQueue = [];\n static create(peerId, libp2p, keepAliveOptions, relay, options) {\n let instance = ConnectionManager.instances.get(peerId);\n if (!instance) {\n instance = new ConnectionManager(libp2p, keepAliveOptions, relay, options);\n ConnectionManager.instances.set(peerId, instance);\n }\n return instance;\n }\n async getPeersByDiscovery() {\n const peersDiscovered = await this.libp2p.peerStore.all();\n const peersConnected = this.libp2p\n .getConnections()\n .map((conn) => conn.remotePeer);\n const peersDiscoveredByBootstrap = [];\n const peersDiscoveredByPeerExchange = [];\n const peersConnectedByBootstrap = [];\n const peersConnectedByPeerExchange = [];\n for (const peer of peersDiscovered) {\n const tags = await this.getTagNamesForPeer(peer.id);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP)) {\n peersDiscoveredByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE)) {\n peersDiscoveredByPeerExchange.push(peer);\n }\n }\n for (const peerId of peersConnected) {\n const peer = await this.libp2p.peerStore.get(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP)) {\n peersConnectedByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE)) {\n peersConnectedByPeerExchange.push(peer);\n }\n }\n return {\n DISCOVERED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP]: peersDiscoveredByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE]: peersDiscoveredByPeerExchange,\n },\n CONNECTED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP]: peersConnectedByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.PEER_EXCHANGE]: peersConnectedByPeerExchange,\n },\n };\n }\n constructor(libp2p, keepAliveOptions, relay, options) {\n super();\n this.libp2p = libp2p;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n maxParallelDials: DEFAULT_MAX_PARALLEL_DIALS,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_3__.KeepAliveManager(keepAliveOptions, relay);\n this.run()\n .then(() => log(`Connection Manager is now running`))\n .catch((error) => log(`Unexpected error while running service`, error));\n // libp2p emits `peer:discovery` events during its initialization\n // which means that before the ConnectionManager is initialized, some peers may have been discovered\n // we will dial the peers in peerStore ONCE before we start to listen to the `peer:discovery` events within the ConnectionManager\n this.dialPeerStorePeers().catch((error) => log(`Unexpected error while dialing peer store peers`, error));\n }\n async dialPeerStorePeers() {\n const peerInfos = await this.libp2p.peerStore.all();\n const dialPromises = [];\n for (const peerInfo of peerInfos) {\n if (this.libp2p.getConnections().find((c) => c.remotePeer === peerInfo.id))\n continue;\n dialPromises.push(this.attemptDial(peerInfo.id));\n }\n try {\n await Promise.all(dialPromises);\n }\n catch (error) {\n log(`Unexpected error while dialing peer store peers`, error);\n }\n }\n async run() {\n // start event listeners\n this.startPeerDiscoveryListener();\n this.startPeerConnectionListener();\n this.startPeerDisconnectionListener();\n }\n stop() {\n this.keepAliveManager.stopAll();\n this.libp2p.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2p.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2p.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n this.currentActiveDialCount += 1;\n let dialAttempt = 0;\n while (dialAttempt < this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()} on attempt ${dialAttempt + 1}`);\n await this.libp2p.dial(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n // add tag to connection describing discovery mechanism\n // don't add duplicate tags\n this.libp2p.getConnections(peerId).forEach((conn) => {\n conn.tags = Array.from(new Set([...conn.tags, ...tags]));\n });\n this.dialAttemptsForPeer.delete(peerId.toString());\n // Dialing succeeded, break the loop\n break;\n }\n catch (error) {\n if (error instanceof AggregateError) {\n // Handle AggregateError\n log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);\n }\n else {\n // Handle generic error\n log(`Error dialing peer ${peerId.toString()} - ${error.message}`);\n }\n this.dialErrorsForPeer.set(peerId.toString(), error);\n dialAttempt++;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt);\n }\n }\n // Always decrease the active dial count and process the dial queue\n this.currentActiveDialCount--;\n this.processDialQueue();\n // If max dial attempts reached and dialing failed, delete the peer\n if (dialAttempt === this.options.maxDialAttemptsForPeer) {\n try {\n const error = this.dialErrorsForPeer.get(peerId.toString());\n let errorMessage;\n if (error instanceof AggregateError) {\n errorMessage = JSON.stringify(error.errors[0]);\n }\n else {\n errorMessage = error.message;\n }\n log(`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`);\n this.dialErrorsForPeer.delete(peerId.toString());\n await this.libp2p.peerStore.delete(peerId);\n }\n catch (error) {\n throw new Error(`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`);\n }\n }\n }\n async dropConnection(peerId) {\n try {\n this.keepAliveManager.stop(peerId);\n await this.libp2p.hangUp(peerId);\n log(`Dropped connection with peer ${peerId.toString()}`);\n }\n catch (error) {\n log(`Error dropping connection with peer ${peerId.toString()} - ${error}`);\n }\n }\n processDialQueue() {\n if (this.pendingPeerDialQueue.length > 0 &&\n this.currentActiveDialCount < this.options.maxParallelDials) {\n const peerId = this.pendingPeerDialQueue.shift();\n if (!peerId)\n return;\n this.attemptDial(peerId).catch((error) => {\n log(error);\n });\n }\n }\n startPeerDiscoveryListener() {\n this.libp2p.addEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2p.addEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n }\n startPeerDisconnectionListener() {\n // TODO: ensure that these following issues are updated and confirmed\n /**\n * NOTE: Event is not being emitted on closing nor losing a connection.\n * @see https://github.com/libp2p/js-libp2p/issues/939\n * @see https://github.com/status-im/js-waku/issues/252\n *\n * >This event will be triggered anytime we are disconnected from another peer,\n * >regardless of the circumstances of that disconnection.\n * >If we happen to have multiple connections to a peer,\n * >this event will **only** be triggered when the last connection is closed.\n * @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100\n */\n this.libp2p.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n }\n async attemptDial(peerId) {\n if (this.currentActiveDialCount >= this.options.maxParallelDials) {\n this.pendingPeerDialQueue.push(peerId);\n return;\n }\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => {\n throw `Error dialing peer ${peerId.toString()} : ${err}`;\n });\n }\n onEventHandlers = {\n \"peer:discovery\": (evt) => {\n void (async () => {\n const { id: peerId } = evt.detail;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(isBootstrap\n ? _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP\n : _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE, {\n detail: peerId,\n }));\n try {\n await this.attemptDial(peerId);\n }\n catch (error) {\n log(`Error dialing peer ${peerId.toString()} : ${error}`);\n }\n })();\n },\n \"peer:connect\": (evt) => {\n void (async () => {\n const peerId = evt.detail;\n this.keepAliveManager.start(peerId, this.libp2p.services.ping);\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const bootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => conn.tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP));\n // If we have too many bootstrap connections, drop one\n if (bootstrapConnections.length > this.options.maxBootstrapPeersAllowed) {\n await this.dropConnection(peerId);\n }\n else {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP, {\n detail: peerId,\n }));\n }\n }\n else {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE, {\n detail: peerId,\n }));\n }\n })();\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail);\n };\n },\n };\n /**\n * Checks if the peer is dialable based on the following conditions:\n * 1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.\n * 2. If the peer is not a bootstrap peer\n */\n async shouldDialPeer(peerId) {\n const isConnected = this.libp2p.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const tagNames = await this.getTagNamesForPeer(peerId);\n const isBootstrap = tagNames.some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => {\n return conn.tags.find((name) => name === _waku_interfaces__WEBPACK_IMPORTED_MODULE_1__.Tags.BOOTSTRAP);\n }).length;\n if (currentBootstrapConnections < this.options.maxBootstrapPeersAllowed)\n return true;\n }\n else {\n return true;\n }\n return false;\n }\n /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n try {\n const peer = await this.libp2p.peerStore.get(peerId);\n return Array.from(peer.tags.keys());\n }\n catch (error) {\n log(`Failed to get peer ${peerId}, error: ${error}`);\n return [];\n }\n }\n}\n\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/connection_manager.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js ***! - \******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPubSubTopic: () => (/* binding */ DefaultPubSubTopic)\n/* harmony export */ });\n/**\n * DefaultPubSubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubSubTopic = \"/waku/2/default-waku/proto\";\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionManager: () => (/* binding */ ConnectionManager),\n/* harmony export */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED: () => (/* binding */ DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED),\n/* harmony export */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER: () => (/* binding */ DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER),\n/* harmony export */ DEFAULT_MAX_PARALLEL_DIALS: () => (/* binding */ DEFAULT_MAX_PARALLEL_DIALS)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nconst DEFAULT_MAX_PARALLEL_DIALS = 3;\nclass ConnectionManager extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.TypedEventEmitter {\n configuredPubsubTopics;\n static instances = new Map();\n keepAliveManager;\n options;\n libp2p;\n dialAttemptsForPeer = new Map();\n dialErrorsForPeer = new Map();\n currentActiveParallelDialCount = 0;\n pendingPeerDialQueue = [];\n online = false;\n isConnected() {\n return this.online;\n }\n toggleOnline() {\n if (!this.online) {\n this.online = true;\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EConnectionStateEvents.CONNECTION_STATUS, {\n detail: this.online\n }));\n }\n }\n toggleOffline() {\n if (this.online && this.libp2p.getConnections().length == 0) {\n this.online = false;\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EConnectionStateEvents.CONNECTION_STATUS, {\n detail: this.online\n }));\n }\n }\n static create(peerId, libp2p, keepAliveOptions, pubsubTopics, relay, options) {\n let instance = ConnectionManager.instances.get(peerId);\n if (!instance) {\n instance = new ConnectionManager(libp2p, keepAliveOptions, pubsubTopics, relay, options);\n ConnectionManager.instances.set(peerId, instance);\n }\n return instance;\n }\n async getPeersByDiscovery() {\n const peersDiscovered = await this.libp2p.peerStore.all();\n const peersConnected = this.libp2p\n .getConnections()\n .map((conn) => conn.remotePeer);\n const peersDiscoveredByBootstrap = [];\n const peersDiscoveredByPeerExchange = [];\n const peersDiscoveredByLocal = [];\n const peersConnectedByBootstrap = [];\n const peersConnectedByPeerExchange = [];\n const peersConnectedByLocal = [];\n for (const peer of peersDiscovered) {\n const tags = await this.getTagNamesForPeer(peer.id);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP)) {\n peersDiscoveredByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.PEER_EXCHANGE)) {\n peersDiscoveredByPeerExchange.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.LOCAL)) {\n peersDiscoveredByLocal.push(peer);\n }\n }\n for (const peerId of peersConnected) {\n const peer = await this.libp2p.peerStore.get(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP)) {\n peersConnectedByBootstrap.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.PEER_EXCHANGE)) {\n peersConnectedByPeerExchange.push(peer);\n }\n else if (tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.LOCAL)) {\n peersConnectedByLocal.push(peer);\n }\n }\n return {\n DISCOVERED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP]: peersDiscoveredByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.PEER_EXCHANGE]: peersDiscoveredByPeerExchange,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.LOCAL]: peersDiscoveredByLocal\n },\n CONNECTED: {\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP]: peersConnectedByBootstrap,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.PEER_EXCHANGE]: peersConnectedByPeerExchange,\n [_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.LOCAL]: peersConnectedByLocal\n }\n };\n }\n constructor(libp2p, keepAliveOptions, configuredPubsubTopics, relay, options) {\n super();\n this.configuredPubsubTopics = configuredPubsubTopics;\n this.libp2p = libp2p;\n this.configuredPubsubTopics = configuredPubsubTopics;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n maxParallelDials: DEFAULT_MAX_PARALLEL_DIALS,\n ...options\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__.KeepAliveManager(keepAliveOptions, relay);\n this.run()\n .then(() => log.info(`Connection Manager is now running`))\n .catch((error) => log.error(`Unexpected error while running service`, error));\n // libp2p emits `peer:discovery` events during its initialization\n // which means that before the ConnectionManager is initialized, some peers may have been discovered\n // we will dial the peers in peerStore ONCE before we start to listen to the `peer:discovery` events within the ConnectionManager\n this.dialPeerStorePeers().catch((error) => log.error(`Unexpected error while dialing peer store peers`, error));\n }\n async dialPeerStorePeers() {\n const peerInfos = await this.libp2p.peerStore.all();\n const dialPromises = [];\n for (const peerInfo of peerInfos) {\n if (this.libp2p.getConnections().find((c) => c.remotePeer === peerInfo.id))\n continue;\n dialPromises.push(this.attemptDial(peerInfo.id));\n }\n try {\n await Promise.all(dialPromises);\n }\n catch (error) {\n log.error(`Unexpected error while dialing peer store peers`, error);\n }\n }\n async run() {\n // start event listeners\n this.startPeerDiscoveryListener();\n this.startPeerConnectionListener();\n this.startPeerDisconnectionListener();\n }\n stop() {\n this.keepAliveManager.stopAll();\n this.libp2p.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2p.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2p.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n this.currentActiveParallelDialCount += 1;\n let dialAttempt = 0;\n while (dialAttempt < this.options.maxDialAttemptsForPeer) {\n try {\n log.info(`Dialing peer ${peerId.toString()} on attempt ${dialAttempt + 1}`);\n await this.libp2p.dial(peerId);\n const tags = await this.getTagNamesForPeer(peerId);\n // add tag to connection describing discovery mechanism\n // don't add duplicate tags\n this.libp2p.getConnections(peerId).forEach((conn) => {\n conn.tags = Array.from(new Set([...conn.tags, ...tags]));\n });\n // instead of deleting the peer from the peer store, we set the dial attempt to -1\n // this helps us keep track of peers that have been dialed before\n this.dialAttemptsForPeer.set(peerId.toString(), -1);\n // Dialing succeeded, break the loop\n break;\n }\n catch (error) {\n if (error instanceof AggregateError) {\n // Handle AggregateError\n log.error(`Error dialing peer ${peerId.toString()} - ${error.errors}`);\n }\n else {\n // Handle generic error\n log.error(`Error dialing peer ${peerId.toString()} - ${error.message}`);\n }\n this.dialErrorsForPeer.set(peerId.toString(), error);\n dialAttempt++;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt);\n }\n }\n // Always decrease the active dial count and process the dial queue\n this.currentActiveParallelDialCount--;\n this.processDialQueue();\n // If max dial attempts reached and dialing failed, delete the peer\n if (dialAttempt === this.options.maxDialAttemptsForPeer) {\n try {\n const error = this.dialErrorsForPeer.get(peerId.toString());\n if (error) {\n let errorMessage;\n if (error instanceof AggregateError) {\n if (!error.errors) {\n log.warn(`No errors array found for AggregateError`);\n }\n else if (error.errors.length === 0) {\n log.warn(`Errors array is empty for AggregateError`);\n }\n else {\n errorMessage = JSON.stringify(error.errors[0]);\n }\n }\n else {\n errorMessage = error.message;\n }\n log.info(`Deleting undialable peer ${peerId.toString()} from peer store. Reason: ${errorMessage}`);\n }\n this.dialErrorsForPeer.delete(peerId.toString());\n await this.libp2p.peerStore.delete(peerId);\n }\n catch (error) {\n throw new Error(`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`);\n }\n }\n }\n async dropConnection(peerId) {\n try {\n this.keepAliveManager.stop(peerId);\n await this.libp2p.hangUp(peerId);\n log.info(`Dropped connection with peer ${peerId.toString()}`);\n }\n catch (error) {\n log.error(`Error dropping connection with peer ${peerId.toString()} - ${error}`);\n }\n }\n processDialQueue() {\n if (this.pendingPeerDialQueue.length > 0 &&\n this.currentActiveParallelDialCount < this.options.maxParallelDials) {\n const peerId = this.pendingPeerDialQueue.shift();\n if (!peerId)\n return;\n this.attemptDial(peerId).catch((error) => {\n log.error(error);\n });\n }\n }\n startPeerDiscoveryListener() {\n this.libp2p.addEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2p.addEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n }\n startPeerDisconnectionListener() {\n // TODO: ensure that these following issues are updated and confirmed\n /**\n * NOTE: Event is not being emitted on closing nor losing a connection.\n * @see https://github.com/libp2p/js-libp2p/issues/939\n * @see https://github.com/status-im/js-waku/issues/252\n *\n * >This event will be triggered anytime we are disconnected from another peer,\n * >regardless of the circumstances of that disconnection.\n * >If we happen to have multiple connections to a peer,\n * >this event will **only** be triggered when the last connection is closed.\n * @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100\n */\n this.libp2p.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n }\n async attemptDial(peerId) {\n if (!(await this.shouldDialPeer(peerId)))\n return;\n if (this.currentActiveParallelDialCount >= this.options.maxParallelDials) {\n this.pendingPeerDialQueue.push(peerId);\n return;\n }\n this.dialPeer(peerId).catch((err) => {\n log.error(`Error dialing peer ${peerId.toString()} : ${err}`);\n });\n }\n onEventHandlers = {\n \"peer:discovery\": (evt) => {\n void (async () => {\n const { id: peerId } = evt.detail;\n await this.dispatchDiscoveryEvent(peerId);\n try {\n await this.attemptDial(peerId);\n }\n catch (error) {\n log.error(`Error dialing peer ${peerId.toString()} : ${error}`);\n }\n })();\n },\n \"peer:connect\": (evt) => {\n void (async () => {\n log.info(`Connected to peer ${evt.detail.toString()}`);\n const peerId = evt.detail;\n this.keepAliveManager.start(peerId, this.libp2p.services.ping, this.libp2p.peerStore);\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const bootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => conn.tags.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP));\n // If we have too many bootstrap connections, drop one\n if (bootstrapConnections.length > this.options.maxBootstrapPeersAllowed) {\n await this.dropConnection(peerId);\n }\n else {\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP, {\n detail: peerId\n }));\n }\n }\n else {\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE, {\n detail: peerId\n }));\n }\n this.toggleOnline();\n })();\n },\n \"peer:disconnect\": (evt) => {\n void (async () => {\n this.keepAliveManager.stop(evt.detail);\n this.toggleOffline();\n })();\n }\n };\n /**\n * Checks if the peer should be dialed based on the following conditions:\n * 1. If the peer is already connected, don't dial\n * 2. If the peer is not part of any of the configured pubsub topics, don't dial\n * 3. If the peer is not dialable based on bootstrap status, don't dial\n * 4. If the peer is already has an active dial attempt, or has been dialed before, don't dial it\n * @returns true if the peer should be dialed, false otherwise\n */\n async shouldDialPeer(peerId) {\n // if we're already connected to the peer, don't dial\n const isConnected = this.libp2p.getConnections(peerId).length > 0;\n if (isConnected) {\n log.warn(`Already connected to peer ${peerId.toString()}. Not dialing.`);\n return false;\n }\n // if the peer is not part of any of the configured pubsub topics, don't dial\n if (!(await this.isPeerTopicConfigured(peerId))) {\n const shardInfo = await this.getPeerShardInfo(peerId, this.libp2p.peerStore);\n log.warn(`Discovered peer ${peerId.toString()} with ShardInfo ${shardInfo} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}).\n Not dialing.`);\n return false;\n }\n // if the peer is not dialable based on bootstrap status, don't dial\n if (!(await this.isPeerDialableBasedOnBootstrapStatus(peerId))) {\n log.warn(`Peer ${peerId.toString()} is not dialable based on bootstrap status. Not dialing.`);\n return false;\n }\n // If the peer is already already has an active dial attempt, or has been dialed before, don't dial it\n if (this.dialAttemptsForPeer.has(peerId.toString())) {\n log.warn(`Peer ${peerId.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`);\n return false;\n }\n return true;\n }\n /**\n * Checks if the peer is dialable based on the following conditions:\n * 1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.\n * 2. If the peer is not a bootstrap peer\n */\n async isPeerDialableBasedOnBootstrapStatus(peerId) {\n const tagNames = await this.getTagNamesForPeer(peerId);\n const isBootstrap = tagNames.some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2p\n .getConnections()\n .filter((conn) => {\n return conn.tags.find((name) => name === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n }).length;\n if (currentBootstrapConnections < this.options.maxBootstrapPeersAllowed)\n return true;\n }\n else {\n return true;\n }\n return false;\n }\n async dispatchDiscoveryEvent(peerId) {\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CustomEvent(isBootstrap\n ? _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP\n : _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE, {\n detail: peerId\n }));\n }\n /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n try {\n const peer = await this.libp2p.peerStore.get(peerId);\n return Array.from(peer.tags.keys());\n }\n catch (error) {\n log.error(`Failed to get peer ${peerId}, error: ${error}`);\n return [];\n }\n }\n async isPeerTopicConfigured(peerId) {\n const shardInfo = await this.getPeerShardInfo(peerId, this.libp2p.peerStore);\n // If there's no shard information, simply return true\n if (!shardInfo)\n return true;\n const pubsubTopics = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.shardInfoToPubsubTopics)(shardInfo);\n const isTopicConfigured = pubsubTopics.some((topic) => this.configuredPubsubTopics.includes(topic));\n return isTopicConfigured;\n }\n async getPeerShardInfo(peerId, peerStore) {\n const peer = await peerStore.get(peerId);\n const shardInfoBytes = peer.metadata.get(\"shardInfo\");\n if (!shardInfoBytes)\n return undefined;\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.decodeRelayShard)(shardInfoBytes);\n }\n}\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/connection_manager.js?"); /***/ }), @@ -6126,7 +6551,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterPushRpc: () => (/* binding */ FilterPushRpc),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ FilterSubscribeRpc: () => (/* binding */ FilterSubscribeRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterPushRPC represents a message conforming to the Waku FilterPush protocol.\n * Protocol documentation: https://rfc.vac.dev/spec/12/\n */\nclass FilterPushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.decode(bytes);\n return new FilterPushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.encode(this.proto);\n }\n get wakuMessage() {\n return this.proto.wakuMessage;\n }\n /**\n * Get the pubsub topic from the FilterPushRpc object.\n * @returns string\n */\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n}\nclass FilterSubscribeRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createSubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBE,\n pubsubTopic,\n contentTopics,\n });\n }\n static createUnsubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE,\n pubsubTopic,\n contentTopics,\n });\n }\n static createUnsubscribeAllRequest(pubsubTopic) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE_ALL,\n pubsubTopic,\n contentTopics: [],\n });\n }\n static createSubscriberPingRequest() {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBER_PING,\n pubsubTopic: \"\",\n contentTopics: [],\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.decode(bytes);\n return new FilterSubscribeRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.encode(this.proto);\n }\n get filterSubscribeType() {\n return this.proto.filterSubscribeType;\n }\n get requestId() {\n return this.proto.requestId;\n }\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n get contentTopics() {\n return this.proto.contentTopics;\n }\n}\nclass FilterSubscribeResponse {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.decode(bytes);\n return new FilterSubscribeResponse(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.encode(this.proto);\n }\n get statusCode() {\n return this.proto.statusCode;\n }\n get statusDesc() {\n return this.proto.statusDesc;\n }\n get requestId() {\n return this.proto.requestId;\n }\n}\n//# sourceMappingURL=filter_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/filter_rpc.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterPushRpc: () => (/* binding */ FilterPushRpc),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ FilterSubscribeRpc: () => (/* binding */ FilterSubscribeRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterPushRPC represents a message conforming to the Waku FilterPush protocol.\n * Protocol documentation: https://rfc.vac.dev/spec/12/\n */\nclass FilterPushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.decode(bytes);\n return new FilterPushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.MessagePush.encode(this.proto);\n }\n get wakuMessage() {\n return this.proto.wakuMessage;\n }\n /**\n * Get the pubsub topic from the FilterPushRpc object.\n * @returns string\n */\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n}\nclass FilterSubscribeRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createSubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBE,\n pubsubTopic,\n contentTopics\n });\n }\n static createUnsubscribeRequest(pubsubTopic, contentTopics) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE,\n pubsubTopic,\n contentTopics\n });\n }\n static createUnsubscribeAllRequest(pubsubTopic) {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.UNSUBSCRIBE_ALL,\n pubsubTopic,\n contentTopics: []\n });\n }\n static createSubscriberPingRequest() {\n return new FilterSubscribeRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n filterSubscribeType: _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.FilterSubscribeType.SUBSCRIBER_PING,\n pubsubTopic: \"\",\n contentTopics: []\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.decode(bytes);\n return new FilterSubscribeRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeRequest.encode(this.proto);\n }\n get filterSubscribeType() {\n return this.proto.filterSubscribeType;\n }\n get requestId() {\n return this.proto.requestId;\n }\n get pubsubTopic() {\n return this.proto.pubsubTopic;\n }\n get contentTopics() {\n return this.proto.contentTopics;\n }\n}\nclass FilterSubscribeResponse {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.decode(bytes);\n return new FilterSubscribeResponse(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter_v2.FilterSubscribeResponse.encode(this.proto);\n }\n get statusCode() {\n return this.proto.statusCode;\n }\n get statusDesc() {\n return this.proto.statusDesc;\n }\n get requestId() {\n return this.proto.requestId;\n }\n}\n//# sourceMappingURL=filter_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/filter_rpc.js?"); /***/ }), @@ -6137,7 +6562,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ wakuFilter: () => (/* binding */ wakuFilter)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/filter_rpc.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter:v2\");\nconst FilterCodecs = {\n SUBSCRIBE: \"/vac/waku/filter-subscribe/2.0.0-beta1\",\n PUSH: \"/vac/waku/filter-push/2.0.0-beta1\",\n};\nclass Subscription {\n peer;\n pubSubTopic;\n newStream;\n subscriptionCallbacks;\n constructor(pubSubTopic, remotePeer, newStream) {\n this.peer = remotePeer;\n this.pubSubTopic = pubSubTopic;\n this.newStream = newStream;\n this.subscriptionCallbacks = new Map();\n }\n async subscribe(decoders, callback) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const decodersGroupedByCT = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(decodersArray);\n const contentTopics = Array.from(decodersGroupedByCT.keys());\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscribeRequest(this.pubSubTopic, contentTopics);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter subscribe request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log(\"Subscribed to peer \", this.peer.id.toString(), \"for content topics\", contentTopics);\n }\n catch (e) {\n throw new Error(\"Error subscribing to peer: \" +\n this.peer.id.toString() +\n \" for content topics: \" +\n contentTopics +\n \": \" +\n e);\n }\n // Save the callback functions by content topics so they\n // can easily be removed (reciprocally replaced) if `unsubscribe` (reciprocally `subscribe`)\n // is called for those content topics\n decodersGroupedByCT.forEach((decoders, contentTopic) => {\n // Cast the type because a given `subscriptionCallbacks` map may hold\n // Decoder that decode to different implementations of `IDecodedMessage`\n const subscriptionCallback = {\n decoders,\n callback,\n };\n // The callback and decoder may override previous values, this is on\n // purpose as the user may call `subscribe` to refresh the subscription\n this.subscriptionCallbacks.set(contentTopic, subscriptionCallback);\n });\n }\n async unsubscribe(contentTopics) {\n const stream = await this.newStream(this.peer);\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeRequest(this.pubSubTopic, contentTopics);\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([unsubscribeRequest.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream.sink);\n }\n catch (error) {\n throw new Error(\"Error subscribing: \" + error);\n }\n contentTopics.forEach((contentTopic) => {\n this.subscriptionCallbacks.delete(contentTopic);\n });\n }\n async ping() {\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscriberPingRequest();\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter ping request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log(\"Ping successful\");\n }\n catch (error) {\n log(\"Error pinging: \", error);\n throw new Error(\"Error pinging: \" + error);\n }\n }\n async unsubscribeAll() {\n const stream = await this.newStream(this.peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeAllRequest(this.pubSubTopic);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter unsubscribe all request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n this.subscriptionCallbacks.clear();\n log(\"Unsubscribed from all content topics\");\n }\n catch (error) {\n throw new Error(\"Error unsubscribing from all content topics: \" + error);\n }\n }\n async processMessage(message) {\n const contentTopic = message.contentTopic;\n const subscriptionCallback = this.subscriptionCallbacks.get(contentTopic);\n if (!subscriptionCallback) {\n log(\"No subscription callback available for \", contentTopic);\n return;\n }\n await pushMessage(subscriptionCallback, this.pubSubTopic, message);\n }\n}\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n options;\n activeSubscriptions = new Map();\n getActiveSubscription(pubSubTopic, peerIdStr) {\n return this.activeSubscriptions.get(`${pubSubTopic}_${peerIdStr}`);\n }\n setActiveSubscription(pubSubTopic, peerIdStr, subscription) {\n this.activeSubscriptions.set(`${pubSubTopic}_${peerIdStr}`, subscription);\n return subscription;\n }\n constructor(libp2p, options) {\n super(FilterCodecs.SUBSCRIBE, libp2p.components);\n libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {\n log(\"Failed to register \", FilterCodecs.PUSH, e);\n });\n this.activeSubscriptions = new Map();\n this.options = options ?? {};\n }\n async createSubscription(pubSubTopic, peerId) {\n const _pubSubTopic = pubSubTopic ?? this.options.pubSubTopic ?? _constants_js__WEBPACK_IMPORTED_MODULE_6__.DefaultPubSubTopic;\n const peer = await this.getPeer(peerId);\n const subscription = this.getActiveSubscription(_pubSubTopic, peer.id.toString()) ??\n this.setActiveSubscription(_pubSubTopic, peer.id.toString(), new Subscription(_pubSubTopic, peer, this.newStream.bind(this, peer)));\n return subscription;\n }\n toSubscriptionIterator(decoders, opts) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)(this, decoders, opts);\n }\n /**\n * This method is used to satisfy the `IReceiver` interface.\n *\n * @hidden\n *\n * @param decoders The decoders to use for the subscription.\n * @param callback The callback function to use for the subscription.\n * @param opts Optional protocol options for the subscription.\n *\n * @returns A Promise that resolves to a function that unsubscribes from the subscription.\n *\n * @remarks\n * This method should not be used directly.\n * Instead, use `createSubscription` to create a new subscription.\n */\n async subscribe(decoders, callback, opts) {\n const subscription = await this.createSubscription(undefined, opts?.peerId);\n await subscription.subscribe(decoders, callback);\n const contentTopics = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(Array.isArray(decoders) ? decoders : [decoders]).keys());\n return async () => {\n await subscription.unsubscribe(contentTopics);\n };\n }\n onRequest(streamData) {\n log(\"Receiving message push\");\n try {\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)(streamData.stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => {\n for await (const bytes of source) {\n const response = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterPushRpc.decode(bytes.slice());\n const { pubsubTopic, wakuMessage } = response;\n if (!wakuMessage) {\n log(\"Received empty message\");\n return;\n }\n if (!pubsubTopic) {\n log(\"PubSub topic missing from push message\");\n return;\n }\n const peerIdStr = streamData.connection.remotePeer.toString();\n const subscription = this.getActiveSubscription(pubsubTopic, peerIdStr);\n if (!subscription) {\n log(`No subscription locally registered for topic ${pubsubTopic}`);\n return;\n }\n await subscription.processMessage(wakuMessage);\n }\n }).then(() => {\n log(\"Receiving pipe closed.\");\n }, (e) => {\n log(\"Error with receiving pipe\", e);\n });\n }\n catch (e) {\n log(\"Error decoding message\", e);\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\nasync function pushMessage(subscriptionCallback, pubSubTopic, message) {\n const { decoders, callback } = subscriptionCallback;\n const { contentTopic } = message;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n try {\n const decodePromises = decoders.map((dec) => dec\n .fromProtoObj(pubSubTopic, message)\n .then((decoded) => decoded || Promise.reject(\"Decoding failed\")));\n const decodedMessage = await Promise.any(decodePromises);\n await callback(decodedMessage);\n }\n catch (e) {\n log(\"Error decoding message\", e);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterCodecs: () => (/* binding */ FilterCodecs),\n/* harmony export */ wakuFilter: () => (/* binding */ wakuFilter)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_message_hash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/message-hash */ \"./node_modules/@waku/sdk/node_modules/@waku/message-hash/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/filter_rpc.js\");\n\n\n\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"filter:v2\");\nconst FilterCodecs = {\n SUBSCRIBE: \"/vac/waku/filter-subscribe/2.0.0-beta1\",\n PUSH: \"/vac/waku/filter-push/2.0.0-beta1\"\n};\n/**\n * A subscription object refers to a subscription to a given pubsub topic.\n */\nclass Subscription {\n peers;\n pubsubTopic;\n newStream;\n receivedMessagesHashStr = [];\n subscriptionCallbacks;\n constructor(pubsubTopic, remotePeers, newStream) {\n this.peers = remotePeers;\n this.pubsubTopic = pubsubTopic;\n this.newStream = newStream;\n this.subscriptionCallbacks = new Map();\n }\n async subscribe(decoders, callback) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n // check that all decoders are configured for the same pubsub topic as this subscription\n decodersArray.forEach((decoder) => {\n if (decoder.pubsubTopic !== this.pubsubTopic) {\n throw new Error(`Pubsub topic not configured: decoder is configured for pubsub topic ${decoder.pubsubTopic} but this subscription is for pubsub topic ${this.pubsubTopic}. Please create a new Subscription for the different pubsub topic.`);\n }\n });\n const decodersGroupedByCT = (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.groupByContentTopic)(decodersArray);\n const contentTopics = Array.from(decodersGroupedByCT.keys());\n const promises = this.peers.map(async (peer) => {\n const stream = await this.newStream(peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscribeRequest(this.pubsubTopic, contentTopics);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n if (!res || !res.length) {\n throw Error(`No response received for request ${request.requestId}: ${res}`);\n }\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter subscribe request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log.info(\"Subscribed to peer \", peer.id.toString(), \"for content topics\", contentTopics);\n }\n catch (e) {\n throw new Error(\"Error subscribing to peer: \" +\n peer.id.toString() +\n \" for content topics: \" +\n contentTopics +\n \": \" +\n e);\n }\n });\n const results = await Promise.allSettled(promises);\n this.handleErrors(results, \"subscribe\");\n // Save the callback functions by content topics so they\n // can easily be removed (reciprocally replaced) if `unsubscribe` (reciprocally `subscribe`)\n // is called for those content topics\n decodersGroupedByCT.forEach((decoders, contentTopic) => {\n // Cast the type because a given `subscriptionCallbacks` map may hold\n // Decoder that decode to different implementations of `IDecodedMessage`\n const subscriptionCallback = {\n decoders,\n callback\n };\n // The callback and decoder may override previous values, this is on\n // purpose as the user may call `subscribe` to refresh the subscription\n this.subscriptionCallbacks.set(contentTopic, subscriptionCallback);\n });\n }\n async unsubscribe(contentTopics) {\n const promises = this.peers.map(async (peer) => {\n const stream = await this.newStream(peer);\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeRequest(this.pubsubTopic, contentTopics);\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([unsubscribeRequest.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream.sink);\n }\n catch (error) {\n throw new Error(\"Error unsubscribing: \" + error);\n }\n contentTopics.forEach((contentTopic) => {\n this.subscriptionCallbacks.delete(contentTopic);\n });\n });\n const results = await Promise.allSettled(promises);\n this.handleErrors(results, \"unsubscribe\");\n }\n async ping() {\n const promises = this.peers.map(async (peer) => {\n const stream = await this.newStream(peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createSubscriberPingRequest();\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n if (!res || !res.length) {\n throw Error(`No response received for request ${request.requestId}: ${res}`);\n }\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter ping request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n log.info(`Ping successful for peer ${peer.id.toString()}`);\n }\n catch (error) {\n log.error(\"Error pinging: \", error);\n throw error; // Rethrow the actual error instead of wrapping it\n }\n });\n const results = await Promise.allSettled(promises);\n this.handleErrors(results, \"ping\");\n }\n async unsubscribeAll() {\n const promises = this.peers.map(async (peer) => {\n const stream = await this.newStream(peer);\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeRpc.createUnsubscribeAllRequest(this.pubsubTopic);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n if (!res || !res.length) {\n throw Error(`No response received for request ${request.requestId}: ${res}`);\n }\n const { statusCode, requestId, statusDesc } = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterSubscribeResponse.decode(res[0].slice());\n if (statusCode < 200 || statusCode >= 300) {\n throw new Error(`Filter unsubscribe all request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);\n }\n this.subscriptionCallbacks.clear();\n log.info(`Unsubscribed from all content topics for pubsub topic ${this.pubsubTopic}`);\n }\n catch (error) {\n throw new Error(\"Error unsubscribing from all content topics: \" + error);\n }\n });\n const results = await Promise.allSettled(promises);\n this.handleErrors(results, \"unsubscribeAll\");\n }\n async processMessage(message) {\n const hashedMessageStr = (0,_waku_message_hash__WEBPACK_IMPORTED_MODULE_1__.messageHashStr)(this.pubsubTopic, message);\n if (this.receivedMessagesHashStr.includes(hashedMessageStr)) {\n log.info(\"Message already received, skipping\");\n return;\n }\n this.receivedMessagesHashStr.push(hashedMessageStr);\n const { contentTopic } = message;\n const subscriptionCallback = this.subscriptionCallbacks.get(contentTopic);\n if (!subscriptionCallback) {\n log.error(\"No subscription callback available for \", contentTopic);\n return;\n }\n log.info(\"Processing message with content topic \", contentTopic, \" on pubsub topic \", this.pubsubTopic);\n await pushMessage(subscriptionCallback, this.pubsubTopic, message);\n }\n // Filter out only the rejected promises and extract & handle their reasons\n handleErrors(results, type) {\n const errors = results\n .filter((result) => result.status === \"rejected\")\n .map((rejectedResult) => rejectedResult.reason);\n if (errors.length === this.peers.length) {\n const errorCounts = new Map();\n // TODO: streamline error logging with https://github.com/orgs/waku-org/projects/2/views/1?pane=issue&itemId=42849952\n errors.forEach((error) => {\n const message = error instanceof Error ? error.message : String(error);\n errorCounts.set(message, (errorCounts.get(message) || 0) + 1);\n });\n const uniqueErrorMessages = Array.from(errorCounts, ([message, count]) => `${message} (occurred ${count} times)`).join(\", \");\n throw new Error(`Error ${type} all peers: ${uniqueErrorMessages}`);\n }\n else if (errors.length > 0) {\n // TODO: handle renewing faulty peers with new peers (https://github.com/waku-org/js-waku/issues/1463)\n log.warn(`Some ${type} failed. These will be refreshed with new peers`, errors);\n }\n else {\n log.info(`${type} successful for all peers`);\n }\n }\n}\nconst DEFAULT_NUM_PEERS = 3;\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_6__.BaseProtocol {\n activeSubscriptions = new Map();\n getActiveSubscription(pubsubTopic) {\n return this.activeSubscriptions.get(pubsubTopic);\n }\n setActiveSubscription(pubsubTopic, subscription) {\n this.activeSubscriptions.set(pubsubTopic, subscription);\n return subscription;\n }\n //TODO: Remove when FilterCore and FilterSDK are introduced\n numPeersToUse;\n constructor(libp2p, options) {\n super(FilterCodecs.SUBSCRIBE, libp2p.components, log, options.pubsubTopics, options);\n this.numPeersToUse = options?.numPeersToUse ?? DEFAULT_NUM_PEERS;\n libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {\n log.error(\"Failed to register \", FilterCodecs.PUSH, e);\n });\n this.activeSubscriptions = new Map();\n }\n /**\n * Creates a new subscription to the given pubsub topic.\n * The subscription is made to multiple peers for decentralization.\n * @param pubsubTopicShardInfo The pubsub topic to subscribe to.\n * @returns The subscription object.\n */\n async createSubscription(pubsubTopicShardInfo = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DefaultPubsubTopic) {\n const pubsubTopic = typeof pubsubTopicShardInfo == \"string\"\n ? pubsubTopicShardInfo\n : (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.singleShardInfoToPubsubTopic)(pubsubTopicShardInfo);\n (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.ensurePubsubTopicIsConfigured)(pubsubTopic, this.pubsubTopics);\n const peers = await this.getPeers({\n maxBootstrapPeers: 1,\n numPeers: this.numPeersToUse\n });\n if (peers.length === 0) {\n throw new Error(\"No peer found to initiate subscription.\");\n }\n log.info(`Creating filter subscription with ${peers.length} peers: `, peers.map((peer) => peer.id.toString()));\n const subscription = this.getActiveSubscription(pubsubTopic) ??\n this.setActiveSubscription(pubsubTopic, new Subscription(pubsubTopic, peers, this.getStream.bind(this)));\n return subscription;\n }\n toSubscriptionIterator(decoders) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.toAsyncIterator)(this, decoders);\n }\n /**\n * This method is used to satisfy the `IReceiver` interface.\n *\n * @hidden\n *\n * @param decoders The decoders to use for the subscription.\n * @param callback The callback function to use for the subscription.\n * @param opts Optional protocol options for the subscription.\n *\n * @returns A Promise that resolves to a function that unsubscribes from the subscription.\n *\n * @remarks\n * This method should not be used directly.\n * Instead, use `createSubscription` to create a new subscription.\n */\n async subscribe(decoders, callback) {\n const pubsubTopics = this.getPubsubTopics(decoders);\n if (pubsubTopics.length === 0) {\n throw Error(\"Failed to subscribe: no pubsubTopic found on decoders provided.\");\n }\n if (pubsubTopics.length > 1) {\n throw Error(\"Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.\");\n }\n const subscription = await this.createSubscription(pubsubTopics[0]);\n await subscription.subscribe(decoders, callback);\n const contentTopics = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.groupByContentTopic)(Array.isArray(decoders) ? decoders : [decoders]).keys());\n return async () => {\n await subscription.unsubscribe(contentTopics);\n };\n }\n onRequest(streamData) {\n const { connection, stream } = streamData;\n const { remotePeer } = connection;\n log.info(`Received message from ${remotePeer.toString()}`);\n try {\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => {\n for await (const bytes of source) {\n const response = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__.FilterPushRpc.decode(bytes.slice());\n const { pubsubTopic, wakuMessage } = response;\n if (!wakuMessage) {\n log.error(\"Received empty message\");\n return;\n }\n if (!pubsubTopic) {\n log.error(\"Pubsub topic missing from push message\");\n return;\n }\n const subscription = this.getActiveSubscription(pubsubTopic);\n if (!subscription) {\n log.error(`No subscription locally registered for topic ${pubsubTopic}`);\n return;\n }\n await subscription.processMessage(wakuMessage);\n }\n }).then(() => {\n log.info(\"Receiving pipe closed.\");\n }, (e) => {\n log.error(\"Error with receiving pipe\", e);\n });\n }\n catch (e) {\n log.error(\"Error decoding message\", e);\n }\n }\n getPubsubTopics(decoders) {\n if (!Array.isArray(decoders)) {\n return [decoders.pubsubTopic];\n }\n if (decoders.length === 0) {\n return [];\n }\n const pubsubTopics = new Set(decoders.map((d) => d.pubsubTopic));\n return [...pubsubTopics];\n }\n}\nfunction wakuFilter(init = { pubsubTopics: [] }) {\n return (libp2p) => new Filter(libp2p, init);\n}\nasync function pushMessage(subscriptionCallback, pubsubTopic, message) {\n const { decoders, callback } = subscriptionCallback;\n const { contentTopic } = message;\n if (!contentTopic) {\n log.warn(\"Message has no content topic, skipping\");\n return;\n }\n try {\n const decodePromises = decoders.map((dec) => dec\n .fromProtoObj(pubsubTopic, message)\n .then((decoded) => decoded || Promise.reject(\"Decoding failed\")));\n const decodedMessage = await Promise.any(decodePromises);\n await callback(decodedMessage);\n }\n catch (e) {\n log.error(\"Error decoding message\", e);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filter/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filterPeers.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filterPeers.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ filterPeersByDiscovery: () => (/* binding */ filterPeersByDiscovery)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n\n/**\n * Retrieves a list of peers based on the specified criteria:\n * 1. If numPeers is 0, return all peers\n * 2. Bootstrap peers are prioritized\n * 3. Non-bootstrap peers are randomly selected to fill up to numPeers\n *\n * @param peers - The list of peers to filter from.\n * @param numPeers - The total number of peers to retrieve. If 0, all peers are returned, irrespective of `maxBootstrapPeers`.\n * @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.\n * @returns An array of peers based on the specified criteria.\n */\nfunction filterPeersByDiscovery(peers, numPeers, maxBootstrapPeers) {\n // Collect the bootstrap peers up to the specified maximum\n let bootstrapPeers = peers\n .filter((peer) => peer.tags.has(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP))\n .slice(0, maxBootstrapPeers);\n // If numPeers is less than the number of bootstrap peers, adjust the bootstrapPeers array\n if (numPeers > 0 && numPeers < bootstrapPeers.length) {\n bootstrapPeers = bootstrapPeers.slice(0, numPeers);\n }\n // Collect non-bootstrap peers\n const nonBootstrapPeers = peers.filter((peer) => !peer.tags.has(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP));\n // If numPeers is 0, return all peers\n if (numPeers === 0) {\n return [...bootstrapPeers, ...nonBootstrapPeers];\n }\n // Initialize the list of selected peers with the bootstrap peers\n const selectedPeers = [...bootstrapPeers];\n // Fill up to numPeers with remaining random peers if needed\n while (selectedPeers.length < numPeers && nonBootstrapPeers.length > 0) {\n const randomIndex = Math.floor(Math.random() * nonBootstrapPeers.length);\n const randomPeer = nonBootstrapPeers.splice(randomIndex, 1)[0];\n selectedPeers.push(randomPeer);\n }\n return selectedPeers;\n}\n//# sourceMappingURL=filterPeers.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/filterPeers.js?"); /***/ }), @@ -6148,7 +6584,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KeepAliveManager: () => (/* binding */ KeepAliveManager),\n/* harmony export */ RelayPingContentTopic: () => (/* binding */ RelayPingContentTopic)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/index.js\");\n\n\nconst RelayPingContentTopic = \"/relay-ping/1/ping/null\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:keep-alive\");\nclass KeepAliveManager {\n pingKeepAliveTimers;\n relayKeepAliveTimers;\n options;\n relay;\n constructor(options, relay) {\n this.pingKeepAliveTimers = new Map();\n this.relayKeepAliveTimers = new Map();\n this.options = options;\n this.relay = relay;\n }\n start(peerId, libp2pPing) {\n // Just in case a timer already exist for this peer\n this.stop(peerId);\n const { pingKeepAlive: pingPeriodSecs, relayKeepAlive: relayPeriodSecs } = this.options;\n const peerIdStr = peerId.toString();\n if (pingPeriodSecs !== 0) {\n const interval = setInterval(() => {\n libp2pPing.ping(peerId).catch((e) => {\n log(`Ping failed (${peerIdStr})`, e);\n });\n }, pingPeriodSecs * 1000);\n this.pingKeepAliveTimers.set(peerIdStr, interval);\n }\n const relay = this.relay;\n if (relay && relayPeriodSecs !== 0) {\n const encoder = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.createEncoder)({\n contentTopic: RelayPingContentTopic,\n ephemeral: true,\n });\n const interval = setInterval(() => {\n log(\"Sending Waku Relay ping message\");\n relay\n .send(encoder, { payload: new Uint8Array([1]) })\n .catch((e) => log(\"Failed to send relay ping\", e));\n }, relayPeriodSecs * 1000);\n this.relayKeepAliveTimers.set(peerId, interval);\n }\n }\n stop(peerId) {\n const peerIdStr = peerId.toString();\n if (this.pingKeepAliveTimers.has(peerIdStr)) {\n clearInterval(this.pingKeepAliveTimers.get(peerIdStr));\n this.pingKeepAliveTimers.delete(peerIdStr);\n }\n if (this.relayKeepAliveTimers.has(peerId)) {\n clearInterval(this.relayKeepAliveTimers.get(peerId));\n this.relayKeepAliveTimers.delete(peerId);\n }\n }\n stopAll() {\n for (const timer of [\n ...Object.values(this.pingKeepAliveTimers),\n ...Object.values(this.relayKeepAliveTimers),\n ]) {\n clearInterval(timer);\n }\n this.pingKeepAliveTimers.clear();\n this.relayKeepAliveTimers.clear();\n }\n}\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ KeepAliveManager: () => (/* binding */ KeepAliveManager),\n/* harmony export */ RelayPingContentTopic: () => (/* binding */ RelayPingContentTopic)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _message_version_0_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./message/version_0.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js\");\n\n\n\nconst RelayPingContentTopic = \"/relay-ping/1/ping/null\";\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(\"keep-alive\");\nclass KeepAliveManager {\n pingKeepAliveTimers;\n relayKeepAliveTimers;\n options;\n relay;\n constructor(options, relay) {\n this.pingKeepAliveTimers = new Map();\n this.relayKeepAliveTimers = new Map();\n this.options = options;\n this.relay = relay;\n }\n start(peerId, libp2pPing, peerStore) {\n // Just in case a timer already exists for this peer\n this.stop(peerId);\n const { pingKeepAlive: pingPeriodSecs, relayKeepAlive: relayPeriodSecs } = this.options;\n const peerIdStr = peerId.toString();\n // Ping the peer every pingPeriodSecs seconds\n // if pingPeriodSecs is 0, don't ping the peer\n if (pingPeriodSecs !== 0) {\n const interval = setInterval(() => {\n void (async () => {\n let ping;\n try {\n // ping the peer for keep alive\n // also update the peer store with the latency\n try {\n ping = await libp2pPing.ping(peerId);\n log.info(`Ping succeeded (${peerIdStr})`, ping);\n }\n catch (error) {\n log.error(`Ping failed for peer (${peerIdStr}).\n Next ping will be attempted in ${pingPeriodSecs} seconds.\n `);\n return;\n }\n try {\n await peerStore.patch(peerId, {\n metadata: {\n ping: (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(ping.toString())\n }\n });\n }\n catch (e) {\n log.error(\"Failed to update ping\", e);\n }\n }\n catch (e) {\n log.error(`Ping failed (${peerIdStr})`, e);\n }\n })();\n }, pingPeriodSecs * 1000);\n this.pingKeepAliveTimers.set(peerIdStr, interval);\n }\n const relay = this.relay;\n if (relay && relayPeriodSecs !== 0) {\n const intervals = this.scheduleRelayPings(relay, relayPeriodSecs, peerId.toString());\n this.relayKeepAliveTimers.set(peerId, intervals);\n }\n }\n stop(peerId) {\n const peerIdStr = peerId.toString();\n if (this.pingKeepAliveTimers.has(peerIdStr)) {\n clearInterval(this.pingKeepAliveTimers.get(peerIdStr));\n this.pingKeepAliveTimers.delete(peerIdStr);\n }\n if (this.relayKeepAliveTimers.has(peerId)) {\n this.relayKeepAliveTimers.get(peerId)?.map(clearInterval);\n this.relayKeepAliveTimers.delete(peerId);\n }\n }\n stopAll() {\n for (const timer of [\n ...Object.values(this.pingKeepAliveTimers),\n ...Object.values(this.relayKeepAliveTimers)\n ]) {\n clearInterval(timer);\n }\n this.pingKeepAliveTimers.clear();\n this.relayKeepAliveTimers.clear();\n }\n connectionsExist() {\n return (this.pingKeepAliveTimers.size > 0 || this.relayKeepAliveTimers.size > 0);\n }\n scheduleRelayPings(relay, relayPeriodSecs, peerIdStr) {\n // send a ping message to each PubsubTopic the peer is part of\n const intervals = [];\n for (const topic of relay.pubsubTopics) {\n const meshPeers = relay.getMeshPeers(topic);\n if (!meshPeers.includes(peerIdStr))\n continue;\n const encoder = (0,_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__.createEncoder)({\n pubsubTopicShardInfo: (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.pubsubTopicToSingleShardInfo)(topic),\n contentTopic: RelayPingContentTopic,\n ephemeral: true\n });\n const interval = setInterval(() => {\n log.info(\"Sending Waku Relay ping message\");\n relay\n .send(encoder, { payload: new Uint8Array([1]) })\n .catch((e) => log.error(\"Failed to send relay ping\", e));\n }, relayPeriodSecs * 1000);\n intervals.push(interval);\n }\n return intervals;\n }\n}\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/keep_alive_manager.js?"); /***/ }), @@ -6159,7 +6595,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LightPushCodec: () => (/* binding */ LightPushCodec),\n/* harmony export */ PushResponse: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_1__.PushResponse),\n/* harmony export */ wakuLightPush: () => (/* binding */ wakuLightPush)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./push_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/push_rpc.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:light-push\");\nconst LightPushCodec = \"/vac/waku/lightpush/2.0.0-beta1\";\n\n/**\n * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).\n */\nclass LightPush extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__.BaseProtocol {\n options;\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.components);\n this.options = options || {};\n }\n async send(encoder, message, opts) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic } = this.options;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n const recipients = [];\n let error = undefined;\n try {\n if (!(0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.isSizeValid)(message.payload)) {\n log(\"Failed to send waku light push: message is bigger that 1MB\");\n return {\n recipients,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.SIZE_TOO_BIG,\n };\n }\n const protoMessage = await encoder.toProtoObj(message);\n if (!protoMessage) {\n log(\"Failed to encode to protoMessage, aborting push\");\n return {\n recipients,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.ENCODE_FAILED,\n };\n }\n const query = _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__.PushRpc.createRequest(protoMessage, pubSubTopic);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)([query.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n try {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const response = _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__.PushRpc.decode(bytes).response;\n if (response?.isSuccess) {\n recipients.push(peer.id);\n }\n else {\n log(\"No response in PushRPC\");\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.NO_RPC_RESPONSE;\n }\n }\n catch (err) {\n log(\"Failed to decode push reply\", err);\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.DECODE_FAILED;\n }\n }\n catch (err) {\n log(\"Failed to send waku light push request\", err);\n error = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.SendError.GENERIC_FAIL;\n }\n return {\n error,\n recipients,\n };\n }\n}\nfunction wakuLightPush(init = {}) {\n return (libp2p) => new LightPush(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LightPushCodec: () => (/* binding */ LightPushCodec),\n/* harmony export */ LightPushCore: () => (/* binding */ LightPushCore),\n/* harmony export */ PushResponse: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_1__.PushResponse)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./push_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/push_rpc.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"light-push\");\nconst LightPushCodec = \"/vac/waku/lightpush/2.0.0-beta1\";\n\n/**\n * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).\n */\nclass LightPushCore extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_7__.BaseProtocol {\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.components, log, options.pubsubTopics, options);\n }\n async preparePushMessage(encoder, message) {\n try {\n if (!message.payload || message.payload.length === 0) {\n log.error(\"Failed to send waku light push: payload is empty\");\n return { query: null, error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.EMPTY_PAYLOAD };\n }\n if (!(await (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.isMessageSizeUnderCap)(encoder, message))) {\n log.error(\"Failed to send waku light push: message is bigger than 1MB\");\n return { query: null, error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.SIZE_TOO_BIG };\n }\n const protoMessage = await encoder.toProtoObj(message);\n if (!protoMessage) {\n log.error(\"Failed to encode to protoMessage, aborting push\");\n return {\n query: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.ENCODE_FAILED\n };\n }\n const query = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.createRequest(protoMessage, encoder.pubsubTopic);\n return { query, error: null };\n }\n catch (error) {\n log.error(\"Failed to prepare push message\", error);\n return {\n query: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.GENERIC_FAIL\n };\n }\n }\n async send(encoder, message, peer) {\n const { query, error: preparationError } = await this.preparePushMessage(encoder, message);\n if (preparationError || !query) {\n return {\n success: null,\n failure: {\n error: preparationError,\n peerId: peer.id\n }\n };\n }\n let stream;\n try {\n stream = await this.getStream(peer);\n }\n catch (err) {\n log.error(`Failed to get a stream for remote peer${peer.id.toString()}`, err);\n return {\n success: null,\n failure: {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.REMOTE_PEER_FAULT,\n peerId: peer.id\n }\n };\n }\n let res;\n try {\n res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([query.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n }\n catch (err) {\n log.error(\"Failed to send waku light push request\", err);\n return {\n success: null,\n failure: {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.GENERIC_FAIL,\n peerId: peer.id\n }\n };\n }\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n let response;\n try {\n response = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.decode(bytes).response;\n }\n catch (err) {\n log.error(\"Failed to decode push reply\", err);\n return {\n success: null,\n failure: {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.DECODE_FAILED,\n peerId: peer.id\n }\n };\n }\n if (!response) {\n log.error(\"Remote peer fault: No response in PushRPC\");\n return {\n success: null,\n failure: {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.REMOTE_PEER_FAULT,\n peerId: peer.id\n }\n };\n }\n if (!response.isSuccess) {\n log.error(\"Remote peer rejected the message: \", response.info);\n return {\n success: null,\n failure: {\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.REMOTE_PEER_REJECTED,\n peerId: peer.id\n }\n };\n }\n return { success: peer.id, failure: null };\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/index.js?"); /***/ }), @@ -6170,7 +6606,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nclass PushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(message, pubSubTopic) {\n return new PushRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n message: message,\n pubsubTopic: pubSubTopic,\n },\n response: undefined,\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.decode(bytes);\n return new PushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.encode(this.proto);\n }\n get query() {\n return this.proto.request;\n }\n get response() {\n return this.proto.response;\n }\n}\n//# sourceMappingURL=push_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/push_rpc.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nclass PushRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(message, pubsubTopic) {\n return new PushRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n message: message,\n pubsubTopic: pubsubTopic\n },\n response: undefined\n });\n }\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.decode(bytes);\n return new PushRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_lightpush.PushRpc.encode(this.proto);\n }\n get query() {\n return this.proto.request;\n }\n get response() {\n return this.proto.response;\n }\n}\n//# sourceMappingURL=push_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/light_push/push_rpc.js?"); /***/ }), @@ -6192,7 +6628,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* binding */ DecodedMessage),\n/* harmony export */ Decoder: () => (/* binding */ Decoder),\n/* harmony export */ Encoder: () => (/* binding */ Encoder),\n/* harmony export */ Version: () => (/* binding */ Version),\n/* harmony export */ createDecoder: () => (/* binding */ createDecoder),\n/* harmony export */ createEncoder: () => (/* binding */ createEncoder),\n/* harmony export */ proto: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:message:version-0\");\nconst OneMillion = BigInt(1000000);\nconst Version = 0;\n\nclass DecodedMessage {\n pubSubTopic;\n proto;\n constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n }\n get ephemeral() {\n return Boolean(this.proto.ephemeral);\n }\n get payload() {\n return this.proto.payload;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n get _rawTimestamp() {\n return this.proto.timestamp;\n }\n get timestamp() {\n // In the case we receive a value that is bigger than JS's max number,\n // we catch the error and return undefined.\n try {\n if (this.proto.timestamp) {\n // nanoseconds 10^-9 to milliseconds 10^-3\n const timestamp = this.proto.timestamp / OneMillion;\n return new Date(Number(timestamp));\n }\n return;\n }\n catch (e) {\n return;\n }\n }\n get meta() {\n return this.proto.meta;\n }\n get version() {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n return this.proto.version ?? 0;\n }\n get rateLimitProof() {\n return this.proto.rateLimitProof;\n }\n}\nclass Encoder {\n contentTopic;\n ephemeral;\n metaSetter;\n constructor(contentTopic, ephemeral = false, metaSetter) {\n this.contentTopic = contentTopic;\n this.ephemeral = ephemeral;\n this.metaSetter = metaSetter;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n async toWire(message) {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.encode(await this.toProtoObj(message));\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n const protoMessage = {\n payload: message.payload,\n version: Version,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n meta: undefined,\n rateLimitProof: message.rateLimitProof,\n ephemeral: this.ephemeral,\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * Creates an encoder that encode messages without Waku level encryption or signature.\n *\n * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format to be sent over the Waku network. The resulting encoder can then be\n * pass to { @link @waku/interfaces.LightPush.push } or\n * { @link @waku/interfaces.Relay.send } to automatically encode outgoing\n * messages.\n */\nfunction createEncoder({ contentTopic, ephemeral, metaSetter, }) {\n return new Encoder(contentTopic, ephemeral, metaSetter);\n}\nclass Decoder {\n contentTopic;\n constructor(contentTopic) {\n this.contentTopic = contentTopic;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(bytes);\n log(\"Message decoded\", protoMessage);\n return Promise.resolve({\n payload: protoMessage.payload,\n contentTopic: protoMessage.contentTopic,\n version: protoMessage.version ?? undefined,\n timestamp: protoMessage.timestamp ?? undefined,\n meta: protoMessage.meta ?? undefined,\n rateLimitProof: protoMessage.rateLimitProof ?? undefined,\n ephemeral: protoMessage.ephemeral ?? false,\n });\n }\n async fromProtoObj(pubSubTopic, proto) {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n if (proto.version ?? 0 !== Version) {\n log(\"Failed to decode due to incorrect version, expected:\", Version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n return new DecodedMessage(pubSubTopic, proto);\n }\n}\n/**\n * Creates a decoder that decode messages without Waku level encryption.\n *\n * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format when received from the Waku network. The resulting decoder can then be\n * pass to { @link @waku/interfaces.Filter.subscribe } or\n * { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming\n * messages.\n *\n * @param contentTopic The resulting decoder will only decode messages with this content topic.\n */\nfunction createDecoder(contentTopic) {\n return new Decoder(contentTopic);\n}\n//# sourceMappingURL=version_0.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DecodedMessage: () => (/* binding */ DecodedMessage),\n/* harmony export */ Decoder: () => (/* binding */ Decoder),\n/* harmony export */ Encoder: () => (/* binding */ Encoder),\n/* harmony export */ Version: () => (/* binding */ Version),\n/* harmony export */ createDecoder: () => (/* binding */ createDecoder),\n/* harmony export */ createEncoder: () => (/* binding */ createEncoder),\n/* harmony export */ proto: () => (/* reexport safe */ _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"message:version-0\");\nconst OneMillion = BigInt(1_000_000);\nconst Version = 0;\n\nclass DecodedMessage {\n pubsubTopic;\n proto;\n constructor(pubsubTopic, proto) {\n this.pubsubTopic = pubsubTopic;\n this.proto = proto;\n }\n get ephemeral() {\n return Boolean(this.proto.ephemeral);\n }\n get payload() {\n return this.proto.payload;\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n get _rawTimestamp() {\n return this.proto.timestamp;\n }\n get timestamp() {\n // In the case we receive a value that is bigger than JS's max number,\n // we catch the error and return undefined.\n try {\n if (this.proto.timestamp) {\n // nanoseconds 10^-9 to milliseconds 10^-3\n const timestamp = this.proto.timestamp / OneMillion;\n return new Date(Number(timestamp));\n }\n return;\n }\n catch (e) {\n return;\n }\n }\n get meta() {\n return this.proto.meta;\n }\n get version() {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n return this.proto.version ?? 0;\n }\n get rateLimitProof() {\n return this.proto.rateLimitProof;\n }\n}\nclass Encoder {\n contentTopic;\n ephemeral;\n pubsubTopic;\n metaSetter;\n constructor(contentTopic, ephemeral = false, pubsubTopic, metaSetter) {\n this.contentTopic = contentTopic;\n this.ephemeral = ephemeral;\n this.pubsubTopic = pubsubTopic;\n this.metaSetter = metaSetter;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n async toWire(message) {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.encode(await this.toProtoObj(message));\n }\n async toProtoObj(message) {\n const timestamp = message.timestamp ?? new Date();\n const protoMessage = {\n payload: message.payload,\n version: Version,\n contentTopic: this.contentTopic,\n timestamp: BigInt(timestamp.valueOf()) * OneMillion,\n meta: undefined,\n rateLimitProof: message.rateLimitProof,\n ephemeral: this.ephemeral\n };\n if (this.metaSetter) {\n const meta = this.metaSetter(protoMessage);\n return { ...protoMessage, meta };\n }\n return protoMessage;\n }\n}\n/**\n * Creates an encoder that encode messages without Waku level encryption or signature.\n *\n * An encoder is used to encode messages in the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format to be sent over the Waku network. The resulting encoder can then be\n * pass to { @link @waku/interfaces!ISender.send } to automatically encode outgoing\n * messages.\n */\nfunction createEncoder({ pubsubTopic, pubsubTopicShardInfo, contentTopic, ephemeral, metaSetter }) {\n return new Encoder(contentTopic, ephemeral, (0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.determinePubsubTopic)(contentTopic, pubsubTopic ?? pubsubTopicShardInfo), metaSetter);\n}\nclass Decoder {\n pubsubTopic;\n contentTopic;\n constructor(pubsubTopic, contentTopic) {\n this.pubsubTopic = pubsubTopic;\n this.contentTopic = contentTopic;\n if (!contentTopic || contentTopic === \"\") {\n throw new Error(\"Content topic must be specified\");\n }\n }\n fromWireToProtoObj(bytes) {\n const protoMessage = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_message.WakuMessage.decode(bytes);\n return Promise.resolve({\n payload: protoMessage.payload,\n contentTopic: protoMessage.contentTopic,\n version: protoMessage.version ?? undefined,\n timestamp: protoMessage.timestamp ?? undefined,\n meta: protoMessage.meta ?? undefined,\n rateLimitProof: protoMessage.rateLimitProof ?? undefined,\n ephemeral: protoMessage.ephemeral ?? false\n });\n }\n async fromProtoObj(pubsubTopic, proto) {\n // https://rfc.vac.dev/spec/14/\n // > If omitted, the value SHOULD be interpreted as version 0.\n if (proto.version ?? 0 !== Version) {\n log.error(\"Failed to decode due to incorrect version, expected:\", Version, \", actual:\", proto.version);\n return Promise.resolve(undefined);\n }\n return new DecodedMessage(pubsubTopic, proto);\n }\n}\n/**\n * Creates a decoder that decode messages without Waku level encryption.\n *\n * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)\n * format when received from the Waku network. The resulting decoder can then be\n * pass to { @link @waku/interfaces!IReceiver.subscribe } to automatically decode incoming\n * messages.\n *\n * @param contentTopic The resulting decoder will only decode messages with this content topic.\n */\nfunction createDecoder(contentTopic, pubsubTopicShardInfo) {\n return new Decoder((0,_waku_utils__WEBPACK_IMPORTED_MODULE_1__.determinePubsubTopic)(contentTopic, pubsubTopicShardInfo), contentTopic);\n}\n//# sourceMappingURL=version_0.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/message/version_0.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/metadata/index.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/metadata/index.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MetadataCodec: () => (/* binding */ MetadataCodec),\n/* harmony export */ wakuMetadata: () => (/* binding */ wakuMetadata)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n\n\n\n\n\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_2__.Logger(\"metadata\");\nconst MetadataCodec = \"/vac/waku/metadata/1.0.0\";\nclass Metadata extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_7__.BaseProtocol {\n shardInfo;\n libp2pComponents;\n handshakesConfirmed = new Map();\n constructor(shardInfo, libp2p) {\n super(MetadataCodec, libp2p.components, log, (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.shardInfoToPubsubTopics)(shardInfo));\n this.shardInfo = shardInfo;\n this.libp2pComponents = libp2p;\n void libp2p.registrar.handle(MetadataCodec, (streamData) => {\n void this.onRequest(streamData);\n });\n }\n /**\n * Handle an incoming metadata request\n */\n async onRequest(streamData) {\n try {\n const { stream, connection } = streamData;\n const encodedShardInfo = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.proto_metadata.WakuMetadataResponse.encode(this.shardInfo);\n const encodedResponse = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([encodedShardInfo], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n const { error, shardInfo } = this.decodeMetadataResponse(encodedResponse);\n if (error) {\n return;\n }\n await this.savePeerShardInfo(connection.remotePeer, shardInfo);\n }\n catch (error) {\n log.error(\"Error handling metadata request\", error);\n }\n }\n /**\n * Make a metadata query to a peer\n */\n async query(peerId) {\n const request = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.proto_metadata.WakuMetadataRequest.encode(this.shardInfo);\n const peer = await this.peerStore.get(peerId);\n if (!peer) {\n return {\n shardInfo: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.NO_PEER_AVAILABLE\n };\n }\n const stream = await this.getStream(peer);\n const encodedResponse = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)([request], it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_4__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n const { error, shardInfo } = this.decodeMetadataResponse(encodedResponse);\n if (error) {\n return {\n shardInfo: null,\n error\n };\n }\n await this.savePeerShardInfo(peerId, shardInfo);\n return {\n shardInfo,\n error: null\n };\n }\n async confirmOrAttemptHandshake(peerId) {\n const shardInfo = this.handshakesConfirmed.get(peerId.toString());\n if (shardInfo) {\n return {\n shardInfo,\n error: null\n };\n }\n return await this.query(peerId);\n }\n decodeMetadataResponse(encodedResponse) {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList();\n encodedResponse.forEach((chunk) => {\n bytes.append(chunk);\n });\n const response = _waku_proto__WEBPACK_IMPORTED_MODULE_1__.proto_metadata.WakuMetadataResponse.decode(bytes);\n if (!response) {\n log.error(\"Error decoding metadata response\");\n return {\n shardInfo: null,\n error: _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.ProtocolError.DECODE_FAILED\n };\n }\n return {\n shardInfo: response,\n error: null\n };\n }\n async savePeerShardInfo(peerId, shardInfo) {\n // add or update the shardInfo to peer store\n await this.libp2pComponents.peerStore.merge(peerId, {\n metadata: {\n shardInfo: (0,_waku_utils__WEBPACK_IMPORTED_MODULE_2__.encodeRelayShard)(shardInfo)\n }\n });\n this.handshakesConfirmed.set(peerId.toString(), shardInfo);\n }\n}\nfunction wakuMetadata(shardInfo) {\n return (components) => new Metadata(shardInfo, components);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/metadata/index.js?"); /***/ }), @@ -6203,7 +6650,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nconst OneMillion = BigInt(1000000);\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\nclass HistoryRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n get query() {\n return this.proto.query;\n }\n get response() {\n return this.proto.response;\n }\n /**\n * Create History Query.\n */\n static createQuery(params) {\n const contentFilters = params.contentTopics.map((contentTopic) => {\n return { contentTopic };\n });\n const direction = directionToProto(params.pageDirection);\n const pagingInfo = {\n pageSize: BigInt(params.pageSize),\n cursor: params.cursor,\n direction,\n };\n let startTime, endTime;\n if (params.startTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n startTime = BigInt(params.startTime.valueOf()) * OneMillion;\n }\n if (params.endTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n endTime = BigInt(params.endTime.valueOf()) * OneMillion;\n }\n return new HistoryRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n query: {\n pubsubTopic: params.pubSubTopic,\n contentFilters,\n pagingInfo,\n startTime,\n endTime,\n },\n response: undefined,\n });\n }\n decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.decode(bytes);\n return new HistoryRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.encode(this.proto);\n }\n}\nfunction directionToProto(pageDirection) {\n switch (pageDirection) {\n case PageDirection.BACKWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n case PageDirection.FORWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.FORWARD;\n default:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n }\n}\n//# sourceMappingURL=history_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/history_rpc.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nconst OneMillion = BigInt(1_000_000);\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\nclass HistoryRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n get query() {\n return this.proto.query;\n }\n get response() {\n return this.proto.response;\n }\n /**\n * Create History Query.\n */\n static createQuery(params) {\n const contentFilters = params.contentTopics.map((contentTopic) => {\n return { contentTopic };\n });\n const direction = directionToProto(params.pageDirection);\n const pagingInfo = {\n pageSize: BigInt(params.pageSize),\n cursor: params.cursor,\n direction\n };\n let startTime, endTime;\n if (params.startTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n startTime = BigInt(params.startTime.valueOf()) * OneMillion;\n }\n if (params.endTime) {\n // milliseconds 10^-3 to nanoseconds 10^-9\n endTime = BigInt(params.endTime.valueOf()) * OneMillion;\n }\n return new HistoryRpc({\n requestId: (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n query: {\n pubsubTopic: params.pubsubTopic,\n contentFilters,\n pagingInfo,\n startTime,\n endTime\n },\n response: undefined\n });\n }\n decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.decode(bytes);\n return new HistoryRpc(res);\n }\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryRpc.encode(this.proto);\n }\n}\nfunction directionToProto(pageDirection) {\n switch (pageDirection) {\n case PageDirection.BACKWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n case PageDirection.FORWARD:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.FORWARD;\n default:\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.PagingInfo.Direction.BACKWARD;\n }\n}\n//# sourceMappingURL=history_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/history_rpc.js?"); /***/ }), @@ -6214,7 +6661,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPageSize: () => (/* binding */ DefaultPageSize),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection),\n/* harmony export */ StoreCodec: () => (/* binding */ StoreCodec),\n/* harmony export */ createCursor: () => (/* binding */ createCursor),\n/* harmony export */ wakuStore: () => (/* binding */ wakuStore)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./history_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/history_rpc.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar HistoryError = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:store\");\nconst StoreCodec = \"/vac/waku/store/2.0.0-beta4\";\nconst DefaultPageSize = 10;\n\n/**\n * Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).\n *\n * The Waku Store protocol can be used to retrieved historical messages.\n */\nclass Store extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__.BaseProtocol {\n options;\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.components);\n this.options = options ?? {};\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * The callback function takes a `WakuMessage` in input,\n * messages are processed in order:\n * - oldest to latest if `options.pageDirection` == { @link PageDirection.FORWARD }\n * - latest to oldest if `options.pageDirection` == { @link PageDirection.BACKWARD }\n *\n * The ordering may affect performance.\n * The ordering depends on the behavior of the remote store node.\n * If strong ordering is needed, you may need to handle this at application level\n * and set your own timestamps too (the WakuMessage timestamps are not certified).\n *\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n */\n async queryOrderedCallback(decoders, callback, options) {\n let abort = false;\n for await (const promises of this.queryGenerator(decoders, options)) {\n if (abort)\n break;\n const messagesOrUndef = await Promise.all(promises);\n let messages = messagesOrUndef.filter(_waku_utils__WEBPACK_IMPORTED_MODULE_1__.isDefined);\n // Messages in pages are ordered from oldest (first) to most recent (last).\n // https://github.com/vacp2p/rfc/issues/533\n if (typeof options?.pageDirection === \"undefined\" ||\n options?.pageDirection === _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection.BACKWARD) {\n messages = messages.reverse();\n }\n await Promise.all(messages.map(async (msg) => {\n if (msg && !abort) {\n abort = Boolean(await callback(msg));\n }\n }));\n }\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * The callback function takes a `Promise` in input,\n * useful if messages needs to be decrypted and performance matters.\n *\n * The order of the messages passed to the callback is as follows:\n * - within a page, messages are expected to be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n *\n * Do note that the resolution of the `Promise {\n if (!abort) {\n abort = Boolean(await callback(msg));\n }\n });\n promises = promises.concat(_promises);\n }\n await Promise.all(promises);\n }\n /**\n * Do a query to a Waku Store to retrieve historical/missed messages.\n *\n * This is a generator, useful if you want most control on how messages\n * are processed.\n *\n * The order of the messages returned by the remote Waku node SHOULD BE\n * as follows:\n * - within a page, messages SHOULD be ordered from oldest to most recent\n * - pages direction depends on { @link QueryOptions.pageDirection }\n *\n * However, there is no way to guarantee the behavior of the remote node.\n *\n * @throws If not able to reach a Waku Store peer to query,\n * or if an error is encountered when processing the reply,\n * or if two decoders with the same content topic are passed.\n */\n async *queryGenerator(decoders, options) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic } = this.options;\n let startTime, endTime;\n if (options?.timeFilter) {\n startTime = options.timeFilter.startTime;\n endTime = options.timeFilter.endTime;\n }\n const decodersAsMap = new Map();\n decoders.forEach((dec) => {\n if (decodersAsMap.has(dec.contentTopic)) {\n throw new Error(\"API does not support different decoder per content topic\");\n }\n decodersAsMap.set(dec.contentTopic, dec);\n });\n const contentTopics = decoders.map((dec) => dec.contentTopic);\n const queryOpts = Object.assign({\n pubSubTopic: pubSubTopic,\n pageDirection: _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.PageDirection.BACKWARD,\n pageSize: DefaultPageSize,\n }, options, { contentTopics, startTime, endTime });\n log(\"Querying history with the following options\", {\n ...options,\n peerId: options?.peerId?.toString(),\n });\n const peer = await this.getPeer(options?.peerId);\n for await (const messages of paginate(this.newStream.bind(this, peer), queryOpts, decodersAsMap, options?.cursor)) {\n yield messages;\n }\n }\n}\nasync function* paginate(streamFactory, queryOpts, decoders, cursor) {\n if (queryOpts.contentTopics.toString() !==\n Array.from(decoders.keys()).toString()) {\n throw new Error(\"Internal error, the decoders should match the query's content topics\");\n }\n let currentCursor = cursor;\n while (true) {\n queryOpts.cursor = currentCursor;\n const historyRpcQuery = _history_rpc_js__WEBPACK_IMPORTED_MODULE_11__.HistoryRpc.createQuery(queryOpts);\n log(\"Querying store peer\", `for (${queryOpts.pubSubTopic})`, queryOpts.contentTopics);\n const stream = await streamFactory();\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_5__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const reply = historyRpcQuery.decode(bytes);\n if (!reply.response) {\n log(\"Stopping pagination due to store `response` field missing\");\n break;\n }\n const response = reply.response;\n if (response.error && response.error !== HistoryError.NONE) {\n throw \"History response contains an Error: \" + response.error;\n }\n if (!response.messages || !response.messages.length) {\n log(\"Stopping pagination due to store `response.messages` field missing or empty\");\n break;\n }\n log(`${response.messages.length} messages retrieved from store`);\n yield response.messages.map((protoMsg) => {\n const contentTopic = protoMsg.contentTopic;\n if (typeof contentTopic !== \"undefined\") {\n const decoder = decoders.get(contentTopic);\n if (decoder) {\n return decoder.fromProtoObj(queryOpts.pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_10__.toProtoMessage)(protoMsg));\n }\n }\n return Promise.resolve(undefined);\n });\n const nextCursor = response.pagingInfo?.cursor;\n if (typeof nextCursor === \"undefined\") {\n // If the server does not return cursor then there is an issue,\n // Need to abort, or we end up in an infinite loop\n log(\"Stopping pagination due to `response.pagingInfo.cursor` missing from store response\");\n break;\n }\n currentCursor = nextCursor;\n const responsePageSize = response.pagingInfo?.pageSize;\n const queryPageSize = historyRpcQuery.query?.pagingInfo?.pageSize;\n if (\n // Response page size smaller than query, meaning this is the last page\n responsePageSize &&\n queryPageSize &&\n responsePageSize < queryPageSize) {\n break;\n }\n }\n}\nasync function createCursor(message, pubsubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_9__.DefaultPubSubTopic) {\n if (!message ||\n !message.timestamp ||\n !message.payload ||\n !message.contentTopic) {\n throw new Error(\"Message is missing required fields\");\n }\n const contentTopicBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_12__.sha256)((0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_2__.concat)([contentTopicBytes, message.payload]));\n const messageTime = BigInt(message.timestamp.getTime()) * BigInt(1000000);\n return {\n digest,\n pubsubTopic,\n senderTime: messageTime,\n receiverTime: messageTime,\n };\n}\nfunction wakuStore(init = {}) {\n return (libp2p) => new Store(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PageDirection: () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PageDirection),\n/* harmony export */ StoreCodec: () => (/* binding */ StoreCodec),\n/* harmony export */ StoreCore: () => (/* binding */ StoreCore)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./history_rpc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/history_rpc.js\");\n\n\n\n\n\n\n\n\n\nvar HistoryError = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_store.HistoryResponse.HistoryError;\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"store\");\nconst StoreCodec = \"/vac/waku/store/2.0.0-beta4\";\n\n/**\n * Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).\n *\n * The Waku Store protocol can be used to retrieved historical messages.\n */\nclass StoreCore extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_6__.BaseProtocol {\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.components, log, options.pubsubTopics, options);\n }\n async *queryPerPage(queryOpts, decoders, peer) {\n if (queryOpts.contentTopics.toString() !==\n Array.from(decoders.keys()).toString()) {\n throw new Error(\"Internal error, the decoders should match the query's content topics\");\n }\n let currentCursor = queryOpts.cursor;\n while (true) {\n queryOpts.cursor = currentCursor;\n const historyRpcQuery = _history_rpc_js__WEBPACK_IMPORTED_MODULE_8__.HistoryRpc.createQuery(queryOpts);\n const stream = await this.getStream(peer);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const reply = historyRpcQuery.decode(bytes);\n if (!reply.response) {\n log.warn(\"Stopping pagination due to store `response` field missing\");\n break;\n }\n const response = reply.response;\n if (response.error && response.error !== HistoryError.NONE) {\n throw \"History response contains an Error: \" + response.error;\n }\n if (!response.messages || !response.messages.length) {\n log.warn(\"Stopping pagination due to store `response.messages` field missing or empty\");\n break;\n }\n log.error(`${response.messages.length} messages retrieved from store`);\n yield response.messages.map((protoMsg) => {\n const contentTopic = protoMsg.contentTopic;\n if (typeof contentTopic !== \"undefined\") {\n const decoder = decoders.get(contentTopic);\n if (decoder) {\n return decoder.fromProtoObj(queryOpts.pubsubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__.toProtoMessage)(protoMsg));\n }\n }\n return Promise.resolve(undefined);\n });\n const nextCursor = response.pagingInfo?.cursor;\n if (typeof nextCursor === \"undefined\") {\n // If the server does not return cursor then there is an issue,\n // Need to abort, or we end up in an infinite loop\n log.warn(\"Stopping pagination due to `response.pagingInfo.cursor` missing from store response\");\n break;\n }\n currentCursor = nextCursor;\n const responsePageSize = response.pagingInfo?.pageSize;\n const queryPageSize = historyRpcQuery.query?.pagingInfo?.pageSize;\n if (\n // Response page size smaller than query, meaning this is the last page\n responsePageSize &&\n queryPageSize &&\n responsePageSize < queryPageSize) {\n break;\n }\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/store/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/stream_manager.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/stream_manager.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ StreamManager: () => (/* binding */ StreamManager)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var _waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/utils/dist/libp2p/index.js\");\n\n\nclass StreamManager {\n multicodec;\n getConnections;\n addEventListener;\n streamPool;\n log;\n constructor(multicodec, getConnections, addEventListener) {\n this.multicodec = multicodec;\n this.getConnections = getConnections;\n this.addEventListener = addEventListener;\n this.log = new _waku_utils__WEBPACK_IMPORTED_MODULE_0__.Logger(`stream-manager:${multicodec}`);\n this.addEventListener(\"peer:update\", this.handlePeerUpdateStreamPool.bind(this));\n this.getStream = this.getStream.bind(this);\n this.streamPool = new Map();\n }\n async getStream(peer) {\n const peerIdStr = peer.id.toString();\n const streamPromise = this.streamPool.get(peerIdStr);\n if (!streamPromise) {\n return this.newStream(peer); // fallback by creating a new stream on the spot\n }\n // We have the stream, let's remove it from the map\n this.streamPool.delete(peerIdStr);\n this.prepareNewStream(peer);\n const stream = await streamPromise;\n if (!stream || stream.status === \"closed\") {\n return this.newStream(peer); // fallback by creating a new stream on the spot\n }\n return stream;\n }\n async newStream(peer) {\n const connections = this.getConnections(peer.id);\n const connection = (0,_waku_utils_libp2p__WEBPACK_IMPORTED_MODULE_1__.selectConnection)(connections);\n if (!connection) {\n throw new Error(\"Failed to get a connection to the peer\");\n }\n return connection.newStream(this.multicodec);\n }\n prepareNewStream(peer) {\n const streamPromise = this.newStream(peer).catch(() => {\n // No error thrown as this call is not triggered by the user\n this.log.error(`Failed to prepare a new stream for ${peer.id.toString()}`);\n });\n this.streamPool.set(peer.id.toString(), streamPromise);\n }\n handlePeerUpdateStreamPool = (evt) => {\n const peer = evt.detail.peer;\n if (peer.protocols.includes(this.multicodec)) {\n this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);\n this.prepareNewStream(peer);\n }\n };\n}\n//# sourceMappingURL=stream_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/stream_manager.js?"); /***/ }), @@ -6225,7 +6683,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toProtoMessage: () => (/* binding */ toProtoMessage)\n/* harmony export */ });\nconst EmptyMessage = {\n payload: new Uint8Array(),\n contentTopic: \"\",\n version: undefined,\n timestamp: undefined,\n meta: undefined,\n rateLimitProof: undefined,\n ephemeral: undefined,\n};\nfunction toProtoMessage(wire) {\n return { ...EmptyMessage, ...wire };\n}\n//# sourceMappingURL=to_proto_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/to_proto_message.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toProtoMessage: () => (/* binding */ toProtoMessage)\n/* harmony export */ });\nconst EmptyMessage = {\n payload: new Uint8Array(),\n contentTopic: \"\",\n version: undefined,\n timestamp: undefined,\n meta: undefined,\n rateLimitProof: undefined,\n ephemeral: undefined\n};\nfunction toProtoMessage(wire) {\n return { ...EmptyMessage, ...wire };\n}\n//# sourceMappingURL=to_proto_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/to_proto_message.js?"); /***/ }), @@ -6236,18 +6694,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ waitForRemotePeer: () => (/* binding */ waitForRemotePeer)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var p_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-event */ \"./node_modules/p-event/index.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:wait-for-remote-peer\");\n/**\n * Wait for a remote peer to be ready given the passed protocols.\n * Must be used after attempting to connect to nodes, using\n * {@link @waku/core.WakuNode.dial} or a bootstrap method with\n * {@link @waku/sdk.createLightNode}.\n *\n * If the passed protocols is a GossipSub protocol, then it resolves only once\n * a peer is in a mesh, to help ensure that other peers will send and receive\n * message to us.\n *\n * @param waku The Waku Node\n * @param protocols The protocols that need to be enabled by remote peers.\n * @param timeoutMs A timeout value in milliseconds..\n *\n * @returns A promise that **resolves** if all desired protocols are fulfilled by\n * remote nodes, **rejects** if the timeoutMs is reached.\n * @throws If passing a protocol that is not mounted\n * @default Wait for remote peers with protocols enabled locally and no time out is applied.\n */\nasync function waitForRemotePeer(waku, protocols, timeoutMs) {\n protocols = protocols ?? getEnabledProtocols(waku);\n if (!waku.isStarted())\n return Promise.reject(\"Waku node is not started\");\n const promises = [];\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay)) {\n if (!waku.relay)\n throw new Error(\"Cannot wait for Relay peer: protocol not mounted\");\n promises.push(waitForGossipSubPeerInMesh(waku.relay));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store)) {\n if (!waku.store)\n throw new Error(\"Cannot wait for Store peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.store));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush)) {\n if (!waku.lightPush)\n throw new Error(\"Cannot wait for LightPush peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.lightPush));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter)) {\n if (!waku.filter)\n throw new Error(\"Cannot wait for Filter peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.filter));\n }\n if (timeoutMs) {\n await rejectOnTimeout(Promise.all(promises), timeoutMs, \"Timed out waiting for a remote peer.\");\n }\n else {\n await Promise.all(promises);\n }\n}\n/**\n * Wait for a peer with the given protocol to be connected.\n */\nasync function waitForConnectedPeer(protocol) {\n const codec = protocol.multicodec;\n const peers = await protocol.peers();\n if (peers.length) {\n log(`${codec} peer found: `, peers[0].id.toString());\n return;\n }\n await new Promise((resolve) => {\n const cb = (evt) => {\n if (evt.detail?.protocols?.includes(codec)) {\n log(\"Resolving for\", codec, evt.detail.protocols);\n protocol.removeLibp2pEventListener(\"peer:identify\", cb);\n resolve();\n }\n };\n protocol.addLibp2pEventListener(\"peer:identify\", cb);\n });\n}\n/**\n * Wait for a peer with the given protocol to be connected and in the gossipsub\n * mesh.\n */\nasync function waitForGossipSubPeerInMesh(waku) {\n let peers = waku.getMeshPeers();\n while (peers.length == 0) {\n await (0,p_event__WEBPACK_IMPORTED_MODULE_2__.pEvent)(waku.gossipSub, \"gossipsub:heartbeat\");\n peers = waku.getMeshPeers();\n }\n}\nconst awaitTimeout = (ms, rejectReason) => new Promise((_resolve, reject) => setTimeout(() => reject(rejectReason), ms));\nasync function rejectOnTimeout(promise, timeoutMs, rejectReason) {\n await Promise.race([promise, awaitTimeout(timeoutMs, rejectReason)]);\n}\nfunction getEnabledProtocols(waku) {\n const protocols = [];\n if (waku.relay) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay);\n }\n if (waku.filter) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter);\n }\n if (waku.store) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store);\n }\n if (waku.lightPush) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush);\n }\n return protocols;\n}\n//# sourceMappingURL=wait_for_remote_peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/waku.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/waku.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPingKeepAliveValueSecs: () => (/* binding */ DefaultPingKeepAliveValueSecs),\n/* harmony export */ DefaultRelayKeepAliveValueSecs: () => (/* binding */ DefaultRelayKeepAliveValueSecs),\n/* harmony export */ DefaultUserAgent: () => (/* binding */ DefaultUserAgent),\n/* harmony export */ WakuNode: () => (/* binding */ WakuNode)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/connection_manager.js\");\n\n\n\n\n\nconst DefaultPingKeepAliveValueSecs = 0;\nconst DefaultRelayKeepAliveValueSecs = 5 * 60;\nconst DefaultUserAgent = \"js-waku\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_3__(\"waku:waku\");\nclass WakuNode {\n libp2p;\n relay;\n store;\n filter;\n lightPush;\n connectionManager;\n constructor(options, libp2p, store, lightPush, filter, relay) {\n this.libp2p = libp2p;\n if (store) {\n this.store = store(libp2p);\n }\n if (filter) {\n this.filter = filter(libp2p);\n }\n if (lightPush) {\n this.lightPush = lightPush(libp2p);\n }\n if (relay) {\n this.relay = relay(libp2p);\n }\n const pingKeepAlive = options.pingKeepAlive || DefaultPingKeepAliveValueSecs;\n const relayKeepAlive = this.relay\n ? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs\n : 0;\n const peerId = this.libp2p.peerId.toString();\n this.connectionManager = _connection_manager_js__WEBPACK_IMPORTED_MODULE_4__.ConnectionManager.create(peerId, libp2p, { pingKeepAlive, relayKeepAlive }, this.relay);\n log(\"Waku node created\", peerId, `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this\n .lightPush}, filter: ${!!this.filter}`);\n }\n /**\n * Dials to the provided peer.\n *\n * @param peer The peer to dial\n * @param protocols Waku protocols we expect from the peer; Defaults to mounted protocols\n */\n async dial(peer, protocols) {\n const _protocols = protocols ?? [];\n const peerId = mapToPeerIdOrMultiaddr(peer);\n if (typeof protocols === \"undefined\") {\n this.relay && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay);\n this.store && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store);\n this.filter && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter);\n this.lightPush && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush);\n }\n const codecs = [];\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Relay)) {\n if (this.relay) {\n this.relay.gossipSub.multicodecs.forEach((codec) => codecs.push(codec));\n }\n else {\n log(\"Relay codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Store)) {\n if (this.store) {\n codecs.push(this.store.multicodec);\n }\n else {\n log(\"Store codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.LightPush)) {\n if (this.lightPush) {\n codecs.push(this.lightPush.multicodec);\n }\n else {\n log(\"Light Push codec not included in dial codec: protocol not mounted locally\");\n }\n }\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_2__.Protocols.Filter)) {\n if (this.filter) {\n codecs.push(this.filter.multicodec);\n }\n else {\n log(\"Filter codec not included in dial codec: protocol not mounted locally\");\n }\n }\n log(`Dialing to ${peerId.toString()} with protocols ${_protocols}`);\n return this.libp2p.dialProtocol(peerId, codecs);\n }\n async start() {\n await this.libp2p.start();\n }\n async stop() {\n this.connectionManager.stop();\n await this.libp2p.stop();\n }\n isStarted() {\n return this.libp2p.isStarted();\n }\n /**\n * Return the local multiaddr with peer id on which libp2p is listening.\n *\n * @throws if libp2p is not listening on localhost.\n */\n getLocalMultiaddrWithID() {\n const localMultiaddr = this.libp2p\n .getMultiaddrs()\n .find((addr) => addr.toString().match(/127\\.0\\.0\\.1/));\n if (!localMultiaddr || localMultiaddr.toString() === \"\") {\n throw \"Not listening on localhost\";\n }\n return localMultiaddr + \"/p2p/\" + this.libp2p.peerId.toString();\n }\n}\nfunction mapToPeerIdOrMultiaddr(peerId) {\n return (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__.isPeerId)(peerId) ? peerId : (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(peerId);\n}\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/waku.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ waitForRemotePeer: () => (/* binding */ waitForRemotePeer)\n/* harmony export */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var p_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-event */ \"./node_modules/@waku/sdk/node_modules/p-event/index.js\");\n\n\n\nconst log = new _waku_utils__WEBPACK_IMPORTED_MODULE_1__.Logger(\"wait-for-remote-peer\");\n//TODO: move this function within the Waku class: https://github.com/waku-org/js-waku/issues/1761\n/**\n * Wait for a remote peer to be ready given the passed protocols.\n * Must be used after attempting to connect to nodes, using\n * {@link @waku/sdk!WakuNode.dial} or a bootstrap method with\n * {@link @waku/sdk!createLightNode}.\n *\n * If the passed protocols is a GossipSub protocol, then it resolves only once\n * a peer is in a mesh, to help ensure that other peers will send and receive\n * message to us.\n *\n * @param waku The Waku Node\n * @param protocols The protocols that need to be enabled by remote peers.\n * @param timeoutMs A timeout value in milliseconds..\n *\n * @returns A promise that **resolves** if all desired protocols are fulfilled by\n * remote nodes, **rejects** if the timeoutMs is reached.\n * @throws If passing a protocol that is not mounted\n * @default Wait for remote peers with protocols enabled locally and no time out is applied.\n */\nasync function waitForRemotePeer(waku, protocols, timeoutMs) {\n protocols = protocols ?? getEnabledProtocols(waku);\n if (!waku.isStarted())\n return Promise.reject(\"Waku node is not started\");\n const promises = [];\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay)) {\n if (!waku.relay)\n throw new Error(\"Cannot wait for Relay peer: protocol not mounted\");\n promises.push(waitForGossipSubPeerInMesh(waku.relay));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store)) {\n if (!waku.store)\n throw new Error(\"Cannot wait for Store peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.store.protocol, waku.libp2p.services.metadata));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush)) {\n if (!waku.lightPush)\n throw new Error(\"Cannot wait for LightPush peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.lightPush.protocol, waku.libp2p.services.metadata));\n }\n if (protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter)) {\n if (!waku.filter)\n throw new Error(\"Cannot wait for Filter peer: protocol not mounted\");\n promises.push(waitForConnectedPeer(waku.filter, waku.libp2p.services.metadata));\n }\n if (timeoutMs) {\n await rejectOnTimeout(Promise.all(promises), timeoutMs, \"Timed out waiting for a remote peer.\");\n }\n else {\n await Promise.all(promises);\n }\n}\n//TODO: move this function within protocol SDK class: https://github.com/waku-org/js-waku/issues/1761\n/**\n * Wait for a peer with the given protocol to be connected.\n * If sharding is enabled on the node, it will also wait for the peer to be confirmed by the metadata service.\n */\nasync function waitForConnectedPeer(protocol, metadataService) {\n const codec = protocol.multicodec;\n const peers = await protocol.connectedPeers();\n if (peers.length) {\n if (!metadataService) {\n log.info(`${codec} peer found: `, peers[0].id.toString());\n return;\n }\n // once a peer is connected, we need to confirm the metadata handshake with at least one of those peers if sharding is enabled\n try {\n await Promise.any(peers.map((peer) => metadataService.confirmOrAttemptHandshake(peer.id)));\n return;\n }\n catch (e) {\n if (e.code === \"ERR_CONNECTION_BEING_CLOSED\")\n log.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`);\n log.error(`Error waiting for handshake confirmation: ${e}`);\n }\n }\n log.info(`Waiting for ${codec} peer`);\n // else we'll just wait for the next peer to connect\n await new Promise((resolve) => {\n const cb = (evt) => {\n if (evt.detail?.protocols?.includes(codec)) {\n if (metadataService) {\n metadataService\n .confirmOrAttemptHandshake(evt.detail.peerId)\n .then(() => {\n protocol.removeLibp2pEventListener(\"peer:identify\", cb);\n resolve();\n })\n .catch((e) => {\n if (e.code === \"ERR_CONNECTION_BEING_CLOSED\")\n log.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`);\n log.error(`Error waiting for handshake confirmation: ${e}`);\n });\n }\n else {\n protocol.removeLibp2pEventListener(\"peer:identify\", cb);\n resolve();\n }\n }\n };\n protocol.addLibp2pEventListener(\"peer:identify\", cb);\n });\n}\n/**\n * Wait for at least one peer with the given protocol to be connected and in the gossipsub\n * mesh for all pubsubTopics.\n */\nasync function waitForGossipSubPeerInMesh(waku) {\n let peers = waku.getMeshPeers();\n const pubsubTopics = waku.pubsubTopics;\n for (const topic of pubsubTopics) {\n while (peers.length == 0) {\n await (0,p_event__WEBPACK_IMPORTED_MODULE_2__.pEvent)(waku.gossipSub, \"gossipsub:heartbeat\");\n peers = waku.getMeshPeers(topic);\n }\n }\n}\nconst awaitTimeout = (ms, rejectReason) => new Promise((_resolve, reject) => setTimeout(() => reject(rejectReason), ms));\nasync function rejectOnTimeout(promise, timeoutMs, rejectReason) {\n await Promise.race([promise, awaitTimeout(timeoutMs, rejectReason)]);\n}\nfunction getEnabledProtocols(waku) {\n const protocols = [];\n if (waku.relay) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay);\n }\n if (waku.filter) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter);\n }\n if (waku.store) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store);\n }\n if (waku.lightPush) {\n protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush);\n }\n return protocols;\n}\n//# sourceMappingURL=wait_for_remote_peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/core/dist/lib/wait_for_remote_peer.js?"); /***/ }), @@ -6258,7 +6705,29 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/connection_manager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EConnectionStateEvents: () => (/* binding */ EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n Tags[\"LOCAL\"] = \"local-peer-cache\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\nvar EConnectionStateEvents;\n(function (EConnectionStateEvents) {\n EConnectionStateEvents[\"CONNECTION_STATUS\"] = \"waku:connection\";\n})(EConnectionStateEvents || (EConnectionStateEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/connection_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/constants.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/constants.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* binding */ DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* binding */ DefaultPubsubTopic)\n/* harmony export */ });\n/**\n * DefaultPubsubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubsubTopic = \"/waku/2/default-waku/proto\";\n/**\n * The default cluster ID for The Waku Network\n */\nconst DEFAULT_CLUSTER_ID = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/dns_discovery.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/dns_discovery.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/dns_discovery.js?"); /***/ }), @@ -6291,7 +6760,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=filter /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ SendError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.SendError),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DefaultPubsubTopic),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n/* harmony import */ var _dns_discovery_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./dns_discovery.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/dns_discovery.js\");\n/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./metadata.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/metadata.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/constants.js\");\n/* harmony import */ var _local_storage_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./local_storage.js */ \"./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/local_storage.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/index.js?"); /***/ }), @@ -6328,6 +6797,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=light_ /***/ }), +/***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/local_storage.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/local_storage.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=local_storage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/local_storage.js?"); + +/***/ }), + /***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/message.js": /*!******************************************************************************!*\ !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/message.js ***! @@ -6339,6 +6819,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=messag /***/ }), +/***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/metadata.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/metadata.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/metadata.js?"); + +/***/ }), + /***/ "./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/misc.js": /*!***************************************************************************!*\ !*** ./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/misc.js ***! @@ -6368,7 +6859,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=peer_e /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Protocols: () => (/* binding */ Protocols),\n/* harmony export */ SendError: () => (/* binding */ SendError)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar SendError;\n(function (SendError) {\n SendError[\"GENERIC_FAIL\"] = \"Generic error\";\n SendError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n SendError[\"DECODE_FAILED\"] = \"Failed to decode\";\n SendError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n SendError[\"NO_RPC_RESPONSE\"] = \"No RPC response\";\n})(SendError || (SendError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/protocols.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ProtocolError: () => (/* binding */ ProtocolError),\n/* harmony export */ Protocols: () => (/* binding */ Protocols)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar ProtocolError;\n(function (ProtocolError) {\n /** Could not determine the origin of the fault. Best to check connectivity and try again */\n ProtocolError[\"GENERIC_FAIL\"] = \"Generic error\";\n /**\n * Failure to protobuf encode the message. This is not recoverable and needs\n * further investigation.\n */\n ProtocolError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n /**\n * Failure to protobuf decode the message. May be due to a remote peer issue,\n * ensuring that messages are sent via several peer enable mitigation of this error.\n */\n ProtocolError[\"DECODE_FAILED\"] = \"Failed to decode\";\n /**\n * The message payload is empty, making the message invalid. Ensure that a non-empty\n * payload is set on the outgoing message.\n */\n ProtocolError[\"EMPTY_PAYLOAD\"] = \"Payload is empty\";\n /**\n * The message size is above the maximum message size allowed on the Waku Network.\n * Compressing the message or using an alternative strategy for large messages is recommended.\n */\n ProtocolError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n /**\n * The PubsubTopic passed to the send function is not configured on the Waku node.\n * Please ensure that the PubsubTopic is used when initializing the Waku node.\n */\n ProtocolError[\"TOPIC_NOT_CONFIGURED\"] = \"Topic not configured\";\n /**\n * Failure to find a peer with suitable protocols. This may due to a connection issue.\n * Mitigation can be: retrying after a given time period, display connectivity issue\n * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`\n * on the connection manager before retrying.\n */\n ProtocolError[\"NO_PEER_AVAILABLE\"] = \"No peer available\";\n /**\n * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_FAULT\"] = \"Remote peer fault\";\n /**\n * The remote peer rejected the message. Information provided by the remote peer\n * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_REJECTED\"] = \"Remote peer rejected\";\n /**\n * The protocol request timed out without a response. This may be due to a connection issue.\n * Mitigation can be: retrying after a given time period\n */\n ProtocolError[\"REQUEST_TIMEOUT\"] = \"Request timeout\";\n})(ProtocolError || (ProtocolError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/interfaces/dist/protocols.js?"); /***/ }), @@ -6427,6 +6918,105 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.j /***/ }), +/***/ "./node_modules/@waku/sdk/node_modules/@waku/message-hash/dist/index.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/message-hash/dist/index.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ messageHash: () => (/* binding */ messageHash),\n/* harmony export */ messageHashStr: () => (/* binding */ messageHashStr)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n\n\n/**\n * Deterministic Message Hashing as defined in\n * [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/#deterministic-message-hashing)\n */\nfunction messageHash(pubsubTopic, message) {\n const pubsubTopicBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.utf8ToBytes)(pubsubTopic);\n const contentTopicBytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.utf8ToBytes)(message.contentTopic);\n let bytes;\n if (message.meta) {\n bytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.concat)([\n pubsubTopicBytes,\n message.payload,\n contentTopicBytes,\n message.meta\n ]);\n }\n else {\n bytes = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.concat)([pubsubTopicBytes, message.payload, contentTopicBytes]);\n }\n return (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_1__.sha256)(bytes);\n}\nfunction messageHashStr(pubsubTopic, message) {\n const hash = messageHash(pubsubTopic, message);\n const hashStr = (0,_waku_utils_bytes__WEBPACK_IMPORTED_MODULE_0__.bytesToUtf8)(hash);\n return hashStr;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/message-hash/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.subscribe != null && obj.subscribe !== false)) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if ((obj.topic != null && obj.topic !== '')) {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n subscribe: false,\n topic: '',\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.subscribe = reader.bool();\n break;\n }\n case 2: {\n obj.topic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec(), opts);\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = FilterRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.push = MessagePush.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.push\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec(), opts);\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter_v2.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter_v2.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null && __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.filterSubscribeType = FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n }\n case 10: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 11: {\n if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentTopics\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentTopics.push(reader.string());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec(), opts);\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if ((obj.statusCode != null && obj.statusCode !== 0)) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: '',\n statusCode: 0\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 10: {\n obj.statusCode = reader.uint32();\n break;\n }\n case 11: {\n obj.statusDesc = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec(), opts);\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.wakuMessage\n });\n break;\n }\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec(), opts);\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter_v2.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/light_push.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/light_push.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 2: {\n obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.message\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec(), opts);\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.isSuccess != null && obj.isSuccess !== false)) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n isSuccess: false\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.isSuccess = reader.bool();\n break;\n }\n case 2: {\n obj.info = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec(), opts);\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.request = PushRequest.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.request\n });\n break;\n }\n case 3: {\n obj.response = PushResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec(), opts);\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/message.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/message.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/metadata.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/metadata.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ WakuMetadataRequest: () => (/* binding */ WakuMetadataRequest),\n/* harmony export */ WakuMetadataResponse: () => (/* binding */ WakuMetadataResponse)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar WakuMetadataRequest;\n(function (WakuMetadataRequest) {\n let _codec;\n WakuMetadataRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataRequest.codec());\n };\n WakuMetadataRequest.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataRequest.codec(), opts);\n };\n})(WakuMetadataRequest || (WakuMetadataRequest = {}));\nvar WakuMetadataResponse;\n(function (WakuMetadataResponse) {\n let _codec;\n WakuMetadataResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.clusterId != null) {\n w.uint32(8);\n w.uint32(obj.clusterId);\n }\n if (obj.shards != null) {\n for (const value of obj.shards) {\n w.uint32(16);\n w.uint32(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n shards: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.clusterId = reader.uint32();\n break;\n }\n case 2: {\n if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"shards\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.shards.push(reader.uint32());\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMetadataResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMetadataResponse.codec());\n };\n WakuMetadataResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMetadataResponse.codec(), opts);\n };\n})(WakuMetadataResponse || (WakuMetadataResponse = {}));\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/peer_exchange.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/peer_exchange.js ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.enr = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec(), opts);\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.numPeers = reader.uint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec(), opts);\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n peerInfos: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"peerInfos\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.peerInfos$\n }));\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec(), opts);\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 2: {\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec(), opts);\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/store.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/store.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.digest != null && obj.digest.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if ((obj.receiverTime != null && obj.receiverTime !== 0n)) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if ((obj.senderTime != null && obj.senderTime !== 0n)) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n digest: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.digest = reader.bytes();\n break;\n }\n case 2: {\n obj.receiverTime = reader.sint64();\n break;\n }\n case 3: {\n obj.senderTime = reader.sint64();\n break;\n }\n case 4: {\n obj.pubsubTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec(), opts);\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.pageSize = reader.uint64();\n break;\n }\n case 2: {\n obj.cursor = Index.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.cursor\n });\n break;\n }\n case 3: {\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec(), opts);\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec(), opts);\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentFilters: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.pubsubTopic = reader.string();\n break;\n }\n case 3: {\n if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"contentFilters\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.contentFilters$\n }));\n break;\n }\n case 4: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 5: {\n obj.startTime = reader.sint64();\n break;\n }\n case 6: {\n obj.endTime = reader.sint64();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec(), opts);\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n HistoryError[\"TOO_MANY_RESULTS\"] = \"TOO_MANY_RESULTS\";\n HistoryError[\"SERVICE_UNAVAILABLE\"] = \"SERVICE_UNAVAILABLE\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n __HistoryErrorValues[__HistoryErrorValues[\"TOO_MANY_RESULTS\"] = 429] = \"TOO_MANY_RESULTS\";\n __HistoryErrorValues[__HistoryErrorValues[\"SERVICE_UNAVAILABLE\"] = 503] = \"SERVICE_UNAVAILABLE\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {\n throw new protons_runtime__WEBPACK_IMPORTED_MODULE_0__.CodeError('decode error - map field \"messages\" had too many elements', 'ERR_MAX_LENGTH');\n }\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.messages$\n }));\n break;\n }\n case 3: {\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.pagingInfo\n });\n break;\n }\n case 4: {\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec(), opts);\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.requestId != null && obj.requestId !== '')) {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n requestId: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.requestId = reader.string();\n break;\n }\n case 2: {\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.query\n });\n break;\n }\n case 3: {\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.response\n });\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec(), opts);\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.proof != null && obj.proof.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if ((obj.epoch != null && obj.epoch.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if ((obj.shareX != null && obj.shareX.byteLength > 0)) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if ((obj.shareY != null && obj.shareY.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n proof: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n merkleRoot: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n epoch: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareX: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n shareY: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n nullifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n rlnIdentifier: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0)\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.proof = reader.bytes();\n break;\n }\n case 2: {\n obj.merkleRoot = reader.bytes();\n break;\n }\n case 3: {\n obj.epoch = reader.bytes();\n break;\n }\n case 4: {\n obj.shareX = reader.bytes();\n break;\n }\n case 5: {\n obj.shareY = reader.bytes();\n break;\n }\n case 6: {\n obj.nullifier = reader.bytes();\n break;\n }\n case 7: {\n obj.rlnIdentifier = reader.bytes();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec(), opts);\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n payload: (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.alloc)(0),\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n obj.payload = reader.bytes();\n break;\n }\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n case 3: {\n obj.version = reader.uint32();\n break;\n }\n case 10: {\n obj.timestamp = reader.sint64();\n break;\n }\n case 11: {\n obj.meta = reader.bytes();\n break;\n }\n case 21: {\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {\n limits: opts.limits?.rateLimitProof\n });\n break;\n }\n case 31: {\n obj.ephemeral = reader.bool();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec(), opts);\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/topic_only_message.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/topic_only_message.js ***! + \**********************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if ((obj.contentTopic != null && obj.contentTopic !== '')) {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length, opts = {}) => {\n const obj = {\n contentTopic: ''\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2: {\n obj.contentTopic = reader.string();\n break;\n }\n default: {\n reader.skipType(tag & 7);\n break;\n }\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf, opts) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec(), opts);\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/topic_only_message.js?"); + +/***/ }), + /***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js": /*!***********************************************************************!*\ !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js ***! @@ -6434,557 +7024,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.j /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _lib_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _lib_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _lib_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/message.js\");\n/* harmony import */ var _lib_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/filter.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter.js\");\n/* harmony import */ var _lib_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/topic_only_message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/topic_only_message.js\");\n/* harmony import */ var _lib_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/filter_v2.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter_v2.js\");\n/* harmony import */ var _lib_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/light_push.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/light_push.js\");\n/* harmony import */ var _lib_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/store.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/store.js\");\n/* harmony import */ var _lib_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/peer_exchange.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/peer_exchange.js\");\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushResponse: () => (/* reexport safe */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__.PushResponse),\n/* harmony export */ TopicOnlyMessage: () => (/* reexport safe */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__.TopicOnlyMessage),\n/* harmony export */ WakuMessage: () => (/* reexport safe */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__.WakuMessage),\n/* harmony export */ proto_filter: () => (/* reexport module object */ _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ proto_filter_v2: () => (/* reexport module object */ _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ proto_lightpush: () => (/* reexport module object */ _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ proto_message: () => (/* reexport module object */ _generated_message_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ proto_metadata: () => (/* reexport module object */ _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__),\n/* harmony export */ proto_peer_exchange: () => (/* reexport module object */ _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ proto_store: () => (/* reexport module object */ _generated_store_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ proto_topic_only_message: () => (/* reexport module object */ _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__)\n/* harmony export */ });\n/* harmony import */ var _generated_message_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generated/message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/message.js\");\n/* harmony import */ var _generated_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./generated/filter.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter.js\");\n/* harmony import */ var _generated_topic_only_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./generated/topic_only_message.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/topic_only_message.js\");\n/* harmony import */ var _generated_filter_v2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./generated/filter_v2.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/filter_v2.js\");\n/* harmony import */ var _generated_light_push_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generated/light_push.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/light_push.js\");\n/* harmony import */ var _generated_store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./generated/store.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/store.js\");\n/* harmony import */ var _generated_peer_exchange_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./generated/peer_exchange.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/peer_exchange.js\");\n/* harmony import */ var _generated_metadata_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./generated/metadata.js */ \"./node_modules/@waku/sdk/node_modules/@waku/proto/dist/generated/metadata.js\");\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/index.js?"); /***/ }), -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter.js ***! - \****************************************************************************/ +/***/ "./node_modules/@waku/sdk/node_modules/p-event/index.js": +/*!**************************************************************!*\ + !*** ./node_modules/@waku/sdk/node_modules/p-event/index.js ***! + \**************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterRequest: () => (/* binding */ FilterRequest),\n/* harmony export */ FilterRpc: () => (/* binding */ FilterRpc),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterRequest;\n(function (FilterRequest) {\n let ContentFilter;\n (function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));\n let _codec;\n FilterRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.subscribe != null && obj.subscribe !== false) {\n w.uint32(8);\n w.bool(obj.subscribe);\n }\n if (obj.topic != null && obj.topic !== \"\") {\n w.uint32(18);\n w.string(obj.topic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n FilterRequest.ContentFilter.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n subscribe: false,\n topic: \"\",\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.subscribe = reader.bool();\n break;\n case 2:\n obj.topic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRequest.codec());\n };\n FilterRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRequest.codec());\n };\n})(FilterRequest || (FilterRequest = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(10);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar FilterRpc;\n(function (FilterRpc) {\n let _codec;\n FilterRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n FilterRequest.codec().encode(obj.request, w);\n }\n if (obj.push != null) {\n w.uint32(26);\n MessagePush.codec().encode(obj.push, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = FilterRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.push = MessagePush.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterRpc.codec());\n };\n FilterRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterRpc.codec());\n };\n})(FilterRpc || (FilterRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter_v2.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter_v2.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FilterSubscribeRequest: () => (/* binding */ FilterSubscribeRequest),\n/* harmony export */ FilterSubscribeResponse: () => (/* binding */ FilterSubscribeResponse),\n/* harmony export */ MessagePush: () => (/* binding */ MessagePush),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar FilterSubscribeRequest;\n(function (FilterSubscribeRequest) {\n let FilterSubscribeType;\n (function (FilterSubscribeType) {\n FilterSubscribeType[\"SUBSCRIBER_PING\"] = \"SUBSCRIBER_PING\";\n FilterSubscribeType[\"SUBSCRIBE\"] = \"SUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE\"] = \"UNSUBSCRIBE\";\n FilterSubscribeType[\"UNSUBSCRIBE_ALL\"] = \"UNSUBSCRIBE_ALL\";\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let __FilterSubscribeTypeValues;\n (function (__FilterSubscribeTypeValues) {\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBER_PING\"] = 0] = \"SUBSCRIBER_PING\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"SUBSCRIBE\"] = 1] = \"SUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE\"] = 2] = \"UNSUBSCRIBE\";\n __FilterSubscribeTypeValues[__FilterSubscribeTypeValues[\"UNSUBSCRIBE_ALL\"] = 3] = \"UNSUBSCRIBE_ALL\";\n })(__FilterSubscribeTypeValues || (__FilterSubscribeTypeValues = {}));\n (function (FilterSubscribeType) {\n FilterSubscribeType.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__FilterSubscribeTypeValues);\n };\n })(FilterSubscribeType = FilterSubscribeRequest.FilterSubscribeType || (FilterSubscribeRequest.FilterSubscribeType = {}));\n let _codec;\n FilterSubscribeRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.filterSubscribeType != null &&\n __FilterSubscribeTypeValues[obj.filterSubscribeType] !== 0) {\n w.uint32(16);\n FilterSubscribeRequest.FilterSubscribeType.codec().encode(obj.filterSubscribeType, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(82);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentTopics != null) {\n for (const value of obj.contentTopics) {\n w.uint32(90);\n w.string(value);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,\n contentTopics: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.filterSubscribeType =\n FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader);\n break;\n case 10:\n obj.pubsubTopic = reader.string();\n break;\n case 11:\n obj.contentTopics.push(reader.string());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeRequest.codec());\n };\n FilterSubscribeRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeRequest.codec());\n };\n})(FilterSubscribeRequest || (FilterSubscribeRequest = {}));\nvar FilterSubscribeResponse;\n(function (FilterSubscribeResponse) {\n let _codec;\n FilterSubscribeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.statusCode != null && obj.statusCode !== 0) {\n w.uint32(80);\n w.uint32(obj.statusCode);\n }\n if (obj.statusDesc != null) {\n w.uint32(90);\n w.string(obj.statusDesc);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n statusCode: 0,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 10:\n obj.statusCode = reader.uint32();\n break;\n case 11:\n obj.statusDesc = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n FilterSubscribeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, FilterSubscribeResponse.codec());\n };\n FilterSubscribeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, FilterSubscribeResponse.codec());\n };\n})(FilterSubscribeResponse || (FilterSubscribeResponse = {}));\nvar MessagePush;\n(function (MessagePush) {\n let _codec;\n MessagePush.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.wakuMessage != null) {\n w.uint32(10);\n WakuMessage.codec().encode(obj.wakuMessage, w);\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n MessagePush.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, MessagePush.codec());\n };\n MessagePush.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, MessagePush.codec());\n };\n})(MessagePush || (MessagePush = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=filter_v2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/filter_v2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/light_push.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/light_push.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PushRequest: () => (/* binding */ PushRequest),\n/* harmony export */ PushResponse: () => (/* binding */ PushResponse),\n/* harmony export */ PushRpc: () => (/* binding */ PushRpc),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PushRequest;\n(function (PushRequest) {\n let _codec;\n PushRequest.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(10);\n w.string(obj.pubsubTopic);\n }\n if (obj.message != null) {\n w.uint32(18);\n WakuMessage.codec().encode(obj.message, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pubsubTopic = reader.string();\n break;\n case 2:\n obj.message = WakuMessage.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRequest.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRequest.codec());\n };\n PushRequest.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRequest.codec());\n };\n})(PushRequest || (PushRequest = {}));\nvar PushResponse;\n(function (PushResponse) {\n let _codec;\n PushResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.isSuccess != null && obj.isSuccess !== false) {\n w.uint32(8);\n w.bool(obj.isSuccess);\n }\n if (obj.info != null) {\n w.uint32(18);\n w.string(obj.info);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n isSuccess: false,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.isSuccess = reader.bool();\n break;\n case 2:\n obj.info = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushResponse.codec());\n };\n PushResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushResponse.codec());\n };\n})(PushResponse || (PushResponse = {}));\nvar PushRpc;\n(function (PushRpc) {\n let _codec;\n PushRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.request != null) {\n w.uint32(18);\n PushRequest.codec().encode(obj.request, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n PushResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.request = PushRequest.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = PushResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PushRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PushRpc.codec());\n };\n PushRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PushRpc.codec());\n };\n})(PushRpc || (PushRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/light_push.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/message.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/message.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/peer_exchange.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/peer_exchange.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerExchangeQuery: () => (/* binding */ PeerExchangeQuery),\n/* harmony export */ PeerExchangeRPC: () => (/* binding */ PeerExchangeRPC),\n/* harmony export */ PeerExchangeResponse: () => (/* binding */ PeerExchangeResponse),\n/* harmony export */ PeerInfo: () => (/* binding */ PeerInfo)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar PeerInfo;\n(function (PeerInfo) {\n let _codec;\n PeerInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.enr != null) {\n w.uint32(10);\n w.bytes(obj.enr);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.enr = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerInfo.codec());\n };\n PeerInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerInfo.codec());\n };\n})(PeerInfo || (PeerInfo = {}));\nvar PeerExchangeQuery;\n(function (PeerExchangeQuery) {\n let _codec;\n PeerExchangeQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.numPeers != null) {\n w.uint32(8);\n w.uint64(obj.numPeers);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.numPeers = reader.uint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeQuery.codec());\n };\n PeerExchangeQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeQuery.codec());\n };\n})(PeerExchangeQuery || (PeerExchangeQuery = {}));\nvar PeerExchangeResponse;\n(function (PeerExchangeResponse) {\n let _codec;\n PeerExchangeResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.peerInfos != null) {\n for (const value of obj.peerInfos) {\n w.uint32(10);\n PeerInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerInfos: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeResponse.codec());\n };\n PeerExchangeResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeResponse.codec());\n };\n})(PeerExchangeResponse || (PeerExchangeResponse = {}));\nvar PeerExchangeRPC;\n(function (PeerExchangeRPC) {\n let _codec;\n PeerExchangeRPC.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.query != null) {\n w.uint32(10);\n PeerExchangeQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(18);\n PeerExchangeResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32());\n break;\n case 2:\n obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PeerExchangeRPC.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerExchangeRPC.codec());\n };\n PeerExchangeRPC.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerExchangeRPC.codec());\n };\n})(PeerExchangeRPC || (PeerExchangeRPC = {}));\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/peer_exchange.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/store.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/store.js ***! - \***************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ContentFilter: () => (/* binding */ ContentFilter),\n/* harmony export */ HistoryQuery: () => (/* binding */ HistoryQuery),\n/* harmony export */ HistoryResponse: () => (/* binding */ HistoryResponse),\n/* harmony export */ HistoryRpc: () => (/* binding */ HistoryRpc),\n/* harmony export */ Index: () => (/* binding */ Index),\n/* harmony export */ PagingInfo: () => (/* binding */ PagingInfo),\n/* harmony export */ RateLimitProof: () => (/* binding */ RateLimitProof),\n/* harmony export */ WakuMessage: () => (/* binding */ WakuMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Index;\n(function (Index) {\n let _codec;\n Index.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.digest != null && obj.digest.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.digest);\n }\n if (obj.receiverTime != null && obj.receiverTime !== 0n) {\n w.uint32(16);\n w.sint64(obj.receiverTime);\n }\n if (obj.senderTime != null && obj.senderTime !== 0n) {\n w.uint32(24);\n w.sint64(obj.senderTime);\n }\n if (obj.pubsubTopic != null && obj.pubsubTopic !== \"\") {\n w.uint32(34);\n w.string(obj.pubsubTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n digest: new Uint8Array(0),\n receiverTime: 0n,\n senderTime: 0n,\n pubsubTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.digest = reader.bytes();\n break;\n case 2:\n obj.receiverTime = reader.sint64();\n break;\n case 3:\n obj.senderTime = reader.sint64();\n break;\n case 4:\n obj.pubsubTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Index.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Index.codec());\n };\n Index.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Index.codec());\n };\n})(Index || (Index = {}));\nvar PagingInfo;\n(function (PagingInfo) {\n let Direction;\n (function (Direction) {\n Direction[\"BACKWARD\"] = \"BACKWARD\";\n Direction[\"FORWARD\"] = \"FORWARD\";\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let __DirectionValues;\n (function (__DirectionValues) {\n __DirectionValues[__DirectionValues[\"BACKWARD\"] = 0] = \"BACKWARD\";\n __DirectionValues[__DirectionValues[\"FORWARD\"] = 1] = \"FORWARD\";\n })(__DirectionValues || (__DirectionValues = {}));\n (function (Direction) {\n Direction.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__DirectionValues);\n };\n })(Direction = PagingInfo.Direction || (PagingInfo.Direction = {}));\n let _codec;\n PagingInfo.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pageSize != null) {\n w.uint32(8);\n w.uint64(obj.pageSize);\n }\n if (obj.cursor != null) {\n w.uint32(18);\n Index.codec().encode(obj.cursor, w);\n }\n if (obj.direction != null) {\n w.uint32(24);\n PagingInfo.Direction.codec().encode(obj.direction, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {};\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.pageSize = reader.uint64();\n break;\n case 2:\n obj.cursor = Index.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.direction = PagingInfo.Direction.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n PagingInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PagingInfo.codec());\n };\n PagingInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PagingInfo.codec());\n };\n})(PagingInfo || (PagingInfo = {}));\nvar ContentFilter;\n(function (ContentFilter) {\n let _codec;\n ContentFilter.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(10);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n ContentFilter.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, ContentFilter.codec());\n };\n ContentFilter.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, ContentFilter.codec());\n };\n})(ContentFilter || (ContentFilter = {}));\nvar HistoryQuery;\n(function (HistoryQuery) {\n let _codec;\n HistoryQuery.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.pubsubTopic != null) {\n w.uint32(18);\n w.string(obj.pubsubTopic);\n }\n if (obj.contentFilters != null) {\n for (const value of obj.contentFilters) {\n w.uint32(26);\n ContentFilter.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(34);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.startTime != null) {\n w.uint32(40);\n w.sint64(obj.startTime);\n }\n if (obj.endTime != null) {\n w.uint32(48);\n w.sint64(obj.endTime);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentFilters: [],\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.pubsubTopic = reader.string();\n break;\n case 3:\n obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 5:\n obj.startTime = reader.sint64();\n break;\n case 6:\n obj.endTime = reader.sint64();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryQuery.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryQuery.codec());\n };\n HistoryQuery.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryQuery.codec());\n };\n})(HistoryQuery || (HistoryQuery = {}));\nvar HistoryResponse;\n(function (HistoryResponse) {\n let HistoryError;\n (function (HistoryError) {\n HistoryError[\"NONE\"] = \"NONE\";\n HistoryError[\"INVALID_CURSOR\"] = \"INVALID_CURSOR\";\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let __HistoryErrorValues;\n (function (__HistoryErrorValues) {\n __HistoryErrorValues[__HistoryErrorValues[\"NONE\"] = 0] = \"NONE\";\n __HistoryErrorValues[__HistoryErrorValues[\"INVALID_CURSOR\"] = 1] = \"INVALID_CURSOR\";\n })(__HistoryErrorValues || (__HistoryErrorValues = {}));\n (function (HistoryError) {\n HistoryError.codec = () => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.enumeration)(__HistoryErrorValues);\n };\n })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));\n let _codec;\n HistoryResponse.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.messages != null) {\n for (const value of obj.messages) {\n w.uint32(18);\n WakuMessage.codec().encode(value, w);\n }\n }\n if (obj.pagingInfo != null) {\n w.uint32(26);\n PagingInfo.codec().encode(obj.pagingInfo, w);\n }\n if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {\n w.uint32(32);\n HistoryResponse.HistoryError.codec().encode(obj.error, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n messages: [],\n error: HistoryError.NONE,\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));\n break;\n case 3:\n obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());\n break;\n case 4:\n obj.error = HistoryResponse.HistoryError.codec().decode(reader);\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryResponse.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryResponse.codec());\n };\n HistoryResponse.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryResponse.codec());\n };\n})(HistoryResponse || (HistoryResponse = {}));\nvar HistoryRpc;\n(function (HistoryRpc) {\n let _codec;\n HistoryRpc.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.requestId != null && obj.requestId !== \"\") {\n w.uint32(10);\n w.string(obj.requestId);\n }\n if (obj.query != null) {\n w.uint32(18);\n HistoryQuery.codec().encode(obj.query, w);\n }\n if (obj.response != null) {\n w.uint32(26);\n HistoryResponse.codec().encode(obj.response, w);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n requestId: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.requestId = reader.string();\n break;\n case 2:\n obj.query = HistoryQuery.codec().decode(reader, reader.uint32());\n break;\n case 3:\n obj.response = HistoryResponse.codec().decode(reader, reader.uint32());\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n HistoryRpc.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, HistoryRpc.codec());\n };\n HistoryRpc.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, HistoryRpc.codec());\n };\n})(HistoryRpc || (HistoryRpc = {}));\nvar RateLimitProof;\n(function (RateLimitProof) {\n let _codec;\n RateLimitProof.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.proof != null && obj.proof.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.proof);\n }\n if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {\n w.uint32(18);\n w.bytes(obj.merkleRoot);\n }\n if (obj.epoch != null && obj.epoch.byteLength > 0) {\n w.uint32(26);\n w.bytes(obj.epoch);\n }\n if (obj.shareX != null && obj.shareX.byteLength > 0) {\n w.uint32(34);\n w.bytes(obj.shareX);\n }\n if (obj.shareY != null && obj.shareY.byteLength > 0) {\n w.uint32(42);\n w.bytes(obj.shareY);\n }\n if (obj.nullifier != null && obj.nullifier.byteLength > 0) {\n w.uint32(50);\n w.bytes(obj.nullifier);\n }\n if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {\n w.uint32(58);\n w.bytes(obj.rlnIdentifier);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n proof: new Uint8Array(0),\n merkleRoot: new Uint8Array(0),\n epoch: new Uint8Array(0),\n shareX: new Uint8Array(0),\n shareY: new Uint8Array(0),\n nullifier: new Uint8Array(0),\n rlnIdentifier: new Uint8Array(0),\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.proof = reader.bytes();\n break;\n case 2:\n obj.merkleRoot = reader.bytes();\n break;\n case 3:\n obj.epoch = reader.bytes();\n break;\n case 4:\n obj.shareX = reader.bytes();\n break;\n case 5:\n obj.shareY = reader.bytes();\n break;\n case 6:\n obj.nullifier = reader.bytes();\n break;\n case 7:\n obj.rlnIdentifier = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n RateLimitProof.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, RateLimitProof.codec());\n };\n RateLimitProof.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, RateLimitProof.codec());\n };\n})(RateLimitProof || (RateLimitProof = {}));\nvar WakuMessage;\n(function (WakuMessage) {\n let _codec;\n WakuMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.payload != null && obj.payload.byteLength > 0) {\n w.uint32(10);\n w.bytes(obj.payload);\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (obj.version != null) {\n w.uint32(24);\n w.uint32(obj.version);\n }\n if (obj.timestamp != null) {\n w.uint32(80);\n w.sint64(obj.timestamp);\n }\n if (obj.meta != null) {\n w.uint32(90);\n w.bytes(obj.meta);\n }\n if (obj.rateLimitProof != null) {\n w.uint32(170);\n RateLimitProof.codec().encode(obj.rateLimitProof, w);\n }\n if (obj.ephemeral != null) {\n w.uint32(248);\n w.bool(obj.ephemeral);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n payload: new Uint8Array(0),\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n obj.payload = reader.bytes();\n break;\n case 2:\n obj.contentTopic = reader.string();\n break;\n case 3:\n obj.version = reader.uint32();\n break;\n case 10:\n obj.timestamp = reader.sint64();\n break;\n case 11:\n obj.meta = reader.bytes();\n break;\n case 21:\n obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());\n break;\n case 31:\n obj.ephemeral = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n WakuMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, WakuMessage.codec());\n };\n WakuMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, WakuMessage.codec());\n };\n})(WakuMessage || (WakuMessage = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/store.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/topic_only_message.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/topic_only_message.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TopicOnlyMessage: () => (/* binding */ TopicOnlyMessage)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar TopicOnlyMessage;\n(function (TopicOnlyMessage) {\n let _codec;\n TopicOnlyMessage.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.contentTopic != null && obj.contentTopic !== \"\") {\n w.uint32(18);\n w.string(obj.contentTopic);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n contentTopic: \"\",\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 2:\n obj.contentTopic = reader.string();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n TopicOnlyMessage.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, TopicOnlyMessage.codec());\n };\n TopicOnlyMessage.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, TopicOnlyMessage.codec());\n };\n})(TopicOnlyMessage || (TopicOnlyMessage = {}));\n//# sourceMappingURL=topic_only_message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/abort-error.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/abort-error.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError)\n/* harmony export */ });\nclass AbortError extends Error {\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n//# sourceMappingURL=abort-error.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/abort-error.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* reexport safe */ _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError),\n/* harmony export */ abortableDuplex: () => (/* binding */ abortableDuplex),\n/* harmony export */ abortableSink: () => (/* binding */ abortableSink),\n/* harmony export */ abortableSource: () => (/* binding */ abortableSource),\n/* harmony export */ abortableTransform: () => (/* binding */ abortableSink)\n/* harmony export */ });\n/* harmony import */ var _abort_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abort-error.js */ \"./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/abort-error.js\");\n/* harmony import */ var get_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! get-iterator */ \"./node_modules/get-iterator/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n * import { abortableSource } from 'abortable-iterator'\n *\n * async function main () {\n * // An example function that creates an async iterator that yields an increasing\n * // number every x milliseconds and NEVER ENDS!\n * const asyncCounter = async function * (start, delay) {\n * let i = start\n * while (true) {\n * yield new Promise(resolve => setTimeout(() => resolve(i++), delay))\n * }\n * }\n *\n * // Create a counter that'll yield numbers from 0 upwards every second\n * const everySecond = asyncCounter(0, 1000)\n *\n * // Make everySecond abortable!\n * const controller = new AbortController()\n * const abortableEverySecond = abortableSource(everySecond, controller.signal)\n *\n * // Abort after 5 seconds\n * setTimeout(() => controller.abort(), 5000)\n *\n * try {\n * // Start the iteration, which will throw after 5 seconds when it is aborted\n * for await (const n of abortableEverySecond) {\n * console.log(n)\n * }\n * } catch (err) {\n * if (err.code === 'ERR_ABORTED') {\n * // Expected - all ok :D\n * } else {\n * throw err\n * }\n * }\n * }\n *\n * main()\n * ```\n */\n\n\n/**\n * Wrap an iterator to make it abortable, allow cleanup when aborted via onAbort\n */\nfunction abortableSource(source, signal, options) {\n const opts = options ?? {};\n const iterator = (0,get_iterator__WEBPACK_IMPORTED_MODULE_1__.getIterator)(source);\n async function* abortable() {\n let nextAbortHandler;\n const abortHandler = () => {\n if (nextAbortHandler != null)\n nextAbortHandler();\n };\n signal.addEventListener('abort', abortHandler);\n while (true) {\n let result;\n try {\n if (signal.aborted) {\n const { abortMessage, abortCode } = opts;\n throw new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode);\n }\n const abort = new Promise((resolve, reject) => {\n nextAbortHandler = () => {\n const { abortMessage, abortCode } = opts;\n reject(new _abort_error_js__WEBPACK_IMPORTED_MODULE_0__.AbortError(abortMessage, abortCode));\n };\n });\n // Race the iterator and the abort signals\n result = await Promise.race([abort, iterator.next()]);\n nextAbortHandler = null;\n }\n catch (err) {\n signal.removeEventListener('abort', abortHandler);\n // Might not have been aborted by a known signal\n const isKnownAborter = err.type === 'aborted' && signal.aborted;\n if (isKnownAborter && (opts.onAbort != null)) {\n // Do any custom abort handling for the iterator\n opts.onAbort(source);\n }\n // End the iterator if it is a generator\n if (typeof iterator.return === 'function') {\n try {\n const p = iterator.return();\n if (p instanceof Promise) { // eslint-disable-line max-depth\n p.catch(err => {\n if (opts.onReturnError != null) {\n opts.onReturnError(err);\n }\n });\n }\n }\n catch (err) {\n if (opts.onReturnError != null) { // eslint-disable-line max-depth\n opts.onReturnError(err);\n }\n }\n }\n if (isKnownAborter && opts.returnOnAbort === true) {\n return;\n }\n throw err;\n }\n if (result.done === true) {\n break;\n }\n yield result.value;\n }\n signal.removeEventListener('abort', abortHandler);\n }\n return abortable();\n}\nfunction abortableSink(sink, signal, options) {\n return (source) => sink(abortableSource(source, signal, options));\n}\nfunction abortableDuplex(duplex, signal, options) {\n return {\n sink: abortableSink(duplex.sink, signal, {\n ...options,\n onAbort: undefined\n }),\n source: abortableSource(duplex.source, signal, options)\n };\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/base.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/base.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseDatastore: () => (/* binding */ BaseDatastore)\n/* harmony export */ });\n/* harmony import */ var it_drain__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-drain */ \"./node_modules/@waku/sdk/node_modules/it-drain/dist/src/index.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-filter */ \"./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var it_sort__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-sort */ \"./node_modules/@waku/sdk/node_modules/it-sort/dist/src/index.js\");\n/* harmony import */ var it_take__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-take */ \"./node_modules/@waku/sdk/node_modules/it-take/dist/src/index.js\");\n\n\n\n\nclass BaseDatastore {\n put(key, val, options) {\n return Promise.reject(new Error('.put is not implemented'));\n }\n get(key, options) {\n return Promise.reject(new Error('.get is not implemented'));\n }\n has(key, options) {\n return Promise.reject(new Error('.has is not implemented'));\n }\n delete(key, options) {\n return Promise.reject(new Error('.delete is not implemented'));\n }\n async *putMany(source, options = {}) {\n for await (const { key, value } of source) {\n await this.put(key, value, options);\n yield key;\n }\n }\n async *getMany(source, options = {}) {\n for await (const key of source) {\n yield {\n key,\n value: await this.get(key, options)\n };\n }\n }\n async *deleteMany(source, options = {}) {\n for await (const key of source) {\n await this.delete(key, options);\n yield key;\n }\n }\n batch() {\n let puts = [];\n let dels = [];\n return {\n put(key, value) {\n puts.push({ key, value });\n },\n delete(key) {\n dels.push(key);\n },\n commit: async (options) => {\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.putMany(puts, options));\n puts = [];\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.deleteMany(dels, options));\n dels = [];\n }\n };\n }\n /**\n * Extending classes should override `query` or implement this method\n */\n // eslint-disable-next-line require-yield\n async *_all(q, options) {\n throw new Error('._all is not implemented');\n }\n /**\n * Extending classes should override `queryKeys` or implement this method\n */\n // eslint-disable-next-line require-yield\n async *_allKeys(q, options) {\n throw new Error('._allKeys is not implemented');\n }\n query(q, options) {\n let it = this._all(q, options);\n if (q.prefix != null) {\n const prefix = q.prefix;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, (e) => e.key.toString().startsWith(prefix));\n }\n if (Array.isArray(q.filters)) {\n it = q.filters.reduce((it, f) => (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, f), it);\n }\n if (Array.isArray(q.orders)) {\n it = q.orders.reduce((it, f) => (0,it_sort__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(it, f), it);\n }\n if (q.offset != null) {\n let i = 0;\n const offset = q.offset;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, () => i++ >= offset);\n }\n if (q.limit != null) {\n it = (0,it_take__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(it, q.limit);\n }\n return it;\n }\n queryKeys(q, options) {\n let it = this._allKeys(q, options);\n if (q.prefix != null) {\n const prefix = q.prefix;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, (key) => key.toString().startsWith(prefix));\n }\n if (Array.isArray(q.filters)) {\n it = q.filters.reduce((it, f) => (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, f), it);\n }\n if (Array.isArray(q.orders)) {\n it = q.orders.reduce((it, f) => (0,it_sort__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(it, f), it);\n }\n if (q.offset != null) {\n const offset = q.offset;\n let i = 0;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, () => i++ >= offset);\n }\n if (q.limit != null) {\n it = (0,it_take__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(it, q.limit);\n }\n return it;\n }\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/errors.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/errors.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ abortedError: () => (/* binding */ abortedError),\n/* harmony export */ dbDeleteFailedError: () => (/* binding */ dbDeleteFailedError),\n/* harmony export */ dbOpenFailedError: () => (/* binding */ dbOpenFailedError),\n/* harmony export */ dbReadFailedError: () => (/* binding */ dbReadFailedError),\n/* harmony export */ dbWriteFailedError: () => (/* binding */ dbWriteFailedError),\n/* harmony export */ notFoundError: () => (/* binding */ notFoundError)\n/* harmony export */ });\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n\nfunction dbOpenFailedError(err) {\n err = err ?? new Error('Cannot open database');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_OPEN_FAILED');\n}\nfunction dbDeleteFailedError(err) {\n err = err ?? new Error('Delete failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_DELETE_FAILED');\n}\nfunction dbWriteFailedError(err) {\n err = err ?? new Error('Write failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_WRITE_FAILED');\n}\nfunction dbReadFailedError(err) {\n err = err ?? new Error('Read failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_READ_FAILED');\n}\nfunction notFoundError(err) {\n err = err ?? new Error('Not Found');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_NOT_FOUND');\n}\nfunction abortedError(err) {\n err = err ?? new Error('Aborted');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_ABORTED');\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/memory.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/memory.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MemoryDatastore: () => (/* binding */ MemoryDatastore)\n/* harmony export */ });\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/base.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/errors.js\");\n\n\n\nclass MemoryDatastore extends _base_js__WEBPACK_IMPORTED_MODULE_1__.BaseDatastore {\n data;\n constructor() {\n super();\n this.data = new Map();\n }\n put(key, val) {\n this.data.set(key.toString(), val);\n return key;\n }\n get(key) {\n const result = this.data.get(key.toString());\n if (result == null) {\n throw _errors_js__WEBPACK_IMPORTED_MODULE_2__.notFoundError();\n }\n return result;\n }\n has(key) {\n return this.data.has(key.toString());\n }\n delete(key) {\n this.data.delete(key.toString());\n }\n *_all() {\n for (const [key, value] of this.data.entries()) {\n yield { key: new interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__.Key(key), value };\n }\n }\n *_allKeys() {\n for (const key of this.data.keys()) {\n yield new interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__.Key(key);\n }\n }\n}\n//# sourceMappingURL=memory.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/memory.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-drain/dist/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-drain/dist/src/index.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values.\n *\n * @example\n *\n * ```javascript\n * import drain from 'it-drain'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * drain(values)\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import drain from 'it-drain'\n *\n * const values = async function * {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * await drain(values())\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction drain(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars\n })();\n }\n else {\n for (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars\n }\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (drain);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-drain/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_peekable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-peekable */ \"./node_modules/it-peekable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Filter values out of an (async)iterable\n *\n * @example\n *\n * ```javascript\n * import all from 'it-all'\n * import filter from 'it-filter'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const fn = val => val > 2 // Return boolean to keep item\n *\n * const arr = all(filter(values, fn))\n *\n * console.info(arr) // 3, 4\n * ```\n *\n * Async sources and filter functions must be awaited:\n *\n * ```javascript\n * import all from 'it-all'\n * import filter from 'it-filter'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const fn = async val => val > 2 // Return boolean or promise of boolean to keep item\n *\n * const arr = await all(filter(values, fn))\n *\n * console.info(arr) // 3, 4\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction filter(source, fn) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n for await (const entry of source) {\n if (await fn(entry)) {\n yield entry;\n }\n }\n })();\n }\n // if mapping function returns a promise we have to return an async generator\n const peekable = (0,it_peekable__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n const { value, done } = peekable.next();\n if (done === true) {\n return (function* () { }());\n }\n const res = fn(value);\n // @ts-expect-error .then is not present on O\n if (typeof res.then === 'function') {\n return (async function* () {\n if (await res) {\n yield value;\n }\n for await (const entry of peekable) {\n if (await fn(entry)) {\n yield entry;\n }\n }\n })();\n }\n const func = fn;\n return (function* () {\n if (res === true) {\n yield value;\n }\n for (const entry of peekable) {\n if (func(entry)) {\n yield entry;\n }\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (filter);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Return the first value in an (async)iterable\n *\n * @example\n *\n * ```javascript\n * import first from 'it-first'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const res = first(values)\n *\n * console.info(res) // 0\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import first from 'it-first'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const res = await first(values())\n *\n * console.info(res) // 0\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction first(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n })();\n }\n for (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (first);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-map/dist/src/index.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-map/dist/src/index.js ***! - \**********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_peekable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-peekable */ \"./node_modules/it-peekable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Convert one value from an (async)iterator into another.\n *\n * @example\n *\n * ```javascript\n * import map from 'it-map'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const result = map(values, (val) => val++)\n *\n * console.info(result) // [1, 2, 3, 4, 5]\n * ```\n *\n * Async sources and transforms must be awaited:\n *\n * ```javascript\n * import map from 'it-map'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const result = await map(values(), async (val) => val++)\n *\n * console.info(result) // [1, 2, 3, 4, 5]\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction map(source, func) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n for await (const val of source) {\n yield func(val);\n }\n })();\n }\n // if mapping function returns a promise we have to return an async generator\n const peekable = (0,it_peekable__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n const { value, done } = peekable.next();\n if (done === true) {\n return (function* () { }());\n }\n const res = func(value);\n // @ts-expect-error .then is not present on O\n if (typeof res.then === 'function') {\n return (async function* () {\n yield await res;\n for await (const val of peekable) {\n yield func(val);\n }\n })();\n }\n const fn = func;\n return (function* () {\n yield res;\n for (const val of peekable) {\n yield fn(val);\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (map);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-map/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Merge several (async)iterables into one, yield values as they arrive.\n *\n * Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.\n *\n * @example\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values1 = [0, 1, 2, 3, 4]\n * const values2 = [5, 6, 7, 8, 9]\n *\n * const arr = all(merge(values1, values2))\n *\n * console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const values1 = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n * const values2 = async function * () {\n * yield * [5, 6, 7, 8, 9]\n * }\n *\n * const arr = await all(merge(values1(), values2()))\n *\n * console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction merge(...sources) {\n const syncSources = [];\n for (const source of sources) {\n if (!isAsyncIterable(source)) {\n syncSources.push(source);\n }\n }\n if (syncSources.length === sources.length) {\n // all sources are synchronous\n return (function* () {\n for (const source of syncSources) {\n yield* source;\n }\n })();\n }\n return (async function* () {\n const output = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n void Promise.resolve().then(async () => {\n try {\n await Promise.all(sources.map(async (source) => {\n for await (const item of source) {\n output.push(item);\n }\n }));\n output.end();\n }\n catch (err) {\n output.end(err);\n }\n });\n yield* output;\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (merge);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pipe: () => (/* binding */ pipe),\n/* harmony export */ rawPipe: () => (/* binding */ rawPipe)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js\");\n\n\nfunction pipe(first, ...rest) {\n if (first == null) {\n throw new Error('Empty pipeline');\n }\n // Duplex at start: wrap in function and return duplex source\n if (isDuplex(first)) {\n const duplex = first;\n first = () => duplex.source;\n // Iterable at start: wrap in function\n }\n else if (isIterable(first) || isAsyncIterable(first)) {\n const source = first;\n first = () => source;\n }\n const fns = [first, ...rest];\n if (fns.length > 1) {\n // Duplex at end: use duplex sink\n if (isDuplex(fns[fns.length - 1])) {\n fns[fns.length - 1] = fns[fns.length - 1].sink;\n }\n }\n if (fns.length > 2) {\n // Duplex in the middle, consume source with duplex sink and return duplex source\n for (let i = 1; i < fns.length - 1; i++) {\n if (isDuplex(fns[i])) {\n fns[i] = duplexPipelineFn(fns[i]);\n }\n }\n }\n return rawPipe(...fns);\n}\nconst rawPipe = (...fns) => {\n let res;\n while (fns.length > 0) {\n res = fns.shift()(res);\n }\n return res;\n};\nconst isAsyncIterable = (obj) => {\n return obj?.[Symbol.asyncIterator] != null;\n};\nconst isIterable = (obj) => {\n return obj?.[Symbol.iterator] != null;\n};\nconst isDuplex = (obj) => {\n if (obj == null) {\n return false;\n }\n return obj.sink != null && obj.source != null;\n};\nconst duplexPipelineFn = (duplex) => {\n return (source) => {\n const p = duplex.sink(source);\n if (p?.then != null) {\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n p.then(() => {\n stream.end();\n }, (err) => {\n stream.end(err);\n });\n let sourceWrap;\n const source = duplex.source;\n if (isAsyncIterable(source)) {\n sourceWrap = async function* () {\n yield* source;\n stream.end();\n };\n }\n else if (isIterable(source)) {\n sourceWrap = function* () {\n yield* source;\n stream.end();\n };\n }\n else {\n throw new Error('Unknown duplex source type - must be Iterable or AsyncIterable');\n }\n return (0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(stream, sourceWrap());\n }\n return duplex.source;\n };\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-sort/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-sort/dist/src/index.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Consumes all values from an (async)iterable and returns them sorted by the passed sort function.\n *\n * @example\n *\n * ```javascript\n * import sort from 'it-sort'\n * import all from 'it-all'\n *\n * const sorter = (a, b) => {\n * return a.localeCompare(b)\n * }\n *\n * // This can also be an iterator, generator, etc\n * const values = ['foo', 'bar']\n *\n * const arr = all(sort(values, sorter))\n *\n * console.info(arr) // 'bar', 'foo'\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import sort from 'it-sort'\n * import all from 'it-all'\n *\n * const sorter = (a, b) => {\n * return a.localeCompare(b)\n * }\n *\n * const values = async function * () {\n * yield * ['foo', 'bar']\n * }\n *\n * const arr = await all(sort(values, sorter))\n *\n * console.info(arr) // 'bar', 'foo'\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction sort(source, sorter) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n const arr = await (0,it_all__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n yield* arr.sort(sorter);\n })();\n }\n return (function* () {\n const arr = (0,it_all__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n yield* arr.sort(sorter);\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (sort);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-sort/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/it-take/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/it-take/dist/src/index.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * For when you only want a few values out of an (async)iterable.\n *\n * @example\n *\n * ```javascript\n * import take from 'it-take'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const arr = all(take(values, 2))\n *\n * console.info(arr) // 0, 1\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import take from 'it-take'\n * import all from 'it-all'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const arr = await all(take(values(), 2))\n *\n * console.info(arr) // 0, 1\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction take(source, limit) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n let items = 0;\n if (limit < 1) {\n return;\n }\n for await (const entry of source) {\n yield entry;\n items++;\n if (items === limit) {\n return;\n }\n }\n })();\n }\n return (function* () {\n let items = 0;\n if (limit < 1) {\n return;\n }\n for (const entry of source) {\n yield entry;\n items++;\n if (items === limit) {\n return;\n }\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (take);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/it-take/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/index.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultAddressManager: () => (/* binding */ DefaultAddressManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/utils.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:address-manager');\nconst defaultAddressFilter = (addrs) => addrs;\n/**\n * If the passed multiaddr contains the passed peer id, remove it\n */\nfunction stripPeerId(ma, peerId) {\n const observedPeerIdStr = ma.getPeerId();\n // strip our peer id if it has been passed\n if (observedPeerIdStr != null) {\n const observedPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(observedPeerIdStr);\n // use same encoding for comparison\n if (observedPeerId.equals(peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(`/p2p/${peerId.toString()}`));\n }\n }\n return ma;\n}\nclass DefaultAddressManager {\n components;\n // this is an array to allow for duplicates, e.g. multiples of `/ip4/0.0.0.0/tcp/0`\n listen;\n announce;\n observed;\n announceFilter;\n /**\n * Responsible for managing the peer addresses.\n * Peers can specify their listen and announce addresses.\n * The listen addresses will be used by the libp2p transports to listen for new connections,\n * while the announce addresses will be used for the peer addresses' to other peers in the network.\n */\n constructor(components, init = {}) {\n const { listen = [], announce = [] } = init;\n this.components = components;\n this.listen = listen.map(ma => ma.toString());\n this.announce = new Set(announce.map(ma => ma.toString()));\n this.observed = new Map();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n // this method gets called repeatedly on startup when transports start listening so\n // debounce it so we don't cause multiple self:peer:update events to be emitted\n this._updatePeerStoreAddresses = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.debounce)(this._updatePeerStoreAddresses.bind(this), 1000);\n // update our stored addresses when new transports listen\n components.events.addEventListener('transport:listening', () => {\n this._updatePeerStoreAddresses();\n });\n // update our stored addresses when existing transports stop listening\n components.events.addEventListener('transport:close', () => {\n this._updatePeerStoreAddresses();\n });\n }\n _updatePeerStoreAddresses() {\n // if announce addresses have been configured, ensure they make it into our peer\n // record for things like identify\n const addrs = this.getAnnounceAddrs()\n .concat(this.components.transportManager.getAddrs())\n .concat([...this.observed.entries()]\n .filter(([_, metadata]) => metadata.confident)\n .map(([str]) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(str))).map(ma => {\n // strip our peer id if it is present\n if (ma.getPeerId() === this.components.peerId.toString()) {\n return ma.decapsulate(`/p2p/${this.components.peerId.toString()}`);\n }\n return ma;\n });\n this.components.peerStore.patch(this.components.peerId, {\n multiaddrs: addrs\n })\n .catch(err => { log.error('error updating addresses', err); });\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(a));\n }\n /**\n * Get peer announcing multiaddrs\n */\n getAnnounceAddrs() {\n return Array.from(this.announce).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(a));\n }\n /**\n * Get observed multiaddrs\n */\n getObservedAddrs() {\n return Array.from(this.observed).map(([a]) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n // do not trigger the change:addresses event if we already know about this address\n if (this.observed.has(addrString)) {\n return;\n }\n this.observed.set(addrString, {\n confident: false\n });\n }\n confirmObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n const metadata = this.observed.get(addrString) ?? {\n confident: false\n };\n const startingConfidence = metadata.confident;\n this.observed.set(addrString, {\n confident: true\n });\n // only trigger the 'self:peer:update' event if our confidence in an address has changed\n if (!startingConfidence) {\n this._updatePeerStoreAddresses();\n }\n }\n removeObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n this.observed.delete(addrString);\n }\n getAddresses() {\n let addrs = this.getAnnounceAddrs().map(ma => ma.toString());\n if (addrs.length === 0) {\n // no configured announce addrs, add configured listen addresses\n addrs = this.components.transportManager.getAddrs().map(ma => ma.toString());\n }\n // add observed addresses we are confident in\n addrs = addrs.concat(Array.from(this.observed)\n .filter(([ma, metadata]) => metadata.confident)\n .map(([ma]) => ma));\n // dedupe multiaddrs\n const addrSet = new Set(addrs);\n // Create advertising list\n return this.announceFilter(Array.from(addrSet)\n .map(str => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(str)))\n .map(ma => {\n // do not append our peer id to a path multiaddr as it will become invalid\n if (ma.protos().pop()?.path === true) {\n return ma;\n }\n if (ma.getPeerId() === this.components.peerId.toString()) {\n return ma;\n }\n return ma.encapsulate(`/p2p/${this.components.peerId.toString()}`);\n });\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/utils.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/utils.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ debounce: () => (/* binding */ debounce)\n/* harmony export */ });\nfunction debounce(func, wait) {\n let timeout;\n return function () {\n const later = function () {\n timeout = undefined;\n func();\n };\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/components.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/components.js ***! - \***************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultComponents: () => (/* binding */ defaultComponents)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/startable */ \"./node_modules/@libp2p/interfaces/dist/src/startable.js\");\n\n\nclass DefaultComponents {\n components = {};\n _started = false;\n constructor(init = {}) {\n this.components = {};\n for (const [key, value] of Object.entries(init)) {\n this.components[key] = value;\n }\n }\n isStarted() {\n return this._started;\n }\n async _invokeStartableMethod(methodName) {\n await Promise.all(Object.values(this.components)\n .filter(obj => (0,_libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_1__.isStartable)(obj))\n .map(async (startable) => {\n await startable[methodName]?.();\n }));\n }\n async beforeStart() {\n await this._invokeStartableMethod('beforeStart');\n }\n async start() {\n await this._invokeStartableMethod('start');\n this._started = true;\n }\n async afterStart() {\n await this._invokeStartableMethod('afterStart');\n }\n async beforeStop() {\n await this._invokeStartableMethod('beforeStop');\n }\n async stop() {\n await this._invokeStartableMethod('stop');\n this._started = false;\n }\n async afterStop() {\n await this._invokeStartableMethod('afterStop');\n }\n}\nconst OPTIONAL_SERVICES = [\n 'metrics',\n 'connectionProtector'\n];\nconst NON_SERVICE_PROPERTIES = [\n 'components',\n 'isStarted',\n 'beforeStart',\n 'start',\n 'afterStart',\n 'beforeStop',\n 'stop',\n 'afterStop',\n 'then',\n '_invokeStartableMethod'\n];\nfunction defaultComponents(init = {}) {\n const components = new DefaultComponents(init);\n const proxy = new Proxy(components, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && !NON_SERVICE_PROPERTIES.includes(prop)) {\n const service = components.components[prop];\n if (service == null && !OPTIONAL_SERVICES.includes(prop)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`${prop} not set`, 'ERR_SERVICE_MISSING');\n }\n return service;\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, value) {\n if (typeof prop === 'string') {\n components.components[prop] = value;\n }\n else {\n Reflect.set(target, prop, value);\n }\n return true;\n }\n });\n // @ts-expect-error component keys are proxied\n return proxy;\n}\n//# sourceMappingURL=components.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/components.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ validateConfig: () => (/* binding */ validateConfig)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\n\nconst DefaultConfig = {\n addresses: {\n listen: [],\n announce: [],\n noAnnounce: [],\n announceFilter: (multiaddrs) => multiaddrs\n },\n connectionManager: {\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_3__.dnsaddrResolver\n },\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_2__.publicAddressesFirst\n },\n transportManager: {\n faultTolerance: _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__.FaultTolerance.FATAL_ALL\n }\n};\nfunction validateConfig(opts) {\n const resultingOptions = (0,merge_options__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(DefaultConfig, opts);\n if (resultingOptions.transports == null || resultingOptions.transports.length < 1) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_5__.messages.ERR_TRANSPORTS_REQUIRED, _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_TRANSPORTS_REQUIRED);\n }\n if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_5__.messages.ERR_PROTECTOR_REQUIRED, _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_PROTECTOR_REQUIRED);\n }\n return resultingOptions;\n}\n//# sourceMappingURL=config.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config/connection-gater.browser.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config/connection-gater.browser.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ connectionGater: () => (/* binding */ connectionGater)\n/* harmony export */ });\n/* harmony import */ var private_ip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! private-ip */ \"./node_modules/private-ip/index.js\");\n\n/**\n * Returns a connection gater that disallows dialling private addresses by\n * default. Browsers are severely limited in their resource usage so don't\n * waste time trying to dial undiallable addresses.\n */\nfunction connectionGater(gater = {}) {\n return {\n denyDialPeer: async () => false,\n denyDialMultiaddr: async (multiaddr) => {\n const tuples = multiaddr.stringTuples();\n if (tuples[0][0] === 4 || tuples[0][0] === 41) {\n return Boolean((0,private_ip__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(`${tuples[0][1]}`));\n }\n return false;\n },\n denyInboundConnection: async () => false,\n denyOutboundConnection: async () => false,\n denyInboundEncryptedConnection: async () => false,\n denyOutboundEncryptedConnection: async () => false,\n denyInboundUpgradedConnection: async () => false,\n denyOutboundUpgradedConnection: async () => false,\n filterMultiaddrForPeer: async () => true,\n ...gater\n };\n}\n//# sourceMappingURL=connection-gater.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config/connection-gater.browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/auto-dial.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/auto-dial.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AutoDial: () => (/* binding */ AutoDial)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _utils_peer_job_queue_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/peer-job-queue.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/utils/peer-job-queue.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager:auto-dial');\nconst defaultOptions = {\n minConnections: _constants_js__WEBPACK_IMPORTED_MODULE_3__.MIN_CONNECTIONS,\n maxQueueLength: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_MAX_QUEUE_LENGTH,\n autoDialConcurrency: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_CONCURRENCY,\n autoDialPriority: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_PRIORITY,\n autoDialInterval: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_INTERVAL\n};\nclass AutoDial {\n connectionManager;\n peerStore;\n queue;\n minConnections;\n autoDialPriority;\n autoDialIntervalMs;\n autoDialMaxQueueLength;\n autoDialInterval;\n started;\n running;\n /**\n * Proactively tries to connect to known peers stored in the PeerStore.\n * It will keep the number of connections below the upper limit and sort\n * the peers to connect based on whether we know their keys and protocols.\n */\n constructor(components, init) {\n this.connectionManager = components.connectionManager;\n this.peerStore = components.peerStore;\n this.minConnections = init.minConnections ?? defaultOptions.minConnections;\n this.autoDialPriority = init.autoDialPriority ?? defaultOptions.autoDialPriority;\n this.autoDialIntervalMs = init.autoDialInterval ?? defaultOptions.autoDialInterval;\n this.autoDialMaxQueueLength = init.maxQueueLength ?? defaultOptions.maxQueueLength;\n this.started = false;\n this.running = false;\n this.queue = new _utils_peer_job_queue_js__WEBPACK_IMPORTED_MODULE_2__.PeerJobQueue({\n concurrency: init.autoDialConcurrency ?? defaultOptions.autoDialConcurrency\n });\n this.queue.addListener('error', (err) => {\n log.error('error during auto-dial', err);\n });\n // check the min connection limit whenever a peer disconnects\n components.events.addEventListener('connection:close', () => {\n this.autoDial()\n .catch(err => {\n log.error(err);\n });\n });\n }\n isStarted() {\n return this.started;\n }\n start() {\n this.autoDialInterval = setTimeout(() => {\n this.autoDial()\n .catch(err => {\n log.error('error while autodialing', err);\n });\n }, this.autoDialIntervalMs);\n this.started = true;\n }\n afterStart() {\n this.autoDial()\n .catch(err => {\n log.error('error while autodialing', err);\n });\n }\n stop() {\n // clear the queue\n this.queue.clear();\n clearTimeout(this.autoDialInterval);\n this.started = false;\n this.running = false;\n }\n async autoDial() {\n if (!this.started) {\n return;\n }\n const connections = this.connectionManager.getConnectionsMap();\n const numConnections = connections.size;\n // Already has enough connections\n if (numConnections >= this.minConnections) {\n log.trace('have enough connections %d/%d', numConnections, this.minConnections);\n return;\n }\n if (this.queue.size > this.autoDialMaxQueueLength) {\n log('not enough connections %d/%d but auto dial queue is full', numConnections, this.minConnections);\n return;\n }\n if (this.running) {\n log('not enough connections %d/%d - but skipping autodial as it is already running', numConnections, this.minConnections);\n return;\n }\n this.running = true;\n log('not enough connections %d/%d - will dial peers to increase the number of connections', numConnections, this.minConnections);\n const dialQueue = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__.PeerSet(\n // @ts-expect-error boolean filter removes falsy peer IDs\n this.connectionManager.getDialQueue()\n .map(queue => queue.peerId)\n .filter(Boolean));\n // Sort peers on whether we know protocols or public keys for them\n const peers = await this.peerStore.all({\n filters: [\n // Remove some peers\n (peer) => {\n // Remove peers without addresses\n if (peer.addresses.length === 0) {\n log.trace('not autodialing %p because they have no addresses');\n return false;\n }\n // remove peers we are already connected to\n if (connections.has(peer.id)) {\n log.trace('not autodialing %p because they are already connected');\n return false;\n }\n // remove peers we are already dialling\n if (dialQueue.has(peer.id)) {\n log.trace('not autodialing %p because they are already being dialed');\n return false;\n }\n // remove peers already in the autodial queue\n if (this.queue.hasJob(peer.id)) {\n log.trace('not autodialing %p because they are already being autodialed');\n return false;\n }\n return true;\n }\n ]\n });\n // shuffle the peers - this is so peers with the same tag values will be\n // dialled in a different order each time\n const shuffledPeers = peers.sort(() => Math.random() > 0.5 ? 1 : -1);\n // Sort shuffled peers by tag value\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__.PeerMap();\n for (const peer of shuffledPeers) {\n if (peerValues.has(peer.id)) {\n continue;\n }\n // sum all tag values\n peerValues.set(peer.id, [...peer.tags.values()].reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\n }\n // sort by value, highest to lowest\n const sortedPeers = shuffledPeers.sort((a, b) => {\n const peerAValue = peerValues.get(a.id) ?? 0;\n const peerBValue = peerValues.get(b.id) ?? 0;\n if (peerAValue > peerBValue) {\n return -1;\n }\n if (peerAValue < peerBValue) {\n return 1;\n }\n return 0;\n });\n log('selected %d/%d peers to dial', sortedPeers.length, peers.length);\n for (const peer of sortedPeers) {\n this.queue.add(async () => {\n const numConnections = this.connectionManager.getConnectionsMap().size;\n // Check to see if we still need to auto dial\n if (numConnections >= this.minConnections) {\n log('got enough connections now %d/%d', numConnections, this.minConnections);\n this.queue.clear();\n return;\n }\n log('connecting to a peerStore stored peer %p', peer.id);\n await this.connectionManager.openConnection(peer.id, {\n // @ts-expect-error needs adding to the ConnectionManager interface\n priority: this.autoDialPriority\n });\n }, {\n peerId: peer.id\n }).catch(err => {\n log.error('could not connect to peerStore stored peer', err);\n });\n }\n this.running = false;\n if (this.started) {\n this.autoDialInterval = setTimeout(() => {\n this.autoDial()\n .catch(err => {\n log.error('error while autodialing', err);\n });\n }, this.autoDialIntervalMs);\n }\n }\n}\n//# sourceMappingURL=auto-dial.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/auto-dial.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/connection-pruner.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/connection-pruner.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionPruner: () => (/* binding */ ConnectionPruner)\n/* harmony export */ });\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager:connection-pruner');\nconst defaultOptions = {\n maxConnections: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_CONNECTIONS,\n allow: []\n};\n/**\n * If we go over the max connections limit, choose some connections to close\n */\nclass ConnectionPruner {\n maxConnections;\n connectionManager;\n peerStore;\n allow;\n events;\n constructor(components, init = {}) {\n this.maxConnections = init.maxConnections ?? defaultOptions.maxConnections;\n this.allow = init.allow ?? defaultOptions.allow;\n this.connectionManager = components.connectionManager;\n this.peerStore = components.peerStore;\n this.events = components.events;\n // check the max connection limit whenever a peer connects\n components.events.addEventListener('connection:open', () => {\n this.maybePruneConnections()\n .catch(err => {\n log.error(err);\n });\n });\n }\n /**\n * If we have more connections than our maximum, select some excess connections\n * to prune based on peer value\n */\n async maybePruneConnections() {\n const connections = this.connectionManager.getConnections();\n const numConnections = connections.length;\n const toPrune = Math.max(numConnections - this.maxConnections, 0);\n log('checking max connections limit %d/%d', numConnections, this.maxConnections);\n if (numConnections <= this.maxConnections) {\n return;\n }\n log('max connections limit exceeded %d/%d, pruning %d connection(s)', numConnections, this.maxConnections, toPrune);\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__.PeerMap();\n // work out peer values\n for (const connection of connections) {\n const remotePeer = connection.remotePeer;\n if (peerValues.has(remotePeer)) {\n continue;\n }\n peerValues.set(remotePeer, 0);\n try {\n const peer = await this.peerStore.get(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, [...peer.tags.values()].reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n log.error('error loading peer tags', err);\n }\n }\n }\n // sort by value, lowest to highest\n const sortedConnections = connections.sort((a, b) => {\n const peerAValue = peerValues.get(a.remotePeer) ?? 0;\n const peerBValue = peerValues.get(b.remotePeer) ?? 0;\n if (peerAValue > peerBValue) {\n return 1;\n }\n if (peerAValue < peerBValue) {\n return -1;\n }\n // if the peers have an equal tag value then we want to close short-lived connections first\n const connectionALifespan = a.stat.timeline.open;\n const connectionBLifespan = b.stat.timeline.open;\n if (connectionALifespan < connectionBLifespan) {\n return 1;\n }\n if (connectionALifespan > connectionBLifespan) {\n return -1;\n }\n return 0;\n });\n // close some connections\n const toClose = [];\n for (const connection of sortedConnections) {\n log('too many connections open - closing a connection to %p', connection.remotePeer);\n // check allow list\n const connectionInAllowList = this.allow.some((ma) => {\n return connection.remoteAddr.toString().startsWith(ma.toString());\n });\n // Connections in the allow list should be excluded from pruning\n if (!connectionInAllowList) {\n toClose.push(connection);\n }\n if (toClose.length === toPrune) {\n break;\n }\n }\n // close connections\n await Promise.all(toClose.map(async (connection) => {\n try {\n await connection.close();\n }\n catch (err) {\n log.error(err);\n }\n }));\n // despatch prune event\n this.events.safeDispatchEvent('connection:prune', { detail: toClose });\n }\n}\n//# sourceMappingURL=connection-pruner.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/connection-pruner.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AUTO_DIAL_CONCURRENCY: () => (/* binding */ AUTO_DIAL_CONCURRENCY),\n/* harmony export */ AUTO_DIAL_INTERVAL: () => (/* binding */ AUTO_DIAL_INTERVAL),\n/* harmony export */ AUTO_DIAL_MAX_QUEUE_LENGTH: () => (/* binding */ AUTO_DIAL_MAX_QUEUE_LENGTH),\n/* harmony export */ AUTO_DIAL_PRIORITY: () => (/* binding */ AUTO_DIAL_PRIORITY),\n/* harmony export */ DIAL_TIMEOUT: () => (/* binding */ DIAL_TIMEOUT),\n/* harmony export */ INBOUND_CONNECTION_THRESHOLD: () => (/* binding */ INBOUND_CONNECTION_THRESHOLD),\n/* harmony export */ INBOUND_UPGRADE_TIMEOUT: () => (/* binding */ INBOUND_UPGRADE_TIMEOUT),\n/* harmony export */ MAX_CONNECTIONS: () => (/* binding */ MAX_CONNECTIONS),\n/* harmony export */ MAX_INCOMING_PENDING_CONNECTIONS: () => (/* binding */ MAX_INCOMING_PENDING_CONNECTIONS),\n/* harmony export */ MAX_PARALLEL_DIALS: () => (/* binding */ MAX_PARALLEL_DIALS),\n/* harmony export */ MAX_PARALLEL_DIALS_PER_PEER: () => (/* binding */ MAX_PARALLEL_DIALS_PER_PEER),\n/* harmony export */ MAX_PEER_ADDRS_TO_DIAL: () => (/* binding */ MAX_PEER_ADDRS_TO_DIAL),\n/* harmony export */ MIN_CONNECTIONS: () => (/* binding */ MIN_CONNECTIONS)\n/* harmony export */ });\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#dialTimeout\n */\nconst DIAL_TIMEOUT = 30e3;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundUpgradeTimeout\n */\nconst INBOUND_UPGRADE_TIMEOUT = 30e3;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials\n */\nconst MAX_PARALLEL_DIALS = 100;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxPeerAddrsToDial\n */\nconst MAX_PEER_ADDRS_TO_DIAL = 25;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDialsPerPeer\n */\nconst MAX_PARALLEL_DIALS_PER_PEER = 10;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections\n */\nconst MIN_CONNECTIONS = 50;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections\n */\nconst MAX_CONNECTIONS = 300;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialInterval\n */\nconst AUTO_DIAL_INTERVAL = 5000;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialConcurrency\n */\nconst AUTO_DIAL_CONCURRENCY = 25;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialPriority\n */\nconst AUTO_DIAL_PRIORITY = 0;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialMaxQueueLength\n */\nconst AUTO_DIAL_MAX_QUEUE_LENGTH = 100;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundConnectionThreshold\n */\nconst INBOUND_CONNECTION_THRESHOLD = 5;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxIncomingPendingConnections\n */\nconst MAX_INCOMING_PENDING_CONNECTIONS = 10;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/dial-queue.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/dial-queue.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DialQueue: () => (/* binding */ DialQueue)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! p-queue */ \"./node_modules/p-queue/dist/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/get-peer.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/utils.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:connection-manager:dial-queue');\nconst defaultOptions = {\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_3__.publicAddressesFirst,\n maxParallelDials: _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PARALLEL_DIALS,\n maxPeerAddrsToDial: _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PEER_ADDRS_TO_DIAL,\n maxParallelDialsPerPeer: _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PARALLEL_DIALS_PER_PEER,\n dialTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_10__.DIAL_TIMEOUT,\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_5__.dnsaddrResolver\n }\n};\nclass DialQueue {\n pendingDials;\n queue;\n peerId;\n peerStore;\n connectionGater;\n transportManager;\n addressSorter;\n maxPeerAddrsToDial;\n maxParallelDialsPerPeer;\n dialTimeout;\n inProgressDialCount;\n pendingDialCount;\n shutDownController;\n constructor(components, init = {}) {\n this.addressSorter = init.addressSorter ?? defaultOptions.addressSorter;\n this.maxPeerAddrsToDial = init.maxPeerAddrsToDial ?? defaultOptions.maxPeerAddrsToDial;\n this.maxParallelDialsPerPeer = init.maxParallelDialsPerPeer ?? defaultOptions.maxParallelDialsPerPeer;\n this.dialTimeout = init.dialTimeout ?? defaultOptions.dialTimeout;\n this.peerId = components.peerId;\n this.peerStore = components.peerStore;\n this.connectionGater = components.connectionGater;\n this.transportManager = components.transportManager;\n this.shutDownController = new AbortController();\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, this.shutDownController.signal);\n }\n catch { }\n this.pendingDialCount = components.metrics?.registerMetric('libp2p_dialler_pending_dials');\n this.inProgressDialCount = components.metrics?.registerMetric('libp2p_dialler_in_progress_dials');\n this.pendingDials = [];\n for (const [key, value] of Object.entries(init.resolvers ?? {})) {\n _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_4__.resolvers.set(key, value);\n }\n // controls dial concurrency\n this.queue = new p_queue__WEBPACK_IMPORTED_MODULE_7__[\"default\"]({\n concurrency: init.maxParallelDials ?? defaultOptions.maxParallelDials\n });\n // a job was added to the queue\n this.queue.on('add', () => {\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n // a queued job started\n this.queue.on('active', () => {\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n // a started job completed without error\n this.queue.on('completed', () => {\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n // a started job errored\n this.queue.on('error', (err) => {\n log.error('error in dial queue', err);\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n // all queued jobs have been started\n this.queue.on('empty', () => {\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n // add started jobs have run and the queue is empty\n this.queue.on('idle', () => {\n this.pendingDialCount?.update(this.queue.size);\n this.inProgressDialCount?.update(this.queue.pending);\n });\n }\n /**\n * Clears any pending dials\n */\n stop() {\n this.shutDownController.abort();\n }\n /**\n * Connects to a given peer, multiaddr or list of multiaddrs.\n *\n * If a peer is passed, all known multiaddrs will be tried. If a multiaddr or\n * multiaddrs are passed only those will be dialled.\n *\n * Where a list of multiaddrs is passed, if any contain a peer id then all\n * multiaddrs in the list must contain the same peer id.\n *\n * The dial to the first address that is successfully able to upgrade a connection\n * will be used, all other dials will be aborted when that happens.\n */\n async dial(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddrs } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_9__.getPeerAddress)(peerIdOrMultiaddr);\n const addrs = multiaddrs.map(multiaddr => ({\n multiaddr,\n isCertified: false\n }));\n // create abort conditions - need to do this before `calculateMultiaddrs` as we may be about to\n // resolve a dns addr which can time out\n const signal = this.createDialAbortControllers(options.signal);\n let addrsToDial;\n try {\n // load addresses from address book, resolve and dnsaddrs, filter undiallables, add peer IDs, etc\n addrsToDial = await this.calculateMultiaddrs(peerId, addrs, {\n ...options,\n signal\n });\n }\n catch (err) {\n signal.clear();\n throw err;\n }\n // ready to dial, all async work finished - make sure we don't have any\n // pending dials in progress for this peer or set of multiaddrs\n const existingDial = this.pendingDials.find(dial => {\n // is the dial for the same peer id?\n if (dial.peerId != null && peerId != null && dial.peerId.equals(peerId)) {\n return true;\n }\n // is the dial for the same set of multiaddrs?\n if (addrsToDial.map(({ multiaddr }) => multiaddr.toString()).join() === dial.multiaddrs.map(multiaddr => multiaddr.toString()).join()) {\n return true;\n }\n return false;\n });\n if (existingDial != null) {\n log('joining existing dial target for %p', peerId);\n signal.clear();\n return existingDial.promise;\n }\n log('creating dial target for', addrsToDial.map(({ multiaddr }) => multiaddr.toString()));\n // @ts-expect-error .promise property is set below\n const pendingDial = {\n id: randomId(),\n status: 'queued',\n peerId,\n multiaddrs: addrsToDial.map(({ multiaddr }) => multiaddr)\n };\n pendingDial.promise = this.performDial(pendingDial, {\n ...options,\n signal\n })\n .finally(() => {\n // remove our pending dial entry\n this.pendingDials = this.pendingDials.filter(p => p.id !== pendingDial.id);\n // clean up abort signals/controllers\n signal.clear();\n })\n .catch(err => {\n log.error('dial failed to %s', pendingDial.multiaddrs.map(ma => ma.toString()).join(', '), err);\n // Error is a timeout\n if (signal.aborted) {\n const error = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(err.message, _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_TIMEOUT);\n throw error;\n }\n throw err;\n });\n // let other dials join this one\n this.pendingDials.push(pendingDial);\n return pendingDial.promise;\n }\n createDialAbortControllers(userSignal) {\n // let any signal abort the dial\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_6__.anySignal)([AbortSignal.timeout(this.dialTimeout),\n this.shutDownController.signal,\n userSignal\n ]);\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n return signal;\n }\n // eslint-disable-next-line complexity\n async calculateMultiaddrs(peerId, addrs = [], options = {}) {\n // if a peer id or multiaddr(s) with a peer id, make sure it isn't our peer id and that we are allowed to dial it\n if (peerId != null) {\n if (this.peerId.equals(peerId)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Tried to dial self', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_DIALED_SELF);\n }\n if ((await this.connectionGater.denyDialPeer?.(peerId)) === true) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('The dial request is blocked by gater.allowDialPeer', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_PEER_DIAL_INTERCEPTED);\n }\n // if just a peer id was passed, load available multiaddrs for this peer from the address book\n if (addrs.length === 0) {\n log('loading multiaddrs for %p', peerId);\n try {\n const peer = await this.peerStore.get(peerId);\n addrs.push(...peer.addresses);\n log('loaded multiaddrs for %p', peerId, addrs.map(({ multiaddr }) => multiaddr.toString()));\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n }\n }\n // resolve addresses - this can result in a one-to-many translation when dnsaddrs are resolved\n const resolvedAddresses = (await Promise.all(addrs.map(async (addr) => {\n const result = await (0,_utils_js__WEBPACK_IMPORTED_MODULE_11__.resolveMultiaddrs)(addr.multiaddr, options);\n if (result.length === 1 && result[0].equals(addr.multiaddr)) {\n return addr;\n }\n return result.map(multiaddr => ({\n multiaddr,\n isCertified: false\n }));\n })))\n .flat();\n // filter out any multiaddrs that we do not have transports for\n const filteredAddrs = resolvedAddresses.filter(addr => Boolean(this.transportManager.transportForMultiaddr(addr.multiaddr)));\n // deduplicate addresses\n const dedupedAddrs = new Map();\n for (const addr of filteredAddrs) {\n const maStr = addr.multiaddr.toString();\n const existing = dedupedAddrs.get(maStr);\n if (existing != null) {\n existing.isCertified = existing.isCertified || addr.isCertified || false;\n continue;\n }\n dedupedAddrs.set(maStr, addr);\n }\n let dedupedMultiaddrs = [...dedupedAddrs.values()];\n if (dedupedMultiaddrs.length === 0 || dedupedMultiaddrs.length > this.maxPeerAddrsToDial) {\n log('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()));\n log('addresses for %p after filtering', peerId ?? 'unknown peer', dedupedMultiaddrs.map(({ multiaddr }) => multiaddr.toString()));\n }\n // make sure we actually have some addresses to dial\n if (dedupedMultiaddrs.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('The dial request has no valid addresses', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_NO_VALID_ADDRESSES);\n }\n // make sure we don't have too many addresses to dial\n if (dedupedMultiaddrs.length > this.maxPeerAddrsToDial) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('dial with more addresses than allowed', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_TOO_MANY_ADDRESSES);\n }\n // ensure the peer id is appended to the multiaddr\n if (peerId != null) {\n const peerIdMultiaddr = `/p2p/${peerId.toString()}`;\n dedupedMultiaddrs = dedupedMultiaddrs.map(addr => {\n const addressPeerId = addr.multiaddr.getPeerId();\n const lastProto = addr.multiaddr.protos().pop();\n // do not append peer id to path multiaddrs\n if (lastProto?.path === true) {\n return addr;\n }\n // append peer id to multiaddr if it is not already present\n if (addressPeerId !== peerId.toString()) {\n return {\n multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),\n isCertified: addr.isCertified\n };\n }\n return addr;\n });\n }\n const gatedAdrs = [];\n for (const addr of dedupedMultiaddrs) {\n if (this.connectionGater.denyDialMultiaddr != null && await this.connectionGater.denyDialMultiaddr(addr.multiaddr)) {\n continue;\n }\n gatedAdrs.push(addr);\n }\n const sortedGatedAddrs = gatedAdrs.sort(this.addressSorter);\n // make sure we actually have some addresses to dial\n if (sortedGatedAddrs.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('The connection gater denied all addresses in the dial request', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_NO_VALID_ADDRESSES);\n }\n return sortedGatedAddrs;\n }\n async performDial(pendingDial, options = {}) {\n const dialAbortControllers = pendingDial.multiaddrs.map(() => new AbortController());\n try {\n // internal peer dial queue to ensure we only dial the configured number of addresses\n // per peer at the same time to prevent one peer with a lot of addresses swamping\n // the dial queue\n const peerDialQueue = new p_queue__WEBPACK_IMPORTED_MODULE_7__[\"default\"]({\n concurrency: this.maxParallelDialsPerPeer\n });\n peerDialQueue.on('error', (err) => {\n log.error('error dialling', err);\n });\n const conn = await Promise.any(pendingDial.multiaddrs.map(async (addr, i) => {\n const controller = dialAbortControllers[i];\n if (controller == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('dialAction did not come with an AbortController', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_INVALID_PARAMETERS);\n }\n // let any signal abort the dial\n const signal = (0,_utils_js__WEBPACK_IMPORTED_MODULE_11__.combineSignals)(controller.signal, options.signal);\n signal.addEventListener('abort', () => {\n log('dial to %s aborted', addr);\n });\n const deferred = (0,p_defer__WEBPACK_IMPORTED_MODULE_12__[\"default\"])();\n await peerDialQueue.add(async () => {\n if (signal.aborted) {\n log('dial to %s was aborted before reaching the head of the peer dial queue', addr);\n deferred.reject(new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.AbortError());\n return;\n }\n // add the individual dial to the dial queue so we don't breach maxConcurrentDials\n await this.queue.add(async () => {\n try {\n if (signal.aborted) {\n log('dial to %s was aborted before reaching the head of the dial queue', addr);\n deferred.reject(new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.AbortError());\n return;\n }\n // update dial status\n pendingDial.status = 'active';\n const conn = await this.transportManager.dial(addr, {\n ...options,\n signal\n });\n if (controller.signal.aborted) {\n // another dial succeeded faster than this one\n log('multiple dials succeeded, closing superfluous connection');\n conn.close().catch(err => {\n log.error('error closing superfluous connection', err);\n });\n deferred.reject(new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.AbortError());\n return;\n }\n // remove the successful AbortController so it is not aborted\n dialAbortControllers[i] = undefined;\n // immediately abort any other dials\n dialAbortControllers.forEach(c => {\n if (c !== undefined) {\n c.abort();\n }\n });\n log('dial to %s succeeded', addr);\n // resolve the connection promise\n deferred.resolve(conn);\n }\n catch (err) {\n // something only went wrong if our signal was not aborted\n log.error('error during dial of %s', addr, err);\n deferred.reject(err);\n }\n }, {\n ...options,\n signal\n }).catch(err => {\n deferred.reject(err);\n });\n }, {\n signal\n }).catch(err => {\n deferred.reject(err);\n }).finally(() => {\n signal.clear();\n });\n return deferred.promise;\n }));\n // dial succeeded or failed\n if (conn == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('successful dial led to empty object returned from peer dial queue', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_TRANSPORT_DIAL_FAILED);\n }\n pendingDial.status = 'success';\n return conn;\n }\n catch (err) {\n pendingDial.status = 'error';\n // if we only dialled one address, unwrap the AggregateError to provide more\n // useful feedback to the user\n if (pendingDial.multiaddrs.length === 1 && err.name === 'AggregateError') {\n throw err.errors[0];\n }\n throw err;\n }\n }\n}\n/**\n * Returns a random string\n */\nfunction randomId() {\n return `${(parseInt(String(Math.random() * 1e9), 10)).toString()}${Date.now()}`;\n}\n//# sourceMappingURL=dial-queue.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/dial-queue.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/index.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultConnectionManager: () => (/* binding */ DefaultConnectionManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-store/tags */ \"./node_modules/@waku/sdk/node_modules/@libp2p/interface-peer-store/dist/src/tags.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/get-peer.js\");\n/* harmony import */ var _auto_dial_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./auto-dial.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/auto-dial.js\");\n/* harmony import */ var _connection_pruner_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./connection-pruner.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/connection-pruner.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js\");\n/* harmony import */ var _dial_queue_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./dial-queue.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/dial-queue.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:connection-manager');\nconst DEFAULT_DIAL_PRIORITY = 50;\nconst defaultOptions = {\n minConnections: _constants_js__WEBPACK_IMPORTED_MODULE_12__.MIN_CONNECTIONS,\n maxConnections: _constants_js__WEBPACK_IMPORTED_MODULE_12__.MAX_CONNECTIONS,\n inboundConnectionThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_12__.INBOUND_CONNECTION_THRESHOLD,\n maxIncomingPendingConnections: _constants_js__WEBPACK_IMPORTED_MODULE_12__.MAX_INCOMING_PENDING_CONNECTIONS,\n autoDialConcurrency: _constants_js__WEBPACK_IMPORTED_MODULE_12__.AUTO_DIAL_CONCURRENCY,\n autoDialPriority: _constants_js__WEBPACK_IMPORTED_MODULE_12__.AUTO_DIAL_PRIORITY,\n autoDialMaxQueueLength: _constants_js__WEBPACK_IMPORTED_MODULE_12__.AUTO_DIAL_MAX_QUEUE_LENGTH\n};\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager {\n started;\n connections;\n allow;\n deny;\n maxIncomingPendingConnections;\n incomingPendingConnections;\n maxConnections;\n dialQueue;\n autoDial;\n connectionPruner;\n inboundConnectionRateLimiter;\n peerStore;\n metrics;\n events;\n constructor(components, init = {}) {\n this.maxConnections = init.maxConnections ?? defaultOptions.maxConnections;\n const minConnections = init.minConnections ?? defaultOptions.minConnections;\n if (this.maxConnections < minConnections) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Connection Manager maxConnections must be greater than minConnections', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_INVALID_PARAMETERS);\n }\n /**\n * Map of connections per peer\n */\n this.connections = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_3__.PeerMap();\n this.started = false;\n this.peerStore = components.peerStore;\n this.metrics = components.metrics;\n this.events = components.events;\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.events.addEventListener('connection:open', this.onConnect);\n this.events.addEventListener('connection:close', this.onDisconnect);\n // allow/deny lists\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(ma));\n this.incomingPendingConnections = 0;\n this.maxIncomingPendingConnections = init.maxIncomingPendingConnections ?? defaultOptions.maxIncomingPendingConnections;\n // controls individual peers trying to dial us too quickly\n this.inboundConnectionRateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_7__.RateLimiterMemory({\n points: init.inboundConnectionThreshold ?? defaultOptions.inboundConnectionThreshold,\n duration: 1\n });\n // controls what happens when we don't have enough connections\n this.autoDial = new _auto_dial_js__WEBPACK_IMPORTED_MODULE_10__.AutoDial({\n connectionManager: this,\n peerStore: components.peerStore,\n events: components.events\n }, {\n minConnections,\n autoDialConcurrency: init.autoDialConcurrency ?? defaultOptions.autoDialConcurrency,\n autoDialPriority: init.autoDialPriority ?? defaultOptions.autoDialPriority,\n maxQueueLength: init.autoDialMaxQueueLength ?? defaultOptions.autoDialMaxQueueLength\n });\n // controls what happens when we have too many connections\n this.connectionPruner = new _connection_pruner_js__WEBPACK_IMPORTED_MODULE_11__.ConnectionPruner({\n connectionManager: this,\n peerStore: components.peerStore,\n events: components.events\n }, {\n maxConnections: this.maxConnections,\n allow: this.allow\n });\n this.dialQueue = new _dial_queue_js__WEBPACK_IMPORTED_MODULE_13__.DialQueue({\n peerId: components.peerId,\n metrics: components.metrics,\n peerStore: components.peerStore,\n transportManager: components.transportManager,\n connectionGater: components.connectionGater\n }, {\n addressSorter: init.addressSorter ?? _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_4__.publicAddressesFirst,\n maxParallelDials: init.maxParallelDials ?? _constants_js__WEBPACK_IMPORTED_MODULE_12__.MAX_PARALLEL_DIALS,\n maxPeerAddrsToDial: init.maxPeerAddrsToDial ?? _constants_js__WEBPACK_IMPORTED_MODULE_12__.MAX_PEER_ADDRS_TO_DIAL,\n dialTimeout: init.dialTimeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_12__.DIAL_TIMEOUT,\n resolvers: init.resolvers ?? {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_6__.dnsaddrResolver\n }\n });\n }\n isStarted() {\n return this.started;\n }\n /**\n * Starts the Connection Manager. If Metrics are not enabled on libp2p\n * only event loop and connection limits will be monitored.\n */\n async start() {\n // track inbound/outbound connections\n this.metrics?.registerMetricGroup('libp2p_connection_manager_connections', {\n calculate: () => {\n const metric = {\n inbound: 0,\n outbound: 0\n };\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n if (conn.stat.direction === 'inbound') {\n metric.inbound++;\n }\n else {\n metric.outbound++;\n }\n }\n }\n return metric;\n }\n });\n // track total number of streams per protocol\n this.metrics?.registerMetricGroup('libp2p_protocol_streams_total', {\n label: 'protocol',\n calculate: () => {\n const metric = {};\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n for (const stream of conn.streams) {\n const key = `${stream.stat.direction} ${stream.stat.protocol ?? 'unnegotiated'}`;\n metric[key] = (metric[key] ?? 0) + 1;\n }\n }\n }\n return metric;\n }\n });\n // track 90th percentile of streams per protocol\n this.metrics?.registerMetricGroup('libp2p_connection_manager_protocol_streams_per_connection_90th_percentile', {\n label: 'protocol',\n calculate: () => {\n const allStreams = {};\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n const streams = {};\n for (const stream of conn.streams) {\n const key = `${stream.stat.direction} ${stream.stat.protocol ?? 'unnegotiated'}`;\n streams[key] = (streams[key] ?? 0) + 1;\n }\n for (const [protocol, count] of Object.entries(streams)) {\n allStreams[protocol] = allStreams[protocol] ?? [];\n allStreams[protocol].push(count);\n }\n }\n }\n const metric = {};\n for (let [protocol, counts] of Object.entries(allStreams)) {\n counts = counts.sort((a, b) => a - b);\n const index = Math.floor(counts.length * 0.9);\n metric[protocol] = counts[index];\n }\n return metric;\n }\n });\n this.autoDial.start();\n this.started = true;\n log('started');\n }\n async afterStart() {\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = await this.peerStore.all({\n filters: [(peer) => {\n return peer.tags.has(_libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_0__.KEEP_ALIVE);\n }]\n });\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer.id)\n .catch(err => {\n log.error(err);\n });\n }));\n })\n .catch(err => {\n log.error(err);\n });\n this.autoDial.afterStart();\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.dialQueue.stop();\n this.autoDial.stop();\n // Close all connections we're tracking\n const tasks = [];\n for (const connectionList of this.connections.values()) {\n for (const connection of connectionList) {\n tasks.push((async () => {\n try {\n await connection.close();\n }\n catch (err) {\n log.error(err);\n }\n })());\n }\n }\n log('closing %d connections', tasks.length);\n await Promise.all(tasks);\n this.connections.clear();\n log('stopped');\n }\n onConnect(evt) {\n void this._onConnect(evt).catch(err => {\n log.error(err);\n });\n }\n /**\n * Tracks the incoming connection and check the connection limit\n */\n async _onConnect(evt) {\n const { detail: connection } = evt;\n if (!this.started) {\n // This can happen when we are in the process of shutting down the node\n await connection.close();\n return;\n }\n const peerId = connection.remotePeer;\n const storedConns = this.connections.get(peerId);\n let isNewPeer = false;\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n isNewPeer = true;\n this.connections.set(peerId, [connection]);\n }\n // only need to store RSA public keys, all other types are embedded in the peer id\n if (peerId.publicKey != null && peerId.type === 'RSA') {\n await this.peerStore.patch(peerId, {\n publicKey: peerId.publicKey\n });\n }\n if (isNewPeer) {\n this.events.safeDispatchEvent('peer:connect', { detail: connection.remotePeer });\n }\n }\n /**\n * Removes the connection from tracking\n */\n onDisconnect(evt) {\n const { detail: connection } = evt;\n if (!this.started) {\n // This can happen when we are in the process of shutting down the node\n return;\n }\n const peerId = connection.remotePeer;\n let storedConn = this.connections.get(peerId);\n if (storedConn != null && storedConn.length > 1) {\n storedConn = storedConn.filter((conn) => conn.id !== connection.id);\n this.connections.set(peerId, storedConn);\n }\n else if (storedConn != null) {\n this.connections.delete(peerId);\n this.events.safeDispatchEvent('peer:disconnect', { detail: connection.remotePeer });\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n getConnectionsMap() {\n return this.connections;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n if (!this.isStarted()) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Not started', _errors_js__WEBPACK_IMPORTED_MODULE_8__.codes.ERR_NODE_NOT_STARTED);\n }\n const { peerId } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_9__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId != null) {\n log('dial %p', peerId);\n const existingConnections = this.getConnections(peerId);\n if (existingConnections.length > 0) {\n log('had an existing connection to %p', peerId);\n return existingConnections[0];\n }\n }\n const connection = await this.dialQueue.dial(peerIdOrMultiaddr, {\n ...options,\n priority: options.priority ?? DEFAULT_DIAL_PRIORITY\n });\n let peerConnections = this.connections.get(connection.remotePeer);\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer, peerConnections);\n }\n // we get notified of connections via the Upgrader emitting \"connection\"\n // events, double check we aren't already tracking this connection before\n // storing it\n let trackedConnection = false;\n for (const conn of peerConnections) {\n if (conn.id === connection.id) {\n trackedConnection = true;\n }\n }\n if (!trackedConnection) {\n peerConnections.push(connection);\n }\n return connection;\n }\n async closeConnections(peerId) {\n const connections = this.connections.get(peerId) ?? [];\n await Promise.all(connections.map(async (connection) => {\n await connection.close();\n }));\n }\n async acceptIncomingConnection(maConn) {\n // check deny list\n const denyConnection = this.deny.some(ma => {\n return maConn.remoteAddr.toString().startsWith(ma.toString());\n });\n if (denyConnection) {\n log('connection from %s refused - connection remote address was in deny list', maConn.remoteAddr);\n return false;\n }\n // check allow list\n const allowConnection = this.allow.some(ma => {\n return maConn.remoteAddr.toString().startsWith(ma.toString());\n });\n if (allowConnection) {\n this.incomingPendingConnections++;\n return true;\n }\n // check pending connections\n if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {\n log('connection from %s refused - incomingPendingConnections exceeded by peer %s', maConn.remoteAddr);\n return false;\n }\n if (maConn.remoteAddr.isThinWaistAddress()) {\n const host = maConn.remoteAddr.nodeAddress().address;\n try {\n await this.inboundConnectionRateLimiter.consume(host, 1);\n }\n catch {\n log('connection from %s refused - inboundConnectionThreshold exceeded by host %s', host, maConn.remoteAddr);\n return false;\n }\n }\n if (this.getConnections().length < this.maxConnections) {\n this.incomingPendingConnections++;\n return true;\n }\n log('connection from %s refused - maxConnections exceeded', maConn.remoteAddr);\n return false;\n }\n afterUpgradeInbound() {\n this.incomingPendingConnections--;\n }\n getDialQueue() {\n return this.dialQueue.pendingDials;\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/utils.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/utils.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ combineSignals: () => (/* binding */ combineSignals),\n/* harmony export */ resolveMultiaddrs: () => (/* binding */ resolveMultiaddrs)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:connection-manager:utils');\n/**\n * Resolve multiaddr recursively\n */\nasync function resolveMultiaddrs(ma, options) {\n // TODO: recursive logic should live in multiaddr once dns4/dns6 support is in place\n // Now only supporting resolve for dnsaddr\n const resolvableProto = ma.protoNames().includes('dnsaddr');\n // Multiaddr is not resolvable? End recursion!\n if (!resolvableProto) {\n return [ma];\n }\n const resolvedMultiaddrs = await resolveRecord(ma, options);\n const recursiveMultiaddrs = await Promise.all(resolvedMultiaddrs.map(async (nm) => {\n return resolveMultiaddrs(nm, options);\n }));\n const addrs = recursiveMultiaddrs.flat();\n const output = addrs.reduce((array, newM) => {\n if (array.find(m => m.equals(newM)) == null) {\n array.push(newM);\n }\n return array;\n }, ([]));\n log('resolved %s to', ma, output.map(ma => ma.toString()));\n return output;\n}\n/**\n * Resolve a given multiaddr. If this fails, an empty array will be returned\n */\nasync function resolveRecord(ma, options) {\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(ma.toString()); // Use current multiaddr module\n const multiaddrs = await ma.resolve(options);\n return multiaddrs;\n }\n catch (err) {\n log.error(`multiaddr ${ma.toString()} could not be resolved`, err);\n return [];\n }\n}\nfunction combineSignals(...signals) {\n const sigs = [];\n for (const sig of signals) {\n if (sig != null) {\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, sig);\n }\n catch { }\n sigs.push(sig);\n }\n }\n // let any signal abort the dial\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_3__.anySignal)(sigs);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n return signal;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection/index.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionImpl: () => (/* binding */ ConnectionImpl),\n/* harmony export */ createConnection: () => (/* binding */ createConnection)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_connection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-connection */ \"./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/index.js\");\n/* harmony import */ var _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface-connection/status */ \"./node_modules/@waku/sdk/node_modules/@libp2p/interface-connection/dist/src/status.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.logger)('libp2p:connection');\n/**\n * An implementation of the js-libp2p connection.\n * Any libp2p transport should use an upgrader to return this connection.\n */\nclass ConnectionImpl {\n /**\n * Connection identifier.\n */\n id;\n /**\n * Observed multiaddr of the remote peer\n */\n remoteAddr;\n /**\n * Remote peer id\n */\n remotePeer;\n /**\n * Connection metadata\n */\n stat;\n /**\n * User provided tags\n *\n */\n tags;\n /**\n * Reference to the new stream function of the multiplexer\n */\n _newStream;\n /**\n * Reference to the close function of the raw connection\n */\n _close;\n /**\n * Reference to the getStreams function of the muxer\n */\n _getStreams;\n _closing;\n /**\n * An implementation of the js-libp2p connection.\n * Any libp2p transport should use an upgrader to return this connection.\n */\n constructor(init) {\n const { remoteAddr, remotePeer, newStream, close, getStreams, stat } = init;\n this.id = `${(parseInt(String(Math.random() * 1e9))).toString(36)}${Date.now()}`;\n this.remoteAddr = remoteAddr;\n this.remotePeer = remotePeer;\n this.stat = {\n ...stat,\n status: _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.OPEN\n };\n this._newStream = newStream;\n this._close = close;\n this._getStreams = getStreams;\n this.tags = [];\n this._closing = false;\n }\n [Symbol.toStringTag] = 'Connection';\n [_libp2p_interface_connection__WEBPACK_IMPORTED_MODULE_0__.symbol] = true;\n /**\n * Get all the streams of the muxer\n */\n get streams() {\n return this._getStreams();\n }\n /**\n * Create a new stream from this connection\n */\n async newStream(protocols, options) {\n if (this.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.CLOSING) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('the connection is being closed', 'ERR_CONNECTION_BEING_CLOSED');\n }\n if (this.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.CLOSED) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('the connection is closed', 'ERR_CONNECTION_CLOSED');\n }\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n const stream = await this._newStream(protocols, options);\n stream.stat.direction = 'outbound';\n return stream;\n }\n /**\n * Add a stream when it is opened to the registry\n */\n addStream(stream) {\n stream.stat.direction = 'inbound';\n }\n /**\n * Remove stream registry after it is closed\n */\n removeStream(id) {\n }\n /**\n * Close the connection\n */\n async close() {\n if (this.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.CLOSED || this._closing) {\n return;\n }\n this.stat.status = _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.CLOSING;\n // close all streams - this can throw if we're not multiplexed\n try {\n this.streams.forEach(s => { s.close(); });\n }\n catch (err) {\n log.error(err);\n }\n // Close raw connection\n this._closing = true;\n await this._close();\n this._closing = false;\n this.stat.timeline.close = Date.now();\n this.stat.status = _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_1__.CLOSED;\n }\n}\nfunction createConnection(init) {\n return new ConnectionImpl(init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/index.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CompoundContentRouting: () => (/* binding */ CompoundContentRouting)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/utils.js\");\n\n\n\n\n\nclass CompoundContentRouting {\n routers;\n started;\n components;\n constructor(components, init) {\n this.routers = init.routers ?? [];\n this.started = false;\n this.components = components;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n }\n async stop() {\n this.started = false;\n }\n /**\n * Iterates over all content routers in parallel to find providers of the given key\n */\n async *findProviders(key, options = {}) {\n if (this.routers.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('No content routers available', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n yield* (0,it_pipe__WEBPACK_IMPORTED_MODULE_2__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(...this.routers.map(router => router.findProviders(key, options))), (source) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.storeAddresses)(source, this.components.peerStore), (source) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.uniquePeers)(source), (source) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.requirePeers)(source));\n }\n /**\n * Iterates over all content routers in parallel to notify it is\n * a provider of the given key\n */\n async provide(key, options = {}) {\n if (this.routers.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('No content routers available', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n await Promise.all(this.routers.map(async (router) => { await router.provide(key, options); }));\n }\n /**\n * Store the given key/value pair in the available content routings\n */\n async put(key, value, options) {\n if (!this.isStarted()) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_3__.messages.NOT_STARTED_YET, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.DHT_NOT_STARTED);\n }\n await Promise.all(this.routers.map(async (router) => {\n await router.put(key, value, options);\n }));\n }\n /**\n * Get the value to the given key.\n * Times out after 1 minute by default.\n */\n async get(key, options) {\n if (!this.isStarted()) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_3__.messages.NOT_STARTED_YET, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.DHT_NOT_STARTED);\n }\n return Promise.any(this.routers.map(async (router) => {\n return router.get(key, options);\n }));\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/utils.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/utils.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ requirePeers: () => (/* binding */ requirePeers),\n/* harmony export */ storeAddresses: () => (/* binding */ storeAddresses),\n/* harmony export */ uniquePeers: () => (/* binding */ uniquePeers)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-filter */ \"./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var it_map__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-map */ \"./node_modules/@waku/sdk/node_modules/it-map/dist/src/index.js\");\n\n\n\n/**\n * Store the multiaddrs from every peer in the passed peer store\n */\nasync function* storeAddresses(source, peerStore) {\n yield* (0,it_map__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source, async (peer) => {\n // ensure we have the addresses for a given peer\n await peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs\n });\n return peer;\n });\n}\n/**\n * Filter peers by unique peer id\n */\nfunction uniquePeers(source) {\n /** @type Set */\n const seen = new Set();\n return (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(source, (peer) => {\n // dedupe by peer id\n if (seen.has(peer.id.toString())) {\n return false;\n }\n seen.add(peer.id.toString());\n return true;\n });\n}\n/**\n * Require at least `min` peers to be yielded from `source`\n */\nasync function* requirePeers(source, min = 1) {\n let seen = 0;\n for await (const peer of source) {\n seen++;\n yield peer;\n }\n if (seen < min) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`more peers required, seen: ${seen} min: ${min}`, 'NOT_FOUND');\n }\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes),\n/* harmony export */ messages: () => (/* binding */ messages)\n/* harmony export */ });\nvar messages;\n(function (messages) {\n messages[\"NOT_STARTED_YET\"] = \"The libp2p node is not started yet\";\n messages[\"DHT_DISABLED\"] = \"DHT is not available\";\n messages[\"PUBSUB_DISABLED\"] = \"PubSub is not available\";\n messages[\"CONN_ENCRYPTION_REQUIRED\"] = \"At least one connection encryption module is required\";\n messages[\"ERR_TRANSPORTS_REQUIRED\"] = \"At least one transport module is required\";\n messages[\"ERR_PROTECTOR_REQUIRED\"] = \"Private network is enforced, but no protector was provided\";\n messages[\"NOT_FOUND\"] = \"Not found\";\n})(messages || (messages = {}));\nvar codes;\n(function (codes) {\n codes[\"DHT_DISABLED\"] = \"ERR_DHT_DISABLED\";\n codes[\"ERR_PUBSUB_DISABLED\"] = \"ERR_PUBSUB_DISABLED\";\n codes[\"PUBSUB_NOT_STARTED\"] = \"ERR_PUBSUB_NOT_STARTED\";\n codes[\"DHT_NOT_STARTED\"] = \"ERR_DHT_NOT_STARTED\";\n codes[\"CONN_ENCRYPTION_REQUIRED\"] = \"ERR_CONN_ENCRYPTION_REQUIRED\";\n codes[\"ERR_TRANSPORTS_REQUIRED\"] = \"ERR_TRANSPORTS_REQUIRED\";\n codes[\"ERR_PROTECTOR_REQUIRED\"] = \"ERR_PROTECTOR_REQUIRED\";\n codes[\"ERR_PEER_DIAL_INTERCEPTED\"] = \"ERR_PEER_DIAL_INTERCEPTED\";\n codes[\"ERR_CONNECTION_INTERCEPTED\"] = \"ERR_CONNECTION_INTERCEPTED\";\n codes[\"ERR_INVALID_PROTOCOLS_FOR_STREAM\"] = \"ERR_INVALID_PROTOCOLS_FOR_STREAM\";\n codes[\"ERR_CONNECTION_ENDED\"] = \"ERR_CONNECTION_ENDED\";\n codes[\"ERR_CONNECTION_FAILED\"] = \"ERR_CONNECTION_FAILED\";\n codes[\"ERR_NODE_NOT_STARTED\"] = \"ERR_NODE_NOT_STARTED\";\n codes[\"ERR_ALREADY_ABORTED\"] = \"ERR_ALREADY_ABORTED\";\n codes[\"ERR_TOO_MANY_ADDRESSES\"] = \"ERR_TOO_MANY_ADDRESSES\";\n codes[\"ERR_NO_VALID_ADDRESSES\"] = \"ERR_NO_VALID_ADDRESSES\";\n codes[\"ERR_RELAYED_DIAL\"] = \"ERR_RELAYED_DIAL\";\n codes[\"ERR_DIALED_SELF\"] = \"ERR_DIALED_SELF\";\n codes[\"ERR_DISCOVERED_SELF\"] = \"ERR_DISCOVERED_SELF\";\n codes[\"ERR_DUPLICATE_TRANSPORT\"] = \"ERR_DUPLICATE_TRANSPORT\";\n codes[\"ERR_ENCRYPTION_FAILED\"] = \"ERR_ENCRYPTION_FAILED\";\n codes[\"ERR_HOP_REQUEST_FAILED\"] = \"ERR_HOP_REQUEST_FAILED\";\n codes[\"ERR_INVALID_KEY\"] = \"ERR_INVALID_KEY\";\n codes[\"ERR_INVALID_MESSAGE\"] = \"ERR_INVALID_MESSAGE\";\n codes[\"ERR_INVALID_PARAMETERS\"] = \"ERR_INVALID_PARAMETERS\";\n codes[\"ERR_INVALID_PEER\"] = \"ERR_INVALID_PEER\";\n codes[\"ERR_MUXER_UNAVAILABLE\"] = \"ERR_MUXER_UNAVAILABLE\";\n codes[\"ERR_NOT_FOUND\"] = \"ERR_NOT_FOUND\";\n codes[\"ERR_TIMEOUT\"] = \"ERR_TIMEOUT\";\n codes[\"ERR_TRANSPORT_UNAVAILABLE\"] = \"ERR_TRANSPORT_UNAVAILABLE\";\n codes[\"ERR_TRANSPORT_DIAL_FAILED\"] = \"ERR_TRANSPORT_DIAL_FAILED\";\n codes[\"ERR_UNSUPPORTED_PROTOCOL\"] = \"ERR_UNSUPPORTED_PROTOCOL\";\n codes[\"ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED\"] = \"ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED\";\n codes[\"ERR_INVALID_MULTIADDR\"] = \"ERR_INVALID_MULTIADDR\";\n codes[\"ERR_SIGNATURE_NOT_VALID\"] = \"ERR_SIGNATURE_NOT_VALID\";\n codes[\"ERR_FIND_SELF\"] = \"ERR_FIND_SELF\";\n codes[\"ERR_NO_ROUTERS_AVAILABLE\"] = \"ERR_NO_ROUTERS_AVAILABLE\";\n codes[\"ERR_CONNECTION_NOT_MULTIPLEXED\"] = \"ERR_CONNECTION_NOT_MULTIPLEXED\";\n codes[\"ERR_NO_DIAL_TOKENS\"] = \"ERR_NO_DIAL_TOKENS\";\n codes[\"ERR_KEYCHAIN_REQUIRED\"] = \"ERR_KEYCHAIN_REQUIRED\";\n codes[\"ERR_INVALID_CMS\"] = \"ERR_INVALID_CMS\";\n codes[\"ERR_MISSING_KEYS\"] = \"ERR_MISSING_KEYS\";\n codes[\"ERR_NO_KEY\"] = \"ERR_NO_KEY\";\n codes[\"ERR_INVALID_KEY_NAME\"] = \"ERR_INVALID_KEY_NAME\";\n codes[\"ERR_INVALID_KEY_TYPE\"] = \"ERR_INVALID_KEY_TYPE\";\n codes[\"ERR_KEY_ALREADY_EXISTS\"] = \"ERR_KEY_ALREADY_EXISTS\";\n codes[\"ERR_INVALID_KEY_SIZE\"] = \"ERR_INVALID_KEY_SIZE\";\n codes[\"ERR_KEY_NOT_FOUND\"] = \"ERR_KEY_NOT_FOUND\";\n codes[\"ERR_OLD_KEY_NAME_INVALID\"] = \"ERR_OLD_KEY_NAME_INVALID\";\n codes[\"ERR_NEW_KEY_NAME_INVALID\"] = \"ERR_NEW_KEY_NAME_INVALID\";\n codes[\"ERR_PASSWORD_REQUIRED\"] = \"ERR_PASSWORD_REQUIRED\";\n codes[\"ERR_PEM_REQUIRED\"] = \"ERR_PEM_REQUIRED\";\n codes[\"ERR_CANNOT_READ_KEY\"] = \"ERR_CANNOT_READ_KEY\";\n codes[\"ERR_MISSING_PRIVATE_KEY\"] = \"ERR_MISSING_PRIVATE_KEY\";\n codes[\"ERR_MISSING_PUBLIC_KEY\"] = \"ERR_MISSING_PUBLIC_KEY\";\n codes[\"ERR_INVALID_OLD_PASS_TYPE\"] = \"ERR_INVALID_OLD_PASS_TYPE\";\n codes[\"ERR_INVALID_NEW_PASS_TYPE\"] = \"ERR_INVALID_NEW_PASS_TYPE\";\n codes[\"ERR_INVALID_PASS_LENGTH\"] = \"ERR_INVALID_PASS_LENGTH\";\n codes[\"ERR_NOT_IMPLEMENTED\"] = \"ERR_NOT_IMPLEMENTED\";\n codes[\"ERR_WRONG_PING_ACK\"] = \"ERR_WRONG_PING_ACK\";\n codes[\"ERR_INVALID_RECORD\"] = \"ERR_INVALID_RECORD\";\n codes[\"ERR_ALREADY_SUCCEEDED\"] = \"ERR_ALREADY_SUCCEEDED\";\n codes[\"ERR_NO_HANDLER_FOR_PROTOCOL\"] = \"ERR_NO_HANDLER_FOR_PROTOCOL\";\n codes[\"ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS\"] = \"ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS\";\n codes[\"ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS\"] = \"ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS\";\n codes[\"ERR_CONNECTION_DENIED\"] = \"ERR_CONNECTION_DENIED\";\n codes[\"ERR_TRANSFER_LIMIT_EXCEEDED\"] = \"ERR_TRANSFER_LIMIT_EXCEEDED\";\n})(codes || (codes = {}));\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/get-peer.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/get-peer.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPeerAddress: () => (/* binding */ getPeerAddress)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:get-peer');\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr or an array of Multiaddrs\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_0__.isPeerId)(peer)) {\n return { peerId: peer, multiaddrs: [] };\n }\n if (!Array.isArray(peer)) {\n peer = [peer];\n }\n let peerId;\n if (peer.length > 0) {\n const peerIdStr = peer[0].getPeerId();\n peerId = peerIdStr == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromString)(peerIdStr);\n // ensure PeerId is either not set or is consistent\n peer.forEach(ma => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_4__.isMultiaddr)(ma)) {\n log.error('multiaddr %s was invalid', ma);\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Invalid Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_MULTIADDR);\n }\n const maPeerIdStr = ma.getPeerId();\n if (maPeerIdStr == null) {\n if (peerId != null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Multiaddrs must all have the same peer id or have no peer id', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n else {\n const maPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromString)(maPeerIdStr);\n if (peerId == null || !peerId.equals(maPeerId)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Multiaddrs must all have the same peer id or have no peer id', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n });\n }\n return {\n peerId,\n multiaddrs: peer\n };\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/get-peer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/consts.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/consts.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AGENT_VERSION: () => (/* binding */ AGENT_VERSION),\n/* harmony export */ IDENTIFY_PROTOCOL_VERSION: () => (/* binding */ IDENTIFY_PROTOCOL_VERSION),\n/* harmony export */ MULTICODEC_IDENTIFY: () => (/* binding */ MULTICODEC_IDENTIFY),\n/* harmony export */ MULTICODEC_IDENTIFY_PROTOCOL_NAME: () => (/* binding */ MULTICODEC_IDENTIFY_PROTOCOL_NAME),\n/* harmony export */ MULTICODEC_IDENTIFY_PROTOCOL_VERSION: () => (/* binding */ MULTICODEC_IDENTIFY_PROTOCOL_VERSION),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME),\n/* harmony export */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION: () => (/* binding */ MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION),\n/* harmony export */ PROTOCOL_VERSION: () => (/* binding */ PROTOCOL_VERSION)\n/* harmony export */ });\n/* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../version.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/version.js\");\n\nconst PROTOCOL_VERSION = 'ipfs/0.1.0'; // deprecated\nconst AGENT_VERSION = `js-libp2p/${_version_js__WEBPACK_IMPORTED_MODULE_0__.version}`;\nconst MULTICODEC_IDENTIFY = '/ipfs/id/1.0.0'; // deprecated\nconst MULTICODEC_IDENTIFY_PUSH = '/ipfs/id/push/1.0.0'; // deprecated\nconst IDENTIFY_PROTOCOL_VERSION = '0.1.0';\nconst MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id';\nconst MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push';\nconst MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0';\nconst MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0';\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/consts.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/identify.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/identify.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultIdentifyService: () => (/* binding */ DefaultIdentifyService)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-first */ \"./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pb_stream__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! it-pb-stream */ \"./node_modules/it-pb-stream/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/pb/message.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:identify');\n// https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52\nconst MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;\nconst defaultValues = {\n protocolPrefix: 'ipfs',\n agentVersion: _consts_js__WEBPACK_IMPORTED_MODULE_16__.AGENT_VERSION,\n // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L48\n timeout: 60000,\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n maxPushIncomingStreams: 1,\n maxPushOutgoingStreams: 1,\n maxObservedAddresses: 10,\n maxIdentifyMessageSize: 8192\n};\nclass DefaultIdentifyService {\n identifyProtocolStr;\n identifyPushProtocolStr;\n host;\n started;\n timeout;\n peerId;\n peerStore;\n registrar;\n connectionManager;\n addressManager;\n maxInboundStreams;\n maxOutboundStreams;\n maxPushIncomingStreams;\n maxPushOutgoingStreams;\n maxIdentifyMessageSize;\n maxObservedAddresses;\n events;\n constructor(components, init) {\n this.started = false;\n this.peerId = components.peerId;\n this.peerStore = components.peerStore;\n this.registrar = components.registrar;\n this.addressManager = components.addressManager;\n this.connectionManager = components.connectionManager;\n this.events = components.events;\n this.identifyProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_16__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_16__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_16__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_16__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n this.timeout = init.timeout ?? defaultValues.timeout;\n this.maxInboundStreams = init.maxInboundStreams ?? defaultValues.maxInboundStreams;\n this.maxOutboundStreams = init.maxOutboundStreams ?? defaultValues.maxOutboundStreams;\n this.maxPushIncomingStreams = init.maxPushIncomingStreams ?? defaultValues.maxPushIncomingStreams;\n this.maxPushOutgoingStreams = init.maxPushOutgoingStreams ?? defaultValues.maxPushOutgoingStreams;\n this.maxIdentifyMessageSize = init.maxIdentifyMessageSize ?? defaultValues.maxIdentifyMessageSize;\n this.maxObservedAddresses = init.maxObservedAddresses ?? defaultValues.maxObservedAddresses;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix ?? defaultValues.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_16__.IDENTIFY_PROTOCOL_VERSION}`,\n agentVersion: init.agentVersion ?? defaultValues.agentVersion\n };\n // When a new connection happens, trigger identify\n components.events.addEventListener('connection:open', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(err => { log.error('error during identify trigged by connection:open', err); });\n });\n // When self peer record changes, trigger identify-push\n components.events.addEventListener('self:peer:update', (evt) => {\n void this.push().catch(err => { log.error(err); });\n });\n // Append user agent version to default AGENT_VERSION depending on the environment\n if (this.host.agentVersion === _consts_js__WEBPACK_IMPORTED_MODULE_16__.AGENT_VERSION) {\n if (wherearewe__WEBPACK_IMPORTED_MODULE_14__.isNode || wherearewe__WEBPACK_IMPORTED_MODULE_14__.isElectronMain) {\n this.host.agentVersion += ` UserAgent=${globalThis.process.version}`;\n }\n else if (wherearewe__WEBPACK_IMPORTED_MODULE_14__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_14__.isWebWorker || wherearewe__WEBPACK_IMPORTED_MODULE_14__.isElectronRenderer || wherearewe__WEBPACK_IMPORTED_MODULE_14__.isReactNative) {\n this.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;\n }\n }\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.peerStore.merge(this.peerId, {\n metadata: {\n AgentVersion: (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(this.host.agentVersion),\n ProtocolVersion: (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(this.host.protocolVersion)\n }\n });\n await this.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams\n });\n await this.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.maxPushIncomingStreams,\n maxOutboundStreams: this.maxPushOutgoingStreams\n });\n this.started = true;\n }\n async stop() {\n await this.registrar.unhandle(this.identifyProtocolStr);\n await this.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async pushToConnections(connections) {\n const listenAddresses = this.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.protocols)('p2p').code));\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord({\n peerId: this.peerId,\n multiaddrs: listenAddresses\n });\n const signedPeerRecord = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.seal(peerRecord, this.peerId);\n const supportedProtocols = this.registrar.getProtocols();\n const peer = await this.peerStore.get(this.peerId);\n const agentVersion = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_13__.toString)(peer.metadata.get('AgentVersion') ?? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(this.host.agentVersion));\n const protocolVersion = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_13__.toString)(peer.metadata.get('ProtocolVersion') ?? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(this.host.protocolVersion));\n const pushes = connections.map(async (connection) => {\n let stream;\n const signal = AbortSignal.timeout(this.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyPushProtocolStr], {\n signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_6__.abortableDuplex)(stream, signal);\n await source.sink((0,it_pipe__WEBPACK_IMPORTED_MODULE_11__.pipe)([_pb_message_js__WEBPACK_IMPORTED_MODULE_17__.Identify.encode({\n listenAddrs: listenAddresses.map(ma => ma.bytes),\n signedPeerRecord: signedPeerRecord.marshal(),\n protocols: supportedProtocols,\n agentVersion,\n protocolVersion\n })], (source) => it_length_prefixed__WEBPACK_IMPORTED_MODULE_9__.encode(source)));\n }\n catch (err) {\n // Just log errors\n log.error('could not push identify update to peer', err);\n }\n finally {\n if (stream != null) {\n stream.close();\n }\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async push() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n await Promise.all(this.connectionManager.getConnections().map(async (conn) => {\n try {\n const peer = await this.peerStore.get(conn.remotePeer);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n return;\n }\n connections.push(conn);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n }));\n await this.pushToConnections(connections);\n }\n async _identify(connection, options = {}) {\n let stream;\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_7__.anySignal)([AbortSignal.timeout(this.timeout), options?.signal]);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyProtocolStr], {\n signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_6__.abortableDuplex)(stream, signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_11__.pipe)([], source, (source) => it_length_prefixed__WEBPACK_IMPORTED_MODULE_9__.decode(source, {\n maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => (0,it_first__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(source));\n if (data == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('No data could be retrieved', _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_CONNECTION_ENDED);\n }\n try {\n return _pb_message_js__WEBPACK_IMPORTED_MODULE_17__.Identify.decode(data);\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_INVALID_MESSAGE);\n }\n }\n finally {\n if (stream != null) {\n stream.close();\n }\n signal.clear();\n }\n }\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, protocols, observedAddr } = message;\n if (publicKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('public key was missing from identify message', _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_MISSING_PUBLIC_KEY);\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('identified peer does not match the expected peer', _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_INVALID_PEER);\n }\n if (this.peerId.equals(id)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('identified peer is our own peer id?', _errors_js__WEBPACK_IMPORTED_MODULE_15__.codes.ERR_INVALID_PEER);\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = getCleanMultiaddr(observedAddr);\n log('identify completed for peer %p and protocols %o', id, protocols);\n log('our observed address is %s', cleanObservedAddr);\n if (cleanObservedAddr != null &&\n this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {\n log('storing our observed address %s', cleanObservedAddr?.toString());\n this.addressManager.addObservedAddr(cleanObservedAddr);\n }\n const signedPeerRecord = await this.#consumeIdentifyMessage(connection.remotePeer, message);\n const result = {\n peerId: id,\n protocolVersion: message.protocolVersion,\n agentVersion: message.agentVersion,\n publicKey: message.publicKey,\n listenAddrs: message.listenAddrs.map(buf => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(buf)),\n observedAddr: message.observedAddr == null ? undefined : (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(message.observedAddr),\n protocols: message.protocols,\n signedPeerRecord\n };\n this.events.safeDispatchEvent('peer:identify', { detail: result });\n }\n /**\n * Sends the `Identify` response with the Signed Peer Record\n * to the requesting peer over the given `connection`\n */\n async _handleIdentify(data) {\n const { connection, stream } = data;\n const signal = AbortSignal.timeout(this.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n try {\n const publicKey = this.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.peerStore.get(this.peerId);\n const multiaddrs = this.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.protocols)('p2p').code));\n let signedPeerRecord = peerData.peerRecordEnvelope;\n if (multiaddrs.length > 0 && signedPeerRecord == null) {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord({\n peerId: this.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.seal(peerRecord, this.peerId);\n signedPeerRecord = envelope.marshal().subarray();\n }\n const message = _pb_message_js__WEBPACK_IMPORTED_MODULE_17__.Identify.encode({\n protocolVersion: this.host.protocolVersion,\n agentVersion: this.host.agentVersion,\n publicKey,\n listenAddrs: multiaddrs.map(addr => addr.bytes),\n signedPeerRecord,\n observedAddr: connection.remoteAddr.bytes,\n protocols: peerData.protocols\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_6__.abortableDuplex)(stream, signal);\n const msgWithLenPrefix = (0,it_pipe__WEBPACK_IMPORTED_MODULE_11__.pipe)([message], (source) => it_length_prefixed__WEBPACK_IMPORTED_MODULE_9__.encode(source));\n await source.sink(msgWithLenPrefix);\n }\n catch (err) {\n log.error('could not respond to identify request', err);\n }\n finally {\n stream.close();\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n try {\n if (this.peerId.equals(connection.remotePeer)) {\n throw new Error('received push from ourselves?');\n }\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_6__.abortableDuplex)(stream, AbortSignal.timeout(this.timeout));\n const pb = (0,it_pb_stream__WEBPACK_IMPORTED_MODULE_10__.pbStream)(source, {\n maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n });\n const message = await pb.readPB(_pb_message_js__WEBPACK_IMPORTED_MODULE_17__.Identify);\n await this.#consumeIdentifyMessage(connection.remotePeer, message);\n }\n catch (err) {\n log.error('received invalid message', err);\n return;\n }\n finally {\n stream.close();\n }\n log('handled push from %p', connection.remotePeer);\n }\n async #consumeIdentifyMessage(remotePeer, message) {\n log('received identify from %p', remotePeer);\n if (message == null) {\n throw new Error('Message was null or undefined');\n }\n const peer = {\n addresses: message.listenAddrs.map(buf => ({\n isCertified: false,\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(buf)\n })),\n protocols: message.protocols,\n metadata: new Map(),\n peerRecordEnvelope: message.signedPeerRecord\n };\n let output;\n // if the peer record has been sent, prefer the addresses in the record as they are signed by the remote peer\n if (message.signedPeerRecord != null) {\n log('received signedPeerRecord in push from %p', remotePeer);\n let peerRecordEnvelope = message.signedPeerRecord;\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.openAndCertify(peerRecordEnvelope, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.DOMAIN);\n let peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(envelope.payload);\n // Verify peerId\n if (!peerRecord.peerId.equals(envelope.peerId)) {\n throw new Error('signing key does not match PeerId in the PeerRecord');\n }\n // Make sure remote peer is the one sending the record\n if (!remotePeer.equals(peerRecord.peerId)) {\n throw new Error('signing key does not match remote PeerId');\n }\n let existingPeer;\n try {\n existingPeer = await this.peerStore.get(peerRecord.peerId);\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n if (existingPeer != null) {\n // don't lose any existing metadata\n peer.metadata = existingPeer.metadata;\n // if we have previously received a signed record for this peer, compare it to the incoming one\n if (existingPeer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(existingPeer.peerRecordEnvelope);\n const storedRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(storedEnvelope.payload);\n // ensure seq is greater than, or equal to, the last received\n if (storedRecord.seqNumber >= peerRecord.seqNumber) {\n log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);\n peerRecord = storedRecord;\n peerRecordEnvelope = existingPeer.peerRecordEnvelope;\n }\n }\n }\n // store the signed record for next time\n peer.peerRecordEnvelope = peerRecordEnvelope;\n // override the stored addresses with the signed multiaddrs\n peer.addresses = peerRecord.multiaddrs.map(multiaddr => ({\n isCertified: true,\n multiaddr\n }));\n output = {\n seq: peerRecord.seqNumber,\n addresses: peerRecord.multiaddrs\n };\n }\n else {\n log('%p did not send a signed peer record', remotePeer);\n }\n if (message.agentVersion != null) {\n peer.metadata.set('AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(message.agentVersion));\n }\n if (message.protocolVersion != null) {\n peer.metadata.set('ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_12__.fromString)(message.protocolVersion));\n }\n await this.peerStore.patch(remotePeer, peer);\n return output;\n }\n}\n/**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\nfunction getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_5__.multiaddr)(addr);\n }\n catch {\n }\n }\n}\n//# sourceMappingURL=identify.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/identify.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/index.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/index.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Message: () => (/* binding */ Message),\n/* harmony export */ identifyService: () => (/* binding */ identifyService),\n/* harmony export */ multicodecs: () => (/* binding */ multicodecs)\n/* harmony export */ });\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _identify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./identify.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/identify.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/pb/message.js\");\n\n\n\n/**\n * The protocols the IdentifyService supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_0__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_0__.MULTICODEC_IDENTIFY_PUSH\n};\nconst Message = { Identify: _pb_message_js__WEBPACK_IMPORTED_MODULE_2__.Identify };\nfunction identifyService(init = {}) {\n return (components) => new _identify_js__WEBPACK_IMPORTED_MODULE_1__.DefaultIdentifyService(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/pb/message.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/pb/message.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Identify: () => (/* binding */ Identify)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/protons-runtime/dist/src/index.js\");\n/* eslint-disable import/export */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\nvar Identify;\n(function (Identify) {\n let _codec;\n Identify.codec = () => {\n if (_codec == null) {\n _codec = (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.message)((obj, w, opts = {}) => {\n if (opts.lengthDelimited !== false) {\n w.fork();\n }\n if (obj.protocolVersion != null) {\n w.uint32(42);\n w.string(obj.protocolVersion);\n }\n if (obj.agentVersion != null) {\n w.uint32(50);\n w.string(obj.agentVersion);\n }\n if (obj.publicKey != null) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if (obj.listenAddrs != null) {\n for (const value of obj.listenAddrs) {\n w.uint32(18);\n w.bytes(value);\n }\n }\n if (obj.observedAddr != null) {\n w.uint32(34);\n w.bytes(obj.observedAddr);\n }\n if (obj.protocols != null) {\n for (const value of obj.protocols) {\n w.uint32(26);\n w.string(value);\n }\n }\n if (obj.signedPeerRecord != null) {\n w.uint32(66);\n w.bytes(obj.signedPeerRecord);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n listenAddrs: [],\n protocols: []\n };\n const end = length == null ? reader.len : reader.pos + length;\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 5:\n obj.protocolVersion = reader.string();\n break;\n case 6:\n obj.agentVersion = reader.string();\n break;\n case 1:\n obj.publicKey = reader.bytes();\n break;\n case 2:\n obj.listenAddrs.push(reader.bytes());\n break;\n case 4:\n obj.observedAddr = reader.bytes();\n break;\n case 3:\n obj.protocols.push(reader.string());\n break;\n case 8:\n obj.signedPeerRecord = reader.bytes();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n Identify.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Identify.codec());\n };\n Identify.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Identify.codec());\n };\n})(Identify || (Identify = {}));\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/identify/pb/message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/index.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/index.js ***! - \**********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createLibp2p: () => (/* binding */ createLibp2p)\n/* harmony export */ });\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/libp2p.js\");\n/**\n * @packageDocumentation\n *\n * Use the `createLibp2p` function to create a libp2p node.\n *\n * @example\n *\n * ```typescript\n * import { createLibp2p } from 'libp2p'\n *\n * const node = await createLibp2p({\n * // ...other options\n * })\n * ```\n */\n\n/**\n * Returns a new instance of the Libp2p interface, generating a new PeerId\n * if one is not passed as part of the options.\n *\n * The node will be started unless `start: false` is passed as an option.\n *\n * @example\n *\n * ```js\n * import { createLibp2p } from 'libp2p'\n * import { tcp } from '@libp2p/tcp'\n * import { mplex } from '@libp2p/mplex'\n * import { noise } from '@chainsafe/libp2p-noise'\n * import { yamux } from '@chainsafe/libp2p-yamux'\n *\n * // specify options\n * const options = {\n * transports: [tcp()],\n * streamMuxers: [yamux(), mplex()],\n * connectionEncryption: [noise()]\n * }\n *\n * // create libp2p\n * const libp2p = await createLibp2p(options)\n * ```\n */\nasync function createLibp2p(options) {\n const node = await (0,_libp2p_js__WEBPACK_IMPORTED_MODULE_0__.createLibp2pNode)(options);\n if (options.start !== false) {\n await node.start();\n }\n return node;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/libp2p.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/libp2p.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Libp2pNode: () => (/* binding */ Libp2pNode),\n/* harmony export */ createLibp2pNode: () => (/* binding */ createLibp2pNode)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface_content_routing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface-content-routing */ \"./node_modules/@libp2p/interface-content-routing/dist/src/index.js\");\n/* harmony import */ var _libp2p_interface_peer_discovery__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface-peer-discovery */ \"./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js\");\n/* harmony import */ var _libp2p_interface_peer_routing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-peer-routing */ \"./node_modules/@libp2p/interface-peer-routing/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_keychain__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/keychain */ \"./node_modules/@libp2p/keychain/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@waku/sdk/node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/@waku/sdk/node_modules/datastore-core/dist/src/memory.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./components.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_connection_gater_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./config/connection-gater.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config/connection-gater.browser.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./config.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _content_routing_index_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./content-routing/index.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/upgrader.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_8__.logger)('libp2p');\nclass Libp2pNode extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.EventEmitter {\n peerId;\n peerStore;\n contentRouting;\n peerRouting;\n keychain;\n metrics;\n services;\n components;\n #started;\n constructor(init) {\n super();\n // event bus - components can listen to this emitter to be notified of system events\n // and also cause them to be emitted\n const events = new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.EventEmitter();\n const originalDispatch = events.dispatchEvent.bind(events);\n events.dispatchEvent = (evt) => {\n const internalResult = originalDispatch(evt);\n const externalResult = this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(evt.type, { detail: evt.detail }));\n return internalResult || externalResult;\n };\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, events);\n }\n catch { }\n this.#started = false;\n this.peerId = init.peerId;\n // @ts-expect-error {} may not be of type T\n this.services = {};\n const components = this.components = (0,_components_js__WEBPACK_IMPORTED_MODULE_19__.defaultComponents)({\n peerId: init.peerId,\n events,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_14__.MemoryDatastore(),\n connectionGater: (0,_config_connection_gater_js__WEBPACK_IMPORTED_MODULE_20__.connectionGater)(init.connectionGater)\n });\n this.peerStore = this.configureComponent('peerStore', new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_12__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n }));\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.configureComponent('metrics', init.metrics(this.components));\n }\n components.events.addEventListener('peer:update', evt => {\n // if there was no peer previously in the peer store this is a new peer\n if (evt.detail.previous == null) {\n this.safeDispatchEvent('peer:discovery', { detail: evt.detail.peer });\n }\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.configureComponent('connectionProtector', init.connectionProtector(components));\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_28__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map((fn, index) => this.configureComponent(`connection-encryption-${index}`, fn(this.components))),\n muxers: (init.streamMuxers ?? []).map((fn, index) => this.configureComponent(`stream-muxers-${index}`, fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Setup the transport manager\n this.configureComponent('transportManager', new _transport_manager_js__WEBPACK_IMPORTED_MODULE_27__.DefaultTransportManager(this.components, init.transportManager));\n // Create the Connection Manager\n this.configureComponent('connectionManager', new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_22__.DefaultConnectionManager(this.components, init.connectionManager));\n // Create the Registrar\n this.configureComponent('registrar', new _registrar_js__WEBPACK_IMPORTED_MODULE_26__.DefaultRegistrar(this.components));\n // Addresses {listen, announce, noAnnounce}\n this.configureComponent('addressManager', new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_18__.DefaultAddressManager(this.components, init.addresses));\n // Create keychain\n const keychainOpts = _libp2p_keychain__WEBPACK_IMPORTED_MODULE_7__.DefaultKeyChain.generateOptions();\n this.keychain = this.configureComponent('keyChain', new _libp2p_keychain__WEBPACK_IMPORTED_MODULE_7__.DefaultKeyChain(this.components, {\n ...keychainOpts,\n ...init.keychain\n }));\n // Peer routers\n const peerRouters = (init.peerRouters ?? []).map((fn, index) => this.configureComponent(`peer-router-${index}`, fn(this.components)));\n this.peerRouting = this.components.peerRouting = this.configureComponent('peerRouting', new _peer_routing_js__WEBPACK_IMPORTED_MODULE_25__.DefaultPeerRouting(this.components, {\n routers: peerRouters\n }));\n // Content routers\n const contentRouters = (init.contentRouters ?? []).map((fn, index) => this.configureComponent(`content-router-${index}`, fn(this.components)));\n this.contentRouting = this.components.contentRouting = this.configureComponent('contentRouting', new _content_routing_index_js__WEBPACK_IMPORTED_MODULE_23__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n (init.peerDiscovery ?? []).forEach((fn, index) => {\n const service = this.configureComponent(`peer-discovery-${index}`, fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.#onDiscoveryPeer(evt);\n });\n });\n // Transport modules\n init.transports.forEach((fn, index) => {\n this.components.transportManager.add(this.configureComponent(`transport-${index}`, fn(this.components)));\n });\n // User defined modules\n if (init.services != null) {\n for (const name of Object.keys(init.services)) {\n const createService = init.services[name];\n const service = createService(this.components);\n if (service == null) {\n log.error('service factory %s returned null or undefined instance', name);\n continue;\n }\n this.services[name] = service;\n this.configureComponent(name, service);\n if (service[_libp2p_interface_content_routing__WEBPACK_IMPORTED_MODULE_2__.contentRouting] != null) {\n log('registering service %s for content routing', name);\n contentRouters.push(service[_libp2p_interface_content_routing__WEBPACK_IMPORTED_MODULE_2__.contentRouting]);\n }\n if (service[_libp2p_interface_peer_routing__WEBPACK_IMPORTED_MODULE_4__.peerRouting] != null) {\n log('registering service %s for peer routing', name);\n peerRouters.push(service[_libp2p_interface_peer_routing__WEBPACK_IMPORTED_MODULE_4__.peerRouting]);\n }\n if (service[_libp2p_interface_peer_discovery__WEBPACK_IMPORTED_MODULE_3__.peerDiscovery] != null) {\n log('registering service %s for peer discovery', name);\n service[_libp2p_interface_peer_discovery__WEBPACK_IMPORTED_MODULE_3__.peerDiscovery].addEventListener('peer', (evt) => {\n this.#onDiscoveryPeer(evt);\n });\n }\n }\n }\n }\n configureComponent(name, component) {\n if (component == null) {\n log.error('component %s was null or undefined', name);\n }\n this.components[name] = component;\n return component;\n }\n /**\n * Starts the libp2p node and all its subsystems\n */\n async start() {\n if (this.#started) {\n return;\n }\n this.#started = true;\n log('libp2p is starting');\n const keys = await this.keychain.listKeys();\n if (keys.find(key => key.name === 'self') == null) {\n log('importing self key into keychain');\n await this.keychain.importPeer('self', this.components.peerId);\n }\n try {\n await this.components.beforeStart?.();\n await this.components.start();\n await this.components.afterStart?.();\n this.safeDispatchEvent('start', { detail: this });\n log('libp2p has started');\n }\n catch (err) {\n log.error('An error occurred starting libp2p', err);\n await this.stop();\n throw err;\n }\n }\n /**\n * Stop the libp2p node by closing its listeners and open connections\n */\n async stop() {\n if (!this.#started) {\n return;\n }\n log('libp2p is stopping');\n this.#started = false;\n await this.components.beforeStop?.();\n await this.components.stop();\n await this.components.afterStop?.();\n this.safeDispatchEvent('stop', { detail: this });\n log('libp2p has stopped');\n }\n isStarted() {\n return this.#started;\n }\n getConnections(peerId) {\n return this.components.connectionManager.getConnections(peerId);\n }\n getDialQueue() {\n return this.components.connectionManager.getDialQueue();\n }\n getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_9__.PeerSet();\n for (const conn of this.components.connectionManager.getConnections()) {\n peerSet.add(conn.remotePeer);\n }\n return Array.from(peerSet);\n }\n async dial(peer, options = {}) {\n return this.components.connectionManager.openConnection(peer, options);\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_5__.CodeError('no protocols were provided to open a stream', _errors_js__WEBPACK_IMPORTED_MODULE_24__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_5__.CodeError('no protocols were provided to open a stream', _errors_js__WEBPACK_IMPORTED_MODULE_24__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return connection.newStream(protocols, options);\n }\n getMultiaddrs() {\n return this.components.addressManager.getAddresses();\n }\n getProtocols() {\n return this.components.registrar.getProtocols();\n }\n async hangUp(peer) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_13__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_10__.peerIdFromString)(peer.getPeerId() ?? '');\n }\n await this.components.connectionManager.closeConnections(peer);\n }\n /**\n * Get the public key for the given peer id\n */\n async getPublicKey(peer, options = {}) {\n log('getPublicKey %p', peer);\n if (peer.publicKey != null) {\n return peer.publicKey;\n }\n const peerInfo = await this.peerStore.get(peer);\n if (peerInfo.id.publicKey != null) {\n return peerInfo.id.publicKey;\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_16__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_17__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search any available content routing methods\n const bytes = await this.contentRouting.get(peerKey, options);\n // ensure the returned key is valid\n (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_1__.unmarshalPublicKey)(bytes);\n await this.peerStore.patch(peer, {\n publicKey: bytes\n });\n return bytes;\n }\n async handle(protocols, handler, options) {\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n await Promise.all(protocols.map(async (protocol) => {\n await this.components.registrar.handle(protocol, handler, options);\n }));\n }\n async unhandle(protocols) {\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n await Promise.all(protocols.map(async (protocol) => {\n await this.components.registrar.unhandle(protocol);\n }));\n }\n async register(protocol, topology) {\n return this.components.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.components.registrar.unregister(id);\n }\n /**\n * Called whenever peer discovery services emit `peer` events and adds peers\n * to the peer store.\n */\n #onDiscoveryPeer(evt) {\n const { detail: peer } = evt;\n if (peer.id.toString() === this.peerId.toString()) {\n log.error(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_24__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n void this.components.peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs,\n protocols: peer.protocols\n })\n .catch(err => { log.error(err); });\n }\n}\n/**\n * Returns a new Libp2pNode instance - this exposes more of the internals than the\n * libp2p interface and is useful for testing and debugging.\n */\nasync function createLibp2pNode(options) {\n if (options.peerId == null) {\n const datastore = options.datastore;\n if (datastore != null) {\n try {\n // try load the peer id from the keychain\n const keyChain = new _libp2p_keychain__WEBPACK_IMPORTED_MODULE_7__.DefaultKeyChain({\n datastore\n }, (0,merge_options__WEBPACK_IMPORTED_MODULE_15__[\"default\"])(_libp2p_keychain__WEBPACK_IMPORTED_MODULE_7__.DefaultKeyChain.generateOptions(), options.keychain));\n options.peerId = await keyChain.exportPeerId('self');\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n throw err;\n }\n }\n }\n }\n if (options.peerId == null) {\n // no peer id in the keychain, create a new peer id\n options.peerId = await (0,_libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_11__.createEd25519PeerId)();\n }\n return new Libp2pNode((0,_config_js__WEBPACK_IMPORTED_MODULE_21__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/libp2p.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/peer-routing.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/peer-routing.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPeerRouting: () => (/* binding */ DefaultPeerRouting)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-filter */ \"./node_modules/@waku/sdk/node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-first */ \"./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-merge */ \"./node_modules/@waku/sdk/node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _content_routing_utils_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./content-routing/utils.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/content-routing/utils.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:peer-routing');\nclass DefaultPeerRouting {\n components;\n routers;\n constructor(components, init) {\n this.components = components;\n this.routers = init.routers ?? [];\n }\n /**\n * Iterates over all peer routers in parallel to find the given peer\n */\n async findPeer(id, options) {\n if (this.routers.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('No peer routers available', _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n if (id.toString() === this.components.peerId.toString()) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('Should not try to find self', _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_FIND_SELF);\n }\n const output = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(...this.routers.map(router => (async function* () {\n try {\n yield await router.findPeer(id, options);\n }\n catch (err) {\n log.error(err);\n }\n })())), (source) => (0,it_filter__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(source, Boolean), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_6__.storeAddresses)(source, this.components.peerStore), async (source) => (0,it_first__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(source));\n if (output != null) {\n return output;\n }\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.NOT_FOUND, _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NOT_FOUND);\n }\n /**\n * Attempt to find the closest peers on the network to the given key\n */\n async *getClosestPeers(key, options) {\n if (this.routers.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('No peer routers available', _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n yield* (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(...this.routers.map(router => router.getClosestPeers(key, options))), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_6__.storeAddresses)(source, this.components.peerStore), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_6__.uniquePeers)(source), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_6__.requirePeers)(source));\n }\n}\n//# sourceMappingURL=peer-routing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/peer-routing.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/constants.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/constants.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_INBOUND_STREAMS: () => (/* binding */ MAX_INBOUND_STREAMS),\n/* harmony export */ MAX_OUTBOUND_STREAMS: () => (/* binding */ MAX_OUTBOUND_STREAMS),\n/* harmony export */ PING_LENGTH: () => (/* binding */ PING_LENGTH),\n/* harmony export */ PROTOCOL: () => (/* binding */ PROTOCOL),\n/* harmony export */ PROTOCOL_NAME: () => (/* binding */ PROTOCOL_NAME),\n/* harmony export */ PROTOCOL_PREFIX: () => (/* binding */ PROTOCOL_PREFIX),\n/* harmony export */ PROTOCOL_VERSION: () => (/* binding */ PROTOCOL_VERSION),\n/* harmony export */ TIMEOUT: () => (/* binding */ TIMEOUT)\n/* harmony export */ });\nconst PROTOCOL = '/ipfs/ping/1.0.0';\nconst PING_LENGTH = 32;\nconst PROTOCOL_VERSION = '1.0.0';\nconst PROTOCOL_NAME = 'ping';\nconst PROTOCOL_PREFIX = 'ipfs';\nconst TIMEOUT = 10000;\n// See https://github.com/libp2p/specs/blob/d4b5fb0152a6bb86cfd9ea/ping/ping.md?plain=1#L38-L43\n// The dialing peer MUST NOT keep more than one outbound stream for the ping protocol per peer.\n// The listening peer SHOULD accept at most two streams per peer since cross-stream behavior is\n// non-linear and stream writes occur asynchronously. The listening peer may perceive the\n// dialing peer closing and opening the wrong streams (for instance, closing stream B and\n// opening stream A even though the dialing peer is opening stream B and closing stream A).\nconst MAX_INBOUND_STREAMS = 2;\nconst MAX_OUTBOUND_STREAMS = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/index.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/index.js ***! - \***************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pingService: () => (/* binding */ pingService)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-first */ \"./node_modules/@waku/sdk/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@waku/sdk/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/constants.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.logger)('libp2p:ping');\nclass DefaultPingService {\n protocol;\n components;\n started;\n timeout;\n maxInboundStreams;\n maxOutboundStreams;\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.protocol = `/${init.protocolPrefix ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.PROTOCOL_PREFIX}/${_constants_js__WEBPACK_IMPORTED_MODULE_10__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_10__.PROTOCOL_VERSION}`;\n this.timeout = init.timeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.TIMEOUT;\n this.maxInboundStreams = init.maxInboundStreams ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_INBOUND_STREAMS;\n this.maxOutboundStreams = init.maxOutboundStreams ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_OUTBOUND_STREAMS;\n }\n async start() {\n await this.components.registrar.handle(this.protocol, this.handleMessage, {\n maxInboundStreams: this.maxInboundStreams,\n maxOutboundStreams: this.maxOutboundStreams\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.protocol);\n this.started = false;\n }\n isStarted() {\n return this.started;\n }\n /**\n * A handler to register with Libp2p to process ping messages\n */\n handleMessage(data) {\n const { stream } = data;\n void (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)(stream, stream)\n .catch(err => {\n log.error(err);\n });\n }\n /**\n * Ping a given peer and wait for its response, getting the operation latency.\n *\n * @param {PeerId|Multiaddr} peer\n * @returns {Promise}\n */\n async ping(peer, options = {}) {\n log('dialing %s to %p', this.protocol, peer);\n const start = Date.now();\n const data = (0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_1__.randomBytes)(_constants_js__WEBPACK_IMPORTED_MODULE_10__.PING_LENGTH);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let stream;\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_5__.anySignal)([AbortSignal.timeout(this.timeout), options?.signal]);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.protocol], {\n signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_4__.abortableDuplex)(stream, signal);\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)([data], source, async (source) => (0,it_first__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(source));\n const end = Date.now();\n if (result == null || !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_8__.equals)(data, result.subarray())) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('Received wrong ping ack', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_WRONG_PING_ACK);\n }\n return end - start;\n }\n finally {\n if (stream != null) {\n stream.close();\n }\n signal.clear();\n }\n }\n}\nfunction pingService(init = {}) {\n return (components) => new DefaultPingService(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/ping/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/registrar.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/registrar.js ***! - \**************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_MAX_INBOUND_STREAMS: () => (/* binding */ DEFAULT_MAX_INBOUND_STREAMS),\n/* harmony export */ DEFAULT_MAX_OUTBOUND_STREAMS: () => (/* binding */ DEFAULT_MAX_OUTBOUND_STREAMS),\n/* harmony export */ DefaultRegistrar: () => (/* binding */ DefaultRegistrar)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-registrar */ \"./node_modules/@libp2p/interface-registrar/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:registrar');\nconst DEFAULT_MAX_INBOUND_STREAMS = 32;\nconst DEFAULT_MAX_OUTBOUND_STREAMS = 64;\n/**\n * Responsible for notifying registered protocols of events in the network.\n */\nclass DefaultRegistrar {\n topologies;\n handlers;\n components;\n constructor(components) {\n this.topologies = new Map();\n this.handlers = new Map();\n this.components = components;\n this._onDisconnect = this._onDisconnect.bind(this);\n this._onPeerUpdate = this._onPeerUpdate.bind(this);\n this._onConnect = this._onConnect.bind(this);\n this.components.events.addEventListener('peer:disconnect', this._onDisconnect);\n this.components.events.addEventListener('peer:connect', this._onConnect);\n this.components.events.addEventListener('peer:update', this._onPeerUpdate);\n }\n getProtocols() {\n return Array.from(new Set([\n ...this.handlers.keys()\n ])).sort();\n }\n getHandler(protocol) {\n const handler = this.handlers.get(protocol);\n if (handler == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`No handler registered for protocol ${protocol}`, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NO_HANDLER_FOR_PROTOCOL);\n }\n return handler;\n }\n getTopologies(protocol) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n return [];\n }\n return [\n ...topologies.values()\n ];\n }\n /**\n * Registers the `handler` for each protocol\n */\n async handle(protocol, handler, opts) {\n if (this.handlers.has(protocol)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`Handler already registered for protocol ${protocol}`, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);\n }\n const options = merge_options__WEBPACK_IMPORTED_MODULE_3__[\"default\"].bind({ ignoreUndefined: true })({\n maxInboundStreams: DEFAULT_MAX_INBOUND_STREAMS,\n maxOutboundStreams: DEFAULT_MAX_OUTBOUND_STREAMS\n }, opts);\n this.handlers.set(protocol, {\n handler,\n options\n });\n // Add new protocol to self protocols in the peer store\n await this.components.peerStore.merge(this.components.peerId, {\n protocols: [protocol]\n });\n }\n /**\n * Removes the handler for each protocol. The protocol\n * will no longer be supported on streams.\n */\n async unhandle(protocols) {\n const protocolList = Array.isArray(protocols) ? protocols : [protocols];\n protocolList.forEach(protocol => {\n this.handlers.delete(protocol);\n });\n // Update self protocols in the peer store\n await this.components.peerStore.patch(this.components.peerId, {\n protocols: protocolList\n });\n }\n /**\n * Register handlers for a set of multicodecs given\n */\n async register(protocol, topology) {\n if (!(0,_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.isTopology)(topology)) {\n log.error('topology must be an instance of interfaces/topology');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('topology must be an instance of interfaces/topology', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_PARAMETERS);\n }\n // Create topology\n const id = `${(Math.random() * 1e9).toString(36)}${Date.now()}`;\n let topologies = this.topologies.get(protocol);\n if (topologies == null) {\n topologies = new Map();\n this.topologies.set(protocol, topologies);\n }\n topologies.set(id, topology);\n // Set registrar\n await topology.setRegistrar(this);\n return id;\n }\n /**\n * Unregister topology\n */\n unregister(id) {\n for (const [protocol, topologies] of this.topologies.entries()) {\n if (topologies.has(id)) {\n topologies.delete(id);\n if (topologies.size === 0) {\n this.topologies.delete(protocol);\n }\n }\n }\n }\n /**\n * Remove a disconnected peer from the record\n */\n _onDisconnect(evt) {\n const remotePeer = evt.detail;\n void this.components.peerStore.get(remotePeer)\n .then(peer => {\n for (const protocol of peer.protocols) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n topology.onDisconnect(remotePeer);\n }\n }\n })\n .catch(err => {\n if (err.code === _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NOT_FOUND) {\n // peer has not completed identify so they are not in the peer store\n return;\n }\n log.error('could not inform topologies of disconnecting peer %p', remotePeer, err);\n });\n }\n /**\n * On peer connected if we already have their protocols. Usually used for reconnects\n * as change:protocols event won't be emitted due to identical protocols.\n */\n _onConnect(evt) {\n const remotePeer = evt.detail;\n void this.components.peerStore.get(remotePeer)\n .then(peer => {\n const connection = this.components.connectionManager.getConnections(peer.id)[0];\n if (connection == null) {\n log('peer %p connected but the connection manager did not have a connection', peer);\n // peer disconnected while we were loading their details from the peer store\n return;\n }\n for (const protocol of peer.protocols) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n topology.onConnect(remotePeer, connection);\n }\n }\n })\n .catch(err => {\n if (err.code === _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NOT_FOUND) {\n // peer has not completed identify so they are not in the peer store\n return;\n }\n log.error('could not inform topologies of connecting peer %p', remotePeer, err);\n });\n }\n /**\n * Check if a new peer support the multicodecs for this topology\n */\n _onPeerUpdate(evt) {\n const { peer, previous } = evt.detail;\n const removed = (previous?.protocols ?? []).filter(protocol => !peer.protocols.includes(protocol));\n const added = peer.protocols.filter(protocol => !(previous?.protocols ?? []).includes(protocol));\n for (const protocol of removed) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n topology.onDisconnect(peer.id);\n }\n }\n for (const protocol of added) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n const connection = this.components.connectionManager.getConnections(peer.id)[0];\n if (connection == null) {\n continue;\n }\n topology.onConnect(peer.id, connection);\n }\n }\n }\n}\n//# sourceMappingURL=registrar.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/registrar.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/transport-manager.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/transport-manager.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultTransportManager: () => (/* binding */ DefaultTransportManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/tracked-map */ \"./node_modules/@libp2p/tracked-map/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:transports');\nclass DefaultTransportManager {\n components;\n transports;\n listeners;\n faultTolerance;\n started;\n constructor(components, init = {}) {\n this.components = components;\n this.started = false;\n this.transports = new Map();\n this.listeners = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_3__.trackedMap)({\n name: 'libp2p_transport_manager_listeners',\n metrics: this.components.metrics\n });\n this.faultTolerance = init.faultTolerance ?? _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__.FaultTolerance.FATAL_ALL;\n }\n /**\n * Adds a `Transport` to the manager\n */\n add(transport) {\n const tag = transport[Symbol.toStringTag];\n if (tag == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Transport must have a valid tag', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_KEY);\n }\n if (this.transports.has(tag)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`There is already a transport with the tag ${tag}`, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_DUPLICATE_TRANSPORT);\n }\n log('adding transport %s', tag);\n this.transports.set(tag, transport);\n if (!this.listeners.has(tag)) {\n this.listeners.set(tag, []);\n }\n }\n isStarted() {\n return this.started;\n }\n start() {\n this.started = true;\n }\n async afterStart() {\n // Listen on the provided transports for the provided addresses\n const addrs = this.components.addressManager.getListenAddrs();\n await this.listen(addrs);\n }\n /**\n * Stops all listeners\n */\n async stop() {\n const tasks = [];\n for (const [key, listeners] of this.listeners) {\n log('closing listeners for %s', key);\n while (listeners.length > 0) {\n const listener = listeners.pop();\n if (listener == null) {\n continue;\n }\n tasks.push(listener.close());\n }\n }\n await Promise.all(tasks);\n log('all listeners closed');\n for (const key of this.listeners.keys()) {\n this.listeners.set(key, []);\n }\n this.started = false;\n }\n /**\n * Dials the given Multiaddr over it's supported transport\n */\n async dial(ma, options) {\n const transport = this.transportForMultiaddr(ma);\n if (transport == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`No transport available for address ${String(ma)}`, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_TRANSPORT_UNAVAILABLE);\n }\n try {\n return await transport.dial(ma, {\n ...options,\n upgrader: this.components.upgrader\n });\n }\n catch (err) {\n if (err.code == null) {\n err.code = _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_TRANSPORT_DIAL_FAILED;\n }\n throw err;\n }\n }\n /**\n * Returns all Multiaddr's the listeners are using\n */\n getAddrs() {\n let addrs = [];\n for (const listeners of this.listeners.values()) {\n for (const listener of listeners) {\n addrs = [...addrs, ...listener.getAddrs()];\n }\n }\n return addrs;\n }\n /**\n * Returns all the transports instances\n */\n getTransports() {\n return Array.of(...this.transports.values());\n }\n /**\n * Returns all the listener instances\n */\n getListeners() {\n return Array.of(...this.listeners.values()).flat();\n }\n /**\n * Finds a transport that matches the given Multiaddr\n */\n transportForMultiaddr(ma) {\n for (const transport of this.transports.values()) {\n const addrs = transport.filter([ma]);\n if (addrs.length > 0) {\n return transport;\n }\n }\n }\n /**\n * Starts listeners for each listen Multiaddr\n */\n async listen(addrs) {\n if (addrs == null || addrs.length === 0) {\n log('no addresses were provided for listening, this node is dial only');\n return;\n }\n const couldNotListen = [];\n for (const [key, transport] of this.transports.entries()) {\n const supportedAddrs = transport.filter(addrs);\n const tasks = [];\n // For each supported multiaddr, create a listener\n for (const addr of supportedAddrs) {\n log('creating listener for %s on %s', key, addr);\n const listener = transport.createListener({\n upgrader: this.components.upgrader\n });\n let listeners = this.listeners.get(key) ?? [];\n if (listeners == null) {\n listeners = [];\n this.listeners.set(key, listeners);\n }\n listeners.push(listener);\n // Track listen/close events\n listener.addEventListener('listening', () => {\n this.components.events.safeDispatchEvent('transport:listening', {\n detail: listener\n });\n });\n listener.addEventListener('close', () => {\n const index = listeners.findIndex(l => l === listener);\n // remove the listener\n listeners.splice(index, 1);\n this.components.events.safeDispatchEvent('transport:close', {\n detail: listener\n });\n });\n // We need to attempt to listen on everything\n tasks.push(listener.listen(addr));\n }\n // Keep track of transports we had no addresses for\n if (tasks.length === 0) {\n couldNotListen.push(key);\n continue;\n }\n const results = await Promise.allSettled(tasks);\n // If we are listening on at least 1 address, succeed.\n // TODO: we should look at adding a retry (`p-retry`) here to better support\n // listening on remote addresses as they may be offline. We could then potentially\n // just wait for any (`p-any`) listener to succeed on each transport before returning\n const isListening = results.find(r => r.status === 'fulfilled');\n if ((isListening == null) && this.faultTolerance !== _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__.FaultTolerance.NO_FATAL) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`Transport (${key}) could not listen on any available address`, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NO_VALID_ADDRESSES);\n }\n }\n // If no transports were able to listen, throw an error. This likely\n // means we were given addresses we do not have transports for\n if (couldNotListen.length === this.transports.size) {\n const message = `no valid addresses were provided for transports [${couldNotListen.join(', ')}]`;\n if (this.faultTolerance === _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_0__.FaultTolerance.FATAL_ALL) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(message, _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NO_VALID_ADDRESSES);\n }\n log(`libp2p in dial mode only: ${message}`);\n }\n }\n /**\n * Removes the given transport from the manager.\n * If a transport has any running listeners, they will be closed.\n */\n async remove(key) {\n log('removing %s', key);\n // Close any running listeners\n for (const listener of this.listeners.get(key) ?? []) {\n await listener.close();\n }\n this.transports.delete(key);\n this.listeners.delete(key);\n }\n /**\n * Removes all transports from the manager.\n * If any listeners are running, they will be closed.\n *\n * @async\n */\n async removeAll() {\n const tasks = [];\n for (const key of this.transports.keys()) {\n tasks.push(this.remove(key));\n }\n await Promise.all(tasks);\n }\n}\n//# sourceMappingURL=transport-manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/transport-manager.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/upgrader.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/upgrader.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultUpgrader: () => (/* binding */ DefaultUpgrader)\n/* harmony export */ });\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@waku/sdk/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _connection_manager_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./connection-manager/constants.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/connection-manager/constants.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/registrar.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_2__.logger)('libp2p:upgrader');\nfunction findIncomingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxInboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_10__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar, options = {}) {\n try {\n const { options } = registrar.getHandler(protocol);\n if (options.maxOutboundStreams != null) {\n return options.maxOutboundStreams;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return options.maxOutboundStreams ?? _registrar_js__WEBPACK_IMPORTED_MODULE_10__.DEFAULT_MAX_OUTBOUND_STREAMS;\n}\nfunction countStreams(protocol, direction, connection) {\n let streamCount = 0;\n connection.streams.forEach(stream => {\n if (stream.stat.direction === direction && stream.stat.protocol === protocol) {\n streamCount++;\n }\n });\n return streamCount;\n}\nclass DefaultUpgrader {\n components;\n connectionEncryption;\n muxers;\n inboundUpgradeTimeout;\n events;\n constructor(components, init) {\n this.components = components;\n this.connectionEncryption = new Map();\n init.connectionEncryption.forEach(encrypter => {\n this.connectionEncryption.set(encrypter.protocol, encrypter);\n });\n this.muxers = new Map();\n init.muxers.forEach(muxer => {\n this.muxers.set(muxer.protocol, muxer);\n });\n this.inboundUpgradeTimeout = init.inboundUpgradeTimeout ?? _connection_manager_constants_js__WEBPACK_IMPORTED_MODULE_8__.INBOUND_UPGRADE_TIMEOUT;\n this.events = components.events;\n }\n async shouldBlockConnection(remotePeer, maConn, connectionType) {\n const connectionGater = this.components.connectionGater[connectionType];\n if (connectionGater !== undefined) {\n if (await connectionGater(remotePeer, maConn)) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`The multiaddr connection is blocked by gater.${connectionType}`, _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n }\n /**\n * Upgrades an inbound connection\n */\n async upgradeInbound(maConn, opts) {\n const accept = await this.components.connectionManager.acceptIncomingConnection(maConn);\n if (!accept) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('connection denied', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_6__.anySignal)([AbortSignal.timeout(this.inboundUpgradeTimeout)]);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n try {\n const abortableStream = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_5__.abortableDuplex)(maConn, signal);\n maConn.source = abortableStream.source;\n maConn.sink = abortableStream.sink;\n if ((await this.components.connectionGater.denyInboundConnection?.(maConn)) === true) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('The multiaddr connection is blocked by gater.acceptConnection', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n this.components.metrics?.trackMultiaddrConnection(maConn);\n log('starting the inbound connection upgrade');\n // Protect\n let protectedConn = maConn;\n if (opts?.skipProtection !== true) {\n const protector = this.components.connectionProtector;\n if (protector != null) {\n log('protecting the inbound connection');\n protectedConn = await protector.protect(maConn);\n }\n }\n try {\n // Encrypt the connection\n encryptedConn = protectedConn;\n if (opts?.skipEncryption !== true) {\n ({\n conn: encryptedConn,\n remotePeer,\n protocol: cryptoProtocol\n } = await this._encryptInbound(protectedConn));\n const maConn = {\n ...protectedConn,\n ...encryptedConn\n };\n await this.shouldBlockConnection(remotePeer, maConn, 'denyInboundEncryptedConnection');\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('inbound connection that skipped encryption must have a peer id', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromString)(idStr);\n cryptoProtocol = 'native';\n remotePeer = remotePeerId;\n }\n upgradedConn = encryptedConn;\n if (opts?.muxerFactory != null) {\n muxerFactory = opts.muxerFactory;\n }\n else if (this.muxers.size > 0) {\n // Multiplex the connection\n const multiplexed = await this._multiplexInbound({\n ...protectedConn,\n ...encryptedConn\n }, this.muxers);\n muxerFactory = multiplexed.muxerFactory;\n upgradedConn = multiplexed.stream;\n }\n }\n catch (err) {\n log.error('Failed to upgrade inbound connection', err);\n throw err;\n }\n await this.shouldBlockConnection(remotePeer, maConn, 'denyInboundUpgradedConnection');\n log('Successfully upgraded inbound connection');\n return this._createConnection({\n cryptoProtocol,\n direction: 'inbound',\n maConn,\n upgradedConn,\n muxerFactory,\n remotePeer\n });\n }\n finally {\n this.components.connectionManager.afterUpgradeInbound();\n signal.clear();\n }\n }\n /**\n * Upgrades an outbound connection\n */\n async upgradeOutbound(maConn, opts) {\n const idStr = maConn.remoteAddr.getPeerId();\n let remotePeerId;\n if (idStr != null) {\n remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__.peerIdFromString)(idStr);\n await this.shouldBlockConnection(remotePeerId, maConn, 'denyOutboundConnection');\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let cryptoProtocol;\n let muxerFactory;\n this.components.metrics?.trackMultiaddrConnection(maConn);\n log('Starting the outbound connection upgrade');\n // If the transport natively supports encryption, skip connection\n // protector and encryption\n // Protect\n let protectedConn = maConn;\n if (opts?.skipProtection !== true) {\n const protector = this.components.connectionProtector;\n if (protector != null) {\n protectedConn = await protector.protect(maConn);\n }\n }\n try {\n // Encrypt the connection\n encryptedConn = protectedConn;\n if (opts?.skipEncryption !== true) {\n ({\n conn: encryptedConn,\n remotePeer,\n protocol: cryptoProtocol\n } = await this._encryptOutbound(protectedConn, remotePeerId));\n const maConn = {\n ...protectedConn,\n ...encryptedConn\n };\n await this.shouldBlockConnection(remotePeer, maConn, 'denyOutboundEncryptedConnection');\n }\n else {\n if (remotePeerId == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Encryption was skipped but no peer id was passed', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_INVALID_PEER);\n }\n cryptoProtocol = 'native';\n remotePeer = remotePeerId;\n }\n upgradedConn = encryptedConn;\n if (opts?.muxerFactory != null) {\n muxerFactory = opts.muxerFactory;\n }\n else if (this.muxers.size > 0) {\n // Multiplex the connection\n const multiplexed = await this._multiplexOutbound({\n ...protectedConn,\n ...encryptedConn\n }, this.muxers);\n muxerFactory = multiplexed.muxerFactory;\n upgradedConn = multiplexed.stream;\n }\n }\n catch (err) {\n log.error('Failed to upgrade outbound connection', err);\n await maConn.close(err);\n throw err;\n }\n await this.shouldBlockConnection(remotePeer, maConn, 'denyOutboundUpgradedConnection');\n log('Successfully upgraded outbound connection');\n return this._createConnection({\n cryptoProtocol,\n direction: 'outbound',\n maConn,\n upgradedConn,\n muxerFactory,\n remotePeer\n });\n }\n /**\n * A convenience method for generating a new `Connection`\n */\n _createConnection(opts) {\n const { cryptoProtocol, direction, maConn, upgradedConn, remotePeer, muxerFactory } = opts;\n let muxer;\n let newStream;\n let connection; // eslint-disable-line prefer-const\n if (muxerFactory != null) {\n // Create the muxer\n muxer = muxerFactory.createStreamMuxer({\n direction,\n // Run anytime a remote stream is created\n onIncomingStream: muxedStream => {\n if (connection == null) {\n return;\n }\n void Promise.resolve()\n .then(async () => {\n const protocols = this.components.registrar.getProtocols();\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.handle(muxedStream, protocols);\n log('%s: incoming stream opened on %s', direction, protocol);\n if (connection == null) {\n return;\n }\n const incomingLimit = findIncomingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'inbound', connection);\n if (streamCount === incomingLimit) {\n const err = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`, _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);\n muxedStream.abort(err);\n throw err;\n }\n // after the handshake the returned stream can have early data so override\n // the souce/sink\n muxedStream.source = stream.source;\n muxedStream.sink = stream.sink;\n muxedStream.stat.protocol = protocol;\n // If a protocol stream has been successfully negotiated and is to be passed to the application,\n // the peerstore should ensure that the peer is registered with that protocol\n await this.components.peerStore.merge(remotePeer, {\n protocols: [protocol]\n });\n connection.addStream(muxedStream);\n this.components.metrics?.trackProtocolStream(muxedStream, connection);\n this._onStream({ connection, stream: muxedStream, protocol });\n })\n .catch(err => {\n log.error(err);\n if (muxedStream.stat.timeline.close == null) {\n muxedStream.close();\n }\n });\n },\n // Run anytime a stream closes\n onStreamEnd: muxedStream => {\n connection?.removeStream(muxedStream.id);\n }\n });\n newStream = async (protocols, options = {}) => {\n if (muxer == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('Stream is not multiplexed', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_MUXER_UNAVAILABLE);\n }\n log('%s: starting new stream on %s', direction, protocols);\n const muxedStream = await muxer.newStream();\n try {\n if (options.signal == null) {\n log('No abort signal was passed while trying to negotiate protocols %s falling back to default timeout', protocols);\n options.signal = AbortSignal.timeout(30000);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_0__.setMaxListeners)?.(Infinity, options.signal);\n }\n catch { }\n }\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.select(muxedStream, protocols, options);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar, options);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount >= outgoingLimit) {\n const err = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`, _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);\n muxedStream.abort(err);\n throw err;\n }\n // If a protocol stream has been successfully negotiated and is to be passed to the application,\n // the peerstore should ensure that the peer is registered with that protocol\n await this.components.peerStore.merge(remotePeer, {\n protocols: [protocol]\n });\n // after the handshake the returned stream can have early data so override\n // the souce/sink\n muxedStream.source = stream.source;\n muxedStream.sink = stream.sink;\n muxedStream.stat.protocol = protocol;\n this.components.metrics?.trackProtocolStream(muxedStream, connection);\n return muxedStream;\n }\n catch (err) {\n log.error('could not create new stream', err);\n if (muxedStream.stat.timeline.close == null) {\n muxedStream.close();\n }\n if (err.code != null) {\n throw err;\n }\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n };\n // Pipe all data through the muxer\n void Promise.all([\n muxer.sink(upgradedConn.source),\n upgradedConn.sink(muxer.source)\n ]).catch(err => {\n log.error(err);\n });\n }\n const _timeline = maConn.timeline;\n maConn.timeline = new Proxy(_timeline, {\n set: (...args) => {\n if (connection != null && args[1] === 'close' && args[2] != null && _timeline.close == null) {\n // Wait for close to finish before notifying of the closure\n (async () => {\n try {\n if (connection.stat.status === 'OPEN') {\n await connection.close();\n }\n }\n catch (err) {\n log.error(err);\n }\n finally {\n this.events.safeDispatchEvent('connection:close', {\n detail: connection\n });\n }\n })().catch(err => {\n log.error(err);\n });\n }\n return Reflect.set(...args);\n }\n });\n maConn.timeline.upgraded = Date.now();\n const errConnectionNotMultiplexed = () => {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('connection is not multiplexed', _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_7__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer,\n stat: {\n status: 'OPEN',\n direction,\n timeline: maConn.timeline,\n multiplexer: muxer?.protocol,\n encryption: cryptoProtocol\n },\n newStream: newStream ?? errConnectionNotMultiplexed,\n getStreams: () => { if (muxer != null) {\n return muxer.streams;\n }\n else {\n return errConnectionNotMultiplexed();\n } },\n close: async () => {\n await maConn.close();\n // Ensure remaining streams are closed\n if (muxer != null) {\n muxer.close();\n }\n }\n });\n this.events.safeDispatchEvent('connection:open', {\n detail: connection\n });\n return connection;\n }\n /**\n * Routes incoming streams to the correct handler\n */\n _onStream(opts) {\n const { connection, stream, protocol } = opts;\n const { handler } = this.components.registrar.getHandler(protocol);\n handler({ connection, stream });\n }\n /**\n * Attempts to encrypt the incoming `connection` with the provided `cryptos`\n */\n async _encryptInbound(connection) {\n const protocols = Array.from(this.connectionEncryption.keys());\n log('handling inbound crypto protocol selection', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.handle(connection, protocols, {\n writeBytes: true\n });\n const encrypter = this.connectionEncryption.get(protocol);\n if (encrypter == null) {\n throw new Error(`no crypto module found for ${protocol}`);\n }\n log('encrypting inbound connection...');\n return {\n ...await encrypter.secureInbound(this.components.peerId, stream),\n protocol\n };\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_ENCRYPTION_FAILED);\n }\n }\n /**\n * Attempts to encrypt the given `connection` with the provided connection encrypters.\n * The first `ConnectionEncrypter` module to succeed will be used\n */\n async _encryptOutbound(connection, remotePeerId) {\n const protocols = Array.from(this.connectionEncryption.keys());\n log('selecting outbound crypto protocol', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.select(connection, protocols, {\n writeBytes: true\n });\n const encrypter = this.connectionEncryption.get(protocol);\n if (encrypter == null) {\n throw new Error(`no crypto module found for ${protocol}`);\n }\n log('encrypting outbound connection to %p', remotePeerId);\n return {\n ...await encrypter.secureOutbound(this.components.peerId, stream, remotePeerId),\n protocol\n };\n }\n catch (err) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_ENCRYPTION_FAILED);\n }\n }\n /**\n * Selects one of the given muxers via multistream-select. That\n * muxer will be used for all future streams on the connection.\n */\n async _multiplexOutbound(connection, muxers) {\n const protocols = Array.from(muxers.keys());\n log('outbound selecting muxer %s', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.select(connection, protocols, {\n writeBytes: true\n });\n log('%s selected as muxer protocol', protocol);\n const muxerFactory = muxers.get(protocol);\n return { stream, muxerFactory };\n }\n catch (err) {\n log.error('error multiplexing outbound stream', err);\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n /**\n * Registers support for one of the given muxers via multistream-select. The\n * selected muxer will be used for all future streams on the connection.\n */\n async _multiplexInbound(connection, muxers) {\n const protocols = Array.from(muxers.keys());\n log('inbound handling muxers %s', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_3__.handle(connection, protocols, {\n writeBytes: true\n });\n const muxerFactory = muxers.get(protocol);\n return { stream, muxerFactory };\n }\n catch (err) {\n log.error('error multiplexing inbound stream', err);\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n}\n//# sourceMappingURL=upgrader.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/upgrader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/utils/peer-job-queue.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/utils/peer-job-queue.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PeerJobQueue: () => (/* binding */ PeerJobQueue)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-queue */ \"./node_modules/p-queue/dist/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/sdk/node_modules/libp2p/dist/src/errors.js\");\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\n\n\n// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nfunction lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = Math.trunc(count / 2);\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\n/**\n * Port of https://github.com/sindresorhus/p-queue/blob/main/source/priority-queue.ts\n * that adds support for filtering jobs by peer id\n */\nclass PeerPriorityQueue {\n #queue = [];\n enqueue(run, options) {\n const peerId = options?.peerId;\n const priority = options?.priority ?? 0;\n if (peerId == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError('missing peer id', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n const element = {\n priority,\n peerId,\n run\n };\n if (this.size > 0 && this.#queue[this.size - 1].priority >= priority) {\n this.#queue.push(element);\n return;\n }\n const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n if (options.peerId != null) {\n const peerId = options.peerId;\n return this.#queue.filter((element) => peerId.equals(element.peerId)).map((element) => element.run);\n }\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n/**\n * Extends PQueue to add support for querying queued jobs by peer id\n */\nclass PeerJobQueue extends p_queue__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n constructor(options = {}) {\n super({\n ...options,\n queueClass: PeerPriorityQueue\n });\n }\n /**\n * Returns true if this queue has a job for the passed peer id that has not yet\n * started to run\n */\n hasJob(peerId) {\n return this.sizeBy({\n peerId\n }) > 0;\n }\n}\n//# sourceMappingURL=peer-job-queue.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/utils/peer-job-queue.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/sdk/node_modules/libp2p/dist/src/version.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/sdk/node_modules/libp2p/dist/src/version.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ name: () => (/* binding */ name),\n/* harmony export */ version: () => (/* binding */ version)\n/* harmony export */ });\nconst version = '0.45.9';\nconst name = 'libp2p';\n//# sourceMappingURL=version.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/libp2p/dist/src/version.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TimeoutError: () => (/* reexport safe */ p_timeout__WEBPACK_IMPORTED_MODULE_0__.TimeoutError),\n/* harmony export */ pEvent: () => (/* binding */ pEvent),\n/* harmony export */ pEventIterator: () => (/* binding */ pEventIterator),\n/* harmony export */ pEventMultiple: () => (/* binding */ pEventMultiple)\n/* harmony export */ });\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n\n\nconst normalizeEmitter = emitter => {\n\tconst addListener = emitter.addEventListener || emitter.on || emitter.addListener;\n\tconst removeListener = emitter.removeEventListener || emitter.off || emitter.removeListener;\n\n\tif (!addListener || !removeListener) {\n\t\tthrow new TypeError('Emitter is not compatible');\n\t}\n\n\treturn {\n\t\taddListener: addListener.bind(emitter),\n\t\tremoveListener: removeListener.bind(emitter),\n\t};\n};\n\nfunction pEventMultiple(emitter, event, options) {\n\tlet cancel;\n\tconst returnValue = new Promise((resolve, reject) => {\n\t\toptions = {\n\t\t\trejectionEvents: ['error'],\n\t\t\tmultiArgs: false,\n\t\t\tresolveImmediately: false,\n\t\t\t...options,\n\t\t};\n\n\t\tif (!(options.count >= 0 && (options.count === Number.POSITIVE_INFINITY || Number.isInteger(options.count)))) {\n\t\t\tthrow new TypeError('The `count` option should be at least 0 or more');\n\t\t}\n\n\t\toptions.signal?.throwIfAborted();\n\n\t\t// Allow multiple events\n\t\tconst events = [event].flat();\n\n\t\tconst items = [];\n\t\tconst {addListener, removeListener} = normalizeEmitter(emitter);\n\n\t\tconst onItem = (...arguments_) => {\n\t\t\tconst value = options.multiArgs ? arguments_ : arguments_[0];\n\n\t\t\t// eslint-disable-next-line unicorn/no-array-callback-reference\n\t\t\tif (options.filter && !options.filter(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\titems.push(value);\n\n\t\t\tif (options.count === items.length) {\n\t\t\t\tcancel();\n\t\t\t\tresolve(items);\n\t\t\t}\n\t\t};\n\n\t\tconst rejectHandler = error => {\n\t\t\tcancel();\n\t\t\treject(error);\n\t\t};\n\n\t\tcancel = () => {\n\t\t\tfor (const event of events) {\n\t\t\t\tremoveListener(event, onItem);\n\t\t\t}\n\n\t\t\tfor (const rejectionEvent of options.rejectionEvents) {\n\t\t\t\tremoveListener(rejectionEvent, rejectHandler);\n\t\t\t}\n\t\t};\n\n\t\tfor (const event of events) {\n\t\t\taddListener(event, onItem);\n\t\t}\n\n\t\tfor (const rejectionEvent of options.rejectionEvents) {\n\t\t\taddListener(rejectionEvent, rejectHandler);\n\t\t}\n\n\t\tif (options.signal) {\n\t\t\toptions.signal.addEventListener('abort', () => {\n\t\t\t\trejectHandler(options.signal.reason);\n\t\t\t}, {once: true});\n\t\t}\n\n\t\tif (options.resolveImmediately) {\n\t\t\tresolve(items);\n\t\t}\n\t});\n\n\treturnValue.cancel = cancel;\n\n\tif (typeof options.timeout === 'number') {\n\t\tconst timeout = (0,p_timeout__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(returnValue, {milliseconds: options.timeout});\n\t\ttimeout.cancel = cancel;\n\t\treturn timeout;\n\t}\n\n\treturn returnValue;\n}\n\nfunction pEvent(emitter, event, options) {\n\tif (typeof options === 'function') {\n\t\toptions = {filter: options};\n\t}\n\n\toptions = {\n\t\t...options,\n\t\tcount: 1,\n\t\tresolveImmediately: false,\n\t};\n\n\tconst arrayPromise = pEventMultiple(emitter, event, options);\n\tconst promise = arrayPromise.then(array => array[0]);\n\tpromise.cancel = arrayPromise.cancel;\n\n\treturn promise;\n}\n\nfunction pEventIterator(emitter, event, options) {\n\tif (typeof options === 'function') {\n\t\toptions = {filter: options};\n\t}\n\n\t// Allow multiple events\n\tconst events = [event].flat();\n\n\toptions = {\n\t\trejectionEvents: ['error'],\n\t\tresolutionEvents: [],\n\t\tlimit: Number.POSITIVE_INFINITY,\n\t\tmultiArgs: false,\n\t\t...options,\n\t};\n\n\tconst {limit} = options;\n\tconst isValidLimit = limit >= 0 && (limit === Number.POSITIVE_INFINITY || Number.isInteger(limit));\n\tif (!isValidLimit) {\n\t\tthrow new TypeError('The `limit` option should be a non-negative integer or Infinity');\n\t}\n\n\toptions.signal?.throwIfAborted();\n\n\tif (limit === 0) {\n\t\t// Return an empty async iterator to avoid any further cost\n\t\treturn {\n\t\t\t[Symbol.asyncIterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tasync next() {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: undefined,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}\n\n\tconst {addListener, removeListener} = normalizeEmitter(emitter);\n\n\tlet isDone = false;\n\tlet error;\n\tlet hasPendingError = false;\n\tconst nextQueue = [];\n\tconst valueQueue = [];\n\tlet eventCount = 0;\n\tlet isLimitReached = false;\n\n\tconst valueHandler = (...arguments_) => {\n\t\teventCount++;\n\t\tisLimitReached = eventCount === limit;\n\n\t\tconst value = options.multiArgs ? arguments_ : arguments_[0];\n\n\t\tif (nextQueue.length > 0) {\n\t\t\tconst {resolve} = nextQueue.shift();\n\n\t\t\tresolve({done: false, value});\n\n\t\t\tif (isLimitReached) {\n\t\t\t\tcancel();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tvalueQueue.push(value);\n\n\t\tif (isLimitReached) {\n\t\t\tcancel();\n\t\t}\n\t};\n\n\tconst cancel = () => {\n\t\tisDone = true;\n\n\t\tfor (const event of events) {\n\t\t\tremoveListener(event, valueHandler);\n\t\t}\n\n\t\tfor (const rejectionEvent of options.rejectionEvents) {\n\t\t\tremoveListener(rejectionEvent, rejectHandler);\n\t\t}\n\n\t\tfor (const resolutionEvent of options.resolutionEvents) {\n\t\t\tremoveListener(resolutionEvent, resolveHandler);\n\t\t}\n\n\t\twhile (nextQueue.length > 0) {\n\t\t\tconst {resolve} = nextQueue.shift();\n\t\t\tresolve({done: true, value: undefined});\n\t\t}\n\t};\n\n\tconst rejectHandler = (...arguments_) => {\n\t\terror = options.multiArgs ? arguments_ : arguments_[0];\n\n\t\tif (nextQueue.length > 0) {\n\t\t\tconst {reject} = nextQueue.shift();\n\t\t\treject(error);\n\t\t} else {\n\t\t\thasPendingError = true;\n\t\t}\n\n\t\tcancel();\n\t};\n\n\tconst resolveHandler = (...arguments_) => {\n\t\tconst value = options.multiArgs ? arguments_ : arguments_[0];\n\n\t\t// eslint-disable-next-line unicorn/no-array-callback-reference\n\t\tif (options.filter && !options.filter(value)) {\n\t\t\tcancel();\n\t\t\treturn;\n\t\t}\n\n\t\tif (nextQueue.length > 0) {\n\t\t\tconst {resolve} = nextQueue.shift();\n\t\t\tresolve({done: true, value});\n\t\t} else {\n\t\t\tvalueQueue.push(value);\n\t\t}\n\n\t\tcancel();\n\t};\n\n\tfor (const event of events) {\n\t\taddListener(event, valueHandler);\n\t}\n\n\tfor (const rejectionEvent of options.rejectionEvents) {\n\t\taddListener(rejectionEvent, rejectHandler);\n\t}\n\n\tfor (const resolutionEvent of options.resolutionEvents) {\n\t\taddListener(resolutionEvent, resolveHandler);\n\t}\n\n\tif (options.signal) {\n\t\toptions.signal.addEventListener('abort', () => {\n\t\t\trejectHandler(options.signal.reason);\n\t\t}, {once: true});\n\t}\n\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\treturn this;\n\t\t},\n\t\tasync next() {\n\t\t\tif (valueQueue.length > 0) {\n\t\t\t\tconst value = valueQueue.shift();\n\t\t\t\treturn {\n\t\t\t\t\tdone: isDone && valueQueue.length === 0 && !isLimitReached,\n\t\t\t\t\tvalue,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (hasPendingError) {\n\t\t\t\thasPendingError = false;\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (isDone) {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: undefined,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tnextQueue.push({resolve, reject});\n\t\t\t});\n\t\t},\n\t\tasync return(value) {\n\t\t\tcancel();\n\t\t\treturn {\n\t\t\t\tdone: isDone,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t},\n\t};\n}\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/sdk/node_modules/p-event/index.js?"); /***/ }), @@ -6995,7 +7046,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),\n/* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),\n/* harmony export */ concat: () => (/* binding */ concat),\n/* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),\n/* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n/**\n * Convert input to a byte array.\n *\n * Handles both `0x` prefixed and non-prefixed strings.\n */\nfunction hexToBytes(hex) {\n if (typeof hex === \"string\") {\n const _hex = hex.replace(/^0x/i, \"\");\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(_hex.toLowerCase(), \"base16\");\n }\n return hex;\n}\n/**\n * Convert byte array to hex string (no `0x` prefix).\n */\nconst bytesToHex = (bytes) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(bytes, \"base16\");\n/**\n * Decode byte array to utf-8 string.\n */\nconst bytesToUtf8 = (b) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(b, \"utf8\");\n/**\n * Encode utf-8 string to byte array.\n */\nconst utf8ToBytes = (s) => (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(s, \"utf8\");\n/**\n * Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`\n */\nfunction concat(byteArrays, totalLength) {\n const len = totalLength ?? byteArrays.reduce((acc, curr) => acc + curr.length, 0);\n const res = new Uint8Array(len);\n let offset = 0;\n for (const bytes of byteArrays) {\n res.set(bytes, offset);\n offset += bytes.length;\n }\n return res;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/bytes/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),\n/* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),\n/* harmony export */ concat: () => (/* binding */ concat),\n/* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),\n/* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n/**\n * Convert input to a byte array.\n *\n * Handles both `0x` prefixed and non-prefixed strings.\n */\nfunction hexToBytes(hex) {\n if (typeof hex === \"string\") {\n const _hex = hex.replace(/^0x/i, \"\");\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(_hex.toLowerCase(), \"base16\");\n }\n return hex;\n}\n/**\n * Convert byte array to hex string (no `0x` prefix).\n */\nconst bytesToHex = (bytes) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(bytes, \"base16\");\n/**\n * Decode byte array to utf-8 string.\n */\nconst bytesToUtf8 = (b) => (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(b, \"utf8\");\n/**\n * Encode utf-8 string to byte array.\n */\nconst utf8ToBytes = (s) => (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_0__.fromString)(s, \"utf8\");\n/**\n * Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`\n */\nfunction concat(byteArrays, totalLength) {\n const len = totalLength ?? byteArrays.reduce((acc, curr) => acc + curr.length, 0);\n const res = new Uint8Array(len);\n let offset = 0;\n for (const bytes of byteArrays) {\n res.set(bytes, offset);\n offset += bytes.length;\n }\n return res;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), @@ -7017,7 +7068,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _random_subset_js__WEBPACK_IMPORTED_MODULE_1__.getPseudoRandomSubset),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _group_by_js__WEBPACK_IMPORTED_MODULE_2__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _is_defined_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isSizeValid: () => (/* reexport safe */ _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__.isSizeValid),\n/* harmony export */ removeItemFromArray: () => (/* binding */ removeItemFromArray),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _is_defined_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is_defined.js */ \"./node_modules/@waku/utils/dist/common/is_defined.js\");\n/* harmony import */ var _random_subset_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./random_subset.js */ \"./node_modules/@waku/utils/dist/common/random_subset.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./group_by.js */ \"./node_modules/@waku/utils/dist/common/group_by.js\");\n/* harmony import */ var _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./to_async_iterator.js */ \"./node_modules/@waku/utils/dist/common/to_async_iterator.js\");\n/* harmony import */ var _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./is_size_valid.js */ \"./node_modules/@waku/utils/dist/common/is_size_valid.js\");\n\n\nfunction removeItemFromArray(arr, value) {\n const index = arr.indexOf(value);\n if (index > -1) {\n arr.splice(index, 1);\n }\n return arr;\n}\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentTopicToPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.contentTopicsByPubsubTopic),\n/* harmony export */ decodeRelayShard: () => (/* reexport safe */ _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__.decodeRelayShard),\n/* harmony export */ determinePubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.determinePubsubTopic),\n/* harmony export */ encodeRelayShard: () => (/* reexport safe */ _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__.encodeRelayShard),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.ensureValidContentTopic),\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _random_subset_js__WEBPACK_IMPORTED_MODULE_1__.getPseudoRandomSubset),\n/* harmony export */ getWsMultiaddrFromMultiaddrs: () => (/* binding */ getWsMultiaddrFromMultiaddrs),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _group_by_js__WEBPACK_IMPORTED_MODULE_2__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _is_defined_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isMessageSizeUnderCap: () => (/* reexport safe */ _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__.isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* reexport safe */ _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__.isWireSizeUnderCap),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.pubsubTopicToSingleShardInfo),\n/* harmony export */ pushOrInitMapSet: () => (/* reexport safe */ _push_or_init_map_js__WEBPACK_IMPORTED_MODULE_6__.pushOrInitMapSet),\n/* harmony export */ removeItemFromArray: () => (/* binding */ removeItemFromArray),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* reexport safe */ _sharding_js__WEBPACK_IMPORTED_MODULE_5__.singleShardInfosToShardInfo),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _is_defined_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is_defined.js */ \"./node_modules/@waku/utils/dist/common/is_defined.js\");\n/* harmony import */ var _random_subset_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./random_subset.js */ \"./node_modules/@waku/utils/dist/common/random_subset.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./group_by.js */ \"./node_modules/@waku/utils/dist/common/group_by.js\");\n/* harmony import */ var _to_async_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./to_async_iterator.js */ \"./node_modules/@waku/utils/dist/common/to_async_iterator.js\");\n/* harmony import */ var _is_size_valid_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./is_size_valid.js */ \"./node_modules/@waku/utils/dist/common/is_size_valid.js\");\n/* harmony import */ var _sharding_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sharding.js */ \"./node_modules/@waku/utils/dist/common/sharding.js\");\n/* harmony import */ var _push_or_init_map_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./push_or_init_map.js */ \"./node_modules/@waku/utils/dist/common/push_or_init_map.js\");\n/* harmony import */ var _relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./relay_shard_codec.js */ \"./node_modules/@waku/utils/dist/common/relay_shard_codec.js\");\n\n\n\n\n\n\n\n\nfunction removeItemFromArray(arr, value) {\n const index = arr.indexOf(value);\n if (index > -1) {\n arr.splice(index, 1);\n }\n return arr;\n}\nfunction getWsMultiaddrFromMultiaddrs(addresses) {\n const wsMultiaddr = addresses.find((addr) => addr.toString().includes(\"ws\") || addr.toString().includes(\"wss\"));\n if (!wsMultiaddr) {\n throw new Error(\"No ws multiaddr found in the given addresses\");\n }\n return wsMultiaddr;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/index.js?"); /***/ }), @@ -7039,7 +7090,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isSizeValid: () => (/* binding */ isSizeValid)\n/* harmony export */ });\nconst MB = 1024 ** 2;\nconst SIZE_CAP = 1; // 1 MB\nconst isSizeValid = (payload) => {\n if (payload.length / MB > SIZE_CAP) {\n return false;\n }\n return true;\n};\n//# sourceMappingURL=is_size_valid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/is_size_valid.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isMessageSizeUnderCap: () => (/* binding */ isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* binding */ isWireSizeUnderCap)\n/* harmony export */ });\nconst MB = 1024 ** 2;\nconst SIZE_CAP_IN_MB = 1;\n/**\n * Return whether the size of the message is under the upper limit for the network.\n * This performs a protobuf encoding! If you have access to the fully encoded message,\n * use {@link isSizeUnderCapBuf} instead.\n * @param message\n * @param encoder\n */\nasync function isMessageSizeUnderCap(encoder, message) {\n const buf = await encoder.toWire(message);\n if (!buf)\n return false;\n return isWireSizeUnderCap(buf);\n}\nconst isWireSizeUnderCap = (buf) => buf.length / MB <= SIZE_CAP_IN_MB;\n//# sourceMappingURL=is_size_valid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/is_size_valid.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/dist/common/push_or_init_map.js": +/*!******************************************************************!*\ + !*** ./node_modules/@waku/utils/dist/common/push_or_init_map.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pushOrInitMapSet: () => (/* binding */ pushOrInitMapSet)\n/* harmony export */ });\nfunction pushOrInitMapSet(map, key, newValue) {\n let arr = map.get(key);\n if (typeof arr === \"undefined\") {\n map.set(key, new Set());\n arr = map.get(key);\n }\n arr.add(newValue);\n}\n//# sourceMappingURL=push_or_init_map.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/push_or_init_map.js?"); /***/ }), @@ -7054,6 +7116,28 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@waku/utils/dist/common/relay_shard_codec.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@waku/utils/dist/common/relay_shard_codec.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeRelayShard: () => (/* binding */ decodeRelayShard),\n/* harmony export */ encodeRelayShard: () => (/* binding */ encodeRelayShard)\n/* harmony export */ });\nconst decodeRelayShard = (bytes) => {\n // explicitly converting to Uint8Array to avoid Buffer\n // https://github.com/libp2p/js-libp2p/issues/2146\n bytes = new Uint8Array(bytes);\n if (bytes.length < 3)\n throw new Error(\"Insufficient data\");\n const view = new DataView(bytes.buffer);\n const clusterId = view.getUint16(0);\n const shards = [];\n if (bytes.length === 130) {\n // rsv format (Bit Vector)\n for (let i = 0; i < 1024; i++) {\n const byteIndex = Math.floor(i / 8) + 2; // Adjusted for the 2-byte cluster field\n const bitIndex = 7 - (i % 8);\n if (view.getUint8(byteIndex) & (1 << bitIndex)) {\n shards.push(i);\n }\n }\n }\n else {\n // rs format (Index List)\n const numIndices = view.getUint8(2);\n for (let i = 0, offset = 3; i < numIndices; i++, offset += 2) {\n if (offset + 1 >= bytes.length)\n throw new Error(\"Unexpected end of data\");\n shards.push(view.getUint16(offset));\n }\n }\n return { clusterId, shards };\n};\nconst encodeRelayShard = (shardInfo) => {\n const { clusterId, shards } = shardInfo;\n const totalLength = shards.length >= 64 ? 130 : 3 + 2 * shards.length;\n const buffer = new ArrayBuffer(totalLength);\n const view = new DataView(buffer);\n view.setUint16(0, clusterId);\n if (shards.length >= 64) {\n // rsv format (Bit Vector)\n for (const index of shards) {\n const byteIndex = Math.floor(index / 8) + 2; // Adjusted for the 2-byte cluster field\n const bitIndex = 7 - (index % 8);\n view.setUint8(byteIndex, view.getUint8(byteIndex) | (1 << bitIndex));\n }\n }\n else {\n // rs format (Index List)\n view.setUint8(2, shards.length);\n for (let i = 0, offset = 3; i < shards.length; i++, offset += 2) {\n view.setUint16(offset, shards[i]);\n }\n }\n return new Uint8Array(buffer);\n};\n//# sourceMappingURL=relay_shard_codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/relay_shard_codec.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/dist/common/sharding.js": +/*!**********************************************************!*\ + !*** ./node_modules/@waku/utils/dist/common/sharding.js ***! + \**********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ contentTopicToPubsubTopic: () => (/* binding */ contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* binding */ contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* binding */ contentTopicsByPubsubTopic),\n/* harmony export */ determinePubsubTopic: () => (/* binding */ determinePubsubTopic),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* binding */ ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* binding */ ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* binding */ ensureValidContentTopic),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* binding */ pubsubTopicToSingleShardInfo),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* binding */ shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* binding */ singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* binding */ singleShardInfosToShardInfo)\n/* harmony export */ });\n/* harmony import */ var _noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _bytes_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes/index.js */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n\n\n\nconst singleShardInfoToPubsubTopic = (shardInfo) => {\n if (shardInfo.clusterId === undefined || shardInfo.shard === undefined)\n throw new Error(\"Invalid shard\");\n return `/waku/2/rs/${shardInfo.clusterId}/${shardInfo.shard}`;\n};\nconst singleShardInfosToShardInfo = (singleShardInfos) => {\n if (singleShardInfos.length === 0)\n throw new Error(\"Invalid shard\");\n const clusterIds = singleShardInfos.map((shardInfo) => shardInfo.clusterId);\n if (new Set(clusterIds).size !== 1) {\n throw new Error(\"Passed shard infos have different clusterIds\");\n }\n const shards = singleShardInfos\n .map((shardInfo) => shardInfo.shard)\n .filter((shard) => shard !== undefined);\n return {\n clusterId: singleShardInfos[0].clusterId,\n shards\n };\n};\nconst shardInfoToPubsubTopics = (shardInfo) => {\n if (\"contentTopics\" in shardInfo && shardInfo.contentTopics) {\n // Autosharding: explicitly defined content topics\n return Array.from(new Set(shardInfo.contentTopics.map((contentTopic) => contentTopicToPubsubTopic(contentTopic, shardInfo.clusterId))));\n }\n else if (\"shards\" in shardInfo) {\n // Static sharding\n if (shardInfo.shards === undefined)\n throw new Error(\"Invalid shard\");\n return Array.from(new Set(shardInfo.shards.map((index) => `/waku/2/rs/${shardInfo.clusterId ?? _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID}/${index}`)));\n }\n else if (\"application\" in shardInfo && \"version\" in shardInfo) {\n // Autosharding: single shard from application and version\n return [\n contentTopicToPubsubTopic(`/${shardInfo.application}/${shardInfo.version}/default/default`, shardInfo.clusterId)\n ];\n }\n else {\n throw new Error(\"Missing required configuration in shard parameters\");\n }\n};\nconst pubsubTopicToSingleShardInfo = (pubsubTopics) => {\n const parts = pubsubTopics.split(\"/\");\n if (parts.length != 6 ||\n parts[1] !== \"waku\" ||\n parts[2] !== \"2\" ||\n parts[3] !== \"rs\")\n throw new Error(\"Invalid pubsub topic\");\n const clusterId = parseInt(parts[4]);\n const shard = parseInt(parts[5]);\n if (isNaN(clusterId) || isNaN(shard))\n throw new Error(\"Invalid clusterId or shard\");\n return {\n clusterId,\n shard\n };\n};\n//TODO: move part of BaseProtocol instead of utils\n// return `ProtocolError.TOPIC_NOT_CONFIGURED` instead of throwing\nfunction ensurePubsubTopicIsConfigured(pubsubTopic, configuredTopics) {\n if (!configuredTopics.includes(pubsubTopic)) {\n throw new Error(`Pubsub topic ${pubsubTopic} has not been configured on this instance. Configured topics are: ${configuredTopics}. Please update your configuration by passing in the topic during Waku node instantiation.`);\n }\n}\n/**\n * Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/\n * @param contentTopic String to validate\n * @returns Object with each content topic field as an attribute\n */\nfunction ensureValidContentTopic(contentTopic) {\n const parts = contentTopic.split(\"/\");\n if (parts.length < 5 || parts.length > 6) {\n throw Error(\"Content topic format is invalid\");\n }\n // Validate generation field if present\n let generation = 0;\n if (parts.length == 6) {\n generation = parseInt(parts[1]);\n if (isNaN(generation)) {\n throw new Error(\"Invalid generation field in content topic\");\n }\n if (generation > 0) {\n throw new Error(\"Generation greater than 0 is not supported\");\n }\n }\n // Validate remaining fields\n const fields = parts.splice(-4);\n // Validate application field\n if (fields[0].length == 0) {\n throw new Error(\"Application field cannot be empty\");\n }\n // Validate version field\n if (fields[1].length == 0) {\n throw new Error(\"Version field cannot be empty\");\n }\n // Validate topic name field\n if (fields[2].length == 0) {\n throw new Error(\"Topic name field cannot be empty\");\n }\n // Validate encoding field\n if (fields[3].length == 0) {\n throw new Error(\"Encoding field cannot be empty\");\n }\n return {\n generation,\n application: fields[0],\n version: fields[1],\n topicName: fields[2],\n encoding: fields[3]\n };\n}\n/**\n * Given a string, determines which autoshard index to use for its pubsub topic.\n * Based on the algorithm described in the RFC: https://rfc.vac.dev/spec/51//#algorithm\n */\nfunction contentTopicToShardIndex(contentTopic, networkShards = 8) {\n const { application, version } = ensureValidContentTopic(contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_2__.sha256)((0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.concat)([(0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(application), (0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_1__.utf8ToBytes)(version)]));\n const dataview = new DataView(digest.buffer.slice(-8));\n return Number(dataview.getBigUint64(0, false) % BigInt(networkShards));\n}\nfunction contentTopicToPubsubTopic(contentTopic, clusterId = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID, networkShards = 8) {\n if (!contentTopic) {\n throw Error(\"Content topic must be specified\");\n }\n const shardIndex = contentTopicToShardIndex(contentTopic, networkShards);\n return `/waku/2/rs/${clusterId}/${shardIndex}`;\n}\n/**\n * Given an array of content topics, groups them together by their Pubsub topic as derived using the algorithm for autosharding.\n * If any of the content topics are not properly formatted, the function will throw an error.\n */\nfunction contentTopicsByPubsubTopic(contentTopics, clusterId = _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID, networkShards = 8) {\n const groupedContentTopics = new Map();\n for (const contentTopic of contentTopics) {\n const pubsubTopic = contentTopicToPubsubTopic(contentTopic, clusterId, networkShards);\n let topics = groupedContentTopics.get(pubsubTopic);\n if (!topics) {\n groupedContentTopics.set(pubsubTopic, []);\n topics = groupedContentTopics.get(pubsubTopic);\n }\n topics.push(contentTopic);\n }\n return groupedContentTopics;\n}\n/**\n * Used when creating encoders/decoders to determine which pubsub topic to use\n */\nfunction determinePubsubTopic(contentTopic, pubsubTopicShardInfo) {\n if (typeof pubsubTopicShardInfo == \"string\") {\n return pubsubTopicShardInfo;\n }\n return pubsubTopicShardInfo?.shard\n ? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)\n : contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId || _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID);\n}\n/**\n * Validates sharding configuration and sets defaults where possible.\n * @returns Validated sharding parameters, with any missing values set to defaults\n */\nconst ensureShardingConfigured = (shardInfo) => {\n const clusterId = shardInfo.clusterId ?? _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_CLUSTER_ID;\n const shards = \"shards\" in shardInfo ? shardInfo.shards : [];\n const contentTopics = \"contentTopics\" in shardInfo ? shardInfo.contentTopics : [];\n const [application, version] = \"application\" in shardInfo && \"version\" in shardInfo\n ? [shardInfo.application, shardInfo.version]\n : [undefined, undefined];\n const isShardsConfigured = shards && shards.length > 0;\n const isContentTopicsConfigured = contentTopics && contentTopics.length > 0;\n const isApplicationVersionConfigured = application && version;\n if (isShardsConfigured) {\n return {\n shardingParams: { clusterId, shards },\n shardInfo: { clusterId, shards },\n pubsubTopics: shardInfoToPubsubTopics({ clusterId, shards })\n };\n }\n if (isContentTopicsConfigured) {\n const pubsubTopics = Array.from(new Set(contentTopics.map((topic) => contentTopicToPubsubTopic(topic, clusterId))));\n const shards = Array.from(new Set(contentTopics.map((topic) => contentTopicToShardIndex(topic))));\n return {\n shardingParams: { clusterId, contentTopics },\n shardInfo: { clusterId, shards },\n pubsubTopics\n };\n }\n if (isApplicationVersionConfigured) {\n const pubsubTopic = contentTopicToPubsubTopic(`/${application}/${version}/default/default`, clusterId);\n return {\n shardingParams: { clusterId, application, version },\n shardInfo: {\n clusterId,\n shards: [pubsubTopicToSingleShardInfo(pubsubTopic).shard]\n },\n pubsubTopics: [pubsubTopic]\n };\n }\n throw new Error(\"Missing minimum required configuration options for static sharding or autosharding.\");\n};\n//# sourceMappingURL=sharding.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/sharding.js?"); + +/***/ }), + /***/ "./node_modules/@waku/utils/dist/common/to_async_iterator.js": /*!*******************************************************************!*\ !*** ./node_modules/@waku/utils/dist/common/to_async_iterator.js ***! @@ -7061,7 +7145,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toAsyncIterator: () => (/* binding */ toAsyncIterator)\n/* harmony export */ });\nconst FRAME_RATE = 60;\n/**\n * Function that transforms IReceiver subscription to iterable stream of data.\n * @param receiver - object that allows to be subscribed to;\n * @param decoder - parameter to be passed to receiver for subscription;\n * @param options - options for receiver for subscription;\n * @param iteratorOptions - optional configuration for iterator;\n * @returns iterator and stop function to terminate it.\n */\nasync function toAsyncIterator(receiver, decoder, options, iteratorOptions) {\n const iteratorDelay = iteratorOptions?.iteratorDelay ?? FRAME_RATE;\n const messages = [];\n let unsubscribe;\n unsubscribe = await receiver.subscribe(decoder, (message) => {\n messages.push(message);\n }, options);\n const isWithTimeout = Number.isInteger(iteratorOptions?.timeoutMs);\n const timeoutMs = iteratorOptions?.timeoutMs ?? 0;\n const startTime = Date.now();\n async function* iterator() {\n while (true) {\n if (isWithTimeout && Date.now() - startTime >= timeoutMs) {\n return;\n }\n await wait(iteratorDelay);\n const message = messages.shift();\n if (!unsubscribe && messages.length === 0) {\n return message;\n }\n if (!message && unsubscribe) {\n continue;\n }\n yield message;\n }\n }\n return {\n iterator: iterator(),\n async stop() {\n if (unsubscribe) {\n await unsubscribe();\n unsubscribe = undefined;\n }\n },\n };\n}\nfunction wait(ms) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n//# sourceMappingURL=to_async_iterator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/to_async_iterator.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toAsyncIterator: () => (/* binding */ toAsyncIterator)\n/* harmony export */ });\nconst FRAME_RATE = 60;\n/**\n * Function that transforms IReceiver subscription to iterable stream of data.\n * @param receiver - object that allows to be subscribed to;\n * @param decoder - parameter to be passed to receiver for subscription;\n * @param options - options for receiver for subscription;\n * @param iteratorOptions - optional configuration for iterator;\n * @returns iterator and stop function to terminate it.\n */\nasync function toAsyncIterator(receiver, decoder, iteratorOptions) {\n const iteratorDelay = iteratorOptions?.iteratorDelay ?? FRAME_RATE;\n const messages = [];\n let unsubscribe;\n unsubscribe = await receiver.subscribe(decoder, (message) => {\n messages.push(message);\n });\n const isWithTimeout = Number.isInteger(iteratorOptions?.timeoutMs);\n const timeoutMs = iteratorOptions?.timeoutMs ?? 0;\n const startTime = Date.now();\n async function* iterator() {\n while (true) {\n if (isWithTimeout && Date.now() - startTime >= timeoutMs) {\n return;\n }\n await wait(iteratorDelay);\n const message = messages.shift();\n if (!unsubscribe && messages.length === 0) {\n return message;\n }\n if (!message && unsubscribe) {\n continue;\n }\n yield message;\n }\n }\n return {\n iterator: iterator(),\n async stop() {\n if (unsubscribe) {\n await unsubscribe();\n unsubscribe = undefined;\n }\n }\n };\n}\nfunction wait(ms) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n//# sourceMappingURL=to_async_iterator.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/to_async_iterator.js?"); /***/ }), @@ -7072,7 +7156,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getPseudoRandomSubset),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isSizeValid: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isSizeValid),\n/* harmony export */ removeItemFromArray: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.removeItemFromArray),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _common_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common/index.js */ \"./node_modules/@waku/utils/dist/common/index.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Logger: () => (/* reexport safe */ _logger_index_js__WEBPACK_IMPORTED_MODULE_1__.Logger),\n/* harmony export */ contentTopicToPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicToPubsubTopic),\n/* harmony export */ contentTopicToShardIndex: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicToShardIndex),\n/* harmony export */ contentTopicsByPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.contentTopicsByPubsubTopic),\n/* harmony export */ decodeRelayShard: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.decodeRelayShard),\n/* harmony export */ determinePubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.determinePubsubTopic),\n/* harmony export */ encodeRelayShard: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.encodeRelayShard),\n/* harmony export */ ensurePubsubTopicIsConfigured: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensurePubsubTopicIsConfigured),\n/* harmony export */ ensureShardingConfigured: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensureShardingConfigured),\n/* harmony export */ ensureValidContentTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.ensureValidContentTopic),\n/* harmony export */ getPseudoRandomSubset: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getPseudoRandomSubset),\n/* harmony export */ getWsMultiaddrFromMultiaddrs: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getWsMultiaddrFromMultiaddrs),\n/* harmony export */ groupByContentTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic),\n/* harmony export */ isDefined: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isMessageSizeUnderCap: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isMessageSizeUnderCap),\n/* harmony export */ isWireSizeUnderCap: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isWireSizeUnderCap),\n/* harmony export */ pubsubTopicToSingleShardInfo: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.pubsubTopicToSingleShardInfo),\n/* harmony export */ pushOrInitMapSet: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.pushOrInitMapSet),\n/* harmony export */ removeItemFromArray: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.removeItemFromArray),\n/* harmony export */ shardInfoToPubsubTopics: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.shardInfoToPubsubTopics),\n/* harmony export */ singleShardInfoToPubsubTopic: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.singleShardInfoToPubsubTopic),\n/* harmony export */ singleShardInfosToShardInfo: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.singleShardInfosToShardInfo),\n/* harmony export */ toAsyncIterator: () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)\n/* harmony export */ });\n/* harmony import */ var _common_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common/index.js */ \"./node_modules/@waku/utils/dist/common/index.js\");\n/* harmony import */ var _logger_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger/index.js */ \"./node_modules/@waku/utils/dist/logger/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/index.js?"); /***/ }), @@ -7083,7 +7167,282 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPeersForProtocol: () => (/* binding */ getPeersForProtocol),\n/* harmony export */ selectConnection: () => (/* binding */ selectConnection),\n/* harmony export */ selectPeerForProtocol: () => (/* binding */ selectPeerForProtocol),\n/* harmony export */ selectRandomPeer: () => (/* binding */ selectRandomPeer)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:libp2p-utils\");\n/**\n * Returns a pseudo-random peer that supports the given protocol.\n * Useful for protocols such as store and light push\n */\nfunction selectRandomPeer(peers) {\n if (peers.length === 0)\n return;\n const index = Math.round(Math.random() * (peers.length - 1));\n return peers[index];\n}\n/**\n * Returns the list of peers that supports the given protocol.\n */\nasync function getPeersForProtocol(peerStore, protocols) {\n const peers = [];\n await peerStore.forEach((peer) => {\n for (let i = 0; i < protocols.length; i++) {\n if (peer.protocols.includes(protocols[i])) {\n peers.push(peer);\n break;\n }\n }\n });\n return peers;\n}\nasync function selectPeerForProtocol(peerStore, protocols, peerId) {\n let peer;\n if (peerId) {\n peer = await peerStore.get(peerId);\n if (!peer) {\n throw new Error(`Failed to retrieve connection details for provided peer in peer store: ${peerId.toString()}`);\n }\n }\n else {\n const peers = await getPeersForProtocol(peerStore, protocols);\n peer = selectRandomPeer(peers);\n if (!peer) {\n throw new Error(`Failed to find known peer that registers protocols: ${protocols}`);\n }\n }\n let protocol;\n for (const codec of protocols) {\n if (peer.protocols.includes(codec)) {\n protocol = codec;\n // Do not break as we want to keep the last value\n }\n }\n log(`Using codec ${protocol}`);\n if (!protocol) {\n throw new Error(`Peer does not register required protocols (${peer.id.toString()}): ${protocols}`);\n }\n return { peer, protocol };\n}\nfunction selectConnection(connections) {\n if (!connections.length)\n return;\n if (connections.length === 1)\n return connections[0];\n let latestConnection;\n connections.forEach((connection) => {\n if (connection.stat.status === \"OPEN\") {\n if (!latestConnection) {\n latestConnection = connection;\n }\n else if (connection.stat.timeline.open > latestConnection.stat.timeline.open) {\n latestConnection = connection;\n }\n }\n });\n return latestConnection;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/libp2p/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getConnectedPeersForProtocolAndShard: () => (/* binding */ getConnectedPeersForProtocolAndShard),\n/* harmony export */ getPeersForProtocol: () => (/* binding */ getPeersForProtocol),\n/* harmony export */ selectConnection: () => (/* binding */ selectConnection),\n/* harmony export */ selectRandomPeer: () => (/* binding */ selectRandomPeer),\n/* harmony export */ sortPeersByLatency: () => (/* binding */ sortPeersByLatency)\n/* harmony export */ });\n/* harmony import */ var _bytes_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes/index.js */ \"./node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var _common_relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/relay_shard_codec.js */ \"./node_modules/@waku/utils/dist/common/relay_shard_codec.js\");\n\n\n/**\n * Returns a pseudo-random peer that supports the given protocol.\n * Useful for protocols such as store and light push\n */\nfunction selectRandomPeer(peers) {\n if (peers.length === 0)\n return;\n const index = Math.round(Math.random() * (peers.length - 1));\n return peers[index];\n}\n/**\n * Function to sort peers by latency from lowest to highest\n * @param peerStore - The Libp2p PeerStore\n * @param peers - The list of peers to choose from\n * @returns Sorted array of peers by latency\n */\nasync function sortPeersByLatency(peerStore, peers) {\n if (peers.length === 0)\n return [];\n const results = await Promise.all(peers.map(async (peer) => {\n try {\n const pingBytes = (await peerStore.get(peer.id)).metadata.get(\"ping\");\n if (!pingBytes)\n return { peer, ping: Infinity };\n const ping = Number((0,_bytes_index_js__WEBPACK_IMPORTED_MODULE_0__.bytesToUtf8)(pingBytes));\n return { peer, ping };\n }\n catch (error) {\n return { peer, ping: Infinity };\n }\n }));\n // filter out null values\n const validResults = results.filter((result) => result !== null);\n return validResults\n .sort((a, b) => a.ping - b.ping)\n .map((result) => result.peer);\n}\n/**\n * Returns the list of peers that supports the given protocol.\n */\nasync function getPeersForProtocol(peerStore, protocols) {\n const peers = [];\n await peerStore.forEach((peer) => {\n for (let i = 0; i < protocols.length; i++) {\n if (peer.protocols.includes(protocols[i])) {\n peers.push(peer);\n break;\n }\n }\n });\n return peers;\n}\nasync function getConnectedPeersForProtocolAndShard(connections, peerStore, protocols, shardInfo) {\n const openConnections = connections.filter((connection) => connection.status === \"open\");\n const peerPromises = openConnections.map(async (connection) => {\n const peer = await peerStore.get(connection.remotePeer);\n const supportsProtocol = protocols.some((protocol) => peer.protocols.includes(protocol));\n if (supportsProtocol) {\n if (shardInfo) {\n const encodedPeerShardInfo = peer.metadata.get(\"shardInfo\");\n const peerShardInfo = encodedPeerShardInfo && (0,_common_relay_shard_codec_js__WEBPACK_IMPORTED_MODULE_1__.decodeRelayShard)(encodedPeerShardInfo);\n if (peerShardInfo && shardInfo.clusterId === peerShardInfo.clusterId) {\n return peer;\n }\n }\n else {\n return peer;\n }\n }\n return null;\n });\n const peersWithNulls = await Promise.all(peerPromises);\n return peersWithNulls.filter((peer) => peer !== null);\n}\nfunction selectConnection(connections) {\n if (!connections.length)\n return;\n if (connections.length === 1)\n return connections[0];\n let latestConnection;\n connections.forEach((connection) => {\n if (connection.status === \"open\") {\n if (!latestConnection) {\n latestConnection = connection;\n }\n else if (connection.timeline.open > latestConnection.timeline.open) {\n latestConnection = connection;\n }\n }\n });\n return latestConnection;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/libp2p/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/dist/logger/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/@waku/utils/dist/logger/index.js ***! + \*******************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Logger: () => (/* binding */ Logger)\n/* harmony export */ });\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n\nconst APP_NAME = \"waku\";\nclass Logger {\n _info;\n _warn;\n _error;\n static createDebugNamespace(level, prefix) {\n return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;\n }\n constructor(prefix) {\n this._info = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"info\", prefix));\n this._warn = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"warn\", prefix));\n this._error = debug__WEBPACK_IMPORTED_MODULE_0__(Logger.createDebugNamespace(\"error\", prefix));\n }\n get info() {\n return this._info;\n }\n get warn() {\n return this._warn;\n }\n get error() {\n return this._error;\n }\n log(level, ...args) {\n const logger = this[level];\n logger(...args);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/logger/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/connection_manager.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/connection_manager.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EConnectionStateEvents: () => (/* binding */ EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* binding */ EPeersByDiscoveryEvents),\n/* harmony export */ Tags: () => (/* binding */ Tags)\n/* harmony export */ });\nvar Tags;\n(function (Tags) {\n Tags[\"BOOTSTRAP\"] = \"bootstrap\";\n Tags[\"PEER_EXCHANGE\"] = \"peer-exchange\";\n Tags[\"LOCAL\"] = \"local-peer-cache\";\n})(Tags || (Tags = {}));\nvar EPeersByDiscoveryEvents;\n(function (EPeersByDiscoveryEvents) {\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_BOOTSTRAP\"] = \"peer:discovery:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_DISCOVERY_PEER_EXCHANGE\"] = \"peer:discovery:peer-exchange\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_BOOTSTRAP\"] = \"peer:connected:bootstrap\";\n EPeersByDiscoveryEvents[\"PEER_CONNECT_PEER_EXCHANGE\"] = \"peer:connected:peer-exchange\";\n})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));\nvar EConnectionStateEvents;\n(function (EConnectionStateEvents) {\n EConnectionStateEvents[\"CONNECTION_STATUS\"] = \"waku:connection\";\n})(EConnectionStateEvents || (EConnectionStateEvents = {}));\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/connection_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/constants.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/constants.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* binding */ DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* binding */ DefaultPubsubTopic)\n/* harmony export */ });\n/**\n * DefaultPubsubTopic is the default gossipsub topic to use for Waku.\n */\nconst DefaultPubsubTopic = \"/waku/2/default-waku/proto\";\n/**\n * The default cluster ID for The Waku Network\n */\nconst DEFAULT_CLUSTER_ID = 1;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/dns_discovery.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/dns_discovery.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=dns_discovery.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/dns_discovery.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/enr.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/enr.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/enr.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/filter.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/filter.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/filter.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/index.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/index.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_CLUSTER_ID: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_CLUSTER_ID),\n/* harmony export */ DefaultPubsubTopic: () => (/* reexport safe */ _constants_js__WEBPACK_IMPORTED_MODULE_17__.DefaultPubsubTopic),\n/* harmony export */ EConnectionStateEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EConnectionStateEvents),\n/* harmony export */ EPeersByDiscoveryEvents: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.EPeersByDiscoveryEvents),\n/* harmony export */ PageDirection: () => (/* reexport safe */ _store_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ ProtocolError: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.ProtocolError),\n/* harmony export */ Protocols: () => (/* reexport safe */ _protocols_js__WEBPACK_IMPORTED_MODULE_5__.Protocols),\n/* harmony export */ Tags: () => (/* reexport safe */ _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.Tags)\n/* harmony export */ });\n/* harmony import */ var _enr_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enr.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/filter.js\");\n/* harmony import */ var _light_push_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./light_push.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/message.js\");\n/* harmony import */ var _peer_exchange_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./peer_exchange.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/waku.js\");\n/* harmony import */ var _connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/misc.js\");\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/libp2p.js\");\n/* harmony import */ var _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/keep_alive_manager.js\");\n/* harmony import */ var _dns_discovery_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./dns_discovery.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/dns_discovery.js\");\n/* harmony import */ var _metadata_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./metadata.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/metadata.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/constants.js\");\n/* harmony import */ var _local_storage_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./local_storage.js */ \"./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/local_storage.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/keep_alive_manager.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/keep_alive_manager.js ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=keep_alive_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/keep_alive_manager.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/libp2p.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/libp2p.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/libp2p.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/light_push.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/light_push.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=light_push.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/light_push.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/local_storage.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/local_storage.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=local_storage.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/local_storage.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/message.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/message.js ***! + \********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/message.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/metadata.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/metadata.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=metadata.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/metadata.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/misc.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/misc.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=misc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/misc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/peer_exchange.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/peer_exchange.js ***! + \**************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=peer_exchange.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/peer_exchange.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/protocols.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/protocols.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ProtocolError: () => (/* binding */ ProtocolError),\n/* harmony export */ Protocols: () => (/* binding */ Protocols)\n/* harmony export */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\nvar ProtocolError;\n(function (ProtocolError) {\n /** Could not determine the origin of the fault. Best to check connectivity and try again */\n ProtocolError[\"GENERIC_FAIL\"] = \"Generic error\";\n /**\n * Failure to protobuf encode the message. This is not recoverable and needs\n * further investigation.\n */\n ProtocolError[\"ENCODE_FAILED\"] = \"Failed to encode\";\n /**\n * Failure to protobuf decode the message. May be due to a remote peer issue,\n * ensuring that messages are sent via several peer enable mitigation of this error.\n */\n ProtocolError[\"DECODE_FAILED\"] = \"Failed to decode\";\n /**\n * The message payload is empty, making the message invalid. Ensure that a non-empty\n * payload is set on the outgoing message.\n */\n ProtocolError[\"EMPTY_PAYLOAD\"] = \"Payload is empty\";\n /**\n * The message size is above the maximum message size allowed on the Waku Network.\n * Compressing the message or using an alternative strategy for large messages is recommended.\n */\n ProtocolError[\"SIZE_TOO_BIG\"] = \"Size is too big\";\n /**\n * The PubsubTopic passed to the send function is not configured on the Waku node.\n * Please ensure that the PubsubTopic is used when initializing the Waku node.\n */\n ProtocolError[\"TOPIC_NOT_CONFIGURED\"] = \"Topic not configured\";\n /**\n * Failure to find a peer with suitable protocols. This may due to a connection issue.\n * Mitigation can be: retrying after a given time period, display connectivity issue\n * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`\n * on the connection manager before retrying.\n */\n ProtocolError[\"NO_PEER_AVAILABLE\"] = \"No peer available\";\n /**\n * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_FAULT\"] = \"Remote peer fault\";\n /**\n * The remote peer rejected the message. Information provided by the remote peer\n * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`\n * or `DECODE_FAILED` can be used.\n */\n ProtocolError[\"REMOTE_PEER_REJECTED\"] = \"Remote peer rejected\";\n /**\n * The protocol request timed out without a response. This may be due to a connection issue.\n * Mitigation can be: retrying after a given time period\n */\n ProtocolError[\"REQUEST_TIMEOUT\"] = \"Request timeout\";\n})(ProtocolError || (ProtocolError = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/protocols.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/receiver.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/receiver.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=receiver.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/receiver.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/relay.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/relay.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=relay.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/relay.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/sender.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/sender.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=sender.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/sender.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/store.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/store.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PageDirection: () => (/* binding */ PageDirection)\n/* harmony export */ });\nvar PageDirection;\n(function (PageDirection) {\n PageDirection[\"BACKWARD\"] = \"backward\";\n PageDirection[\"FORWARD\"] = \"forward\";\n})(PageDirection || (PageDirection = {}));\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/store.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/waku.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/waku.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/@waku/interfaces/dist/waku.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/alloc.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/alloc.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/from-string.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/from-string.js ***! + \***********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/to-string.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/to-string.js ***! + \*********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/bases.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/bases.js ***! + \**********************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -7098,14 +7457,47 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/byte-access/dist/src/index.js": -/*!****************************************************!*\ - !*** ./node_modules/byte-access/dist/src/index.js ***! - \****************************************************/ +/***/ "./node_modules/datastore-core/dist/src/base.js": +/*!******************************************************!*\ + !*** ./node_modules/datastore-core/dist/src/base.js ***! + \******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ accessor)\n/* harmony export */ });\nfunction accessor(buf) {\n if (buf instanceof Uint8Array) {\n return {\n get(index) {\n return buf[index];\n },\n set(index, value) {\n buf[index] = value;\n }\n };\n }\n return {\n get(index) {\n return buf.get(index);\n },\n set(index, value) {\n buf.set(index, value);\n }\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/byte-access/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseDatastore: () => (/* binding */ BaseDatastore)\n/* harmony export */ });\n/* harmony import */ var it_drain__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-drain */ \"./node_modules/it-drain/dist/src/index.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-filter */ \"./node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var it_sort__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-sort */ \"./node_modules/it-sort/dist/src/index.js\");\n/* harmony import */ var it_take__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-take */ \"./node_modules/it-take/dist/src/index.js\");\n\n\n\n\nclass BaseDatastore {\n put(key, val, options) {\n return Promise.reject(new Error('.put is not implemented'));\n }\n get(key, options) {\n return Promise.reject(new Error('.get is not implemented'));\n }\n has(key, options) {\n return Promise.reject(new Error('.has is not implemented'));\n }\n delete(key, options) {\n return Promise.reject(new Error('.delete is not implemented'));\n }\n async *putMany(source, options = {}) {\n for await (const { key, value } of source) {\n await this.put(key, value, options);\n yield key;\n }\n }\n async *getMany(source, options = {}) {\n for await (const key of source) {\n yield {\n key,\n value: await this.get(key, options)\n };\n }\n }\n async *deleteMany(source, options = {}) {\n for await (const key of source) {\n await this.delete(key, options);\n yield key;\n }\n }\n batch() {\n let puts = [];\n let dels = [];\n return {\n put(key, value) {\n puts.push({ key, value });\n },\n delete(key) {\n dels.push(key);\n },\n commit: async (options) => {\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.putMany(puts, options));\n puts = [];\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.deleteMany(dels, options));\n dels = [];\n }\n };\n }\n /**\n * Extending classes should override `query` or implement this method\n */\n // eslint-disable-next-line require-yield\n async *_all(q, options) {\n throw new Error('._all is not implemented');\n }\n /**\n * Extending classes should override `queryKeys` or implement this method\n */\n // eslint-disable-next-line require-yield\n async *_allKeys(q, options) {\n throw new Error('._allKeys is not implemented');\n }\n query(q, options) {\n let it = this._all(q, options);\n if (q.prefix != null) {\n const prefix = q.prefix;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, (e) => e.key.toString().startsWith(prefix));\n }\n if (Array.isArray(q.filters)) {\n it = q.filters.reduce((it, f) => (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, f), it);\n }\n if (Array.isArray(q.orders)) {\n it = q.orders.reduce((it, f) => (0,it_sort__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(it, f), it);\n }\n if (q.offset != null) {\n let i = 0;\n const offset = q.offset;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, () => i++ >= offset);\n }\n if (q.limit != null) {\n it = (0,it_take__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(it, q.limit);\n }\n return it;\n }\n queryKeys(q, options) {\n let it = this._allKeys(q, options);\n if (q.prefix != null) {\n const prefix = q.prefix;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, (key) => key.toString().startsWith(prefix));\n }\n if (Array.isArray(q.filters)) {\n it = q.filters.reduce((it, f) => (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, f), it);\n }\n if (Array.isArray(q.orders)) {\n it = q.orders.reduce((it, f) => (0,it_sort__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(it, f), it);\n }\n if (q.offset != null) {\n const offset = q.offset;\n let i = 0;\n it = (0,it_filter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(it, () => i++ >= offset);\n }\n if (q.limit != null) {\n it = (0,it_take__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(it, q.limit);\n }\n return it;\n }\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/dist/src/base.js?"); + +/***/ }), + +/***/ "./node_modules/datastore-core/dist/src/errors.js": +/*!********************************************************!*\ + !*** ./node_modules/datastore-core/dist/src/errors.js ***! + \********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ abortedError: () => (/* binding */ abortedError),\n/* harmony export */ dbDeleteFailedError: () => (/* binding */ dbDeleteFailedError),\n/* harmony export */ dbOpenFailedError: () => (/* binding */ dbOpenFailedError),\n/* harmony export */ dbReadFailedError: () => (/* binding */ dbReadFailedError),\n/* harmony export */ dbWriteFailedError: () => (/* binding */ dbWriteFailedError),\n/* harmony export */ notFoundError: () => (/* binding */ notFoundError)\n/* harmony export */ });\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n\nfunction dbOpenFailedError(err) {\n err = err ?? new Error('Cannot open database');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_OPEN_FAILED');\n}\nfunction dbDeleteFailedError(err) {\n err = err ?? new Error('Delete failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_DELETE_FAILED');\n}\nfunction dbWriteFailedError(err) {\n err = err ?? new Error('Write failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_WRITE_FAILED');\n}\nfunction dbReadFailedError(err) {\n err = err ?? new Error('Read failed');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_DB_READ_FAILED');\n}\nfunction notFoundError(err) {\n err = err ?? new Error('Not Found');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_NOT_FOUND');\n}\nfunction abortedError(err) {\n err = err ?? new Error('Aborted');\n return err_code__WEBPACK_IMPORTED_MODULE_0__(err, 'ERR_ABORTED');\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/dist/src/errors.js?"); + +/***/ }), + +/***/ "./node_modules/datastore-core/dist/src/memory.js": +/*!********************************************************!*\ + !*** ./node_modules/datastore-core/dist/src/memory.js ***! + \********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MemoryDatastore: () => (/* binding */ MemoryDatastore)\n/* harmony export */ });\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/datastore-core/dist/src/base.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/datastore-core/dist/src/errors.js\");\n\n\n\nclass MemoryDatastore extends _base_js__WEBPACK_IMPORTED_MODULE_1__.BaseDatastore {\n data;\n constructor() {\n super();\n this.data = new Map();\n }\n put(key, val) {\n this.data.set(key.toString(), val);\n return key;\n }\n get(key) {\n const result = this.data.get(key.toString());\n if (result == null) {\n throw _errors_js__WEBPACK_IMPORTED_MODULE_2__.notFoundError();\n }\n return result;\n }\n has(key) {\n return this.data.has(key.toString());\n }\n delete(key) {\n this.data.delete(key.toString());\n }\n *_all() {\n for (const [key, value] of this.data.entries()) {\n yield { key: new interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__.Key(key), value };\n }\n }\n *_allKeys() {\n for (const key of this.data.keys()) {\n yield new interface_datastore_key__WEBPACK_IMPORTED_MODULE_0__.Key(key);\n }\n }\n}\n//# sourceMappingURL=memory.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/dist/src/memory.js?"); + +/***/ }), + +/***/ "./node_modules/delay/index.js": +/*!*************************************!*\ + !*** ./node_modules/delay/index.js ***! + \*************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearDelay: () => (/* binding */ clearDelay),\n/* harmony export */ createDelay: () => (/* binding */ createDelay),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ rangeDelay: () => (/* binding */ rangeDelay)\n/* harmony export */ });\n// From https://github.com/sindresorhus/random-int/blob/c37741b56f76b9160b0b63dae4e9c64875128146/index.js#L13-L15\nconst randomInteger = (minimum, maximum) => Math.floor((Math.random() * (maximum - minimum + 1)) + minimum);\n\nconst createAbortError = () => {\n\tconst error = new Error('Delay aborted');\n\terror.name = 'AbortError';\n\treturn error;\n};\n\nconst clearMethods = new WeakMap();\n\nfunction createDelay({clearTimeout: defaultClear, setTimeout: defaultSet} = {}) {\n\t// We cannot use `async` here as we need the promise identity.\n\treturn (milliseconds, {value, signal} = {}) => {\n\t\t// TODO: Use `signal?.throwIfAborted()` when targeting Node.js 18.\n\t\tif (signal?.aborted) {\n\t\t\treturn Promise.reject(createAbortError());\n\t\t}\n\n\t\tlet timeoutId;\n\t\tlet settle;\n\t\tlet rejectFunction;\n\t\tconst clear = defaultClear ?? clearTimeout;\n\n\t\tconst signalListener = () => {\n\t\t\tclear(timeoutId);\n\t\t\trejectFunction(createAbortError());\n\t\t};\n\n\t\tconst cleanup = () => {\n\t\t\tif (signal) {\n\t\t\t\tsignal.removeEventListener('abort', signalListener);\n\t\t\t}\n\t\t};\n\n\t\tconst delayPromise = new Promise((resolve, reject) => {\n\t\t\tsettle = () => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(value);\n\t\t\t};\n\n\t\t\trejectFunction = reject;\n\t\t\ttimeoutId = (defaultSet ?? setTimeout)(settle, milliseconds);\n\t\t});\n\n\t\tif (signal) {\n\t\t\tsignal.addEventListener('abort', signalListener, {once: true});\n\t\t}\n\n\t\tclearMethods.set(delayPromise, () => {\n\t\t\tclear(timeoutId);\n\t\t\ttimeoutId = null;\n\t\t\tsettle();\n\t\t});\n\n\t\treturn delayPromise;\n\t};\n}\n\nconst delay = createDelay();\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (delay);\n\nasync function rangeDelay(minimum, maximum, options = {}) {\n\treturn delay(randomInteger(minimum, maximum), options);\n}\n\nfunction clearDelay(promise) {\n\tclearMethods.get(promise)?.();\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/delay/index.js?"); /***/ }), @@ -7186,336 +7578,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base10.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base10.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base16.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base16.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base2.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base2.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base256emoji.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base256emoji.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base32.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base32.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base36.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base36.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base58.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base58.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base64.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base64.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base8.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base8.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/identity.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/identity.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/interface.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/interface.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/basics.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/basics.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/block/interface.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/block/interface.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/block/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/cid.js": -/*!************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/cid.js ***! - \************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/interface.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/interface.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/json.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/json.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/raw.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/raw.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/hasher.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/hasher.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/identity.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/identity.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/interface.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/interface.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/sha2-browser.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! - \****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/index.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/interface.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/interface.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/link/interface.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/link/interface.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/base-x.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/base-x.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/varint.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/varint.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/multiformats/dist/src/vendor/varint.js?"); - -/***/ }), - /***/ "./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/alloc.js": /*!*************************************************************************************!*\ !*** ./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/alloc.js ***! @@ -7556,18 +7618,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/interface-datastore/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/util/bases.js?"); - -/***/ }), - -/***/ "./node_modules/ip-regex/index.js": -/*!****************************************!*\ - !*** ./node_modules/ip-regex/index.js ***! - \****************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nconst word = '[a-fA-F\\\\d:]';\n\nconst boundry = options => options && options.includeBoundaries\n\t? `(?:(?<=\\\\s|^)(?=${word})|(?<=${word})(?=\\\\s|$))`\n\t: '';\n\nconst v4 = '(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}';\n\nconst v6segment = '[a-fA-F\\\\d]{1,4}';\n\nconst v6 = `\n(?:\n(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\\s*\\/\\/.*$/gm, '').replace(/\\n/g, '').trim();\n\n// Pre-compile only the exact regexes because adding a global flag make regexes stateful\nconst v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);\nconst v4exact = new RegExp(`^${v4}$`);\nconst v6exact = new RegExp(`^${v6}$`);\n\nconst ipRegex = options => options && options.exact\n\t? v46Exact\n\t: new RegExp(`(?:${boundry(options)}${v4}${boundry(options)})|(?:${boundry(options)}${v6}${boundry(options)})`, 'g');\n\nipRegex.v4 = options => options && options.exact ? v4exact : new RegExp(`${boundry(options)}${v4}${boundry(options)}`, 'g');\nipRegex.v6 = options => options && options.exact ? v6exact : new RegExp(`${boundry(options)}${v6}${boundry(options)}`, 'g');\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ipRegex);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/ip-regex/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -7582,25 +7633,69 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/it-batched-bytes/dist/src/index.js": -/*!*********************************************************!*\ - !*** ./node_modules/it-batched-bytes/dist/src/index.js ***! - \*********************************************************/ +/***/ "./node_modules/it-byte-stream/dist/src/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/it-byte-stream/dist/src/index.js ***! + \*******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * The final batch may be smaller than the max.\n *\n * @example\n *\n * ```javascript\n * import batch from 'it-batched-bytes'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values = [\n * Uint8Array.from([0]),\n * Uint8Array.from([1]),\n * Uint8Array.from([2]),\n * Uint8Array.from([3]),\n * Uint8Array.from([4])\n * ]\n * const batchSize = 2\n *\n * const result = all(batch(values, { size: batchSize }))\n *\n * console.info(result) // [0, 1], [2, 3], [4]\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import batch from 'it-batched-bytes'\n * import all from 'it-all'\n *\n * const values = async function * () {\n * yield Uint8Array.from([0])\n * yield Uint8Array.from([1])\n * yield Uint8Array.from([2])\n * yield Uint8Array.from([3])\n * yield Uint8Array.from([4])\n * }\n * const batchSize = 2\n *\n * const result = await all(batch(values, { size: batchSize }))\n *\n * console.info(result) // [0, 1], [2, 3], [4]\n * ```\n */\n\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nconst DEFAULT_BATCH_SIZE = 1024 * 1024;\nconst DEFAULT_SERIALIZE = (buf, list) => { list.append(buf); };\nfunction batchedBytes(source, options) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n let buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n let ended = false;\n let deferred = (0,p_defer__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n let size = Number(options?.size ?? DEFAULT_BATCH_SIZE);\n if (isNaN(size) || size === 0 || size < 0) {\n size = DEFAULT_BATCH_SIZE;\n }\n if (size !== Math.round(size)) {\n throw new Error('Batch size must be an integer');\n }\n const yieldAfter = options?.yieldAfter ?? 0;\n const serialize = options?.serialize ?? DEFAULT_SERIALIZE;\n void Promise.resolve().then(async () => {\n try {\n let timeout;\n for await (const buf of source) {\n // @ts-expect-error - if buf is not `Uint8Array | Uint8ArrayList` we cannot use the default serializer\n serialize(buf, buffer);\n if (buffer.byteLength >= size) {\n clearTimeout(timeout);\n deferred.resolve();\n continue;\n }\n timeout = setTimeout(() => {\n deferred.resolve();\n }, yieldAfter);\n }\n clearTimeout(timeout);\n deferred.resolve();\n }\n catch (err) {\n deferred.reject(err);\n }\n finally {\n ended = true;\n }\n });\n while (!ended) { // eslint-disable-line no-unmodified-loop-condition\n await deferred.promise;\n deferred = (0,p_defer__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n if (buffer.byteLength > 0) {\n const b = buffer;\n buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n yield b.subarray();\n }\n }\n })();\n }\n return (function* () {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n let size = Number(options?.size ?? DEFAULT_BATCH_SIZE);\n if (isNaN(size) || size === 0 || size < 0) {\n size = DEFAULT_BATCH_SIZE;\n }\n if (size !== Math.round(size)) {\n throw new Error('Batch size must be an integer');\n }\n const serialize = options?.serialize ?? DEFAULT_SERIALIZE;\n for (const buf of source) {\n // @ts-expect-error - if buf is not `Uint8Array | Uint8ArrayList` we cannot use the default serializer\n serialize(buf, buffer);\n if (buffer.byteLength >= size) {\n yield buffer.subarray(0, size);\n buffer.consume(size);\n }\n }\n if (buffer.byteLength > 0) {\n yield buffer.subarray();\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (batchedBytes);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-batched-bytes/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ CodeError: () => (/* binding */ CodeError),\n/* harmony export */ byteStream: () => (/* binding */ byteStream)\n/* harmony export */ });\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _pushable_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pushable.js */ \"./node_modules/it-byte-stream/dist/src/pushable.js\");\n/**\n * @packageDocumentation\n *\n * This module makes it easy to send and receive bytes over streams.\n *\n * @example\n *\n * ```typescript\n * import { byteStream } from 'it-byte-stream'\n *\n * const stream = byteStream(duplex)\n *\n * // read the next chunk\n * const bytes = await stream.read()\n *\n * // read the next five bytes\n * const fiveBytes = await stream.read(5)\n *\n * // write bytes into the stream\n * await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))\n * ```\n */\n\n\nclass CodeError extends Error {\n code;\n constructor(message, code) {\n super(message);\n this.code = code;\n }\n}\nclass AbortError extends CodeError {\n type;\n constructor(message) {\n super(message, 'ABORT_ERR');\n this.type = 'aborted';\n }\n}\nfunction byteStream(duplex, opts) {\n const write = (0,_pushable_js__WEBPACK_IMPORTED_MODULE_1__.pushable)();\n duplex.sink(write).catch(async (err) => {\n await write.end(err);\n });\n duplex.sink = async (source) => {\n for await (const buf of source) {\n await write.push(buf);\n }\n await write.end();\n };\n let source = duplex.source;\n if (duplex.source[Symbol.iterator] != null) {\n source = duplex.source[Symbol.iterator]();\n }\n else if (duplex.source[Symbol.asyncIterator] != null) {\n source = duplex.source[Symbol.asyncIterator]();\n }\n const readBuffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n const W = {\n read: async (bytes, options) => {\n options?.signal?.throwIfAborted();\n let listener;\n const abortPromise = new Promise((resolve, reject) => {\n listener = () => {\n reject(new AbortError('Read aborted'));\n };\n options?.signal?.addEventListener('abort', listener);\n });\n try {\n if (bytes == null) {\n // just read whatever arrives\n const { done, value } = await Promise.race([\n source.next(),\n abortPromise\n ]);\n if (done === true) {\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n }\n return value;\n }\n while (readBuffer.byteLength < bytes) {\n const { value, done } = await Promise.race([\n source.next(),\n abortPromise\n ]);\n if (done === true) {\n throw new CodeError('unexpected end of input', 'ERR_UNEXPECTED_EOF');\n }\n readBuffer.append(value);\n }\n const buf = readBuffer.sublist(0, bytes);\n readBuffer.consume(bytes);\n return buf;\n }\n finally {\n if (listener != null) {\n options?.signal?.removeEventListener('abort', listener);\n }\n }\n },\n write: async (data, options) => {\n options?.signal?.throwIfAborted();\n // just write\n if (data instanceof Uint8Array) {\n await write.push(data, options);\n }\n else {\n await write.push(data.subarray(), options);\n }\n },\n unwrap: () => {\n if (readBuffer.byteLength > 0) {\n const originalStream = duplex.source;\n duplex.source = (async function* () {\n if (opts?.yieldBytes === false) {\n yield readBuffer;\n }\n else {\n yield* readBuffer;\n }\n yield* originalStream;\n }());\n }\n return duplex;\n }\n };\n return W;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-byte-stream/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/it-handshake/dist/src/index.js": -/*!*****************************************************!*\ - !*** ./node_modules/it-handshake/dist/src/index.js ***! - \*****************************************************/ +/***/ "./node_modules/it-byte-stream/dist/src/pushable.js": +/*!**********************************************************!*\ + !*** ./node_modules/it-byte-stream/dist/src/pushable.js ***! + \**********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ handshake: () => (/* binding */ handshake)\n/* harmony export */ });\n/* harmony import */ var it_reader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-reader */ \"./node_modules/it-reader/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/**\n * @packageDocumentation\n *\n * @example\n *\n * ```js\n *\n * import { pipe } from 'it-pipe'\n * import { duplexPair } from 'it-pair/duplex'\n * import { handshake } from 'it-handshake'\n *\n * // Create connected duplex streams\n * const [client, server] = duplexPair()\n * const clientShake = handshake(client)\n * const serverShake = handshake(server)\n *\n * clientShake.write('hello')\n * console.log('client: %s', await serverShake.read())\n * // > client: hello\n * serverShake.write('hi')\n * serverShake.rest() // the server has finished the handshake\n * console.log('server: %s', await clientShake.read())\n * // > server: hi\n * clientShake.rest() // the client has finished the handshake\n *\n * // Make the server echo responses\n * pipe(\n * serverShake.stream,\n * async function * (source) {\n * for await (const message of source) {\n * yield message\n * }\n * },\n * serverShake.stream\n * )\n *\n * // Send and receive an echo through the handshake stream\n * pipe(\n * ['echo'],\n * clientShake.stream,\n * async function * (source) {\n * for await (const bufferList of source) {\n * console.log('Echo response: %s', bufferList.slice())\n * // > Echo response: echo\n * }\n * }\n * )\n * ```\n */\n\n\n\n// Convert a duplex stream into a reader and writer and rest stream\nfunction handshake(stream) {\n const writer = (0,it_pushable__WEBPACK_IMPORTED_MODULE_1__.pushable)(); // Write bytes on demand to the sink\n const source = (0,it_reader__WEBPACK_IMPORTED_MODULE_0__.reader)(stream.source); // Read bytes on demand from the source\n // Waits for a source to be passed to the rest stream's sink\n const sourcePromise = (0,p_defer__WEBPACK_IMPORTED_MODULE_2__[\"default\"])();\n let sinkErr;\n const sinkPromise = stream.sink((async function* () {\n yield* writer;\n const source = await sourcePromise.promise;\n yield* source;\n })());\n sinkPromise.catch(err => {\n sinkErr = err;\n });\n const rest = {\n sink: async (source) => {\n if (sinkErr != null) {\n await Promise.reject(sinkErr);\n return;\n }\n sourcePromise.resolve(source);\n await sinkPromise;\n },\n source\n };\n return {\n reader: source,\n writer,\n stream: rest,\n rest: () => writer.end(),\n write: writer.push,\n read: async () => {\n const res = await source.next();\n if (res.value != null) {\n return res.value;\n }\n }\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-handshake/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pushable: () => (/* binding */ pushable)\n/* harmony export */ });\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var race_signal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! race-signal */ \"./node_modules/race-signal/dist/src/index.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index.js */ \"./node_modules/it-byte-stream/dist/src/index.js\");\n\n\n\nclass QueuelessPushable {\n readNext;\n haveNext;\n ended;\n nextResult;\n constructor() {\n this.ended = false;\n this.readNext = (0,p_defer__WEBPACK_IMPORTED_MODULE_2__[\"default\"])();\n this.haveNext = (0,p_defer__WEBPACK_IMPORTED_MODULE_2__[\"default\"])();\n }\n [Symbol.asyncIterator]() {\n return this;\n }\n async next() {\n if (this.nextResult == null) {\n // wait for the supplier to push a value\n await this.haveNext.promise;\n }\n if (this.nextResult == null) {\n throw new Error('HaveNext promise resolved but nextResult was undefined');\n }\n const nextResult = this.nextResult;\n this.nextResult = undefined;\n // signal to the supplier that we read the value\n this.readNext.resolve();\n this.readNext = (0,p_defer__WEBPACK_IMPORTED_MODULE_2__[\"default\"])();\n return nextResult;\n }\n async throw(err) {\n this.ended = true;\n if (err != null) {\n this.haveNext.reject(err);\n }\n const result = {\n done: true,\n value: undefined\n };\n return result;\n }\n async return() {\n const result = {\n done: true,\n value: undefined\n };\n await this._push(undefined);\n return result;\n }\n async push(value, options) {\n await this._push(value, options);\n }\n async end(err, options) {\n if (err != null) {\n await this.throw(err);\n }\n else {\n // abortable return\n await this._push(undefined, options);\n }\n }\n async _push(value, options) {\n if (value != null && this.ended) {\n throw new Error('Cannot push value onto an ended pushable');\n }\n // already have a value, wait for it to be read\n if (this.nextResult != null) {\n await this.readNext.promise;\n if (this.nextResult != null) {\n throw new Error('NeedNext promise resolved but nextResult was not consumed');\n }\n }\n if (value != null) {\n this.nextResult = { done: false, value };\n }\n else {\n this.ended = true;\n this.nextResult = { done: true, value: undefined };\n }\n // let the consumer know we have a new value\n this.haveNext.resolve();\n this.haveNext = (0,p_defer__WEBPACK_IMPORTED_MODULE_2__[\"default\"])();\n // wait for the consumer to have finished processing the value and requested\n // the next one or for the passed signal to abort the waiting\n await (0,race_signal__WEBPACK_IMPORTED_MODULE_0__.raceSignal)(this.readNext.promise, options?.signal, options);\n }\n}\nfunction pushable() {\n return new QueuelessPushable();\n}\n//# sourceMappingURL=pushable.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-byte-stream/dist/src/pushable.js?"); + +/***/ }), + +/***/ "./node_modules/it-drain/dist/src/index.js": +/*!*************************************************!*\ + !*** ./node_modules/it-drain/dist/src/index.js ***! + \*************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values.\n *\n * @example\n *\n * ```javascript\n * import drain from 'it-drain'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * drain(values)\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import drain from 'it-drain'\n *\n * const values = async function * {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * await drain(values())\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction drain(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars\n })();\n }\n else {\n for (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars\n }\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (drain);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-drain/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/it-filter/dist/src/index.js": +/*!**************************************************!*\ + !*** ./node_modules/it-filter/dist/src/index.js ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_peekable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-peekable */ \"./node_modules/it-peekable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Filter values out of an (async)iterable\n *\n * @example\n *\n * ```javascript\n * import all from 'it-all'\n * import filter from 'it-filter'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const fn = val => val > 2 // Return boolean to keep item\n *\n * const arr = all(filter(values, fn))\n *\n * console.info(arr) // 3, 4\n * ```\n *\n * Async sources and filter functions must be awaited:\n *\n * ```javascript\n * import all from 'it-all'\n * import filter from 'it-filter'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const fn = async val => val > 2 // Return boolean or promise of boolean to keep item\n *\n * const arr = await all(filter(values, fn))\n *\n * console.info(arr) // 3, 4\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction filter(source, fn) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n for await (const entry of source) {\n if (await fn(entry)) {\n yield entry;\n }\n }\n })();\n }\n // if mapping function returns a promise we have to return an async generator\n const peekable = (0,it_peekable__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n const { value, done } = peekable.next();\n if (done === true) {\n return (function* () { }());\n }\n const res = fn(value);\n // @ts-expect-error .then is not present on O\n if (typeof res.then === 'function') {\n return (async function* () {\n if (await res) {\n yield value;\n }\n for await (const entry of peekable) {\n if (await fn(entry)) {\n yield entry;\n }\n }\n })();\n }\n const func = fn;\n return (function* () {\n if (res === true) {\n yield value;\n }\n for (const entry of peekable) {\n if (func(entry)) {\n yield entry;\n }\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (filter);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-filter/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/it-first/dist/src/index.js": +/*!*************************************************!*\ + !*** ./node_modules/it-first/dist/src/index.js ***! + \*************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Return the first value in an (async)iterable\n *\n * @example\n *\n * ```javascript\n * import first from 'it-first'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const res = first(values)\n *\n * console.info(res) // 0\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import first from 'it-first'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const res = await first(values())\n *\n * console.info(res) // 0\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction first(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n })();\n }\n for (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (first);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-first/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/it-length-prefixed-stream/dist/src/index.js": +/*!******************************************************************!*\ + !*** ./node_modules/it-length-prefixed-stream/dist/src/index.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ lpStream: () => (/* binding */ lpStream)\n/* harmony export */ });\n/* harmony import */ var it_byte_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-byte-stream */ \"./node_modules/it-byte-stream/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * This module makes it easy to send and receive length-prefixed byte arrays over streams.\n *\n * @example\n *\n * ```typescript\n * import { lpStream } from 'it-length-prefixed-stream'\n *\n * const stream = lpStream(duplex)\n *\n * // read the next length-prefixed chunk\n * const bytes = await stream.read()\n *\n * // write a length-prefixed chunk\n * await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))\n *\n * // write several chunks, all individually length-prefixed\n * await stream.writeV([\n * Uint8Array.from([0, 1, 2, 3, 4]),\n * Uint8Array.from([5, 6, 7, 8, 9])\n * ])\n * ```\n */\n\n\n\nclass CodeError extends Error {\n code;\n constructor(message, code) {\n super(message);\n this.code = code;\n }\n}\nfunction lpStream(duplex, opts = {}) {\n const bytes = (0,it_byte_stream__WEBPACK_IMPORTED_MODULE_0__.byteStream)(duplex, opts);\n if (opts.maxDataLength != null && opts.maxLengthLength == null) {\n // if max data length is set but max length length is not, calculate the\n // max length length needed to encode max data length\n opts.maxLengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.encodingLength(opts.maxDataLength);\n }\n const decodeLength = opts?.lengthDecoder ?? uint8_varint__WEBPACK_IMPORTED_MODULE_1__.decode;\n const encodeLength = opts?.lengthEncoder ?? uint8_varint__WEBPACK_IMPORTED_MODULE_1__.encode;\n const W = {\n read: async (options) => {\n let dataLength = -1;\n const lengthBuffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList();\n while (true) {\n // read one byte at a time until we can decode a varint\n lengthBuffer.append(await bytes.read(1, options));\n try {\n dataLength = decodeLength(lengthBuffer);\n }\n catch (err) {\n if (err instanceof RangeError) {\n continue;\n }\n throw err;\n }\n if (opts?.maxLengthLength != null && lengthBuffer.byteLength > opts.maxLengthLength) {\n throw new CodeError('message length length too long', 'ERR_MSG_LENGTH_TOO_LONG');\n }\n if (dataLength > -1) {\n break;\n }\n }\n if (opts?.maxDataLength != null && dataLength > opts.maxDataLength) {\n throw new CodeError('message length too long', 'ERR_MSG_DATA_TOO_LONG');\n }\n return bytes.read(dataLength, options);\n },\n write: async (data, options) => {\n // encode, write\n await bytes.write(new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList(encodeLength(data.byteLength), data), options);\n },\n writeV: async (data, options) => {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList(...data.flatMap(buf => ([encodeLength(buf.byteLength), buf])));\n // encode, write\n await bytes.write(list, options);\n },\n unwrap: () => {\n return bytes.unwrap();\n }\n };\n return W;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed-stream/dist/src/index.js?"); /***/ }), @@ -7611,7 +7706,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_DATA_LENGTH: () => (/* binding */ MAX_DATA_LENGTH),\n/* harmony export */ MAX_LENGTH_LENGTH: () => (/* binding */ MAX_LENGTH_LENGTH),\n/* harmony export */ decode: () => (/* binding */ decode)\n/* harmony export */ });\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/it-length-prefixed/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/it-length-prefixed/dist/src/utils.js\");\n/* eslint max-depth: [\"error\", 6] */\n\n\n\n\n// Maximum length of the length section of the message\nconst MAX_LENGTH_LENGTH = 8; // Varint.encode(Number.MAX_SAFE_INTEGER).length\n// Maximum length of the data section of the message\nconst MAX_DATA_LENGTH = 1024 * 1024 * 4;\nvar ReadMode;\n(function (ReadMode) {\n ReadMode[ReadMode[\"LENGTH\"] = 0] = \"LENGTH\";\n ReadMode[ReadMode[\"DATA\"] = 1] = \"DATA\";\n})(ReadMode || (ReadMode = {}));\nconst defaultDecoder = (buf) => {\n const length = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(source, options) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList();\n let mode = ReadMode.LENGTH;\n let dataLength = -1;\n const lengthDecoder = options?.lengthDecoder ?? defaultDecoder;\n const maxLengthLength = options?.maxLengthLength ?? MAX_LENGTH_LENGTH;\n const maxDataLength = options?.maxDataLength ?? MAX_DATA_LENGTH;\n function* maybeYield() {\n while (buffer.byteLength > 0) {\n if (mode === ReadMode.LENGTH) {\n // read length, ignore errors for short reads\n try {\n dataLength = lengthDecoder(buffer);\n if (dataLength < 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length too long'), 'ERR_MSG_DATA_TOO_LONG');\n }\n const dataLengthLength = lengthDecoder.bytes;\n buffer.consume(dataLengthLength);\n if (options?.onLength != null) {\n options.onLength(dataLength);\n }\n mode = ReadMode.DATA;\n }\n catch (err) {\n if (err instanceof RangeError) {\n if (buffer.byteLength > maxLengthLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length length too long'), 'ERR_MSG_LENGTH_TOO_LONG');\n }\n break;\n }\n throw err;\n }\n }\n if (mode === ReadMode.DATA) {\n if (buffer.byteLength < dataLength) {\n // not enough data, wait for more\n break;\n }\n const data = buffer.sublist(0, dataLength);\n buffer.consume(dataLength);\n if (options?.onData != null) {\n options.onData(data);\n }\n yield data;\n mode = ReadMode.LENGTH;\n }\n }\n }\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.isAsyncIterable)(source)) {\n return (async function* () {\n for await (const buf of source) {\n buffer.append(buf);\n yield* maybeYield();\n }\n if (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n })();\n }\n return (function* () {\n for (const buf of source) {\n buffer.append(buf);\n yield* maybeYield();\n }\n if (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n })();\n}\ndecode.fromReader = (reader, options) => {\n let byteLength = 1; // Read single byte chunks until the length is known\n const varByteSource = (async function* () {\n while (true) {\n try {\n const { done, value } = await reader.next(byteLength);\n if (done === true) {\n return;\n }\n if (value != null) {\n yield value;\n }\n }\n catch (err) {\n if (err.code === 'ERR_UNDER_READ') {\n return { done: true, value: null };\n }\n throw err;\n }\n finally {\n // Reset the byteLength so we continue to check for varints\n byteLength = 1;\n }\n }\n }());\n /**\n * Once the length has been parsed, read chunk for that length\n */\n const onLength = (l) => { byteLength = l; };\n return decode(varByteSource, {\n ...(options ?? {}),\n onLength\n });\n};\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/decode.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MAX_DATA_LENGTH: () => (/* binding */ MAX_DATA_LENGTH),\n/* harmony export */ MAX_LENGTH_LENGTH: () => (/* binding */ MAX_LENGTH_LENGTH),\n/* harmony export */ decode: () => (/* binding */ decode)\n/* harmony export */ });\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/it-length-prefixed/dist/src/utils.js\");\n/* eslint max-depth: [\"error\", 6] */\n\n\n\n\n// Maximum length of the length section of the message\nconst MAX_LENGTH_LENGTH = 8; // Varint.encode(Number.MAX_SAFE_INTEGER).length\n// Maximum length of the data section of the message\nconst MAX_DATA_LENGTH = 1024 * 1024 * 4;\nvar ReadMode;\n(function (ReadMode) {\n ReadMode[ReadMode[\"LENGTH\"] = 0] = \"LENGTH\";\n ReadMode[ReadMode[\"DATA\"] = 1] = \"DATA\";\n})(ReadMode || (ReadMode = {}));\nconst defaultDecoder = (buf) => {\n const length = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(source, options) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_2__.Uint8ArrayList();\n let mode = ReadMode.LENGTH;\n let dataLength = -1;\n const lengthDecoder = options?.lengthDecoder ?? defaultDecoder;\n const maxLengthLength = options?.maxLengthLength ?? MAX_LENGTH_LENGTH;\n const maxDataLength = options?.maxDataLength ?? MAX_DATA_LENGTH;\n function* maybeYield() {\n while (buffer.byteLength > 0) {\n if (mode === ReadMode.LENGTH) {\n // read length, ignore errors for short reads\n try {\n dataLength = lengthDecoder(buffer);\n if (dataLength < 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length too long'), 'ERR_MSG_DATA_TOO_LONG');\n }\n const dataLengthLength = lengthDecoder.bytes;\n buffer.consume(dataLengthLength);\n if (options?.onLength != null) {\n options.onLength(dataLength);\n }\n mode = ReadMode.DATA;\n }\n catch (err) {\n if (err instanceof RangeError) {\n if (buffer.byteLength > maxLengthLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length length too long'), 'ERR_MSG_LENGTH_TOO_LONG');\n }\n break;\n }\n throw err;\n }\n }\n if (mode === ReadMode.DATA) {\n if (buffer.byteLength < dataLength) {\n // not enough data, wait for more\n break;\n }\n const data = buffer.sublist(0, dataLength);\n buffer.consume(dataLength);\n if (options?.onData != null) {\n options.onData(data);\n }\n yield data;\n mode = ReadMode.LENGTH;\n }\n }\n }\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.isAsyncIterable)(source)) {\n return (async function* () {\n for await (const buf of source) {\n buffer.append(buf);\n yield* maybeYield();\n }\n if (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n })();\n }\n return (function* () {\n for (const buf of source) {\n buffer.append(buf);\n yield* maybeYield();\n }\n if (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n })();\n}\ndecode.fromReader = (reader, options) => {\n let byteLength = 1; // Read single byte chunks until the length is known\n const varByteSource = (async function* () {\n while (true) {\n try {\n const { done, value } = await reader.next(byteLength);\n if (done === true) {\n return;\n }\n if (value != null) {\n yield value;\n }\n }\n catch (err) {\n if (err.code === 'ERR_UNDER_READ') {\n return { done: true, value: null };\n }\n throw err;\n }\n finally {\n // Reset the byteLength so we continue to check for varints\n byteLength = 1;\n }\n }\n }());\n /**\n * Once the length has been parsed, read chunk for that length\n */\n const onLength = (l) => { byteLength = l; };\n return decode(varByteSource, {\n ...(options ?? {}),\n onLength\n });\n};\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/decode.js?"); /***/ }), @@ -7622,7 +7717,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encode: () => (/* binding */ encode)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/it-length-prefixed/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/it-length-prefixed/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/it-length-prefixed/dist/src/utils.js\");\n\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(length);\n const lengthBuf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(source, options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n function* maybeYield(chunk) {\n // length + data\n const length = encodeLength(chunk.byteLength);\n // yield only Uint8Arrays\n if (length instanceof Uint8Array) {\n yield length;\n }\n else {\n yield* length;\n }\n // yield only Uint8Arrays\n if (chunk instanceof Uint8Array) {\n yield chunk;\n }\n else {\n yield* chunk;\n }\n }\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.isAsyncIterable)(source)) {\n return (async function* () {\n for await (const chunk of source) {\n yield* maybeYield(chunk);\n }\n })();\n }\n return (function* () {\n for (const chunk of source) {\n yield* maybeYield(chunk);\n }\n })();\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/encode.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ encode: () => (/* binding */ encode)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/it-length-prefixed/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/it-length-prefixed/dist/src/utils.js\");\n\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength(length);\n const lengthBuf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(source, options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n function* maybeYield(chunk) {\n // length + data\n const length = encodeLength(chunk.byteLength);\n // yield only Uint8Arrays\n if (length instanceof Uint8Array) {\n yield length;\n }\n else {\n yield* length;\n }\n // yield only Uint8Arrays\n if (chunk instanceof Uint8Array) {\n yield chunk;\n }\n else {\n yield* chunk;\n }\n }\n if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.isAsyncIterable)(source)) {\n return (async function* () {\n for await (const chunk of source) {\n yield* maybeYield(chunk);\n }\n })();\n }\n return (function* () {\n for (const chunk of source) {\n yield* maybeYield(chunk);\n }\n })();\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/encode.js?"); /***/ }), @@ -7648,17 +7743,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/it-length-prefixed/node_modules/uint8-varint/dist/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/it-length-prefixed/node_modules/uint8-varint/dist/src/index.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ decodeUint8Array: () => (/* binding */ decodeUint8Array),\n/* harmony export */ decodeUint8ArrayList: () => (/* binding */ decodeUint8ArrayList),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ encodeUint8Array: () => (/* binding */ encodeUint8Array),\n/* harmony export */ encodeUint8ArrayList: () => (/* binding */ encodeUint8ArrayList),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/it-length-prefixed/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable no-fallthrough */\n\nconst N1 = Math.pow(2, 7);\nconst N2 = Math.pow(2, 14);\nconst N3 = Math.pow(2, 21);\nconst N4 = Math.pow(2, 28);\nconst N5 = Math.pow(2, 35);\nconst N6 = Math.pow(2, 42);\nconst N7 = Math.pow(2, 49);\n/** Most significant bit of a byte */\nconst MSB = 0x80;\n/** Rest of the bits in a byte */\nconst REST = 0x7f;\nfunction encodingLength(value) {\n if (value < N1) {\n return 1;\n }\n if (value < N2) {\n return 2;\n }\n if (value < N3) {\n return 3;\n }\n if (value < N4) {\n return 4;\n }\n if (value < N5) {\n return 5;\n }\n if (value < N6) {\n return 6;\n }\n if (value < N7) {\n return 7;\n }\n if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {\n throw new RangeError('Could not encode varint');\n }\n return 8;\n}\nfunction encodeUint8Array(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 7: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 6: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 5: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 4: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 3: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 2: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 1: {\n buf[offset++] = (value & 0xFF);\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction encodeUint8ArrayList(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 7: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 6: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 5: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 4: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 3: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 2: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 1: {\n buf.set(offset++, (value & 0xFF));\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction decodeUint8Array(buf, offset) {\n let b = buf[offset];\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 1];\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 2];\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 3];\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 4];\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 5];\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 6];\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 7];\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction decodeUint8ArrayList(buf, offset) {\n let b = buf.get(offset);\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 1);\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 2);\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 3);\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 4);\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 5);\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 6);\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 7);\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction encode(value, buf, offset = 0) {\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(encodingLength(value));\n }\n if (buf instanceof Uint8Array) {\n return encodeUint8Array(value, buf, offset);\n }\n else {\n return encodeUint8ArrayList(value, buf, offset);\n }\n}\nfunction decode(buf, offset = 0) {\n if (buf instanceof Uint8Array) {\n return decodeUint8Array(buf, offset);\n }\n else {\n return decodeUint8ArrayList(buf, offset);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/node_modules/uint8-varint/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/it-length-prefixed/node_modules/uint8arrays/dist/src/alloc.js": /*!************************************************************************************!*\ !*** ./node_modules/it-length-prefixed/node_modules/uint8arrays/dist/src/alloc.js ***! @@ -7670,6 +7754,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/it-merge/dist/src/index.js": +/*!*************************************************!*\ + !*** ./node_modules/it-merge/dist/src/index.js ***! + \*************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Merge several (async)iterables into one, yield values as they arrive.\n *\n * Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.\n *\n * @example\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values1 = [0, 1, 2, 3, 4]\n * const values2 = [5, 6, 7, 8, 9]\n *\n * const arr = all(merge(values1, values2))\n *\n * console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import merge from 'it-merge'\n * import all from 'it-all'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const values1 = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n * const values2 = async function * () {\n * yield * [5, 6, 7, 8, 9]\n * }\n *\n * const arr = await all(merge(values1(), values2()))\n *\n * console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction merge(...sources) {\n const syncSources = [];\n for (const source of sources) {\n if (!isAsyncIterable(source)) {\n syncSources.push(source);\n }\n }\n if (syncSources.length === sources.length) {\n // all sources are synchronous\n return (function* () {\n for (const source of syncSources) {\n yield* source;\n }\n })();\n }\n return (async function* () {\n const output = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n void Promise.resolve().then(async () => {\n try {\n await Promise.all(sources.map(async (source) => {\n for await (const item of source) {\n output.push(item);\n }\n }));\n output.end();\n }\n catch (err) {\n output.end(err);\n }\n });\n yield* output;\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (merge);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-merge/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/it-pair/dist/src/duplex.js": /*!*************************************************!*\ !*** ./node_modules/it-pair/dist/src/duplex.js ***! @@ -7692,14 +7787,14 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/it-pb-stream/dist/src/index.js": -/*!*****************************************************!*\ - !*** ./node_modules/it-pb-stream/dist/src/index.js ***! - \*****************************************************/ +/***/ "./node_modules/it-parallel/dist/src/index.js": +/*!****************************************************!*\ + !*** ./node_modules/it-parallel/dist/src/index.js ***! + \****************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pbStream: () => (/* binding */ pbStream)\n/* harmony export */ });\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * This module makes it easy to send and receive Protobuf encoded messages over\n * streams.\n *\n * @example\n *\n * ```typescript\n * import { pbStream } from 'it-pb-stream'\n * import { MessageType } from './src/my-message-type.js'\n *\n * // RequestType and ResponseType have been generate from `.proto` files and have\n * // `.encode` and `.decode` methods for serialization/deserialization\n *\n * const stream = pbStream(duplex)\n * stream.writePB({\n * foo: 'bar'\n * }, MessageType)\n * const res = await stream.readPB(MessageType)\n * ```\n */\n\n\n\n\n\nconst defaultLengthDecoder = (buf) => {\n return uint8_varint__WEBPACK_IMPORTED_MODULE_3__.unsigned.decode(buf);\n};\ndefaultLengthDecoder.bytes = 0;\nfunction pbStream(duplex, opts) {\n const write = (0,it_pushable__WEBPACK_IMPORTED_MODULE_2__.pushable)();\n duplex.sink(write).catch((err) => {\n write.end(err);\n });\n duplex.sink = async (source) => {\n for await (const buf of source) {\n write.push(buf);\n }\n write.end();\n };\n let source = duplex.source;\n if (duplex.source[Symbol.iterator] != null) {\n source = duplex.source[Symbol.iterator]();\n }\n else if (duplex.source[Symbol.asyncIterator] != null) {\n source = duplex.source[Symbol.asyncIterator]();\n }\n const readBuffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_4__.Uint8ArrayList();\n const W = {\n read: async (bytes) => {\n if (bytes == null) {\n // just read whatever arrives\n const { done, value } = await source.next();\n if (done === true) {\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_4__.Uint8ArrayList();\n }\n return value;\n }\n while (readBuffer.byteLength < bytes) {\n const { value, done } = await source.next();\n if (done === true) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n readBuffer.append(value);\n }\n const buf = readBuffer.sublist(0, bytes);\n readBuffer.consume(bytes);\n return buf;\n },\n readLP: async () => {\n let dataLength = -1;\n const lengthBuffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_4__.Uint8ArrayList();\n const decodeLength = opts?.lengthDecoder ?? defaultLengthDecoder;\n while (true) {\n // read one byte at a time until we can decode a varint\n lengthBuffer.append(await W.read(1));\n try {\n dataLength = decodeLength(lengthBuffer);\n }\n catch (err) {\n if (err instanceof RangeError) {\n continue;\n }\n throw err;\n }\n if (dataLength > -1) {\n break;\n }\n if (opts?.maxLengthLength != null && lengthBuffer.byteLength > opts.maxLengthLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length length too long'), 'ERR_MSG_LENGTH_TOO_LONG');\n }\n }\n if (opts?.maxDataLength != null && dataLength > opts.maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('message length too long'), 'ERR_MSG_DATA_TOO_LONG');\n }\n return W.read(dataLength);\n },\n readPB: async (proto) => {\n // readLP, decode\n const value = await W.readLP();\n if (value == null) {\n throw new Error('Value is null');\n }\n // Is this a buffer?\n const buf = value instanceof Uint8Array ? value : value.subarray();\n return proto.decode(buf);\n },\n write: (data) => {\n // just write\n if (data instanceof Uint8Array) {\n write.push(data);\n }\n else {\n write.push(data.subarray());\n }\n },\n writeLP: (data) => {\n // encode, write\n W.write(it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.encode.single(data, opts));\n },\n writePB: (data, proto) => {\n // encode, writeLP\n W.writeLP(proto.encode(data));\n },\n pb: (proto) => {\n return {\n read: async () => W.readPB(proto),\n write: (d) => { W.writePB(d, proto); },\n unwrap: () => W\n };\n },\n unwrap: () => {\n const originalStream = duplex.source;\n duplex.source = (async function* () {\n yield* readBuffer;\n yield* originalStream;\n }());\n return duplex;\n }\n };\n return W;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-pb-stream/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ parallel)\n/* harmony export */ });\n/* harmony import */ var p_defer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/**\n * @packageDocumentation\n *\n * Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input\n *\n * @example\n *\n * ```javascript\n * import parallel from 'it-parallel'\n * import all from 'it-all'\n * import delay from 'delay'\n *\n * // This can also be an iterator, async iterator, generator, etc\n * const input = [\n * async () => {\n * console.info('start 1')\n * await delay(500)\n *\n * console.info('end 1')\n * return 1\n * },\n * async () => {\n * console.info('start 2')\n * await delay(200)\n *\n * console.info('end 2')\n * return 2\n * },\n * async () => {\n * console.info('start 3')\n * await delay(100)\n *\n * console.info('end 3')\n * return 3\n * }\n * ]\n *\n * const result = await all(parallel(input, {\n * concurrency: 2\n * }))\n *\n * // output:\n * // start 1\n * // start 2\n * // end 2\n * // start 3\n * // end 3\n * // end 1\n *\n * console.info(result) // [2, 3, 1]\n * ```\n *\n * If order is important, pass `ordered: true` as an option:\n *\n * ```javascript\n * const result = await all(parallel(input, {\n * concurrency: 2,\n * ordered: true\n * }))\n *\n * // output:\n * // start 1\n * // start 2\n * // end 2\n * // start 3\n * // end 3\n * // end 1\n *\n * console.info(result) // [1, 2, 3]\n * ```\n */\n\nconst CustomEvent = globalThis.CustomEvent ?? Event;\n/**\n * Takes an (async) iterator that emits promise-returning functions,\n * invokes them in parallel and emits the results as they become available but\n * in the same order as the input\n */\nasync function* parallel(source, options = {}) {\n let concurrency = options.concurrency ?? Infinity;\n if (concurrency < 1) {\n concurrency = Infinity;\n }\n const ordered = options.ordered == null ? false : options.ordered;\n const emitter = new EventTarget();\n const ops = [];\n let slotAvailable = (0,p_defer__WEBPACK_IMPORTED_MODULE_0__[\"default\"])();\n let resultAvailable = (0,p_defer__WEBPACK_IMPORTED_MODULE_0__[\"default\"])();\n let sourceFinished = false;\n let sourceErr;\n let opErred = false;\n emitter.addEventListener('task-complete', () => {\n resultAvailable.resolve();\n });\n void Promise.resolve().then(async () => {\n try {\n for await (const task of source) {\n if (ops.length === concurrency) {\n slotAvailable = (0,p_defer__WEBPACK_IMPORTED_MODULE_0__[\"default\"])();\n await slotAvailable.promise;\n }\n if (opErred) {\n break;\n }\n const op = {\n done: false\n };\n ops.push(op);\n task()\n .then(result => {\n op.done = true;\n op.ok = true;\n op.value = result;\n emitter.dispatchEvent(new CustomEvent('task-complete'));\n }, err => {\n op.done = true;\n op.err = err;\n emitter.dispatchEvent(new CustomEvent('task-complete'));\n });\n }\n sourceFinished = true;\n emitter.dispatchEvent(new CustomEvent('task-complete'));\n }\n catch (err) {\n sourceErr = err;\n emitter.dispatchEvent(new CustomEvent('task-complete'));\n }\n });\n function valuesAvailable() {\n if (ordered) {\n return ops[0]?.done;\n }\n return Boolean(ops.find(op => op.done));\n }\n function* yieldOrderedValues() {\n while ((ops.length > 0) && ops[0].done) {\n const op = ops[0];\n ops.shift();\n if (op.ok) {\n yield op.value;\n }\n else {\n // allow the source to exit\n opErred = true;\n slotAvailable.resolve();\n throw op.err;\n }\n slotAvailable.resolve();\n }\n }\n function* yieldUnOrderedValues() {\n // more values can become available while we wait for `yield`\n // to return control to this function\n while (valuesAvailable()) {\n for (let i = 0; i < ops.length; i++) {\n if (ops[i].done) {\n const op = ops[i];\n ops.splice(i, 1);\n i--;\n if (op.ok) {\n yield op.value;\n }\n else {\n opErred = true;\n slotAvailable.resolve();\n throw op.err;\n }\n slotAvailable.resolve();\n }\n }\n }\n }\n while (true) {\n if (!valuesAvailable()) {\n resultAvailable = (0,p_defer__WEBPACK_IMPORTED_MODULE_0__[\"default\"])();\n await resultAvailable.promise;\n }\n if (sourceErr != null) {\n // the source threw an error, propagate it\n throw sourceErr;\n }\n if (ordered) {\n yield* yieldOrderedValues();\n }\n else {\n yield* yieldUnOrderedValues();\n }\n if (sourceFinished && ops.length === 0) {\n // not waiting for any results and no more tasks so we are done\n break;\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-parallel/dist/src/index.js?"); /***/ }), @@ -7714,6 +7809,28 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/it-pipe/dist/src/index.js": +/*!************************************************!*\ + !*** ./node_modules/it-pipe/dist/src/index.js ***! + \************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pipe: () => (/* binding */ pipe),\n/* harmony export */ rawPipe: () => (/* binding */ rawPipe)\n/* harmony export */ });\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/dist/src/index.js\");\n\n\nfunction pipe(first, ...rest) {\n if (first == null) {\n throw new Error('Empty pipeline');\n }\n // Duplex at start: wrap in function and return duplex source\n if (isDuplex(first)) {\n const duplex = first;\n first = () => duplex.source;\n // Iterable at start: wrap in function\n }\n else if (isIterable(first) || isAsyncIterable(first)) {\n const source = first;\n first = () => source;\n }\n const fns = [first, ...rest];\n if (fns.length > 1) {\n // Duplex at end: use duplex sink\n if (isDuplex(fns[fns.length - 1])) {\n fns[fns.length - 1] = fns[fns.length - 1].sink;\n }\n }\n if (fns.length > 2) {\n // Duplex in the middle, consume source with duplex sink and return duplex source\n for (let i = 1; i < fns.length - 1; i++) {\n if (isDuplex(fns[i])) {\n fns[i] = duplexPipelineFn(fns[i]);\n }\n }\n }\n return rawPipe(...fns);\n}\nconst rawPipe = (...fns) => {\n let res;\n while (fns.length > 0) {\n res = fns.shift()(res);\n }\n return res;\n};\nconst isAsyncIterable = (obj) => {\n return obj?.[Symbol.asyncIterator] != null;\n};\nconst isIterable = (obj) => {\n return obj?.[Symbol.iterator] != null;\n};\nconst isDuplex = (obj) => {\n if (obj == null) {\n return false;\n }\n return obj.sink != null && obj.source != null;\n};\nconst duplexPipelineFn = (duplex) => {\n return (source) => {\n const p = duplex.sink(source);\n if (p?.then != null) {\n const stream = (0,it_pushable__WEBPACK_IMPORTED_MODULE_0__.pushable)({\n objectMode: true\n });\n p.then(() => {\n stream.end();\n }, (err) => {\n stream.end(err);\n });\n let sourceWrap;\n const source = duplex.source;\n if (isAsyncIterable(source)) {\n sourceWrap = async function* () {\n yield* source;\n stream.end();\n };\n }\n else if (isIterable(source)) {\n sourceWrap = function* () {\n yield* source;\n stream.end();\n };\n }\n else {\n throw new Error('Unknown duplex source type - must be Iterable or AsyncIterable');\n }\n return (0,it_merge__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(stream, sourceWrap());\n }\n return duplex.source;\n };\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-pipe/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/it-protobuf-stream/dist/src/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/it-protobuf-stream/dist/src/index.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ pbStream: () => (/* binding */ pbStream)\n/* harmony export */ });\n/* harmony import */ var it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed-stream */ \"./node_modules/it-length-prefixed-stream/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * This module makes it easy to send and receive length-prefixed Protobuf encoded\n * messages over streams.\n *\n * @example\n *\n * ```typescript\n * import { pbStream } from 'it-protobuf-stream'\n * import { MessageType } from './src/my-message-type.js'\n *\n * // RequestType and ResponseType have been generate from `.proto` files and have\n * // `.encode` and `.decode` methods for serialization/deserialization\n *\n * const stream = pbStream(duplex)\n *\n * // write a message to the stream\n * stream.write({\n * foo: 'bar'\n * }, MessageType)\n *\n * // read a message from the stream\n * const res = await stream.read(MessageType)\n * ```\n */\n\nfunction pbStream(duplex, opts) {\n const lp = (0,it_length_prefixed_stream__WEBPACK_IMPORTED_MODULE_0__.lpStream)(duplex, opts);\n const W = {\n read: async (proto, options) => {\n // readLP, decode\n const value = await lp.read(options);\n return proto.decode(value);\n },\n write: async (message, proto, options) => {\n // encode, writeLP\n await lp.write(proto.encode(message), options);\n },\n writeV: async (messages, proto, options) => {\n // encode, writeLP\n await lp.writeV(messages.map(message => proto.encode(message)), options);\n },\n pb: (proto) => {\n return {\n read: async (options) => W.read(proto, options),\n write: async (d, options) => W.write(d, proto, options),\n writeV: async (d, options) => W.writeV(d, proto, options),\n unwrap: () => W\n };\n },\n unwrap: () => {\n return lp.unwrap();\n }\n };\n return W;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-protobuf-stream/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/it-pushable/dist/src/fifo.js": /*!***************************************************!*\ !*** ./node_modules/it-pushable/dist/src/fifo.js ***! @@ -7736,14 +7853,25 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/it-reader/dist/src/index.js": -/*!**************************************************!*\ - !*** ./node_modules/it-reader/dist/src/index.js ***! - \**************************************************/ +/***/ "./node_modules/it-sort/dist/src/index.js": +/*!************************************************!*\ + !*** ./node_modules/it-sort/dist/src/index.js ***! + \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ reader: () => (/* binding */ reader)\n/* harmony export */ });\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n\n/**\n * Returns an `AsyncGenerator` that allows reading a set number of bytes from the passed source.\n *\n * @example\n *\n * ```javascript\n * import { reader } from 'it-reader'\n *\n * const stream = reader(source)\n *\n * // read 10 bytes from the stream\n * const { done, value } = await stream.next(10)\n *\n * if (done === true) {\n * // stream finished\n * }\n *\n * if (value != null) {\n * // do something with value\n * }\n * ```\n */\nfunction reader(source) {\n const reader = (async function* () {\n // @ts-expect-error first yield in stream is ignored\n let bytes = yield; // Allows us to receive 8 when reader.next(8) is called\n let bl = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n for await (const chunk of source) {\n if (bytes == null) {\n bl.append(chunk);\n bytes = yield bl;\n bl = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n continue;\n }\n bl.append(chunk);\n while (bl.length >= bytes) {\n const data = bl.sublist(0, bytes);\n bl.consume(bytes);\n bytes = yield data;\n // If we no longer want a specific byte length, we yield the rest now\n if (bytes == null) {\n if (bl.length > 0) {\n bytes = yield bl;\n bl = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList();\n }\n break; // bytes is null and/or no more buffer to yield\n }\n }\n }\n // Consumer wants more bytes but the source has ended and our buffer\n // is not big enough to satisfy.\n if (bytes != null) {\n throw Object.assign(new Error(`stream ended before ${bytes} bytes became available`), { code: 'ERR_UNDER_READ', buffer: bl });\n }\n })();\n void reader.next();\n return reader;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-reader/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/**\n * @packageDocumentation\n *\n * Consumes all values from an (async)iterable and returns them sorted by the passed sort function.\n *\n * @example\n *\n * ```javascript\n * import sort from 'it-sort'\n * import all from 'it-all'\n *\n * const sorter = (a, b) => {\n * return a.localeCompare(b)\n * }\n *\n * // This can also be an iterator, generator, etc\n * const values = ['foo', 'bar']\n *\n * const arr = all(sort(values, sorter))\n *\n * console.info(arr) // 'bar', 'foo'\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import sort from 'it-sort'\n * import all from 'it-all'\n *\n * const sorter = (a, b) => {\n * return a.localeCompare(b)\n * }\n *\n * const values = async function * () {\n * yield * ['foo', 'bar']\n * }\n *\n * const arr = await all(sort(values, sorter))\n *\n * console.info(arr) // 'bar', 'foo'\n * ```\n */\n\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction sort(source, sorter) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n const arr = await (0,it_all__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n yield* arr.sort(sorter);\n })();\n }\n return (function* () {\n const arr = (0,it_all__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(source);\n yield* arr.sort(sorter);\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (sort);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-sort/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/it-take/dist/src/index.js": +/*!************************************************!*\ + !*** ./node_modules/it-take/dist/src/index.js ***! + \************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * For when you only want a few values out of an (async)iterable.\n *\n * @example\n *\n * ```javascript\n * import take from 'it-take'\n * import all from 'it-all'\n *\n * // This can also be an iterator, generator, etc\n * const values = [0, 1, 2, 3, 4]\n *\n * const arr = all(take(values, 2))\n *\n * console.info(arr) // 0, 1\n * ```\n *\n * Async sources must be awaited:\n *\n * ```javascript\n * import take from 'it-take'\n * import all from 'it-all'\n *\n * const values = async function * () {\n * yield * [0, 1, 2, 3, 4]\n * }\n *\n * const arr = await all(take(values(), 2))\n *\n * console.info(arr) // 0, 1\n * ```\n */\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction take(source, limit) {\n if (isAsyncIterable(source)) {\n return (async function* () {\n let items = 0;\n if (limit < 1) {\n return;\n }\n for await (const entry of source) {\n yield entry;\n items++;\n if (items === limit) {\n return;\n }\n }\n })();\n }\n return (function* () {\n let items = 0;\n if (limit < 1) {\n return;\n }\n for (const entry of source) {\n yield entry;\n items++;\n if (items === limit) {\n return;\n }\n }\n })();\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (take);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-take/dist/src/index.js?"); /***/ }), @@ -7824,336 +7952,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base10.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base10.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base16.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base16.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base2.js": -/*!******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base2.js ***! - \******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base256emoji.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base256emoji.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base32.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base32.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base36.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base36.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base58.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base58.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base64.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base64.js ***! - \*******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base8.js": -/*!******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base8.js ***! - \******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/identity.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/identity.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bases/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bases/interface.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/basics.js": -/*!*************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/basics.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/block/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/block/interface.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/block/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js": -/*!************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/cid.js": -/*!**********************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/cid.js ***! - \**********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/interface.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/json.js": -/*!******************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/json.js ***! - \******************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/raw.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/raw.js ***! - \*****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js": -/*!********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/hasher.js": -/*!********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/hasher.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/identity.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/identity.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/interface.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/sha2-browser.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/index.js ***! - \************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/interface.js": -/*!****************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/interface.js ***! - \****************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/link/interface.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/link/interface.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js": -/*!*************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js ***! - \*************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/base-x.js": -/*!********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/base-x.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/varint.js": -/*!********************************************************************************!*\ - !*** ./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/varint.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/multiformats/dist/src/vendor/varint.js?"); - -/***/ }), - /***/ "./node_modules/it-ws/node_modules/uint8arrays/dist/src/alloc.js": /*!***********************************************************************!*\ !*** ./node_modules/it-ws/node_modules/uint8arrays/dist/src/alloc.js ***! @@ -8183,18 +7981,326 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/it-ws/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/it-ws/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/uint8arrays/dist/src/util/bases.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/it-ws/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-ws/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), -/***/ "./node_modules/longbits/dist/src/index.js": +/***/ "./node_modules/libp2p/dist/src/address-manager/index.js": +/*!***************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/address-manager/index.js ***! + \***************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultAddressManager: () => (/* binding */ DefaultAddressManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/address-manager/utils.js\");\n\n\n\nconst defaultAddressFilter = (addrs) => addrs;\n/**\n * If the passed multiaddr contains the passed peer id, remove it\n */\nfunction stripPeerId(ma, peerId) {\n const observedPeerIdStr = ma.getPeerId();\n // strip our peer id if it has been passed\n if (observedPeerIdStr != null) {\n const observedPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(observedPeerIdStr);\n // use same encoding for comparison\n if (observedPeerId.equals(peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(`/p2p/${peerId.toString()}`));\n }\n }\n return ma;\n}\nclass DefaultAddressManager {\n log;\n components;\n // this is an array to allow for duplicates, e.g. multiples of `/ip4/0.0.0.0/tcp/0`\n listen;\n announce;\n observed;\n announceFilter;\n /**\n * Responsible for managing the peer addresses.\n * Peers can specify their listen and announce addresses.\n * The listen addresses will be used by the libp2p transports to listen for new connections,\n * while the announce addresses will be used for the peer addresses' to other peers in the network.\n */\n constructor(components, init = {}) {\n const { listen = [], announce = [] } = init;\n this.components = components;\n this.log = components.logger.forComponent('libp2p:address-manager');\n this.listen = listen.map(ma => ma.toString());\n this.announce = new Set(announce.map(ma => ma.toString()));\n this.observed = new Map();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n // this method gets called repeatedly on startup when transports start listening so\n // debounce it so we don't cause multiple self:peer:update events to be emitted\n this._updatePeerStoreAddresses = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.debounce)(this._updatePeerStoreAddresses.bind(this), 1000);\n // update our stored addresses when new transports listen\n components.events.addEventListener('transport:listening', () => {\n this._updatePeerStoreAddresses();\n });\n // update our stored addresses when existing transports stop listening\n components.events.addEventListener('transport:close', () => {\n this._updatePeerStoreAddresses();\n });\n }\n _updatePeerStoreAddresses() {\n // if announce addresses have been configured, ensure they make it into our peer\n // record for things like identify\n const addrs = this.getAnnounceAddrs()\n .concat(this.components.transportManager.getAddrs())\n .concat([...this.observed.entries()]\n .filter(([_, metadata]) => metadata.confident)\n .map(([str]) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(str))).map(ma => {\n // strip our peer id if it is present\n if (ma.getPeerId() === this.components.peerId.toString()) {\n return ma.decapsulate(`/p2p/${this.components.peerId.toString()}`);\n }\n return ma;\n });\n this.components.peerStore.patch(this.components.peerId, {\n multiaddrs: addrs\n })\n .catch(err => { this.log.error('error updating addresses', err); });\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a));\n }\n /**\n * Get peer announcing multiaddrs\n */\n getAnnounceAddrs() {\n return Array.from(this.announce).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a));\n }\n /**\n * Get observed multiaddrs\n */\n getObservedAddrs() {\n return Array.from(this.observed).map(([a]) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n // do not trigger the change:addresses event if we already know about this address\n if (this.observed.has(addrString)) {\n return;\n }\n this.observed.set(addrString, {\n confident: false\n });\n }\n confirmObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n const metadata = this.observed.get(addrString) ?? {\n confident: false\n };\n const startingConfidence = metadata.confident;\n this.observed.set(addrString, {\n confident: true\n });\n // only trigger the 'self:peer:update' event if our confidence in an address has changed\n if (!startingConfidence) {\n this._updatePeerStoreAddresses();\n }\n }\n removeObservedAddr(addr) {\n addr = stripPeerId(addr, this.components.peerId);\n const addrString = addr.toString();\n this.observed.delete(addrString);\n }\n getAddresses() {\n let addrs = this.getAnnounceAddrs().map(ma => ma.toString());\n if (addrs.length === 0) {\n // no configured announce addrs, add configured listen addresses\n addrs = this.components.transportManager.getAddrs().map(ma => ma.toString());\n }\n // add observed addresses we are confident in\n addrs = addrs.concat(Array.from(this.observed)\n .filter(([ma, metadata]) => metadata.confident)\n .map(([ma]) => ma));\n // dedupe multiaddrs\n const addrSet = new Set(addrs);\n // Create advertising list\n return this.announceFilter(Array.from(addrSet)\n .map(str => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(str)))\n .map(ma => {\n // do not append our peer id to a path multiaddr as it will become invalid\n if (ma.protos().pop()?.path === true) {\n return ma;\n }\n if (ma.getPeerId() === this.components.peerId.toString()) {\n return ma;\n }\n return ma.encapsulate(`/p2p/${this.components.peerId.toString()}`);\n });\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/address-manager/index.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/address-manager/utils.js": +/*!***************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/address-manager/utils.js ***! + \***************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ debounce: () => (/* binding */ debounce)\n/* harmony export */ });\nfunction debounce(func, wait) {\n let timeout;\n return function () {\n const later = function () {\n timeout = undefined;\n func();\n };\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/address-manager/utils.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/components.js": +/*!****************************************************!*\ + !*** ./node_modules/libp2p/dist/src/components.js ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaultComponents: () => (/* binding */ defaultComponents)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/startable.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\nclass DefaultComponents {\n components = {};\n _started = false;\n constructor(init = {}) {\n this.components = {};\n for (const [key, value] of Object.entries(init)) {\n this.components[key] = value;\n }\n if (this.components.logger == null) {\n this.components.logger = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.defaultLogger)();\n }\n }\n isStarted() {\n return this._started;\n }\n async _invokeStartableMethod(methodName) {\n await Promise.all(Object.values(this.components)\n .filter(obj => (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.isStartable)(obj))\n .map(async (startable) => {\n await startable[methodName]?.();\n }));\n }\n async beforeStart() {\n await this._invokeStartableMethod('beforeStart');\n }\n async start() {\n await this._invokeStartableMethod('start');\n this._started = true;\n }\n async afterStart() {\n await this._invokeStartableMethod('afterStart');\n }\n async beforeStop() {\n await this._invokeStartableMethod('beforeStop');\n }\n async stop() {\n await this._invokeStartableMethod('stop');\n this._started = false;\n }\n async afterStop() {\n await this._invokeStartableMethod('afterStop');\n }\n}\nconst OPTIONAL_SERVICES = [\n 'metrics',\n 'connectionProtector',\n 'dns'\n];\nconst NON_SERVICE_PROPERTIES = [\n 'components',\n 'isStarted',\n 'beforeStart',\n 'start',\n 'afterStart',\n 'beforeStop',\n 'stop',\n 'afterStop',\n 'then',\n '_invokeStartableMethod'\n];\nfunction defaultComponents(init = {}) {\n const components = new DefaultComponents(init);\n const proxy = new Proxy(components, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && !NON_SERVICE_PROPERTIES.includes(prop)) {\n const service = components.components[prop];\n if (service == null && !OPTIONAL_SERVICES.includes(prop)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(`${prop} not set`, 'ERR_SERVICE_MISSING');\n }\n return service;\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, value) {\n if (typeof prop === 'string') {\n components.components[prop] = value;\n }\n else {\n Reflect.set(target, prop, value);\n }\n return true;\n }\n });\n // @ts-expect-error component keys are proxied\n return proxy;\n}\n//# sourceMappingURL=components.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/components.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/config.js": +/*!************************************************!*\ + !*** ./node_modules/libp2p/dist/src/config.js ***! + \************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ validateConfig: () => (/* binding */ validateConfig)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/transport/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\n\nconst DefaultConfig = {\n addresses: {\n listen: [],\n announce: [],\n noAnnounce: [],\n announceFilter: (multiaddrs) => multiaddrs\n },\n connectionManager: {\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_0__.dnsaddrResolver\n },\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_2__.defaultAddressSort\n },\n transportManager: {\n faultTolerance: _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.FaultTolerance.FATAL_ALL\n }\n};\nasync function validateConfig(opts) {\n const resultingOptions = (0,merge_options__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(DefaultConfig, opts);\n if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_5__.messages.ERR_PROTECTOR_REQUIRED, _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_PROTECTOR_REQUIRED);\n }\n if (!(await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.peerIdFromKeys)(resultingOptions.privateKey.public.bytes, resultingOptions.privateKey.bytes)).equals(resultingOptions.peerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('Private key doesn\\'t match peer id', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_KEY);\n }\n return resultingOptions;\n}\n//# sourceMappingURL=config.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/config.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/config/connection-gater.browser.js": +/*!*************************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/config/connection-gater.browser.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ connectionGater: () => (/* binding */ connectionGater)\n/* harmony export */ });\n/* harmony import */ var _libp2p_utils_private_ip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/utils/private-ip */ \"./node_modules/@libp2p/utils/dist/src/private-ip.js\");\n\n/**\n * Returns a connection gater that disallows dialling private addresses by\n * default. Browsers are severely limited in their resource usage so don't\n * waste time trying to dial undiallable addresses.\n */\nfunction connectionGater(gater = {}) {\n return {\n denyDialPeer: async () => false,\n denyDialMultiaddr: async (multiaddr) => {\n const tuples = multiaddr.stringTuples();\n if (tuples[0][0] === 4 || tuples[0][0] === 41) {\n return Boolean((0,_libp2p_utils_private_ip__WEBPACK_IMPORTED_MODULE_0__.isPrivateIp)(`${tuples[0][1]}`));\n }\n return false;\n },\n denyInboundConnection: async () => false,\n denyOutboundConnection: async () => false,\n denyInboundEncryptedConnection: async () => false,\n denyOutboundEncryptedConnection: async () => false,\n denyInboundUpgradedConnection: async () => false,\n denyOutboundUpgradedConnection: async () => false,\n filterMultiaddrForPeer: async () => true,\n ...gater\n };\n}\n//# sourceMappingURL=connection-gater.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/config/connection-gater.browser.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/auto-dial.js": +/*!**********************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/auto-dial.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AutoDial: () => (/* binding */ AutoDial)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/set.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _libp2p_utils_peer_queue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/utils/peer-queue */ \"./node_modules/@libp2p/utils/dist/src/peer-queue.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js\");\n\n\n\n\nconst defaultOptions = {\n minConnections: _constants_js__WEBPACK_IMPORTED_MODULE_1__.MIN_CONNECTIONS,\n maxQueueLength: _constants_js__WEBPACK_IMPORTED_MODULE_2__.AUTO_DIAL_MAX_QUEUE_LENGTH,\n autoDialConcurrency: _constants_js__WEBPACK_IMPORTED_MODULE_2__.AUTO_DIAL_CONCURRENCY,\n autoDialPriority: _constants_js__WEBPACK_IMPORTED_MODULE_2__.AUTO_DIAL_PRIORITY,\n autoDialInterval: _constants_js__WEBPACK_IMPORTED_MODULE_2__.AUTO_DIAL_INTERVAL,\n autoDialPeerRetryThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_1__.AUTO_DIAL_PEER_RETRY_THRESHOLD,\n autoDialDiscoveredPeersDebounce: _constants_js__WEBPACK_IMPORTED_MODULE_2__.AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE\n};\nclass AutoDial {\n connectionManager;\n peerStore;\n queue;\n minConnections;\n autoDialPriority;\n autoDialIntervalMs;\n autoDialMaxQueueLength;\n autoDialPeerRetryThresholdMs;\n autoDialDiscoveredPeersDebounce;\n autoDialInterval;\n started;\n running;\n log;\n /**\n * Proactively tries to connect to known peers stored in the PeerStore.\n * It will keep the number of connections below the upper limit and sort\n * the peers to connect based on whether we know their keys and protocols.\n */\n constructor(components, init) {\n this.connectionManager = components.connectionManager;\n this.peerStore = components.peerStore;\n this.minConnections = init.minConnections ?? defaultOptions.minConnections;\n this.autoDialPriority = init.autoDialPriority ?? defaultOptions.autoDialPriority;\n this.autoDialIntervalMs = init.autoDialInterval ?? defaultOptions.autoDialInterval;\n this.autoDialMaxQueueLength = init.maxQueueLength ?? defaultOptions.maxQueueLength;\n this.autoDialPeerRetryThresholdMs = init.autoDialPeerRetryThreshold ?? defaultOptions.autoDialPeerRetryThreshold;\n this.autoDialDiscoveredPeersDebounce = init.autoDialDiscoveredPeersDebounce ?? defaultOptions.autoDialDiscoveredPeersDebounce;\n this.log = components.logger.forComponent('libp2p:connection-manager:auto-dial');\n this.started = false;\n this.running = false;\n this.queue = new _libp2p_utils_peer_queue__WEBPACK_IMPORTED_MODULE_3__.PeerQueue({\n concurrency: init.autoDialConcurrency ?? defaultOptions.autoDialConcurrency,\n metricName: 'libp2p_autodial_queue',\n metrics: components.metrics\n });\n this.queue.addEventListener('error', (evt) => {\n this.log.error('error during auto-dial', evt.detail);\n });\n // check the min connection limit whenever a peer disconnects\n components.events.addEventListener('connection:close', () => {\n this.autoDial()\n .catch(err => {\n this.log.error(err);\n });\n });\n // sometimes peers are discovered in quick succession so add a small\n // debounce to ensure all eligible peers are autodialed\n let debounce;\n // when new peers are discovered, dial them if we don't have\n // enough connections\n components.events.addEventListener('peer:discovery', () => {\n clearTimeout(debounce);\n debounce = setTimeout(() => {\n this.autoDial()\n .catch(err => {\n this.log.error(err);\n });\n }, this.autoDialDiscoveredPeersDebounce);\n });\n }\n isStarted() {\n return this.started;\n }\n start() {\n this.started = true;\n }\n afterStart() {\n this.autoDial()\n .catch(err => {\n this.log.error('error while autodialing', err);\n });\n }\n stop() {\n // clear the queue\n this.queue.clear();\n clearTimeout(this.autoDialInterval);\n this.started = false;\n this.running = false;\n }\n async autoDial() {\n if (!this.started || this.running) {\n return;\n }\n const connections = this.connectionManager.getConnectionsMap();\n const numConnections = connections.size;\n // already have enough connections\n if (numConnections >= this.minConnections) {\n if (this.minConnections > 0) {\n this.log.trace('have enough connections %d/%d', numConnections, this.minConnections);\n }\n // no need to schedule next autodial as it will be run when on\n // connection:close event\n return;\n }\n if (this.queue.size > this.autoDialMaxQueueLength) {\n this.log('not enough connections %d/%d but auto dial queue is full', numConnections, this.minConnections);\n this.sheduleNextAutodial();\n return;\n }\n this.running = true;\n this.log('not enough connections %d/%d - will dial peers to increase the number of connections', numConnections, this.minConnections);\n const dialQueue = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_4__.PeerSet(\n // @ts-expect-error boolean filter removes falsy peer IDs\n this.connectionManager.getDialQueue()\n .map(queue => queue.peerId)\n .filter(Boolean));\n // sort peers on whether we know protocols or public keys for them\n const peers = await this.peerStore.all({\n filters: [\n // remove some peers\n (peer) => {\n // remove peers without addresses\n if (peer.addresses.length === 0) {\n this.log.trace('not autodialing %p because they have no addresses', peer.id);\n return false;\n }\n // remove peers we are already connected to\n if (connections.has(peer.id)) {\n this.log.trace('not autodialing %p because they are already connected', peer.id);\n return false;\n }\n // remove peers we are already dialling\n if (dialQueue.has(peer.id)) {\n this.log.trace('not autodialing %p because they are already being dialed', peer.id);\n return false;\n }\n // remove peers already in the autodial queue\n if (this.queue.has(peer.id)) {\n this.log.trace('not autodialing %p because they are already being autodialed', peer.id);\n return false;\n }\n return true;\n }\n ]\n });\n // shuffle the peers - this is so peers with the same tag values will be\n // dialled in a different order each time\n const shuffledPeers = peers.sort(() => Math.random() > 0.5 ? 1 : -1);\n // sort shuffled peers by tag value\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_5__.PeerMap();\n for (const peer of shuffledPeers) {\n if (peerValues.has(peer.id)) {\n continue;\n }\n // sum all tag values\n peerValues.set(peer.id, [...peer.tags.values()].reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\n }\n // sort by value, highest to lowest\n const sortedPeers = shuffledPeers.sort((a, b) => {\n const peerAValue = peerValues.get(a.id) ?? 0;\n const peerBValue = peerValues.get(b.id) ?? 0;\n if (peerAValue > peerBValue) {\n return -1;\n }\n if (peerAValue < peerBValue) {\n return 1;\n }\n return 0;\n });\n const peersThatHaveNotFailed = sortedPeers.filter(peer => {\n const lastDialFailure = peer.metadata.get(_constants_js__WEBPACK_IMPORTED_MODULE_2__.LAST_DIAL_FAILURE_KEY);\n if (lastDialFailure == null) {\n return true;\n }\n const lastDialFailureTimestamp = parseInt((0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(lastDialFailure));\n if (isNaN(lastDialFailureTimestamp)) {\n return true;\n }\n // only dial if the time since the last failure is above the retry threshold\n return Date.now() - lastDialFailureTimestamp > this.autoDialPeerRetryThresholdMs;\n });\n this.log('selected %d/%d peers to dial', peersThatHaveNotFailed.length, peers.length);\n for (const peer of peersThatHaveNotFailed) {\n this.queue.add(async () => {\n const numConnections = this.connectionManager.getConnectionsMap().size;\n // Check to see if we still need to auto dial\n if (numConnections >= this.minConnections) {\n this.log('got enough connections now %d/%d', numConnections, this.minConnections);\n this.queue.clear();\n return;\n }\n this.log('connecting to a peerStore stored peer %p', peer.id);\n await this.connectionManager.openConnection(peer.id, {\n priority: this.autoDialPriority\n });\n }, {\n peerId: peer.id\n }).catch(err => {\n this.log.error('could not connect to peerStore stored peer', err);\n });\n }\n this.running = false;\n this.sheduleNextAutodial();\n }\n sheduleNextAutodial() {\n if (!this.started) {\n return;\n }\n this.autoDialInterval = setTimeout(() => {\n this.autoDial()\n .catch(err => {\n this.log.error('error while autodialing', err);\n });\n }, this.autoDialIntervalMs);\n }\n}\n//# sourceMappingURL=auto-dial.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/auto-dial.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/connection-pruner.js": +/*!******************************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/connection-pruner.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionPruner: () => (/* binding */ ConnectionPruner)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.browser.js\");\n\n\nconst defaultOptions = {\n maxConnections: _constants_js__WEBPACK_IMPORTED_MODULE_0__.MAX_CONNECTIONS,\n allow: []\n};\n/**\n * If we go over the max connections limit, choose some connections to close\n */\nclass ConnectionPruner {\n maxConnections;\n connectionManager;\n peerStore;\n allow;\n events;\n log;\n constructor(components, init = {}) {\n this.maxConnections = init.maxConnections ?? defaultOptions.maxConnections;\n this.allow = init.allow ?? defaultOptions.allow;\n this.connectionManager = components.connectionManager;\n this.peerStore = components.peerStore;\n this.events = components.events;\n this.log = components.logger.forComponent('libp2p:connection-manager:connection-pruner');\n // check the max connection limit whenever a peer connects\n components.events.addEventListener('connection:open', () => {\n this.maybePruneConnections()\n .catch(err => {\n this.log.error(err);\n });\n });\n }\n /**\n * If we have more connections than our maximum, select some excess connections\n * to prune based on peer value\n */\n async maybePruneConnections() {\n const connections = this.connectionManager.getConnections();\n const numConnections = connections.length;\n const toPrune = Math.max(numConnections - this.maxConnections, 0);\n this.log('checking max connections limit %d/%d', numConnections, this.maxConnections);\n if (numConnections <= this.maxConnections) {\n return;\n }\n this.log('max connections limit exceeded %d/%d, pruning %d connection(s)', numConnections, this.maxConnections, toPrune);\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_1__.PeerMap();\n // work out peer values\n for (const connection of connections) {\n const remotePeer = connection.remotePeer;\n if (peerValues.has(remotePeer)) {\n continue;\n }\n peerValues.set(remotePeer, 0);\n try {\n const peer = await this.peerStore.get(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, [...peer.tags.values()].reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\n }\n catch (err) {\n if (err.code !== 'ERR_NOT_FOUND') {\n this.log.error('error loading peer tags', err);\n }\n }\n }\n // sort by value, lowest to highest\n const sortedConnections = connections.sort((a, b) => {\n const peerAValue = peerValues.get(a.remotePeer) ?? 0;\n const peerBValue = peerValues.get(b.remotePeer) ?? 0;\n if (peerAValue > peerBValue) {\n return 1;\n }\n if (peerAValue < peerBValue) {\n return -1;\n }\n // if the peers have an equal tag value then we want to close short-lived connections first\n const connectionALifespan = a.timeline.open;\n const connectionBLifespan = b.timeline.open;\n if (connectionALifespan < connectionBLifespan) {\n return 1;\n }\n if (connectionALifespan > connectionBLifespan) {\n return -1;\n }\n return 0;\n });\n // close some connections\n const toClose = [];\n for (const connection of sortedConnections) {\n this.log('too many connections open - closing a connection to %p', connection.remotePeer);\n // check allow list\n const connectionInAllowList = this.allow.some((ma) => {\n return connection.remoteAddr.toString().startsWith(ma.toString());\n });\n // Connections in the allow list should be excluded from pruning\n if (!connectionInAllowList) {\n toClose.push(connection);\n }\n if (toClose.length === toPrune) {\n break;\n }\n }\n // close connections\n await Promise.all(toClose.map(async (connection) => {\n try {\n await connection.close();\n }\n catch (err) {\n this.log.error(err);\n }\n }));\n // despatch prune event\n this.events.safeDispatchEvent('connection:prune', { detail: toClose });\n }\n}\n//# sourceMappingURL=connection-pruner.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/connection-pruner.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/constants.browser.js": +/*!******************************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/constants.browser.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AUTO_DIAL_CONCURRENCY: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.AUTO_DIAL_CONCURRENCY),\n/* harmony export */ AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE),\n/* harmony export */ AUTO_DIAL_INTERVAL: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.AUTO_DIAL_INTERVAL),\n/* harmony export */ AUTO_DIAL_MAX_QUEUE_LENGTH: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.AUTO_DIAL_MAX_QUEUE_LENGTH),\n/* harmony export */ AUTO_DIAL_PEER_RETRY_THRESHOLD: () => (/* binding */ AUTO_DIAL_PEER_RETRY_THRESHOLD),\n/* harmony export */ AUTO_DIAL_PRIORITY: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.AUTO_DIAL_PRIORITY),\n/* harmony export */ DIAL_TIMEOUT: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.DIAL_TIMEOUT),\n/* harmony export */ INBOUND_CONNECTION_THRESHOLD: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.INBOUND_CONNECTION_THRESHOLD),\n/* harmony export */ INBOUND_UPGRADE_TIMEOUT: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.INBOUND_UPGRADE_TIMEOUT),\n/* harmony export */ LAST_DIAL_FAILURE_KEY: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.LAST_DIAL_FAILURE_KEY),\n/* harmony export */ MAX_CONNECTIONS: () => (/* binding */ MAX_CONNECTIONS),\n/* harmony export */ MAX_DIAL_QUEUE_LENGTH: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.MAX_DIAL_QUEUE_LENGTH),\n/* harmony export */ MAX_INCOMING_PENDING_CONNECTIONS: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.MAX_INCOMING_PENDING_CONNECTIONS),\n/* harmony export */ MAX_PARALLEL_DIALS: () => (/* binding */ MAX_PARALLEL_DIALS),\n/* harmony export */ MAX_PEER_ADDRS_TO_DIAL: () => (/* reexport safe */ _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__.MAX_PEER_ADDRS_TO_DIAL),\n/* harmony export */ MIN_CONNECTIONS: () => (/* binding */ MIN_CONNECTIONS)\n/* harmony export */ });\n/* harmony import */ var _constants_defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.defaults.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js\");\n\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections\n */\nconst MIN_CONNECTIONS = 5;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections\n */\nconst MAX_CONNECTIONS = 100;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials\n */\nconst MAX_PARALLEL_DIALS = 50;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialPeerRetryThreshold\n */\nconst AUTO_DIAL_PEER_RETRY_THRESHOLD = 1000 * 60 * 7;\n//# sourceMappingURL=constants.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/constants.browser.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AUTO_DIAL_CONCURRENCY: () => (/* binding */ AUTO_DIAL_CONCURRENCY),\n/* harmony export */ AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE: () => (/* binding */ AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE),\n/* harmony export */ AUTO_DIAL_INTERVAL: () => (/* binding */ AUTO_DIAL_INTERVAL),\n/* harmony export */ AUTO_DIAL_MAX_QUEUE_LENGTH: () => (/* binding */ AUTO_DIAL_MAX_QUEUE_LENGTH),\n/* harmony export */ AUTO_DIAL_PRIORITY: () => (/* binding */ AUTO_DIAL_PRIORITY),\n/* harmony export */ DIAL_TIMEOUT: () => (/* binding */ DIAL_TIMEOUT),\n/* harmony export */ INBOUND_CONNECTION_THRESHOLD: () => (/* binding */ INBOUND_CONNECTION_THRESHOLD),\n/* harmony export */ INBOUND_UPGRADE_TIMEOUT: () => (/* binding */ INBOUND_UPGRADE_TIMEOUT),\n/* harmony export */ LAST_DIAL_FAILURE_KEY: () => (/* binding */ LAST_DIAL_FAILURE_KEY),\n/* harmony export */ MAX_DIAL_QUEUE_LENGTH: () => (/* binding */ MAX_DIAL_QUEUE_LENGTH),\n/* harmony export */ MAX_INCOMING_PENDING_CONNECTIONS: () => (/* binding */ MAX_INCOMING_PENDING_CONNECTIONS),\n/* harmony export */ MAX_PEER_ADDRS_TO_DIAL: () => (/* binding */ MAX_PEER_ADDRS_TO_DIAL)\n/* harmony export */ });\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#dialTimeout\n */\nconst DIAL_TIMEOUT = 5e3;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundUpgradeTimeout\n */\nconst INBOUND_UPGRADE_TIMEOUT = 2e3;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxPeerAddrsToDial\n */\nconst MAX_PEER_ADDRS_TO_DIAL = 25;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialInterval\n */\nconst AUTO_DIAL_INTERVAL = 5000;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialConcurrency\n */\nconst AUTO_DIAL_CONCURRENCY = 25;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialPriority\n */\nconst AUTO_DIAL_PRIORITY = 0;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialMaxQueueLength\n */\nconst AUTO_DIAL_MAX_QUEUE_LENGTH = 100;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialDiscoveredPeersDebounce\n */\nconst AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE = 10;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundConnectionThreshold\n */\nconst INBOUND_CONNECTION_THRESHOLD = 5;\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxIncomingPendingConnections\n */\nconst MAX_INCOMING_PENDING_CONNECTIONS = 10;\n/**\n * Store as part of the peer store metadata for a given peer, the value for this\n * key is a timestamp of the last time a dial attempted failed with the relevant\n * peer stored as a string.\n *\n * Used to insure we do not endlessly try to auto dial peers we have recently\n * failed to dial.\n */\nconst LAST_DIAL_FAILURE_KEY = 'last-dial-failure';\n/**\n * @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxDialQueueLength\n */\nconst MAX_DIAL_QUEUE_LENGTH = 500;\n//# sourceMappingURL=constants.defaults.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/dial-queue.js": +/*!***********************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/dial-queue.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DialQueue: () => (/* binding */ DialQueue)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _libp2p_utils_queue__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/utils/queue */ \"./node_modules/@libp2p/utils/dist/src/queue/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var _multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr-matcher */ \"./node_modules/@multiformats/multiaddr-matcher/dist/src/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/connection-manager/utils.js\");\n/* eslint-disable max-depth */\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst defaultOptions = {\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_5__.defaultAddressSort,\n maxParallelDials: _constants_js__WEBPACK_IMPORTED_MODULE_6__.MAX_PARALLEL_DIALS,\n maxDialQueueLength: _constants_js__WEBPACK_IMPORTED_MODULE_7__.MAX_DIAL_QUEUE_LENGTH,\n maxPeerAddrsToDial: _constants_js__WEBPACK_IMPORTED_MODULE_7__.MAX_PEER_ADDRS_TO_DIAL,\n dialTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_7__.DIAL_TIMEOUT,\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__.dnsaddrResolver\n }\n};\nclass DialQueue {\n queue;\n components;\n addressSorter;\n maxPeerAddrsToDial;\n maxDialQueueLength;\n dialTimeout;\n shutDownController;\n connections;\n log;\n constructor(components, init = {}) {\n this.addressSorter = init.addressSorter ?? defaultOptions.addressSorter;\n this.maxPeerAddrsToDial = init.maxPeerAddrsToDial ?? defaultOptions.maxPeerAddrsToDial;\n this.maxDialQueueLength = init.maxDialQueueLength ?? defaultOptions.maxDialQueueLength;\n this.dialTimeout = init.dialTimeout ?? defaultOptions.dialTimeout;\n this.connections = init.connections ?? new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_8__.PeerMap();\n this.log = components.logger.forComponent('libp2p:connection-manager:dial-queue');\n this.components = components;\n this.shutDownController = new AbortController();\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, this.shutDownController.signal);\n for (const [key, value] of Object.entries(init.resolvers ?? {})) {\n _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.resolvers.set(key, value);\n }\n // controls dial concurrency\n this.queue = new _libp2p_utils_queue__WEBPACK_IMPORTED_MODULE_10__.Queue({\n concurrency: init.maxParallelDials ?? defaultOptions.maxParallelDials,\n metricName: 'libp2p_dial_queue',\n metrics: components.metrics\n });\n // a started job errored\n this.queue.addEventListener('error', (event) => {\n this.log.error('error in dial queue', event.detail);\n });\n }\n start() {\n this.shutDownController = new AbortController();\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, this.shutDownController.signal);\n }\n /**\n * Clears any pending dials\n */\n stop() {\n this.shutDownController.abort();\n this.queue.abort();\n }\n /**\n * Connects to a given peer, multiaddr or list of multiaddrs.\n *\n * If a peer is passed, all known multiaddrs will be tried. If a multiaddr or\n * multiaddrs are passed only those will be dialled.\n *\n * Where a list of multiaddrs is passed, if any contain a peer id then all\n * multiaddrs in the list must contain the same peer id.\n *\n * The dial to the first address that is successfully able to upgrade a\n * connection will be used, all other dials will be aborted when that happens.\n */\n async dial(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddrs } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_11__.getPeerAddress)(peerIdOrMultiaddr);\n // make sure we don't have an existing connection to any of the addresses we\n // are about to dial\n const existingConnection = Array.from(this.connections.values()).flat().find(conn => {\n if (options.force === true) {\n return false;\n }\n if (conn.remotePeer.equals(peerId)) {\n return true;\n }\n return multiaddrs.find(addr => {\n return addr.equals(conn.remoteAddr);\n });\n });\n if (existingConnection != null) {\n this.log('already connected to %a', existingConnection.remoteAddr);\n return existingConnection;\n }\n // ready to dial, all async work finished - make sure we don't have any\n // pending dials in progress for this peer or set of multiaddrs\n const existingDial = this.queue.queue.find(job => {\n if (peerId?.equals(job.options.peerId) === true) {\n return true;\n }\n // does the dial contain any of the target multiaddrs?\n const addresses = job.options.multiaddrs;\n if (addresses == null) {\n return false;\n }\n for (const multiaddr of multiaddrs) {\n if (addresses.has(multiaddr.toString())) {\n return true;\n }\n }\n return false;\n });\n if (existingDial != null) {\n this.log('joining existing dial target for %p', peerId);\n // add all multiaddrs to the dial target\n for (const multiaddr of multiaddrs) {\n existingDial.options.multiaddrs.add(multiaddr.toString());\n }\n return existingDial.join(options);\n }\n if (this.queue.size >= this.maxDialQueueLength) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('Dial queue is full', 'ERR_DIAL_QUEUE_FULL');\n }\n this.log('creating dial target for %p', peerId, multiaddrs.map(ma => ma.toString()));\n return this.queue.add(async (options) => {\n // create abort conditions - need to do this before `calculateMultiaddrs` as\n // we may be about to resolve a dns addr which can time out\n const signal = this.createDialAbortController(options?.signal);\n let addrsToDial;\n try {\n // load addresses from address book, resolve and dnsaddrs, filter\n // undiallables, add peer IDs, etc\n addrsToDial = await this.calculateMultiaddrs(peerId, options?.multiaddrs, {\n ...options,\n signal\n });\n addrsToDial.map(({ multiaddr }) => multiaddr.toString()).forEach(addr => {\n options?.multiaddrs.add(addr);\n });\n }\n catch (err) {\n signal.clear();\n throw err;\n }\n try {\n let dialed = 0;\n const errors = [];\n for (const address of addrsToDial) {\n if (dialed === this.maxPeerAddrsToDial) {\n this.log('dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others', dialed, peerId);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('Peer had more than maxPeerAddrsToDial', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_TOO_MANY_ADDRESSES);\n }\n dialed++;\n try {\n const conn = await this.components.transportManager.dial(address.multiaddr, {\n ...options,\n signal\n });\n this.log('dial to %a succeeded', address.multiaddr);\n return conn;\n }\n catch (err) {\n this.log.error('dial failed to %a', address.multiaddr, err);\n if (peerId != null) {\n // record the failed dial\n try {\n await this.components.peerStore.patch(peerId, {\n metadata: {\n [_constants_js__WEBPACK_IMPORTED_MODULE_7__.LAST_DIAL_FAILURE_KEY]: (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(Date.now().toString())\n }\n });\n }\n catch (err) {\n this.log.error('could not update last dial failure key for %p', peerId, err);\n }\n }\n // the user/dial timeout/shutdown controller signal aborted\n if (signal.aborted) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError(err.message, _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.ERR_TIMEOUT);\n }\n errors.push(err);\n }\n }\n if (errors.length === 1) {\n throw errors[0];\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.AggregateCodeError(errors, 'All multiaddr dials failed', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_TRANSPORT_DIAL_FAILED);\n }\n finally {\n // clean up abort signals/controllers\n signal.clear();\n }\n }, {\n peerId,\n priority: options.priority,\n multiaddrs: new Set(multiaddrs.map(ma => ma.toString())),\n signal: options.signal\n });\n }\n createDialAbortController(userSignal) {\n // let any signal abort the dial\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_3__.anySignal)([\n AbortSignal.timeout(this.dialTimeout),\n this.shutDownController.signal,\n userSignal\n ]);\n // This emitter gets listened to a lot\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_9__.setMaxListeners)(Infinity, signal);\n return signal;\n }\n // eslint-disable-next-line complexity\n async calculateMultiaddrs(peerId, multiaddrs = new Set(), options = {}) {\n const addrs = [...multiaddrs].map(ma => ({\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(ma),\n isCertified: false\n }));\n // if a peer id or multiaddr(s) with a peer id, make sure it isn't our peer id and that we are allowed to dial it\n if (peerId != null) {\n if (this.components.peerId.equals(peerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('Tried to dial self', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_DIALED_SELF);\n }\n if ((await this.components.connectionGater.denyDialPeer?.(peerId)) === true) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('The dial request is blocked by gater.allowDialPeer', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_PEER_DIAL_INTERCEPTED);\n }\n // if just a peer id was passed, load available multiaddrs for this peer\n // from the peer store\n if (addrs.length === 0) {\n this.log('loading multiaddrs for %p', peerId);\n try {\n const peer = await this.components.peerStore.get(peerId);\n addrs.push(...peer.addresses);\n this.log('loaded multiaddrs for %p', peerId, addrs.map(({ multiaddr }) => multiaddr.toString()));\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n }\n // if we still don't have any addresses for this peer, try a lookup\n // using the peer routing\n if (addrs.length === 0) {\n this.log('looking up multiaddrs for %p in the peer routing', peerId);\n try {\n const peerInfo = await this.components.peerRouting.findPeer(peerId);\n this.log('found multiaddrs for %p in the peer routing', peerId, addrs.map(({ multiaddr }) => multiaddr.toString()));\n addrs.push(...peerInfo.multiaddrs.map(multiaddr => ({\n multiaddr,\n isCertified: false\n })));\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_NO_ROUTERS_AVAILABLE) {\n this.log.error('looking up multiaddrs for %p in the peer routing failed', peerId, err);\n }\n }\n }\n }\n // resolve addresses - this can result in a one-to-many translation when\n // dnsaddrs are resolved\n let resolvedAddresses = (await Promise.all(addrs.map(async (addr) => {\n const result = await (0,_utils_js__WEBPACK_IMPORTED_MODULE_14__.resolveMultiaddrs)(addr.multiaddr, {\n dns: this.components.dns,\n ...options,\n log: this.log\n });\n if (result.length === 1 && result[0].equals(addr.multiaddr)) {\n return addr;\n }\n return result.map(multiaddr => ({\n multiaddr,\n isCertified: false\n }));\n })))\n .flat();\n // ensure the peer id is appended to the multiaddr\n if (peerId != null) {\n const peerIdMultiaddr = `/p2p/${peerId.toString()}`;\n resolvedAddresses = resolvedAddresses.map(addr => {\n const lastProto = addr.multiaddr.protos().pop();\n // do not append peer id to path multiaddrs\n if (lastProto?.path === true) {\n return addr;\n }\n // append peer id to multiaddr if it is not already present\n if (addr.multiaddr.getPeerId() == null) {\n return {\n multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),\n isCertified: addr.isCertified\n };\n }\n return addr;\n });\n }\n const filteredAddrs = resolvedAddresses.filter(addr => {\n // filter out any multiaddrs that we do not have transports for\n if (this.components.transportManager.transportForMultiaddr(addr.multiaddr) == null) {\n return false;\n }\n // if the resolved multiaddr has a PeerID but it's the wrong one, ignore it\n // - this can happen with addresses like bootstrap.libp2p.io that resolve\n // to multiple different peers\n const addrPeerId = addr.multiaddr.getPeerId();\n if (peerId != null && addrPeerId != null) {\n return peerId.equals(addrPeerId);\n }\n return true;\n });\n // deduplicate addresses\n const dedupedAddrs = new Map();\n for (const addr of filteredAddrs) {\n const maStr = addr.multiaddr.toString();\n const existing = dedupedAddrs.get(maStr);\n if (existing != null) {\n existing.isCertified = existing.isCertified || addr.isCertified || false;\n continue;\n }\n dedupedAddrs.set(maStr, addr);\n }\n const dedupedMultiaddrs = [...dedupedAddrs.values()];\n // make sure we actually have some addresses to dial\n if (dedupedMultiaddrs.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('The dial request has no valid addresses', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_NO_VALID_ADDRESSES);\n }\n const gatedAdrs = [];\n for (const addr of dedupedMultiaddrs) {\n if (this.components.connectionGater.denyDialMultiaddr != null && await this.components.connectionGater.denyDialMultiaddr(addr.multiaddr)) {\n continue;\n }\n gatedAdrs.push(addr);\n }\n const sortedGatedAddrs = gatedAdrs.sort(this.addressSorter);\n // make sure we actually have some addresses to dial\n if (sortedGatedAddrs.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.CodeError('The connection gater denied all addresses in the dial request', _errors_js__WEBPACK_IMPORTED_MODULE_13__.codes.ERR_NO_VALID_ADDRESSES);\n }\n this.log.trace('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()));\n this.log.trace('addresses for %p after filtering', peerId ?? 'unknown peer', sortedGatedAddrs.map(({ multiaddr }) => multiaddr.toString()));\n return sortedGatedAddrs;\n }\n async isDialable(multiaddr, options = {}) {\n if (!Array.isArray(multiaddr)) {\n multiaddr = [multiaddr];\n }\n try {\n const addresses = await this.calculateMultiaddrs(undefined, new Set(multiaddr.map(ma => ma.toString())), options);\n if (options.runOnTransientConnection === false) {\n // return true if any resolved multiaddrs are not relay addresses\n return addresses.find(addr => {\n return !_multiformats_multiaddr_matcher__WEBPACK_IMPORTED_MODULE_2__.Circuit.matches(addr.multiaddr);\n }) != null;\n }\n return true;\n }\n catch (err) {\n this.log.trace('error calculating if multiaddr(s) were dialable', err);\n }\n return false;\n }\n}\n//# sourceMappingURL=dial-queue.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/dial-queue.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/index.js": +/*!******************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/index.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultConnectionManager: () => (/* binding */ DefaultConnectionManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-store/tags.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/map.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _libp2p_utils_rate_limiter__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/utils/rate-limiter */ \"./node_modules/@libp2p/utils/dist/src/rate-limiter.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n/* harmony import */ var _auto_dial_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./auto-dial.js */ \"./node_modules/libp2p/dist/src/connection-manager/auto-dial.js\");\n/* harmony import */ var _connection_pruner_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection-pruner.js */ \"./node_modules/libp2p/dist/src/connection-manager/connection-pruner.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js\");\n/* harmony import */ var _dial_queue_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./dial-queue.js */ \"./node_modules/libp2p/dist/src/connection-manager/dial-queue.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nconst DEFAULT_DIAL_PRIORITY = 50;\nconst defaultOptions = {\n minConnections: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MIN_CONNECTIONS,\n maxConnections: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_CONNECTIONS,\n inboundConnectionThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_3__.INBOUND_CONNECTION_THRESHOLD,\n maxIncomingPendingConnections: _constants_js__WEBPACK_IMPORTED_MODULE_3__.MAX_INCOMING_PENDING_CONNECTIONS,\n autoDialConcurrency: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_CONCURRENCY,\n autoDialPriority: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_PRIORITY,\n autoDialMaxQueueLength: _constants_js__WEBPACK_IMPORTED_MODULE_3__.AUTO_DIAL_MAX_QUEUE_LENGTH\n};\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager {\n started;\n connections;\n allow;\n deny;\n maxIncomingPendingConnections;\n incomingPendingConnections;\n maxConnections;\n dialQueue;\n autoDial;\n connectionPruner;\n inboundConnectionRateLimiter;\n peerStore;\n metrics;\n events;\n log;\n constructor(components, init = {}) {\n this.maxConnections = init.maxConnections ?? defaultOptions.maxConnections;\n const minConnections = init.minConnections ?? defaultOptions.minConnections;\n if (this.maxConnections < minConnections) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('Connection Manager maxConnections must be greater than minConnections', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n /**\n * Map of connections per peer\n */\n this.connections = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_6__.PeerMap();\n this.started = false;\n this.peerStore = components.peerStore;\n this.metrics = components.metrics;\n this.events = components.events;\n this.log = components.logger.forComponent('libp2p:connection-manager');\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.events.addEventListener('connection:open', this.onConnect);\n this.events.addEventListener('connection:close', this.onDisconnect);\n // allow/deny lists\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(ma));\n this.incomingPendingConnections = 0;\n this.maxIncomingPendingConnections = init.maxIncomingPendingConnections ?? defaultOptions.maxIncomingPendingConnections;\n // controls individual peers trying to dial us too quickly\n this.inboundConnectionRateLimiter = new _libp2p_utils_rate_limiter__WEBPACK_IMPORTED_MODULE_7__.RateLimiter({\n points: init.inboundConnectionThreshold ?? defaultOptions.inboundConnectionThreshold,\n duration: 1\n });\n // controls what happens when we don't have enough connections\n this.autoDial = new _auto_dial_js__WEBPACK_IMPORTED_MODULE_8__.AutoDial({\n connectionManager: this,\n peerStore: components.peerStore,\n events: components.events,\n logger: components.logger\n }, {\n minConnections,\n autoDialConcurrency: init.autoDialConcurrency ?? defaultOptions.autoDialConcurrency,\n autoDialPriority: init.autoDialPriority ?? defaultOptions.autoDialPriority,\n maxQueueLength: init.autoDialMaxQueueLength ?? defaultOptions.autoDialMaxQueueLength\n });\n // controls what happens when we have too many connections\n this.connectionPruner = new _connection_pruner_js__WEBPACK_IMPORTED_MODULE_9__.ConnectionPruner({\n connectionManager: this,\n peerStore: components.peerStore,\n events: components.events,\n logger: components.logger\n }, {\n maxConnections: this.maxConnections,\n allow: this.allow\n });\n this.dialQueue = new _dial_queue_js__WEBPACK_IMPORTED_MODULE_10__.DialQueue(components, {\n addressSorter: init.addressSorter ?? _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_11__.defaultAddressSort,\n maxParallelDials: init.maxParallelDials ?? _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_PARALLEL_DIALS,\n maxDialQueueLength: init.maxDialQueueLength ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.MAX_DIAL_QUEUE_LENGTH,\n maxPeerAddrsToDial: init.maxPeerAddrsToDial ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.MAX_PEER_ADDRS_TO_DIAL,\n dialTimeout: init.dialTimeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.DIAL_TIMEOUT,\n resolvers: init.resolvers ?? {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__.dnsaddrResolver\n },\n connections: this.connections\n });\n }\n isStarted() {\n return this.started;\n }\n /**\n * Starts the Connection Manager. If Metrics are not enabled on libp2p\n * only event loop and connection limits will be monitored.\n */\n async start() {\n // track inbound/outbound connections\n this.metrics?.registerMetricGroup('libp2p_connection_manager_connections', {\n calculate: () => {\n const metric = {\n inbound: 0,\n outbound: 0\n };\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n if (conn.direction === 'inbound') {\n metric.inbound++;\n }\n else {\n metric.outbound++;\n }\n }\n }\n return metric;\n }\n });\n // track total number of streams per protocol\n this.metrics?.registerMetricGroup('libp2p_protocol_streams_total', {\n label: 'protocol',\n calculate: () => {\n const metric = {};\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n for (const stream of conn.streams) {\n const key = `${stream.direction} ${stream.protocol ?? 'unnegotiated'}`;\n metric[key] = (metric[key] ?? 0) + 1;\n }\n }\n }\n return metric;\n }\n });\n // track 90th percentile of streams per protocol\n this.metrics?.registerMetricGroup('libp2p_connection_manager_protocol_streams_per_connection_90th_percentile', {\n label: 'protocol',\n calculate: () => {\n const allStreams = {};\n for (const conns of this.connections.values()) {\n for (const conn of conns) {\n const streams = {};\n for (const stream of conn.streams) {\n const key = `${stream.direction} ${stream.protocol ?? 'unnegotiated'}`;\n streams[key] = (streams[key] ?? 0) + 1;\n }\n for (const [protocol, count] of Object.entries(streams)) {\n allStreams[protocol] = allStreams[protocol] ?? [];\n allStreams[protocol].push(count);\n }\n }\n }\n const metric = {};\n for (let [protocol, counts] of Object.entries(allStreams)) {\n counts = counts.sort((a, b) => a - b);\n const index = Math.floor(counts.length * 0.9);\n metric[protocol] = counts[index];\n }\n return metric;\n }\n });\n this.dialQueue.start();\n this.autoDial.start();\n this.started = true;\n this.log('started');\n }\n async afterStart() {\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = await this.peerStore.all({\n filters: [(peer) => {\n return peer.tags.has(_libp2p_interface__WEBPACK_IMPORTED_MODULE_12__.KEEP_ALIVE);\n }]\n });\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer.id)\n .catch(err => {\n this.log.error(err);\n });\n }));\n })\n .catch(err => {\n this.log.error(err);\n });\n this.autoDial.afterStart();\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.dialQueue.stop();\n this.autoDial.stop();\n // Close all connections we're tracking\n const tasks = [];\n for (const connectionList of this.connections.values()) {\n for (const connection of connectionList) {\n tasks.push((async () => {\n try {\n await connection.close();\n }\n catch (err) {\n this.log.error(err);\n }\n })());\n }\n }\n this.log('closing %d connections', tasks.length);\n await Promise.all(tasks);\n this.connections.clear();\n this.log('stopped');\n }\n onConnect(evt) {\n void this._onConnect(evt).catch(err => {\n this.log.error(err);\n });\n }\n /**\n * Tracks the incoming connection and check the connection limit\n */\n async _onConnect(evt) {\n const { detail: connection } = evt;\n if (!this.started) {\n // This can happen when we are in the process of shutting down the node\n await connection.close();\n return;\n }\n const peerId = connection.remotePeer;\n const storedConns = this.connections.get(peerId);\n let isNewPeer = false;\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n isNewPeer = true;\n this.connections.set(peerId, [connection]);\n }\n // only need to store RSA public keys, all other types are embedded in the peer id\n if (peerId.publicKey != null && peerId.type === 'RSA') {\n await this.peerStore.patch(peerId, {\n publicKey: peerId.publicKey\n });\n }\n if (isNewPeer) {\n this.events.safeDispatchEvent('peer:connect', { detail: connection.remotePeer });\n }\n }\n /**\n * Removes the connection from tracking\n */\n onDisconnect(evt) {\n const { detail: connection } = evt;\n if (!this.started) {\n // This can happen when we are in the process of shutting down the node\n return;\n }\n const peerId = connection.remotePeer;\n let storedConn = this.connections.get(peerId);\n if (storedConn != null && storedConn.length > 1) {\n storedConn = storedConn.filter((conn) => conn.id !== connection.id);\n this.connections.set(peerId, storedConn);\n }\n else if (storedConn != null) {\n this.connections.delete(peerId);\n this.events.safeDispatchEvent('peer:disconnect', { detail: connection.remotePeer });\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n getConnectionsMap() {\n return this.connections;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n if (!this.isStarted()) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CodeError('Not started', _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_NODE_NOT_STARTED);\n }\n options.signal?.throwIfAborted();\n const { peerId } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_13__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId != null && options.force !== true) {\n this.log('dial %p', peerId);\n const existingConnection = this.getConnections(peerId)\n .find(conn => !conn.transient);\n if (existingConnection != null) {\n this.log('had an existing non-transient connection to %p', peerId);\n return existingConnection;\n }\n }\n const connection = await this.dialQueue.dial(peerIdOrMultiaddr, {\n ...options,\n priority: options.priority ?? DEFAULT_DIAL_PRIORITY\n });\n let peerConnections = this.connections.get(connection.remotePeer);\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer, peerConnections);\n }\n // we get notified of connections via the Upgrader emitting \"connection\"\n // events, double check we aren't already tracking this connection before\n // storing it\n let trackedConnection = false;\n for (const conn of peerConnections) {\n if (conn.id === connection.id) {\n trackedConnection = true;\n }\n }\n if (!trackedConnection) {\n peerConnections.push(connection);\n }\n return connection;\n }\n async closeConnections(peerId, options = {}) {\n const connections = this.connections.get(peerId) ?? [];\n await Promise.all(connections.map(async (connection) => {\n try {\n await connection.close(options);\n }\n catch (err) {\n connection.abort(err);\n }\n }));\n }\n async acceptIncomingConnection(maConn) {\n // check deny list\n const denyConnection = this.deny.some(ma => {\n return maConn.remoteAddr.toString().startsWith(ma.toString());\n });\n if (denyConnection) {\n this.log('connection from %a refused - connection remote address was in deny list', maConn.remoteAddr);\n return false;\n }\n // check allow list\n const allowConnection = this.allow.some(ma => {\n return maConn.remoteAddr.toString().startsWith(ma.toString());\n });\n if (allowConnection) {\n this.incomingPendingConnections++;\n return true;\n }\n // check pending connections\n if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {\n this.log('connection from %a refused - incomingPendingConnections exceeded by host', maConn.remoteAddr);\n return false;\n }\n if (maConn.remoteAddr.isThinWaistAddress()) {\n const host = maConn.remoteAddr.nodeAddress().address;\n try {\n await this.inboundConnectionRateLimiter.consume(host, 1);\n }\n catch {\n this.log('connection from %a refused - inboundConnectionThreshold exceeded by host %s', maConn.remoteAddr, host);\n return false;\n }\n }\n if (this.getConnections().length < this.maxConnections) {\n this.incomingPendingConnections++;\n return true;\n }\n this.log('connection from %a refused - maxConnections exceeded', maConn.remoteAddr);\n return false;\n }\n afterUpgradeInbound() {\n this.incomingPendingConnections--;\n }\n getDialQueue() {\n const statusMap = {\n queued: 'queued',\n running: 'active',\n errored: 'error',\n complete: 'success'\n };\n return this.dialQueue.queue.queue.map(job => {\n return {\n id: job.id,\n status: statusMap[job.status],\n peerId: job.options.peerId,\n multiaddrs: [...job.options.multiaddrs].map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(ma))\n };\n });\n }\n async isDialable(multiaddr, options = {}) {\n return this.dialQueue.isDialable(multiaddr, options);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/index.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection-manager/utils.js": +/*!******************************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection-manager/utils.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ resolveMultiaddrs: () => (/* binding */ resolveMultiaddrs)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n/**\n * Recursively resolve DNSADDR multiaddrs\n */\nasync function resolveMultiaddrs(ma, options) {\n // check multiaddr resolvers\n let resolvable = false;\n for (const key of _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.resolvers.keys()) {\n resolvable = ma.protoNames().includes(key);\n if (resolvable) {\n break;\n }\n }\n // return multiaddr if it is not resolvable\n if (!resolvable) {\n return [ma];\n }\n const output = await ma.resolve(options);\n options.log('resolved %s to', ma, output.map(ma => ma.toString()));\n return output;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/utils.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/connection/index.js": +/*!**********************************************************!*\ + !*** ./node_modules/libp2p/dist/src/connection/index.js ***! + \**********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConnectionImpl: () => (/* binding */ ConnectionImpl),\n/* harmony export */ createConnection: () => (/* binding */ createConnection)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/connection/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n\nconst CLOSE_TIMEOUT = 500;\n/**\n * An implementation of the js-libp2p connection.\n * Any libp2p transport should use an upgrader to return this connection.\n */\nclass ConnectionImpl {\n /**\n * Connection identifier.\n */\n id;\n /**\n * Observed multiaddr of the remote peer\n */\n remoteAddr;\n /**\n * Remote peer id\n */\n remotePeer;\n direction;\n timeline;\n multiplexer;\n encryption;\n status;\n transient;\n log;\n /**\n * User provided tags\n *\n */\n tags;\n /**\n * Reference to the new stream function of the multiplexer\n */\n _newStream;\n /**\n * Reference to the close function of the raw connection\n */\n _close;\n _abort;\n /**\n * Reference to the getStreams function of the muxer\n */\n _getStreams;\n /**\n * An implementation of the js-libp2p connection.\n * Any libp2p transport should use an upgrader to return this connection.\n */\n constructor(init) {\n const { remoteAddr, remotePeer, newStream, close, abort, getStreams } = init;\n this.id = `${(parseInt(String(Math.random() * 1e9))).toString(36)}${Date.now()}`;\n this.remoteAddr = remoteAddr;\n this.remotePeer = remotePeer;\n this.direction = init.direction;\n this.status = 'open';\n this.timeline = init.timeline;\n this.multiplexer = init.multiplexer;\n this.encryption = init.encryption;\n this.transient = init.transient ?? false;\n this.log = init.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`);\n if (this.remoteAddr.getPeerId() == null) {\n this.remoteAddr = this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`);\n }\n this._newStream = newStream;\n this._close = close;\n this._abort = abort;\n this._getStreams = getStreams;\n this.tags = [];\n }\n [Symbol.toStringTag] = 'Connection';\n [_libp2p_interface__WEBPACK_IMPORTED_MODULE_0__.connectionSymbol] = true;\n /**\n * Get all the streams of the muxer\n */\n get streams() {\n return this._getStreams();\n }\n /**\n * Create a new stream from this connection\n */\n async newStream(protocols, options) {\n if (this.status === 'closing') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('the connection is being closed', 'ERR_CONNECTION_BEING_CLOSED');\n }\n if (this.status === 'closed') {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('the connection is closed', 'ERR_CONNECTION_CLOSED');\n }\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n if (this.transient && options?.runOnTransientConnection !== true) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('Cannot open protocol stream on transient connection', 'ERR_TRANSIENT_CONNECTION');\n }\n const stream = await this._newStream(protocols, options);\n stream.direction = 'outbound';\n return stream;\n }\n /**\n * Close the connection\n */\n async close(options = {}) {\n if (this.status === 'closed' || this.status === 'closing') {\n return;\n }\n this.log('closing connection to %a', this.remoteAddr);\n this.status = 'closing';\n if (options.signal == null) {\n const signal = AbortSignal.timeout(CLOSE_TIMEOUT);\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.setMaxListeners)(Infinity, signal);\n options = {\n ...options,\n signal\n };\n }\n try {\n this.log.trace('closing all streams');\n // close all streams gracefully - this can throw if we're not multiplexed\n await Promise.all(this.streams.map(async (s) => s.close(options)));\n this.log.trace('closing underlying transport');\n // close raw connection\n await this._close(options);\n this.log.trace('updating timeline with close time');\n this.status = 'closed';\n this.timeline.close = Date.now();\n }\n catch (err) {\n this.log.error('error encountered during graceful close of connection to %a', this.remoteAddr, err);\n this.abort(err);\n }\n }\n abort(err) {\n this.log.error('aborting connection to %a due to error', this.remoteAddr, err);\n this.status = 'closing';\n this.streams.forEach(s => { s.abort(err); });\n this.log.error('all streams aborted', this.streams.length);\n // Abort raw connection\n this._abort(err);\n this.timeline.close = Date.now();\n this.status = 'closed';\n }\n}\nfunction createConnection(init) {\n return new ConnectionImpl(init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection/index.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/content-routing.js": +/*!*********************************************************!*\ + !*** ./node_modules/libp2p/dist/src/content-routing.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CompoundContentRouting: () => (/* binding */ CompoundContentRouting)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/set.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\nclass CompoundContentRouting {\n routers;\n started;\n components;\n constructor(components, init) {\n this.routers = init.routers ?? [];\n this.started = false;\n this.components = components;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n }\n async stop() {\n this.started = false;\n }\n /**\n * Iterates over all content routers in parallel to find providers of the given key\n */\n async *findProviders(key, options = {}) {\n if (this.routers.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('No content routers available', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const self = this;\n const seen = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_3__.PeerSet();\n for await (const peer of (0,it_merge__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(...self.routers.map(router => router.findProviders(key, options)))) {\n // the peer was yielded by a content router without multiaddrs and we\n // failed to load them\n if (peer == null) {\n continue;\n }\n // store the addresses for the peer if found\n if (peer.multiaddrs.length > 0) {\n await this.components.peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs\n });\n }\n // deduplicate peers\n if (seen.has(peer.id)) {\n continue;\n }\n seen.add(peer.id);\n yield peer;\n }\n }\n /**\n * Iterates over all content routers in parallel to notify it is\n * a provider of the given key\n */\n async provide(key, options = {}) {\n if (this.routers.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('No content routers available', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n await Promise.all(this.routers.map(async (router) => {\n await router.provide(key, options);\n }));\n }\n /**\n * Store the given key/value pair in the available content routings\n */\n async put(key, value, options) {\n if (!this.isStarted()) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_2__.messages.NOT_STARTED_YET, _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NODE_NOT_STARTED);\n }\n await Promise.all(this.routers.map(async (router) => {\n await router.put(key, value, options);\n }));\n }\n /**\n * Get the value to the given key.\n * Times out after 1 minute by default.\n */\n async get(key, options) {\n if (!this.isStarted()) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_2__.messages.NOT_STARTED_YET, _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NODE_NOT_STARTED);\n }\n return Promise.any(this.routers.map(async (router) => {\n return router.get(key, options);\n }));\n }\n}\n//# sourceMappingURL=content-routing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/content-routing.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/errors.js": +/*!************************************************!*\ + !*** ./node_modules/libp2p/dist/src/errors.js ***! + \************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ codes: () => (/* binding */ codes),\n/* harmony export */ messages: () => (/* binding */ messages)\n/* harmony export */ });\nvar messages;\n(function (messages) {\n messages[\"NOT_STARTED_YET\"] = \"The libp2p node is not started yet\";\n messages[\"ERR_PROTECTOR_REQUIRED\"] = \"Private network is enforced, but no protector was provided\";\n messages[\"NOT_FOUND\"] = \"Not found\";\n})(messages || (messages = {}));\nvar codes;\n(function (codes) {\n codes[\"ERR_PROTECTOR_REQUIRED\"] = \"ERR_PROTECTOR_REQUIRED\";\n codes[\"ERR_PEER_DIAL_INTERCEPTED\"] = \"ERR_PEER_DIAL_INTERCEPTED\";\n codes[\"ERR_CONNECTION_INTERCEPTED\"] = \"ERR_CONNECTION_INTERCEPTED\";\n codes[\"ERR_INVALID_PROTOCOLS_FOR_STREAM\"] = \"ERR_INVALID_PROTOCOLS_FOR_STREAM\";\n codes[\"ERR_CONNECTION_ENDED\"] = \"ERR_CONNECTION_ENDED\";\n codes[\"ERR_CONNECTION_FAILED\"] = \"ERR_CONNECTION_FAILED\";\n codes[\"ERR_NODE_NOT_STARTED\"] = \"ERR_NODE_NOT_STARTED\";\n codes[\"ERR_ALREADY_ABORTED\"] = \"ERR_ALREADY_ABORTED\";\n codes[\"ERR_TOO_MANY_ADDRESSES\"] = \"ERR_TOO_MANY_ADDRESSES\";\n codes[\"ERR_NO_VALID_ADDRESSES\"] = \"ERR_NO_VALID_ADDRESSES\";\n codes[\"ERR_RELAYED_DIAL\"] = \"ERR_RELAYED_DIAL\";\n codes[\"ERR_DIALED_SELF\"] = \"ERR_DIALED_SELF\";\n codes[\"ERR_DISCOVERED_SELF\"] = \"ERR_DISCOVERED_SELF\";\n codes[\"ERR_DUPLICATE_TRANSPORT\"] = \"ERR_DUPLICATE_TRANSPORT\";\n codes[\"ERR_ENCRYPTION_FAILED\"] = \"ERR_ENCRYPTION_FAILED\";\n codes[\"ERR_HOP_REQUEST_FAILED\"] = \"ERR_HOP_REQUEST_FAILED\";\n codes[\"ERR_INVALID_KEY\"] = \"ERR_INVALID_KEY\";\n codes[\"ERR_INVALID_MESSAGE\"] = \"ERR_INVALID_MESSAGE\";\n codes[\"ERR_INVALID_PARAMETERS\"] = \"ERR_INVALID_PARAMETERS\";\n codes[\"ERR_INVALID_PEER\"] = \"ERR_INVALID_PEER\";\n codes[\"ERR_MUXER_UNAVAILABLE\"] = \"ERR_MUXER_UNAVAILABLE\";\n codes[\"ERR_NOT_FOUND\"] = \"ERR_NOT_FOUND\";\n codes[\"ERR_TRANSPORT_UNAVAILABLE\"] = \"ERR_TRANSPORT_UNAVAILABLE\";\n codes[\"ERR_TRANSPORT_DIAL_FAILED\"] = \"ERR_TRANSPORT_DIAL_FAILED\";\n codes[\"ERR_UNSUPPORTED_PROTOCOL\"] = \"ERR_UNSUPPORTED_PROTOCOL\";\n codes[\"ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED\"] = \"ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED\";\n codes[\"ERR_INVALID_MULTIADDR\"] = \"ERR_INVALID_MULTIADDR\";\n codes[\"ERR_SIGNATURE_NOT_VALID\"] = \"ERR_SIGNATURE_NOT_VALID\";\n codes[\"ERR_FIND_SELF\"] = \"ERR_FIND_SELF\";\n codes[\"ERR_NO_ROUTERS_AVAILABLE\"] = \"ERR_NO_ROUTERS_AVAILABLE\";\n codes[\"ERR_CONNECTION_NOT_MULTIPLEXED\"] = \"ERR_CONNECTION_NOT_MULTIPLEXED\";\n codes[\"ERR_NO_DIAL_TOKENS\"] = \"ERR_NO_DIAL_TOKENS\";\n codes[\"ERR_INVALID_CMS\"] = \"ERR_INVALID_CMS\";\n codes[\"ERR_MISSING_KEYS\"] = \"ERR_MISSING_KEYS\";\n codes[\"ERR_NO_KEY\"] = \"ERR_NO_KEY\";\n codes[\"ERR_INVALID_KEY_NAME\"] = \"ERR_INVALID_KEY_NAME\";\n codes[\"ERR_INVALID_KEY_TYPE\"] = \"ERR_INVALID_KEY_TYPE\";\n codes[\"ERR_KEY_ALREADY_EXISTS\"] = \"ERR_KEY_ALREADY_EXISTS\";\n codes[\"ERR_INVALID_KEY_SIZE\"] = \"ERR_INVALID_KEY_SIZE\";\n codes[\"ERR_KEY_NOT_FOUND\"] = \"ERR_KEY_NOT_FOUND\";\n codes[\"ERR_OLD_KEY_NAME_INVALID\"] = \"ERR_OLD_KEY_NAME_INVALID\";\n codes[\"ERR_NEW_KEY_NAME_INVALID\"] = \"ERR_NEW_KEY_NAME_INVALID\";\n codes[\"ERR_PASSWORD_REQUIRED\"] = \"ERR_PASSWORD_REQUIRED\";\n codes[\"ERR_PEM_REQUIRED\"] = \"ERR_PEM_REQUIRED\";\n codes[\"ERR_CANNOT_READ_KEY\"] = \"ERR_CANNOT_READ_KEY\";\n codes[\"ERR_MISSING_PRIVATE_KEY\"] = \"ERR_MISSING_PRIVATE_KEY\";\n codes[\"ERR_MISSING_PUBLIC_KEY\"] = \"ERR_MISSING_PUBLIC_KEY\";\n codes[\"ERR_INVALID_OLD_PASS_TYPE\"] = \"ERR_INVALID_OLD_PASS_TYPE\";\n codes[\"ERR_INVALID_NEW_PASS_TYPE\"] = \"ERR_INVALID_NEW_PASS_TYPE\";\n codes[\"ERR_INVALID_PASS_LENGTH\"] = \"ERR_INVALID_PASS_LENGTH\";\n codes[\"ERR_NOT_IMPLEMENTED\"] = \"ERR_NOT_IMPLEMENTED\";\n codes[\"ERR_WRONG_PING_ACK\"] = \"ERR_WRONG_PING_ACK\";\n codes[\"ERR_INVALID_RECORD\"] = \"ERR_INVALID_RECORD\";\n codes[\"ERR_ALREADY_SUCCEEDED\"] = \"ERR_ALREADY_SUCCEEDED\";\n codes[\"ERR_NO_HANDLER_FOR_PROTOCOL\"] = \"ERR_NO_HANDLER_FOR_PROTOCOL\";\n codes[\"ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS\"] = \"ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS\";\n codes[\"ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS\"] = \"ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS\";\n codes[\"ERR_CONNECTION_DENIED\"] = \"ERR_CONNECTION_DENIED\";\n codes[\"ERR_TRANSFER_LIMIT_EXCEEDED\"] = \"ERR_TRANSFER_LIMIT_EXCEEDED\";\n})(codes || (codes = {}));\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/errors.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/get-peer.js": +/*!**************************************************!*\ + !*** ./node_modules/libp2p/dist/src/get-peer.js ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getPeerAddress: () => (/* binding */ getPeerAddress)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-id/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr or an array of Multiaddrs\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.isPeerId)(peer)) {\n return { peerId: peer, multiaddrs: [] };\n }\n if (!Array.isArray(peer)) {\n peer = [peer];\n }\n let peerId;\n if (peer.length > 0) {\n const peerIdStr = peer[0].getPeerId();\n peerId = peerIdStr == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(peerIdStr);\n // ensure PeerId is either not set or is consistent\n peer.forEach(ma => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.isMultiaddr)(ma)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Invalid Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_MULTIADDR);\n }\n const maPeerIdStr = ma.getPeerId();\n if (maPeerIdStr == null) {\n if (peerId != null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Multiaddrs must all have the same peer id or have no peer id', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n else {\n const maPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(maPeerIdStr);\n if (peerId == null || !peerId.equals(maPeerId)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Multiaddrs must all have the same peer id or have no peer id', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_PARAMETERS);\n }\n }\n });\n }\n return {\n peerId,\n multiaddrs: peer\n };\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/get-peer.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/index.js": +/*!***********************************************!*\ + !*** ./node_modules/libp2p/dist/src/index.js ***! + \***********************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createLibp2p: () => (/* binding */ createLibp2p)\n/* harmony export */ });\n/* harmony import */ var _libp2p_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./libp2p.js */ \"./node_modules/libp2p/dist/src/libp2p.js\");\n/**\n * @packageDocumentation\n *\n * Use the `createLibp2p` function to create a libp2p node.\n *\n * @example\n *\n * ```typescript\n * import { createLibp2p } from 'libp2p'\n *\n * const node = await createLibp2p({\n * // ...other options\n * })\n * ```\n */\n\n/**\n * Returns a new instance of the Libp2p interface, generating a new PeerId\n * if one is not passed as part of the options.\n *\n * The node will be started unless `start: false` is passed as an option.\n *\n * @example\n *\n * ```TypeScript\n * import { createLibp2p } from 'libp2p'\n * import { tcp } from '@libp2p/tcp'\n * import { mplex } from '@libp2p/mplex'\n * import { noise } from '@chainsafe/libp2p-noise'\n * import { yamux } from '@chainsafe/libp2p-yamux'\n *\n * // specify options\n * const options = {\n * transports: [tcp()],\n * streamMuxers: [yamux(), mplex()],\n * connectionEncryption: [noise()]\n * }\n *\n * // create libp2p\n * const libp2p = await createLibp2p(options)\n * ```\n */\nasync function createLibp2p(options = {}) {\n const node = await (0,_libp2p_js__WEBPACK_IMPORTED_MODULE_0__.createLibp2pNode)(options);\n if (options.start !== false) {\n await node.start();\n }\n return node;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/libp2p.js": +/*!************************************************!*\ + !*** ./node_modules/libp2p/dist/src/libp2p.js ***! + \************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Libp2pNode: () => (/* binding */ Libp2pNode),\n/* harmony export */ createLibp2pNode: () => (/* binding */ createLibp2pNode)\n/* harmony export */ });\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/event-target.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/content-routing/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-routing/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/peer-discovery/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/set.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/datastore-core/dist/src/memory.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components.js */ \"./node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_connection_gater_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./config/connection-gater.js */ \"./node_modules/libp2p/dist/src/config/connection-gater.browser.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./config.js */ \"./node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _content_routing_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./content-routing.js */ \"./node_modules/libp2p/dist/src/content-routing.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/libp2p/dist/src/upgrader.js\");\n/* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./version.js */ \"./node_modules/libp2p/dist/src/version.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nclass Libp2pNode extends _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.TypedEventEmitter {\n peerId;\n peerStore;\n contentRouting;\n peerRouting;\n metrics;\n services;\n logger;\n status;\n components;\n log;\n constructor(init) {\n super();\n this.status = 'stopped';\n // event bus - components can listen to this emitter to be notified of system events\n // and also cause them to be emitted\n const events = new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.TypedEventEmitter();\n const originalDispatch = events.dispatchEvent.bind(events);\n events.dispatchEvent = (evt) => {\n const internalResult = originalDispatch(evt);\n const externalResult = this.dispatchEvent(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(evt.type, { detail: evt.detail }));\n return internalResult || externalResult;\n };\n // This emitter gets listened to a lot\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_5__.setMaxListeners)(Infinity, events);\n this.peerId = init.peerId;\n this.logger = init.logger ?? (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_6__.defaultLogger)();\n this.log = this.logger.forComponent('libp2p');\n // @ts-expect-error {} may not be of type T\n this.services = {};\n const components = this.components = (0,_components_js__WEBPACK_IMPORTED_MODULE_7__.defaultComponents)({\n peerId: init.peerId,\n privateKey: init.privateKey,\n nodeInfo: init.nodeInfo ?? {\n name: _version_js__WEBPACK_IMPORTED_MODULE_8__.name,\n version: _version_js__WEBPACK_IMPORTED_MODULE_8__.version\n },\n logger: this.logger,\n events,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_1__.MemoryDatastore(),\n connectionGater: (0,_config_connection_gater_js__WEBPACK_IMPORTED_MODULE_9__.connectionGater)(init.connectionGater),\n dns: init.dns\n });\n this.peerStore = this.configureComponent('peerStore', new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_10__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n }));\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.configureComponent('metrics', init.metrics(this.components));\n }\n components.events.addEventListener('peer:update', evt => {\n // if there was no peer previously in the peer store this is a new peer\n if (evt.detail.previous == null) {\n const peerInfo = {\n id: evt.detail.peer.id,\n multiaddrs: evt.detail.peer.addresses.map(a => a.multiaddr)\n };\n components.events.safeDispatchEvent('peer:discovery', { detail: peerInfo });\n }\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.configureComponent('connectionProtector', init.connectionProtector(components));\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_11__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map((fn, index) => this.configureComponent(`connection-encryption-${index}`, fn(this.components))),\n muxers: (init.streamMuxers ?? []).map((fn, index) => this.configureComponent(`stream-muxers-${index}`, fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Setup the transport manager\n this.configureComponent('transportManager', new _transport_manager_js__WEBPACK_IMPORTED_MODULE_12__.DefaultTransportManager(this.components, init.transportManager));\n // Create the Connection Manager\n this.configureComponent('connectionManager', new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_13__.DefaultConnectionManager(this.components, init.connectionManager));\n // Create the Registrar\n this.configureComponent('registrar', new _registrar_js__WEBPACK_IMPORTED_MODULE_14__.DefaultRegistrar(this.components));\n // Addresses {listen, announce, noAnnounce}\n this.configureComponent('addressManager', new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_15__.DefaultAddressManager(this.components, init.addresses));\n // Peer routers\n const peerRouters = (init.peerRouters ?? []).map((fn, index) => this.configureComponent(`peer-router-${index}`, fn(this.components)));\n this.peerRouting = this.components.peerRouting = this.configureComponent('peerRouting', new _peer_routing_js__WEBPACK_IMPORTED_MODULE_16__.DefaultPeerRouting(this.components, {\n routers: peerRouters\n }));\n // Content routers\n const contentRouters = (init.contentRouters ?? []).map((fn, index) => this.configureComponent(`content-router-${index}`, fn(this.components)));\n this.contentRouting = this.components.contentRouting = this.configureComponent('contentRouting', new _content_routing_js__WEBPACK_IMPORTED_MODULE_17__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n (init.peerDiscovery ?? []).forEach((fn, index) => {\n const service = this.configureComponent(`peer-discovery-${index}`, fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.#onDiscoveryPeer(evt);\n });\n });\n // Transport modules\n init.transports?.forEach((fn, index) => {\n this.components.transportManager.add(this.configureComponent(`transport-${index}`, fn(this.components)));\n });\n // User defined modules\n if (init.services != null) {\n for (const name of Object.keys(init.services)) {\n const createService = init.services[name];\n const service = createService(this.components);\n if (service == null) {\n this.log.error('service factory %s returned null or undefined instance', name);\n continue;\n }\n this.services[name] = service;\n this.configureComponent(name, service);\n if (service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_18__.contentRoutingSymbol] != null) {\n this.log('registering service %s for content routing', name);\n contentRouters.push(service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_18__.contentRoutingSymbol]);\n }\n if (service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_19__.peerRoutingSymbol] != null) {\n this.log('registering service %s for peer routing', name);\n peerRouters.push(service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_19__.peerRoutingSymbol]);\n }\n if (service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_20__.peerDiscoverySymbol] != null) {\n this.log('registering service %s for peer discovery', name);\n service[_libp2p_interface__WEBPACK_IMPORTED_MODULE_20__.peerDiscoverySymbol].addEventListener?.('peer', (evt) => {\n this.#onDiscoveryPeer(evt);\n });\n }\n }\n }\n }\n configureComponent(name, component) {\n if (component == null) {\n this.log.error('component %s was null or undefined', name);\n }\n this.components[name] = component;\n return component;\n }\n /**\n * Starts the libp2p node and all its subsystems\n */\n async start() {\n if (this.status !== 'stopped') {\n return;\n }\n this.status = 'starting';\n this.log('libp2p is starting');\n try {\n await this.components.beforeStart?.();\n await this.components.start();\n await this.components.afterStart?.();\n this.status = 'started';\n this.safeDispatchEvent('start', { detail: this });\n this.log('libp2p has started');\n }\n catch (err) {\n this.log.error('An error occurred starting libp2p', err);\n // set status to 'started' so this.stop() will stop any running components\n this.status = 'started';\n await this.stop();\n throw err;\n }\n }\n /**\n * Stop the libp2p node by closing its listeners and open connections\n */\n async stop() {\n if (this.status !== 'started') {\n return;\n }\n this.log('libp2p is stopping');\n this.status = 'stopping';\n await this.components.beforeStop?.();\n await this.components.stop();\n await this.components.afterStop?.();\n this.status = 'stopped';\n this.safeDispatchEvent('stop', { detail: this });\n this.log('libp2p has stopped');\n }\n getConnections(peerId) {\n return this.components.connectionManager.getConnections(peerId);\n }\n getDialQueue() {\n return this.components.connectionManager.getDialQueue();\n }\n getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_21__.PeerSet();\n for (const conn of this.components.connectionManager.getConnections()) {\n peerSet.add(conn.remotePeer);\n }\n return Array.from(peerSet);\n }\n async dial(peer, options = {}) {\n return this.components.connectionManager.openConnection(peer, {\n // ensure any userland dials take top priority in the queue\n priority: 75,\n ...options\n });\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_22__.CodeError('no protocols were provided to open a stream', _errors_js__WEBPACK_IMPORTED_MODULE_23__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_22__.CodeError('no protocols were provided to open a stream', _errors_js__WEBPACK_IMPORTED_MODULE_23__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return connection.newStream(protocols, options);\n }\n getMultiaddrs() {\n return this.components.addressManager.getAddresses();\n }\n getProtocols() {\n return this.components.registrar.getProtocols();\n }\n async hangUp(peer, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_24__.peerIdFromString)(peer.getPeerId() ?? '');\n }\n await this.components.connectionManager.closeConnections(peer, options);\n }\n /**\n * Get the public key for the given peer id\n */\n async getPublicKey(peer, options = {}) {\n this.log('getPublicKey %p', peer);\n if (peer.publicKey != null) {\n return peer.publicKey;\n }\n try {\n const peerInfo = await this.peerStore.get(peer);\n if (peerInfo.id.publicKey != null) {\n return peerInfo.id.publicKey;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_23__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_2__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search any available content routing methods\n const bytes = await this.contentRouting.get(peerKey, options);\n // ensure the returned key is valid\n (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_25__.unmarshalPublicKey)(bytes);\n await this.peerStore.patch(peer, {\n publicKey: bytes\n });\n return bytes;\n }\n async handle(protocols, handler, options) {\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n await Promise.all(protocols.map(async (protocol) => {\n await this.components.registrar.handle(protocol, handler, options);\n }));\n }\n async unhandle(protocols) {\n if (!Array.isArray(protocols)) {\n protocols = [protocols];\n }\n await Promise.all(protocols.map(async (protocol) => {\n await this.components.registrar.unhandle(protocol);\n }));\n }\n async register(protocol, topology) {\n return this.components.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.components.registrar.unregister(id);\n }\n async isDialable(multiaddr, options = {}) {\n return this.components.connectionManager.isDialable(multiaddr, options);\n }\n /**\n * Called whenever peer discovery services emit `peer` events and adds peers\n * to the peer store.\n */\n #onDiscoveryPeer(evt) {\n const { detail: peer } = evt;\n if (peer.id.toString() === this.peerId.toString()) {\n this.log.error(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_23__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n void this.components.peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs\n })\n .catch(err => { this.log.error(err); });\n }\n}\n/**\n * Returns a new Libp2pNode instance - this exposes more of the internals than the\n * libp2p interface and is useful for testing and debugging.\n */\nasync function createLibp2pNode(options = {}) {\n const peerId = options.peerId ??= await (0,_libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_26__.createEd25519PeerId)();\n if (peerId.privateKey == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_22__.CodeError('peer id was missing private key', 'ERR_MISSING_PRIVATE_KEY');\n }\n options.privateKey ??= await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_25__.unmarshalPrivateKey)(peerId.privateKey);\n return new Libp2pNode(await (0,_config_js__WEBPACK_IMPORTED_MODULE_27__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/libp2p.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/peer-routing.js": +/*!******************************************************!*\ + !*** ./node_modules/libp2p/dist/src/peer-routing.js ***! + \******************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultPeerRouting: () => (/* binding */ DefaultPeerRouting)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/set.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_parallel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-parallel */ \"./node_modules/it-parallel/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\n\n\nclass DefaultPeerRouting {\n log;\n peerId;\n peerStore;\n routers;\n constructor(components, init = {}) {\n this.log = components.logger.forComponent('libp2p:peer-routing');\n this.peerId = components.peerId;\n this.peerStore = components.peerStore;\n this.routers = init.routers ?? [];\n }\n /**\n * Iterates over all peer routers in parallel to find the given peer\n */\n async findPeer(id, options) {\n if (this.routers.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('No peer routers available', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n if (id.toString() === this.peerId.toString()) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('Should not try to find self', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_FIND_SELF);\n }\n const self = this;\n const source = (0,it_merge__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(...this.routers.map(router => (async function* () {\n try {\n yield await router.findPeer(id, options);\n }\n catch (err) {\n self.log.error(err);\n }\n })()));\n for await (const peer of source) {\n if (peer == null) {\n continue;\n }\n // store the addresses for the peer if found\n if (peer.multiaddrs.length > 0) {\n await this.peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs\n });\n }\n return peer;\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(_errors_js__WEBPACK_IMPORTED_MODULE_3__.messages.NOT_FOUND, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND);\n }\n /**\n * Attempt to find the closest peers on the network to the given key\n */\n async *getClosestPeers(key, options = {}) {\n if (this.routers.length === 0) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('No peer routers available', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const self = this;\n const seen = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_4__.PeerSet();\n for await (const peer of (0,it_parallel__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(async function* () {\n const source = (0,it_merge__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(...self.routers.map(router => router.getClosestPeers(key, options)));\n for await (let peer of source) {\n yield async () => {\n // find multiaddrs if they are missing\n if (peer.multiaddrs.length === 0) {\n try {\n peer = await self.findPeer(peer.id, {\n ...options,\n useCache: false\n });\n }\n catch (err) {\n self.log.error('could not find peer multiaddrs', err);\n return;\n }\n }\n return peer;\n };\n }\n }())) {\n if (peer == null) {\n continue;\n }\n // store the addresses for the peer if found\n if (peer.multiaddrs.length > 0) {\n await this.peerStore.merge(peer.id, {\n multiaddrs: peer.multiaddrs\n });\n }\n // deduplicate peers\n if (seen.has(peer.id)) {\n continue;\n }\n seen.add(peer.id);\n yield peer;\n }\n }\n}\n//# sourceMappingURL=peer-routing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/peer-routing.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/registrar.js": +/*!***************************************************!*\ + !*** ./node_modules/libp2p/dist/src/registrar.js ***! + \***************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFAULT_MAX_INBOUND_STREAMS: () => (/* binding */ DEFAULT_MAX_INBOUND_STREAMS),\n/* harmony export */ DEFAULT_MAX_OUTBOUND_STREAMS: () => (/* binding */ DEFAULT_MAX_OUTBOUND_STREAMS),\n/* harmony export */ DefaultRegistrar: () => (/* binding */ DefaultRegistrar)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\nconst DEFAULT_MAX_INBOUND_STREAMS = 32;\nconst DEFAULT_MAX_OUTBOUND_STREAMS = 64;\n/**\n * Responsible for notifying registered protocols of events in the network.\n */\nclass DefaultRegistrar {\n log;\n topologies;\n handlers;\n components;\n constructor(components) {\n this.log = components.logger.forComponent('libp2p:registrar');\n this.topologies = new Map();\n this.handlers = new Map();\n this.components = components;\n this._onDisconnect = this._onDisconnect.bind(this);\n this._onPeerUpdate = this._onPeerUpdate.bind(this);\n this._onPeerIdentify = this._onPeerIdentify.bind(this);\n this.components.events.addEventListener('peer:disconnect', this._onDisconnect);\n this.components.events.addEventListener('peer:update', this._onPeerUpdate);\n this.components.events.addEventListener('peer:identify', this._onPeerIdentify);\n }\n getProtocols() {\n return Array.from(new Set([\n ...this.handlers.keys()\n ])).sort();\n }\n getHandler(protocol) {\n const handler = this.handlers.get(protocol);\n if (handler == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError(`No handler registered for protocol ${protocol}`, _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_HANDLER_FOR_PROTOCOL);\n }\n return handler;\n }\n getTopologies(protocol) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n return [];\n }\n return [\n ...topologies.values()\n ];\n }\n /**\n * Registers the `handler` for each protocol\n */\n async handle(protocol, handler, opts) {\n if (this.handlers.has(protocol)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError(`Handler already registered for protocol ${protocol}`, _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);\n }\n const options = merge_options__WEBPACK_IMPORTED_MODULE_0__[\"default\"].bind({ ignoreUndefined: true })({\n maxInboundStreams: DEFAULT_MAX_INBOUND_STREAMS,\n maxOutboundStreams: DEFAULT_MAX_OUTBOUND_STREAMS\n }, opts);\n this.handlers.set(protocol, {\n handler,\n options\n });\n // Add new protocol to self protocols in the peer store\n await this.components.peerStore.merge(this.components.peerId, {\n protocols: [protocol]\n });\n }\n /**\n * Removes the handler for each protocol. The protocol\n * will no longer be supported on streams.\n */\n async unhandle(protocols) {\n const protocolList = Array.isArray(protocols) ? protocols : [protocols];\n protocolList.forEach(protocol => {\n this.handlers.delete(protocol);\n });\n // Update self protocols in the peer store\n await this.components.peerStore.patch(this.components.peerId, {\n protocols: this.getProtocols()\n });\n }\n /**\n * Register handlers for a set of multicodecs given\n */\n async register(protocol, topology) {\n if (topology == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.CodeError('invalid topology', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n // Create topology\n const id = `${(Math.random() * 1e9).toString(36)}${Date.now()}`;\n let topologies = this.topologies.get(protocol);\n if (topologies == null) {\n topologies = new Map();\n this.topologies.set(protocol, topologies);\n }\n topologies.set(id, topology);\n return id;\n }\n /**\n * Unregister topology\n */\n unregister(id) {\n for (const [protocol, topologies] of this.topologies.entries()) {\n if (topologies.has(id)) {\n topologies.delete(id);\n if (topologies.size === 0) {\n this.topologies.delete(protocol);\n }\n }\n }\n }\n /**\n * Remove a disconnected peer from the record\n */\n _onDisconnect(evt) {\n const remotePeer = evt.detail;\n void this.components.peerStore.get(remotePeer)\n .then(peer => {\n for (const protocol of peer.protocols) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n topology.onDisconnect?.(remotePeer);\n }\n }\n })\n .catch(err => {\n if (err.code === _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n // peer has not completed identify so they are not in the peer store\n return;\n }\n this.log.error('could not inform topologies of disconnecting peer %p', remotePeer, err);\n });\n }\n /**\n * When a peer is updated, if they have removed supported protocols notify any\n * topologies interested in the removed protocols.\n */\n _onPeerUpdate(evt) {\n const { peer, previous } = evt.detail;\n const removed = (previous?.protocols ?? []).filter(protocol => !peer.protocols.includes(protocol));\n for (const protocol of removed) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n topology.onDisconnect?.(peer.id);\n }\n }\n }\n /**\n * After identify has completed and we have received the list of supported\n * protocols, notify any topologies interested in those protocols.\n */\n _onPeerIdentify(evt) {\n const protocols = evt.detail.protocols;\n const connection = evt.detail.connection;\n const peerId = evt.detail.peerId;\n for (const protocol of protocols) {\n const topologies = this.topologies.get(protocol);\n if (topologies == null) {\n // no topologies are interested in this protocol\n continue;\n }\n for (const topology of topologies.values()) {\n if (connection.transient && topology.notifyOnTransient !== true) {\n continue;\n }\n topology.onConnect?.(peerId, connection);\n }\n }\n }\n}\n//# sourceMappingURL=registrar.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/registrar.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/transport-manager.js": +/*!***********************************************************!*\ + !*** ./node_modules/libp2p/dist/src/transport-manager.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultTransportManager: () => (/* binding */ DefaultTransportManager)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/transport/index.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_utils_tracked_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/utils/tracked-map */ \"./node_modules/@libp2p/utils/dist/src/tracked-map.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n\n\n\nclass DefaultTransportManager {\n log;\n components;\n transports;\n listeners;\n faultTolerance;\n started;\n constructor(components, init = {}) {\n this.log = components.logger.forComponent('libp2p:transports');\n this.components = components;\n this.started = false;\n this.transports = new Map();\n this.listeners = (0,_libp2p_utils_tracked_map__WEBPACK_IMPORTED_MODULE_0__.trackedMap)({\n name: 'libp2p_transport_manager_listeners',\n metrics: this.components.metrics\n });\n this.faultTolerance = init.faultTolerance ?? _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.FaultTolerance.FATAL_ALL;\n }\n /**\n * Adds a `Transport` to the manager\n */\n add(transport) {\n const tag = transport[Symbol.toStringTag];\n if (tag == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('Transport must have a valid tag', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_KEY);\n }\n if (this.transports.has(tag)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(`There is already a transport with the tag ${tag}`, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_DUPLICATE_TRANSPORT);\n }\n this.log('adding transport %s', tag);\n this.transports.set(tag, transport);\n if (!this.listeners.has(tag)) {\n this.listeners.set(tag, []);\n }\n }\n isStarted() {\n return this.started;\n }\n start() {\n this.started = true;\n }\n async afterStart() {\n // Listen on the provided transports for the provided addresses\n const addrs = this.components.addressManager.getListenAddrs();\n await this.listen(addrs);\n }\n /**\n * Stops all listeners\n */\n async stop() {\n const tasks = [];\n for (const [key, listeners] of this.listeners) {\n this.log('closing listeners for %s', key);\n while (listeners.length > 0) {\n const listener = listeners.pop();\n if (listener == null) {\n continue;\n }\n tasks.push(listener.close());\n }\n }\n await Promise.all(tasks);\n this.log('all listeners closed');\n for (const key of this.listeners.keys()) {\n this.listeners.set(key, []);\n }\n this.started = false;\n }\n /**\n * Dials the given Multiaddr over it's supported transport\n */\n async dial(ma, options) {\n const transport = this.transportForMultiaddr(ma);\n if (transport == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(`No transport available for address ${String(ma)}`, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TRANSPORT_UNAVAILABLE);\n }\n try {\n return await transport.dial(ma, {\n ...options,\n upgrader: this.components.upgrader\n });\n }\n catch (err) {\n if (err.code == null) {\n err.code = _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TRANSPORT_DIAL_FAILED;\n }\n throw err;\n }\n }\n /**\n * Returns all Multiaddr's the listeners are using\n */\n getAddrs() {\n let addrs = [];\n for (const listeners of this.listeners.values()) {\n for (const listener of listeners) {\n addrs = [...addrs, ...listener.getAddrs()];\n }\n }\n return addrs;\n }\n /**\n * Returns all the transports instances\n */\n getTransports() {\n return Array.of(...this.transports.values());\n }\n /**\n * Returns all the listener instances\n */\n getListeners() {\n return Array.of(...this.listeners.values()).flat();\n }\n /**\n * Finds a transport that matches the given Multiaddr\n */\n transportForMultiaddr(ma) {\n for (const transport of this.transports.values()) {\n const addrs = transport.filter([ma]);\n if (addrs.length > 0) {\n return transport;\n }\n }\n }\n /**\n * Starts listeners for each listen Multiaddr\n */\n async listen(addrs) {\n if (!this.isStarted()) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError('Not started', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NODE_NOT_STARTED);\n }\n if (addrs == null || addrs.length === 0) {\n this.log('no addresses were provided for listening, this node is dial only');\n return;\n }\n const couldNotListen = [];\n for (const [key, transport] of this.transports.entries()) {\n const supportedAddrs = transport.filter(addrs);\n const tasks = [];\n // For each supported multiaddr, create a listener\n for (const addr of supportedAddrs) {\n this.log('creating listener for %s on %a', key, addr);\n const listener = transport.createListener({\n upgrader: this.components.upgrader\n });\n let listeners = this.listeners.get(key) ?? [];\n if (listeners == null) {\n listeners = [];\n this.listeners.set(key, listeners);\n }\n listeners.push(listener);\n // Track listen/close events\n listener.addEventListener('listening', () => {\n this.components.events.safeDispatchEvent('transport:listening', {\n detail: listener\n });\n });\n listener.addEventListener('close', () => {\n const index = listeners.findIndex(l => l === listener);\n // remove the listener\n listeners.splice(index, 1);\n this.components.events.safeDispatchEvent('transport:close', {\n detail: listener\n });\n });\n // We need to attempt to listen on everything\n tasks.push(listener.listen(addr));\n }\n // Keep track of transports we had no addresses for\n if (tasks.length === 0) {\n couldNotListen.push(key);\n continue;\n }\n const results = await Promise.allSettled(tasks);\n // If we are listening on at least 1 address, succeed.\n // TODO: we should look at adding a retry (`p-retry`) here to better support\n // listening on remote addresses as they may be offline. We could then potentially\n // just wait for any (`p-any`) listener to succeed on each transport before returning\n const isListening = results.find(r => r.status === 'fulfilled');\n if ((isListening == null) && this.faultTolerance !== _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.FaultTolerance.NO_FATAL) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(`Transport (${key}) could not listen on any available address`, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_VALID_ADDRESSES);\n }\n }\n // If no transports were able to listen, throw an error. This likely\n // means we were given addresses we do not have transports for\n if (couldNotListen.length === this.transports.size) {\n const message = `no valid addresses were provided for transports [${couldNotListen.join(', ')}]`;\n if (this.faultTolerance === _libp2p_interface__WEBPACK_IMPORTED_MODULE_1__.FaultTolerance.FATAL_ALL) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_2__.CodeError(message, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_VALID_ADDRESSES);\n }\n this.log(`libp2p in dial mode only: ${message}`);\n }\n }\n /**\n * Removes the given transport from the manager.\n * If a transport has any running listeners, they will be closed.\n */\n async remove(key) {\n const listeners = this.listeners.get(key) ?? [];\n this.log.trace('removing transport %s', key);\n // Close any running listeners\n const tasks = [];\n this.log.trace('closing listeners for %s', key);\n while (listeners.length > 0) {\n const listener = listeners.pop();\n if (listener == null) {\n continue;\n }\n tasks.push(listener.close());\n }\n await Promise.all(tasks);\n this.transports.delete(key);\n this.listeners.delete(key);\n }\n /**\n * Removes all transports from the manager.\n * If any listeners are running, they will be closed.\n *\n * @async\n */\n async removeAll() {\n const tasks = [];\n for (const key of this.transports.keys()) {\n tasks.push(this.remove(key));\n }\n await Promise.all(tasks);\n }\n}\n//# sourceMappingURL=transport-manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/transport-manager.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/upgrader.js": +/*!**************************************************!*\ + !*** ./node_modules/libp2p/dist/src/upgrader.js ***! + \**************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DefaultUpgrader: () => (/* binding */ DefaultUpgrader)\n/* harmony export */ });\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface */ \"./node_modules/@libp2p/interface/dist/src/events.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/dist/src/handle.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/dist/src/select.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _connection_manager_constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connection-manager/constants.js */ \"./node_modules/libp2p/dist/src/connection-manager/constants.defaults.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n\n\n\n\n\n\n\nconst DEFAULT_PROTOCOL_SELECT_TIMEOUT = 30000;\nfunction findIncomingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxInboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar, options = {}) {\n try {\n const { options } = registrar.getHandler(protocol);\n if (options.maxOutboundStreams != null) {\n return options.maxOutboundStreams;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return options.maxOutboundStreams ?? _registrar_js__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_MAX_OUTBOUND_STREAMS;\n}\nfunction countStreams(protocol, direction, connection) {\n let streamCount = 0;\n connection.streams.forEach(stream => {\n if (stream.direction === direction && stream.protocol === protocol) {\n streamCount++;\n }\n });\n return streamCount;\n}\nclass DefaultUpgrader {\n components;\n connectionEncryption;\n muxers;\n inboundUpgradeTimeout;\n events;\n constructor(components, init) {\n this.components = components;\n this.connectionEncryption = new Map();\n init.connectionEncryption.forEach(encrypter => {\n this.connectionEncryption.set(encrypter.protocol, encrypter);\n });\n this.muxers = new Map();\n init.muxers.forEach(muxer => {\n this.muxers.set(muxer.protocol, muxer);\n });\n this.inboundUpgradeTimeout = init.inboundUpgradeTimeout ?? _connection_manager_constants_js__WEBPACK_IMPORTED_MODULE_2__.INBOUND_UPGRADE_TIMEOUT;\n this.events = components.events;\n }\n async shouldBlockConnection(remotePeer, maConn, connectionType) {\n const connectionGater = this.components.connectionGater[connectionType];\n if (connectionGater !== undefined) {\n if (await connectionGater(remotePeer, maConn)) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`The multiaddr connection is blocked by gater.${connectionType}`, _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n }\n /**\n * Upgrades an inbound connection\n */\n async upgradeInbound(maConn, opts) {\n const accept = await this.components.connectionManager.acceptIncomingConnection(maConn);\n if (!accept) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('connection denied', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const signal = AbortSignal.timeout(this.inboundUpgradeTimeout);\n const onAbort = () => {\n maConn.abort(new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('inbound upgrade timeout', _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.ERR_TIMEOUT));\n };\n signal.addEventListener('abort', onAbort, { once: true });\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.setMaxListeners)(Infinity, signal);\n try {\n if ((await this.components.connectionGater.denyInboundConnection?.(maConn)) === true) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('The multiaddr connection is blocked by gater.acceptConnection', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n this.components.metrics?.trackMultiaddrConnection(maConn);\n maConn.log('starting the inbound connection upgrade');\n // Protect\n let protectedConn = maConn;\n if (opts?.skipProtection !== true) {\n const protector = this.components.connectionProtector;\n if (protector != null) {\n maConn.log('protecting the inbound connection');\n protectedConn = await protector.protect(maConn);\n }\n }\n try {\n // Encrypt the connection\n encryptedConn = protectedConn;\n if (opts?.skipEncryption !== true) {\n ({\n conn: encryptedConn,\n remotePeer,\n protocol: cryptoProtocol\n } = await this._encryptInbound(protectedConn));\n const maConn = {\n ...protectedConn,\n ...encryptedConn\n };\n await this.shouldBlockConnection(remotePeer, maConn, 'denyInboundEncryptedConnection');\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('inbound connection that skipped encryption must have a peer id', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromString)(idStr);\n cryptoProtocol = 'native';\n remotePeer = remotePeerId;\n }\n upgradedConn = encryptedConn;\n if (opts?.muxerFactory != null) {\n muxerFactory = opts.muxerFactory;\n }\n else if (this.muxers.size > 0) {\n // Multiplex the connection\n const multiplexed = await this._multiplexInbound({\n ...protectedConn,\n ...encryptedConn\n }, this.muxers);\n muxerFactory = multiplexed.muxerFactory;\n upgradedConn = multiplexed.stream;\n }\n }\n catch (err) {\n maConn.log.error('failed to upgrade inbound connection', err);\n throw err;\n }\n await this.shouldBlockConnection(remotePeer, maConn, 'denyInboundUpgradedConnection');\n maConn.log('successfully upgraded inbound connection');\n return this._createConnection({\n cryptoProtocol,\n direction: 'inbound',\n maConn,\n upgradedConn,\n muxerFactory,\n remotePeer,\n transient: opts?.transient\n });\n }\n finally {\n signal.removeEventListener('abort', onAbort);\n this.components.connectionManager.afterUpgradeInbound();\n }\n }\n /**\n * Upgrades an outbound connection\n */\n async upgradeOutbound(maConn, opts) {\n const idStr = maConn.remoteAddr.getPeerId();\n let remotePeerId;\n if (idStr != null) {\n remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromString)(idStr);\n await this.shouldBlockConnection(remotePeerId, maConn, 'denyOutboundConnection');\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let cryptoProtocol;\n let muxerFactory;\n this.components.metrics?.trackMultiaddrConnection(maConn);\n maConn.log('starting the outbound connection upgrade');\n // If the transport natively supports encryption, skip connection\n // protector and encryption\n // Protect\n let protectedConn = maConn;\n if (opts?.skipProtection !== true) {\n const protector = this.components.connectionProtector;\n if (protector != null) {\n protectedConn = await protector.protect(maConn);\n }\n }\n try {\n // Encrypt the connection\n encryptedConn = protectedConn;\n if (opts?.skipEncryption !== true) {\n ({\n conn: encryptedConn,\n remotePeer,\n protocol: cryptoProtocol\n } = await this._encryptOutbound(protectedConn, remotePeerId));\n const maConn = {\n ...protectedConn,\n ...encryptedConn\n };\n await this.shouldBlockConnection(remotePeer, maConn, 'denyOutboundEncryptedConnection');\n }\n else {\n if (remotePeerId == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Encryption was skipped but no peer id was passed', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_INVALID_PEER);\n }\n cryptoProtocol = 'native';\n remotePeer = remotePeerId;\n }\n upgradedConn = encryptedConn;\n if (opts?.muxerFactory != null) {\n muxerFactory = opts.muxerFactory;\n }\n else if (this.muxers.size > 0) {\n // Multiplex the connection\n const multiplexed = await this._multiplexOutbound({\n ...protectedConn,\n ...encryptedConn\n }, this.muxers);\n muxerFactory = multiplexed.muxerFactory;\n upgradedConn = multiplexed.stream;\n }\n }\n catch (err) {\n maConn.log.error('failed to upgrade outbound connection', err);\n await maConn.close(err);\n throw err;\n }\n await this.shouldBlockConnection(remotePeer, maConn, 'denyOutboundUpgradedConnection');\n maConn.log('successfully upgraded outbound connection');\n return this._createConnection({\n cryptoProtocol,\n direction: 'outbound',\n maConn,\n upgradedConn,\n muxerFactory,\n remotePeer,\n transient: opts?.transient\n });\n }\n /**\n * A convenience method for generating a new `Connection`\n */\n _createConnection(opts) {\n const { cryptoProtocol, direction, maConn, upgradedConn, remotePeer, muxerFactory, transient } = opts;\n let muxer;\n let newStream;\n let connection; // eslint-disable-line prefer-const\n if (muxerFactory != null) {\n // Create the muxer\n muxer = muxerFactory.createStreamMuxer({\n direction,\n // Run anytime a remote stream is created\n onIncomingStream: muxedStream => {\n if (connection == null) {\n return;\n }\n void Promise.resolve()\n .then(async () => {\n const protocols = this.components.registrar.getProtocols();\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_6__.handle(muxedStream, protocols, {\n log: muxedStream.log,\n yieldBytes: false\n });\n if (connection == null) {\n return;\n }\n connection.log('incoming stream opened on %s', protocol);\n const incomingLimit = findIncomingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'inbound', connection);\n if (streamCount === incomingLimit) {\n const err = new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`, _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);\n muxedStream.abort(err);\n throw err;\n }\n // after the handshake the returned stream can have early data so override\n // the souce/sink\n muxedStream.source = stream.source;\n muxedStream.sink = stream.sink;\n muxedStream.protocol = protocol;\n // allow closing the write end of a not-yet-negotiated stream\n if (stream.closeWrite != null) {\n muxedStream.closeWrite = stream.closeWrite;\n }\n // allow closing the read end of a not-yet-negotiated stream\n if (stream.closeRead != null) {\n muxedStream.closeRead = stream.closeRead;\n }\n // make sure we don't try to negotiate a stream we are closing\n if (stream.close != null) {\n muxedStream.close = stream.close;\n }\n // If a protocol stream has been successfully negotiated and is to be passed to the application,\n // the peerstore should ensure that the peer is registered with that protocol\n await this.components.peerStore.merge(remotePeer, {\n protocols: [protocol]\n });\n this.components.metrics?.trackProtocolStream(muxedStream, connection);\n this._onStream({ connection, stream: muxedStream, protocol });\n })\n .catch(async (err) => {\n connection.log.error('error handling incoming stream id %s', muxedStream.id, err.message, err.code, err.stack);\n if (muxedStream.timeline.close == null) {\n await muxedStream.close();\n }\n });\n }\n });\n newStream = async (protocols, options = {}) => {\n if (muxer == null) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Stream is not multiplexed', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_MUXER_UNAVAILABLE);\n }\n connection.log('starting new stream for protocols %s', protocols);\n const muxedStream = await muxer.newStream();\n connection.log.trace('started new stream %s for protocols %s', muxedStream.id, protocols);\n try {\n if (options.signal == null) {\n muxedStream.log('no abort signal was passed while trying to negotiate protocols %s falling back to default timeout', protocols);\n const signal = AbortSignal.timeout(DEFAULT_PROTOCOL_SELECT_TIMEOUT);\n (0,_libp2p_interface__WEBPACK_IMPORTED_MODULE_4__.setMaxListeners)(Infinity, signal);\n options = {\n ...options,\n signal\n };\n }\n muxedStream.log.trace('selecting protocol from protocols %s', protocols);\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_7__.select(muxedStream, protocols, {\n ...options,\n log: muxedStream.log,\n yieldBytes: true\n });\n muxedStream.log('selected protocol %s', protocol);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar, options);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount >= outgoingLimit) {\n const err = new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`, _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);\n muxedStream.abort(err);\n throw err;\n }\n // If a protocol stream has been successfully negotiated and is to be passed to the application,\n // the peerstore should ensure that the peer is registered with that protocol\n await this.components.peerStore.merge(remotePeer, {\n protocols: [protocol]\n });\n // after the handshake the returned stream can have early data so override\n // the souce/sink\n muxedStream.source = stream.source;\n muxedStream.sink = stream.sink;\n muxedStream.protocol = protocol;\n // allow closing the write end of a not-yet-negotiated stream\n if (stream.closeWrite != null) {\n muxedStream.closeWrite = stream.closeWrite;\n }\n // allow closing the read end of a not-yet-negotiated stream\n if (stream.closeRead != null) {\n muxedStream.closeRead = stream.closeRead;\n }\n // make sure we don't try to negotiate a stream we are closing\n if (stream.close != null) {\n muxedStream.close = stream.close;\n }\n this.components.metrics?.trackProtocolStream(muxedStream, connection);\n return muxedStream;\n }\n catch (err) {\n connection.log.error('could not create new stream for protocols %s', protocols, err);\n if (muxedStream.timeline.close == null) {\n muxedStream.abort(err);\n }\n if (err.code != null) {\n throw err;\n }\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n };\n // Pipe all data through the muxer\n void Promise.all([\n muxer.sink(upgradedConn.source),\n upgradedConn.sink(muxer.source)\n ]).catch(err => {\n connection.log.error('error piping data through muxer', err);\n });\n }\n const _timeline = maConn.timeline;\n maConn.timeline = new Proxy(_timeline, {\n set: (...args) => {\n if (connection != null && args[1] === 'close' && args[2] != null && _timeline.close == null) {\n // Wait for close to finish before notifying of the closure\n (async () => {\n try {\n if (connection.status === 'open') {\n await connection.close();\n }\n }\n catch (err) {\n connection.log.error('error closing connection after timeline close', err);\n }\n finally {\n this.events.safeDispatchEvent('connection:close', {\n detail: connection\n });\n }\n })().catch(err => {\n connection.log.error('error thrown while dispatching connection:close event', err);\n });\n }\n return Reflect.set(...args);\n }\n });\n maConn.timeline.upgraded = Date.now();\n const errConnectionNotMultiplexed = () => {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('connection is not multiplexed', _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_8__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer,\n status: 'open',\n direction,\n timeline: maConn.timeline,\n multiplexer: muxer?.protocol,\n encryption: cryptoProtocol,\n transient,\n logger: this.components.logger,\n newStream: newStream ?? errConnectionNotMultiplexed,\n getStreams: () => { if (muxer != null) {\n return muxer.streams;\n }\n else {\n return [];\n } },\n close: async (options) => {\n // Ensure remaining streams are closed gracefully\n if (muxer != null) {\n connection.log.trace('close muxer');\n await muxer.close(options);\n }\n connection.log.trace('close maconn');\n // close the underlying transport\n await maConn.close(options);\n connection.log.trace('closed maconn');\n },\n abort: (err) => {\n maConn.abort(err);\n // Ensure remaining streams are aborted\n if (muxer != null) {\n muxer.abort(err);\n }\n }\n });\n this.events.safeDispatchEvent('connection:open', {\n detail: connection\n });\n return connection;\n }\n /**\n * Routes incoming streams to the correct handler\n */\n _onStream(opts) {\n const { connection, stream, protocol } = opts;\n const { handler, options } = this.components.registrar.getHandler(protocol);\n if (connection.transient && options.runOnTransientConnection !== true) {\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError('Cannot open protocol stream on transient connection', 'ERR_TRANSIENT_CONNECTION');\n }\n handler({ connection, stream });\n }\n /**\n * Attempts to encrypt the incoming `connection` with the provided `cryptos`\n */\n async _encryptInbound(connection) {\n const protocols = Array.from(this.connectionEncryption.keys());\n connection.log('handling inbound crypto protocol selection', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_6__.handle(connection, protocols, {\n log: connection.log\n });\n const encrypter = this.connectionEncryption.get(protocol);\n if (encrypter == null) {\n throw new Error(`no crypto module found for ${protocol}`);\n }\n connection.log('encrypting inbound connection using', protocol);\n return {\n ...await encrypter.secureInbound(this.components.peerId, stream),\n protocol\n };\n }\n catch (err) {\n connection.log.error('encrypting inbound connection to %p failed', err);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(err.message, _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_ENCRYPTION_FAILED);\n }\n }\n /**\n * Attempts to encrypt the given `connection` with the provided connection encrypters.\n * The first `ConnectionEncrypter` module to succeed will be used\n */\n async _encryptOutbound(connection, remotePeerId) {\n const protocols = Array.from(this.connectionEncryption.keys());\n connection.log('selecting outbound crypto protocol', protocols);\n try {\n connection.log.trace('selecting encrypter from %s', protocols);\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_7__.select(connection, protocols, {\n log: connection.log,\n yieldBytes: true\n });\n const encrypter = this.connectionEncryption.get(protocol);\n if (encrypter == null) {\n throw new Error(`no crypto module found for ${protocol}`);\n }\n connection.log('encrypting outbound connection to %p using %s', remotePeerId, encrypter);\n return {\n ...await encrypter.secureOutbound(this.components.peerId, stream, remotePeerId),\n protocol\n };\n }\n catch (err) {\n connection.log.error('encrypting outbound connection to %p failed', err);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(err.message, _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_ENCRYPTION_FAILED);\n }\n }\n /**\n * Selects one of the given muxers via multistream-select. That\n * muxer will be used for all future streams on the connection.\n */\n async _multiplexOutbound(connection, muxers) {\n const protocols = Array.from(muxers.keys());\n connection.log('outbound selecting muxer %s', protocols);\n try {\n connection.log.trace('selecting stream muxer from %s', protocols);\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_7__.select(connection, protocols, {\n log: connection.log,\n yieldBytes: true\n });\n connection.log('selected %s as muxer protocol', protocol);\n const muxerFactory = muxers.get(protocol);\n return { stream, muxerFactory };\n }\n catch (err) {\n connection.log.error('error multiplexing outbound connection', err);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n /**\n * Registers support for one of the given muxers via multistream-select. The\n * selected muxer will be used for all future streams on the connection.\n */\n async _multiplexInbound(connection, muxers) {\n const protocols = Array.from(muxers.keys());\n connection.log('inbound handling muxers %s', protocols);\n try {\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_6__.handle(connection, protocols, {\n log: connection.log\n });\n const muxerFactory = muxers.get(protocol);\n return { stream, muxerFactory };\n }\n catch (err) {\n connection.log.error('error multiplexing inbound connection', err);\n throw new _libp2p_interface__WEBPACK_IMPORTED_MODULE_3__.CodeError(String(err), _errors_js__WEBPACK_IMPORTED_MODULE_0__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n}\n//# sourceMappingURL=upgrader.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/upgrader.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/dist/src/version.js": /*!*************************************************!*\ - !*** ./node_modules/longbits/dist/src/index.js ***! + !*** ./node_modules/libp2p/dist/src/version.js ***! \*************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LongBits: () => (/* binding */ LongBits)\n/* harmony export */ });\n/* harmony import */ var byte_access__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! byte-access */ \"./node_modules/byte-access/dist/src/index.js\");\n\nconst TWO_32 = 4294967296;\nclass LongBits {\n constructor(hi = 0, lo = 0) {\n this.hi = hi;\n this.lo = lo;\n }\n /**\n * Returns these hi/lo bits as a BigInt\n */\n toBigInt(unsigned) {\n if (unsigned === true) {\n return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);\n }\n if ((this.hi >>> 31) !== 0) {\n const lo = ~this.lo + 1 >>> 0;\n let hi = ~this.hi >>> 0;\n if (lo === 0) {\n hi = hi + 1 >>> 0;\n }\n return -(BigInt(lo) + (BigInt(hi) << 32n));\n }\n return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);\n }\n /**\n * Returns these hi/lo bits as a Number - this may overflow, toBigInt\n * should be preferred\n */\n toNumber(unsigned) {\n return Number(this.toBigInt(unsigned));\n }\n /**\n * ZigZag decode a LongBits object\n */\n zzDecode() {\n const mask = -(this.lo & 1);\n const lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;\n const hi = (this.hi >>> 1 ^ mask) >>> 0;\n return new LongBits(hi, lo);\n }\n /**\n * ZigZag encode a LongBits object\n */\n zzEncode() {\n const mask = this.hi >> 31;\n const hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;\n const lo = (this.lo << 1 ^ mask) >>> 0;\n return new LongBits(hi, lo);\n }\n /**\n * Encode a LongBits object as a varint byte array\n */\n toBytes(buf, offset = 0) {\n const access = (0,byte_access__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(buf);\n while (this.hi > 0) {\n access.set(offset++, this.lo & 127 | 128);\n this.lo = (this.lo >>> 7 | this.hi << 25) >>> 0;\n this.hi >>>= 7;\n }\n while (this.lo > 127) {\n access.set(offset++, this.lo & 127 | 128);\n this.lo = this.lo >>> 7;\n }\n access.set(offset++, this.lo);\n }\n /**\n * Parse a LongBits object from a BigInt\n */\n static fromBigInt(value) {\n if (value === 0n) {\n return new LongBits();\n }\n const negative = value < 0;\n if (negative) {\n value = -value;\n }\n let hi = Number(value >> 32n) | 0;\n let lo = Number(value - (BigInt(hi) << 32n)) | 0;\n if (negative) {\n hi = ~hi >>> 0;\n lo = ~lo >>> 0;\n if (++lo > TWO_32) {\n lo = 0;\n if (++hi > TWO_32) {\n hi = 0;\n }\n }\n }\n return new LongBits(hi, lo);\n }\n /**\n * Parse a LongBits object from a Number\n */\n static fromNumber(value) {\n if (value === 0) {\n return new LongBits();\n }\n const sign = value < 0;\n if (sign) {\n value = -value;\n }\n let lo = value >>> 0;\n let hi = (value - lo) / 4294967296 >>> 0;\n if (sign) {\n hi = ~hi >>> 0;\n lo = ~lo >>> 0;\n if (++lo > 4294967295) {\n lo = 0;\n if (++hi > 4294967295) {\n hi = 0;\n }\n }\n }\n return new LongBits(hi, lo);\n }\n /**\n * Parse a LongBits object from a varint byte array\n */\n static fromBytes(buf, offset = 0) {\n const access = (0,byte_access__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(buf);\n // tends to deopt with local vars for octet etc.\n const bits = new LongBits();\n let i = 0;\n if (buf.length - offset > 4) { // fast route (lo)\n for (; i < 4; ++i) {\n // 1st..4th\n bits.lo = (bits.lo | (access.get(offset) & 127) << i * 7) >>> 0;\n if (access.get(offset++) < 128) {\n return bits;\n }\n }\n // 5th\n bits.lo = (bits.lo | (access.get(offset) & 127) << 28) >>> 0;\n bits.hi = (bits.hi | (access.get(offset) & 127) >> 4) >>> 0;\n if (access.get(offset++) < 128) {\n return bits;\n }\n i = 0;\n }\n else {\n for (; i < 4; ++i) {\n /* istanbul ignore if */\n if (offset >= buf.length) {\n throw RangeError(`index out of range: ${offset} > ${buf.length}`);\n }\n // 1st..4th\n bits.lo = (bits.lo | (access.get(offset) & 127) << i * 7) >>> 0;\n if (access.get(offset++) < 128) {\n return bits;\n }\n }\n }\n if (buf.length - offset > 4) { // fast route (hi)\n for (; i < 5; ++i) {\n // 6th..10th\n bits.hi = (bits.hi | (access.get(offset) & 127) << i * 7 + 3) >>> 0;\n if (access.get(offset++) < 128) {\n return bits;\n }\n }\n }\n else if (offset < buf.byteLength) {\n for (; i < 5; ++i) {\n /* istanbul ignore if */\n if (offset >= buf.length) {\n throw RangeError(`index out of range: ${offset} > ${buf.length}`);\n }\n // 6th..10th\n bits.hi = (bits.hi | (access.get(offset) & 127) << i * 7 + 3) >>> 0;\n if (access.get(offset++) < 128) {\n return bits;\n }\n }\n }\n /* istanbul ignore next */\n throw RangeError('invalid varint encoding');\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/longbits/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ name: () => (/* binding */ name),\n/* harmony export */ version: () => (/* binding */ version)\n/* harmony export */ });\nconst version = '1.4.2';\nconst name = 'libp2p';\n//# sourceMappingURL=version.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/version.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/alloc.js": +/*!************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/alloc.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/concat.js": +/*!*************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/concat.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ concat: () => (/* binding */ concat)\n/* harmony export */ });\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #alloc */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #util/as-uint8array */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n\n/**\n * Returns a new Uint8Array created by concatenating the passed Uint8Arrays\n */\nfunction concat(arrays, length) {\n if (length == null) {\n length = arrays.reduce((acc, curr) => acc + curr.length, 0);\n }\n const output = (0,_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(length);\n let offset = 0;\n for (const arr of arrays) {\n output.set(arr, offset);\n offset += arr.length;\n }\n return (0,_util_as_uint8array__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(output);\n}\n//# sourceMappingURL=concat.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/concat.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/from-string.js": +/*!******************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/from-string.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ fromString: () => (/* binding */ fromString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Create a `Uint8Array` from the passed string\n *\n * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction fromString(string, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // add multibase prefix\n return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions\n}\n//# sourceMappingURL=from-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/from-string.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/to-string.js": +/*!****************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/to-string.js ***! + \****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/bases.js\");\n\n/**\n * Turns a `Uint8Array` into a string.\n *\n * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.\n *\n * Also `ascii` which is similar to node's 'binary' encoding.\n */\nfunction toString(array, encoding = 'utf8') {\n const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"][encoding];\n if (base == null) {\n throw new Error(`Unsupported encoding \"${encoding}\"`);\n }\n // strip multibase prefix\n return base.encoder.encode(array).substring(1);\n}\n//# sourceMappingURL=to-string.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/to-string.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/as-uint8array.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/as-uint8array.js ***! + \*************************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ asUint8Array: () => (/* binding */ asUint8Array)\n/* harmony export */ });\n/**\n * To guarantee Uint8Array semantics, convert nodejs Buffers\n * into vanilla Uint8Arrays\n */\nfunction asUint8Array(buf) {\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); + +/***/ }), + +/***/ "./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/bases.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/bases.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/libp2p/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -8238,7 +8344,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ createMortice)\n/* harmony export */ });\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-queue */ \"./node_modules/mortice/node_modules/p-queue/dist/index.js\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _node_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node.js */ \"./node_modules/mortice/dist/src/browser.js\");\n/**\n * @packageDocumentation\n *\n * - Reads occur concurrently\n * - Writes occur one at a time\n * - No reads occur while a write operation is in progress\n * - Locks can be created with different names\n * - Reads/writes can time out\n *\n * ## Usage\n *\n * ```javascript\n * import mortice from 'mortice'\n * import delay from 'delay'\n *\n * // the lock name & options objects are both optional\n * const mutex = mortice('my-lock', {\n *\n * // how long before write locks time out (default: 24 hours)\n * timeout: 30000,\n *\n * // control how many read operations are executed concurrently (default: Infinity)\n * concurrency: 5,\n *\n * // by default the the lock will be held on the main thread, set this to true if the\n * // a lock should reside on each worker (default: false)\n * singleProcess: false\n * })\n *\n * Promise.all([\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 1')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 2')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.writeLock()\n *\n * try {\n * await delay(1000)\n *\n * console.info('write 1')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 3')\n * } finally {\n * release()\n * }\n * })()\n * ])\n * ```\n *\n * read 1\n * read 2\n * \n * write 1\n * read 3\n *\n * ## Browser\n *\n * Because there's no global way to evesdrop on messages sent by Web Workers, please pass all created Web Workers to the [`observable-webworkers`](https://npmjs.org/package/observable-webworkers) module:\n *\n * ```javascript\n * // main.js\n * import mortice from 'mortice'\n * import observe from 'observable-webworkers'\n *\n * // create our lock on the main thread, it will be held here\n * const mutex = mortice()\n *\n * const worker = new Worker('worker.js')\n *\n * observe(worker)\n * ```\n *\n * ```javascript\n * // worker.js\n * import mortice from 'mortice'\n * import delay from 'delay'\n *\n * const mutex = mortice()\n *\n * let release = await mutex.readLock()\n * // read something\n * release()\n *\n * release = await mutex.writeLock()\n * // write something\n * release()\n * ```\n */\n\n\n\nconst mutexes = {};\nlet implementation;\nasync function createReleaseable(queue, options) {\n let res;\n const p = new Promise((resolve) => {\n res = resolve;\n });\n void queue.add(async () => (0,p_timeout__WEBPACK_IMPORTED_MODULE_0__[\"default\"])((async () => {\n await new Promise((resolve) => {\n res(() => {\n resolve();\n });\n });\n })(), {\n milliseconds: options.timeout\n }));\n return p;\n}\nconst createMutex = (name, options) => {\n if (implementation.isWorker === true) {\n return {\n readLock: implementation.readLock(name, options),\n writeLock: implementation.writeLock(name, options)\n };\n }\n const masterQueue = new p_queue__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({ concurrency: 1 });\n let readQueue;\n return {\n async readLock() {\n // If there's already a read queue, just add the task to it\n if (readQueue != null) {\n return createReleaseable(readQueue, options);\n }\n // Create a new read queue\n readQueue = new p_queue__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({\n concurrency: options.concurrency,\n autoStart: false\n });\n const localReadQueue = readQueue;\n // Add the task to the read queue\n const readPromise = createReleaseable(readQueue, options);\n void masterQueue.add(async () => {\n // Start the task only once the master queue has completed processing\n // any previous tasks\n localReadQueue.start();\n // Once all the tasks in the read queue have completed, remove it so\n // that the next read lock will occur after any write locks that were\n // started in the interim\n await localReadQueue.onIdle()\n .then(() => {\n if (readQueue === localReadQueue) {\n readQueue = null;\n }\n });\n });\n return readPromise;\n },\n async writeLock() {\n // Remove the read queue reference, so that any later read locks will be\n // added to a new queue that starts after this write lock has been\n // released\n readQueue = null;\n return createReleaseable(masterQueue, options);\n }\n };\n};\nconst defaultOptions = {\n name: 'lock',\n concurrency: Infinity,\n timeout: 84600000,\n singleProcess: false\n};\nfunction createMortice(options) {\n const opts = Object.assign({}, defaultOptions, options);\n if (implementation == null) {\n implementation = (0,_node_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(opts);\n if (implementation.isWorker !== true) {\n // we are master, set up worker requests\n implementation.addEventListener('requestReadLock', (event) => {\n if (mutexes[event.data.name] == null) {\n return;\n }\n void mutexes[event.data.name].readLock()\n .then(async (release) => event.data.handler().finally(() => { release(); }));\n });\n implementation.addEventListener('requestWriteLock', async (event) => {\n if (mutexes[event.data.name] == null) {\n return;\n }\n void mutexes[event.data.name].writeLock()\n .then(async (release) => event.data.handler().finally(() => { release(); }));\n });\n }\n }\n if (mutexes[opts.name] == null) {\n mutexes[opts.name] = createMutex(opts.name, opts);\n }\n return mutexes[opts.name];\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/mortice/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ createMortice)\n/* harmony export */ });\n/* harmony import */ var p_queue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-queue */ \"./node_modules/p-queue/dist/index.js\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _node_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node.js */ \"./node_modules/mortice/dist/src/browser.js\");\n/**\n * @packageDocumentation\n *\n * - Reads occur concurrently\n * - Writes occur one at a time\n * - No reads occur while a write operation is in progress\n * - Locks can be created with different names\n * - Reads/writes can time out\n *\n * ## Usage\n *\n * ```javascript\n * import mortice from 'mortice'\n * import delay from 'delay'\n *\n * // the lock name & options objects are both optional\n * const mutex = mortice('my-lock', {\n *\n * // how long before write locks time out (default: 24 hours)\n * timeout: 30000,\n *\n * // control how many read operations are executed concurrently (default: Infinity)\n * concurrency: 5,\n *\n * // by default the the lock will be held on the main thread, set this to true if the\n * // a lock should reside on each worker (default: false)\n * singleProcess: false\n * })\n *\n * Promise.all([\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 1')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 2')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.writeLock()\n *\n * try {\n * await delay(1000)\n *\n * console.info('write 1')\n * } finally {\n * release()\n * }\n * })(),\n * (async () => {\n * const release = await mutex.readLock()\n *\n * try {\n * console.info('read 3')\n * } finally {\n * release()\n * }\n * })()\n * ])\n * ```\n *\n * read 1\n * read 2\n * \n * write 1\n * read 3\n *\n * ## Browser\n *\n * Because there's no global way to evesdrop on messages sent by Web Workers, please pass all created Web Workers to the [`observable-webworkers`](https://npmjs.org/package/observable-webworkers) module:\n *\n * ```javascript\n * // main.js\n * import mortice from 'mortice'\n * import observe from 'observable-webworkers'\n *\n * // create our lock on the main thread, it will be held here\n * const mutex = mortice()\n *\n * const worker = new Worker('worker.js')\n *\n * observe(worker)\n * ```\n *\n * ```javascript\n * // worker.js\n * import mortice from 'mortice'\n * import delay from 'delay'\n *\n * const mutex = mortice()\n *\n * let release = await mutex.readLock()\n * // read something\n * release()\n *\n * release = await mutex.writeLock()\n * // write something\n * release()\n * ```\n */\n\n\n\nconst mutexes = {};\nlet implementation;\nasync function createReleaseable(queue, options) {\n let res;\n const p = new Promise((resolve) => {\n res = resolve;\n });\n void queue.add(async () => (0,p_timeout__WEBPACK_IMPORTED_MODULE_0__[\"default\"])((async () => {\n await new Promise((resolve) => {\n res(() => {\n resolve();\n });\n });\n })(), {\n milliseconds: options.timeout\n }));\n return p;\n}\nconst createMutex = (name, options) => {\n if (implementation.isWorker === true) {\n return {\n readLock: implementation.readLock(name, options),\n writeLock: implementation.writeLock(name, options)\n };\n }\n const masterQueue = new p_queue__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({ concurrency: 1 });\n let readQueue;\n return {\n async readLock() {\n // If there's already a read queue, just add the task to it\n if (readQueue != null) {\n return createReleaseable(readQueue, options);\n }\n // Create a new read queue\n readQueue = new p_queue__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({\n concurrency: options.concurrency,\n autoStart: false\n });\n const localReadQueue = readQueue;\n // Add the task to the read queue\n const readPromise = createReleaseable(readQueue, options);\n void masterQueue.add(async () => {\n // Start the task only once the master queue has completed processing\n // any previous tasks\n localReadQueue.start();\n // Once all the tasks in the read queue have completed, remove it so\n // that the next read lock will occur after any write locks that were\n // started in the interim\n await localReadQueue.onIdle()\n .then(() => {\n if (readQueue === localReadQueue) {\n readQueue = null;\n }\n });\n });\n return readPromise;\n },\n async writeLock() {\n // Remove the read queue reference, so that any later read locks will be\n // added to a new queue that starts after this write lock has been\n // released\n readQueue = null;\n return createReleaseable(masterQueue, options);\n }\n };\n};\nconst defaultOptions = {\n name: 'lock',\n concurrency: Infinity,\n timeout: 84600000,\n singleProcess: false\n};\nfunction createMortice(options) {\n const opts = Object.assign({}, defaultOptions, options);\n if (implementation == null) {\n implementation = (0,_node_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(opts);\n if (implementation.isWorker !== true) {\n // we are master, set up worker requests\n implementation.addEventListener('requestReadLock', (event) => {\n if (mutexes[event.data.name] == null) {\n return;\n }\n void mutexes[event.data.name].readLock()\n .then(async (release) => event.data.handler().finally(() => { release(); }));\n });\n implementation.addEventListener('requestWriteLock', async (event) => {\n if (mutexes[event.data.name] == null) {\n return;\n }\n void mutexes[event.data.name].writeLock()\n .then(async (release) => event.data.handler().finally(() => { release(); }));\n });\n }\n }\n if (mutexes[opts.name] == null) {\n mutexes[opts.name] = createMutex(opts.name, opts);\n }\n return mutexes[opts.name];\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/mortice/dist/src/index.js?"); /***/ }), @@ -8253,333 +8359,333 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/mortice/node_modules/p-queue/dist/index.js": -/*!*****************************************************************!*\ - !*** ./node_modules/mortice/node_modules/p-queue/dist/index.js ***! - \*****************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PQueue)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./priority-queue.js */ \"./node_modules/mortice/node_modules/p-queue/dist/priority-queue.js\");\n\n\n\n/**\nPromise queue with concurrency control.\n*/\nclass PQueue extends eventemitter3__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n #carryoverConcurrencyCount;\n #isIntervalIgnored;\n #intervalCount = 0;\n #intervalCap;\n #interval;\n #intervalEnd = 0;\n #intervalId;\n #timeoutId;\n #queue;\n #queueClass;\n #pending = 0;\n // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n #concurrency;\n #isPaused;\n #throwOnTimeout;\n /**\n Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.\n\n Applies to each future operation.\n */\n timeout;\n // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`\n constructor(options) {\n super();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = {\n carryoverConcurrencyCount: false,\n intervalCap: Number.POSITIVE_INFINITY,\n interval: 0,\n concurrency: Number.POSITIVE_INFINITY,\n autoStart: true,\n queueClass: _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n ...options,\n };\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${options.intervalCap?.toString() ?? ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${options.interval?.toString() ?? ''}\\` (${typeof options.interval})`);\n }\n this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;\n this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;\n this.#intervalCap = options.intervalCap;\n this.#interval = options.interval;\n this.#queue = new options.queueClass();\n this.#queueClass = options.queueClass;\n this.concurrency = options.concurrency;\n this.timeout = options.timeout;\n this.#throwOnTimeout = options.throwOnTimeout === true;\n this.#isPaused = options.autoStart === false;\n }\n get #doesIntervalAllowAnother() {\n return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;\n }\n get #doesConcurrentAllowAnother() {\n return this.#pending < this.#concurrency;\n }\n #next() {\n this.#pending--;\n this.#tryToStartAnother();\n this.emit('next');\n }\n #onResumeInterval() {\n this.#onInterval();\n this.#initializeIntervalIfNeeded();\n this.#timeoutId = undefined;\n }\n get #isIntervalPaused() {\n const now = Date.now();\n if (this.#intervalId === undefined) {\n const delay = this.#intervalEnd - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n this.#intervalCount = (this.#carryoverConcurrencyCount) ? this.#pending : 0;\n }\n else {\n // Act as the interval is pending\n if (this.#timeoutId === undefined) {\n this.#timeoutId = setTimeout(() => {\n this.#onResumeInterval();\n }, delay);\n }\n return true;\n }\n }\n return false;\n }\n #tryToStartAnother() {\n if (this.#queue.size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (this.#intervalId) {\n clearInterval(this.#intervalId);\n }\n this.#intervalId = undefined;\n this.emit('empty');\n if (this.#pending === 0) {\n this.emit('idle');\n }\n return false;\n }\n if (!this.#isPaused) {\n const canInitializeInterval = !this.#isIntervalPaused;\n if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {\n const job = this.#queue.dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n this.#initializeIntervalIfNeeded();\n }\n return true;\n }\n }\n return false;\n }\n #initializeIntervalIfNeeded() {\n if (this.#isIntervalIgnored || this.#intervalId !== undefined) {\n return;\n }\n this.#intervalId = setInterval(() => {\n this.#onInterval();\n }, this.#interval);\n this.#intervalEnd = Date.now() + this.#interval;\n }\n #onInterval() {\n if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {\n clearInterval(this.#intervalId);\n this.#intervalId = undefined;\n }\n this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;\n this.#processQueue();\n }\n /**\n Executes all queued functions until it reaches the limit.\n */\n #processQueue() {\n // eslint-disable-next-line no-empty\n while (this.#tryToStartAnother()) { }\n }\n get concurrency() {\n return this.#concurrency;\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n this.#concurrency = newConcurrency;\n this.#processQueue();\n }\n async #throwOnAbort(signal) {\n return new Promise((_resolve, reject) => {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n }, { once: true });\n });\n }\n async add(function_, options = {}) {\n options = {\n timeout: this.timeout,\n throwOnTimeout: this.#throwOnTimeout,\n ...options,\n };\n return new Promise((resolve, reject) => {\n this.#queue.enqueue(async () => {\n this.#pending++;\n this.#intervalCount++;\n try {\n options.signal?.throwIfAborted();\n let operation = function_({ signal: options.signal });\n if (options.timeout) {\n operation = (0,p_timeout__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(Promise.resolve(operation), { milliseconds: options.timeout });\n }\n if (options.signal) {\n operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);\n }\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n if (error instanceof p_timeout__WEBPACK_IMPORTED_MODULE_1__.TimeoutError && !options.throwOnTimeout) {\n resolve();\n return;\n }\n reject(error);\n this.emit('error', error);\n }\n finally {\n this.#next();\n }\n }, options);\n this.emit('add');\n this.#tryToStartAnother();\n });\n }\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!this.#isPaused) {\n return this;\n }\n this.#isPaused = false;\n this.#processQueue();\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n this.#isPaused = true;\n }\n /**\n Clear the queue.\n */\n clear() {\n this.#queue = new this.#queueClass();\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('empty');\n }\n /**\n @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.\n\n If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n */\n async onSizeLessThan(limit) {\n // Instantly resolve if the queue is empty.\n if (this.#queue.size < limit) {\n return;\n }\n await this.#onEvent('next', () => this.#queue.size < limit);\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (this.#pending === 0 && this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('idle');\n }\n async #onEvent(event, filter) {\n return new Promise(resolve => {\n const listener = () => {\n if (filter && !filter()) {\n return;\n }\n this.off(event, listener);\n resolve();\n };\n this.on(event, listener);\n });\n }\n /**\n Size of the queue, the number of queued items waiting to run.\n */\n get size() {\n return this.#queue.size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n return this.#queue.filter(options).length;\n }\n /**\n Number of running items (no longer in the queue).\n */\n get pending() {\n return this.#pending;\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return this.#isPaused;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/mortice/node_modules/p-queue/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/mortice/node_modules/p-queue/dist/lower-bound.js": -/*!***********************************************************************!*\ - !*** ./node_modules/mortice/node_modules/p-queue/dist/lower-bound.js ***! - \***********************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ lowerBound)\n/* harmony export */ });\n// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nfunction lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = Math.trunc(count / 2);\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/mortice/node_modules/p-queue/dist/lower-bound.js?"); - -/***/ }), - -/***/ "./node_modules/mortice/node_modules/p-queue/dist/priority-queue.js": -/*!**************************************************************************!*\ - !*** ./node_modules/mortice/node_modules/p-queue/dist/priority-queue.js ***! - \**************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PriorityQueue)\n/* harmony export */ });\n/* harmony import */ var _lower_bound_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lower-bound.js */ \"./node_modules/mortice/node_modules/p-queue/dist/lower-bound.js\");\n\nclass PriorityQueue {\n #queue = [];\n enqueue(run, options) {\n options = {\n priority: 0,\n ...options,\n };\n const element = {\n priority: options.priority,\n run,\n };\n if (this.size && this.#queue[this.size - 1].priority >= options.priority) {\n this.#queue.push(element);\n return;\n }\n const index = (0,_lower_bound_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/mortice/node_modules/p-queue/dist/priority-queue.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base.js": -/*!*****************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base.js ***! - \*****************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../vendor/base-x.js */ \"./node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/multiformats/src/bases/interface.js\");\n\n\n// Linter can't see that API is used in types.\n// eslint-disable-next-line\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n *\n * @class\n * @template {string} Base\n * @template {string} Prefix\n * @implements {API.MultibaseEncoder}\n * @implements {API.BaseEncoder}\n */\nclass Encoder {\n /**\n * @param {Base} name\n * @param {Prefix} prefix\n * @param {(bytes:Uint8Array) => string} baseEncode\n */\n constructor (name, prefix, baseEncode) {\n this.name = name\n this.prefix = prefix\n this.baseEncode = baseEncode\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {API.Multibase}\n */\n encode (bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`\n } else {\n throw Error('Unknown type, must be binary type')\n }\n }\n}\n\n/**\n * @template {string} Prefix\n */\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n *\n * @class\n * @template {string} Base\n * @template {string} Prefix\n * @implements {API.MultibaseDecoder}\n * @implements {API.UnibaseDecoder}\n * @implements {API.BaseDecoder}\n */\nclass Decoder {\n /**\n * @param {Base} name\n * @param {Prefix} prefix\n * @param {(text:string) => Uint8Array} baseDecode\n */\n constructor (name, prefix, baseDecode) {\n this.name = name\n this.prefix = prefix\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character')\n }\n /** @private */\n this.prefixCodePoint = /** @type {number} */ (prefix.codePointAt(0))\n this.baseDecode = baseDecode\n }\n\n /**\n * @param {string} text\n */\n decode (text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)\n }\n return this.baseDecode(text.slice(this.prefix.length))\n } else {\n throw Error('Can only multibase decode strings')\n }\n }\n\n /**\n * @template {string} OtherPrefix\n * @param {API.UnibaseDecoder|ComposedDecoder} decoder\n * @returns {ComposedDecoder}\n */\n or (decoder) {\n return or(this, decoder)\n }\n}\n\n/**\n * @template {string} Prefix\n * @typedef {Record>} Decoders\n */\n\n/**\n * @template {string} Prefix\n * @implements {API.MultibaseDecoder}\n * @implements {API.CombobaseDecoder}\n */\nclass ComposedDecoder {\n /**\n * @param {Decoders} decoders\n */\n constructor (decoders) {\n this.decoders = decoders\n }\n\n /**\n * @template {string} OtherPrefix\n * @param {API.UnibaseDecoder|ComposedDecoder} decoder\n * @returns {ComposedDecoder}\n */\n or (decoder) {\n return or(this, decoder)\n }\n\n /**\n * @param {string} input\n * @returns {Uint8Array}\n */\n decode (input) {\n const prefix = /** @type {Prefix} */ (input[0])\n const decoder = this.decoders[prefix]\n if (decoder) {\n return decoder.decode(input)\n } else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)\n }\n }\n}\n\n/**\n * @template {string} L\n * @template {string} R\n * @param {API.UnibaseDecoder|API.CombobaseDecoder} left\n * @param {API.UnibaseDecoder|API.CombobaseDecoder} right\n * @returns {ComposedDecoder}\n */\nconst or = (left, right) => new ComposedDecoder(/** @type {Decoders} */({\n ...(left.decoders || { [/** @type API.UnibaseDecoder */(left).prefix]: left }),\n ...(right.decoders || { [/** @type API.UnibaseDecoder */(right).prefix]: right })\n}))\n\n/**\n * @class\n * @template {string} Base\n * @template {string} Prefix\n * @implements {API.MultibaseCodec}\n * @implements {API.MultibaseEncoder}\n * @implements {API.MultibaseDecoder}\n * @implements {API.BaseCodec}\n * @implements {API.BaseEncoder}\n * @implements {API.BaseDecoder}\n */\nclass Codec {\n /**\n * @param {Base} name\n * @param {Prefix} prefix\n * @param {(bytes:Uint8Array) => string} baseEncode\n * @param {(text:string) => Uint8Array} baseDecode\n */\n constructor (name, prefix, baseEncode, baseDecode) {\n this.name = name\n this.prefix = prefix\n this.baseEncode = baseEncode\n this.baseDecode = baseDecode\n this.encoder = new Encoder(name, prefix, baseEncode)\n this.decoder = new Decoder(name, prefix, baseDecode)\n }\n\n /**\n * @param {Uint8Array} input\n */\n encode (input) {\n return this.encoder.encode(input)\n }\n\n /**\n * @param {string} input\n */\n decode (input) {\n return this.decoder.decode(input)\n }\n}\n\n/**\n * @template {string} Base\n * @template {string} Prefix\n * @param {object} options\n * @param {Base} options.name\n * @param {Prefix} options.prefix\n * @param {(bytes:Uint8Array) => string} options.encode\n * @param {(input:string) => Uint8Array} options.decode\n * @returns {Codec}\n */\nconst from = ({ name, prefix, encode, decode }) =>\n new Codec(name, prefix, encode, decode)\n\n/**\n * @template {string} Base\n * @template {string} Prefix\n * @param {object} options\n * @param {Base} options.name\n * @param {Prefix} options.prefix\n * @param {string} options.alphabet\n * @returns {Codec}\n */\nconst baseX = ({ prefix, name, alphabet }) => {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(alphabet, name)\n return from({\n prefix,\n name,\n encode,\n /**\n * @param {string} text\n */\n decode: text => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_1__.coerce)(decode(text))\n })\n}\n\n/**\n * @param {string} string\n * @param {string} alphabet\n * @param {number} bitsPerChar\n * @param {string} name\n * @returns {Uint8Array}\n */\nconst decode = (string, alphabet, bitsPerChar, name) => {\n // Build the character lookup table:\n /** @type {Record} */\n const codes = {}\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i\n }\n\n // Count the padding bytes:\n let end = string.length\n while (string[end - 1] === '=') {\n --end\n }\n\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0)\n\n // Parse the data:\n let bits = 0 // Number of bits currently in the buffer\n let buffer = 0 // Bits waiting to be written out, MSB first\n let written = 0 // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]]\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`)\n }\n\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value\n bits += bitsPerChar\n\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8\n out[written++] = 0xff & (buffer >> bits)\n }\n }\n\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || 0xff & (buffer << (8 - bits))) {\n throw new SyntaxError('Unexpected end of data')\n }\n\n return out\n}\n\n/**\n * @param {Uint8Array} data\n * @param {string} alphabet\n * @param {number} bitsPerChar\n * @returns {string}\n */\nconst encode = (data, alphabet, bitsPerChar) => {\n const pad = alphabet[alphabet.length - 1] === '='\n const mask = (1 << bitsPerChar) - 1\n let out = ''\n\n let bits = 0 // Number of bits currently in the buffer\n let buffer = 0 // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i]\n bits += 8\n\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar\n out += alphabet[mask & (buffer >> bits)]\n }\n }\n\n // Partial character:\n if (bits) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))]\n }\n\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while ((out.length * bitsPerChar) & 7) {\n out += '='\n }\n }\n\n return out\n}\n\n/**\n * RFC4648 Factory\n *\n * @template {string} Base\n * @template {string} Prefix\n * @param {object} options\n * @param {Base} options.name\n * @param {Prefix} options.prefix\n * @param {string} options.alphabet\n * @param {number} options.bitsPerChar\n */\nconst rfc4648 = ({ name, prefix, bitsPerChar, alphabet }) => {\n return from({\n prefix,\n name,\n encode (input) {\n return encode(input, alphabet, bitsPerChar)\n },\n decode (input) {\n return decode(input, alphabet, bitsPerChar, name)\n }\n })\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base10.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base10.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base16.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base16.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n// @ts-check\n\n\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n})\n\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base2.js": -/*!******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base2.js ***! - \******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n// @ts-check\n\n\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base256emoji.js": -/*!*************************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base256emoji.js ***! - \*************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂')\nconst alphabetBytesToChars = /** @type {string[]} */ (alphabet.reduce((p, c, i) => { p[i] = c; return p }, /** @type {string[]} */([])))\nconst alphabetCharsToBytes = /** @type {number[]} */ (alphabet.reduce((p, c, i) => { p[/** @type {number} */ (c.codePointAt(0))] = i; return p }, /** @type {number[]} */([])))\n\n/**\n * @param {Uint8Array} data\n * @returns {string}\n */\nfunction encode (data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c]\n return p\n }, '')\n}\n\n/**\n * @param {string} str\n * @returns {Uint8Array}\n */\nfunction decode (str) {\n const byts = []\n for (const char of str) {\n const byt = alphabetCharsToBytes[/** @type {number} */ (char.codePointAt(0))]\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`)\n }\n byts.push(byt)\n }\n return new Uint8Array(byts)\n}\n\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base32.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base32.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n})\n\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n})\n\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n})\n\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n})\n\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n})\n\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n})\n\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n})\n\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n})\n\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base36.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base36.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n})\n\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base58.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base58.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n})\n\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base64.js": -/*!*******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base64.js ***! - \*******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n// @ts-check\n\n\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n})\n\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n})\n\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n})\n\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/base8.js": -/*!******************************************************!*\ - !*** ./node_modules/multiformats/src/bases/base8.js ***! - \******************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n// @ts-check\n\n\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/identity.js": -/*!*********************************************************!*\ - !*** ./node_modules/multiformats/src/bases/identity.js ***! - \*********************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n// @ts-check\n\n\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_1__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_1__.fromString)(str)\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/multiformats/src/bases/interface.js": +/***/ "./node_modules/multiformats/dist/src/bases/base.js": /*!**********************************************************!*\ - !*** ./node_modules/multiformats/src/bases/interface.js ***! + !*** ./node_modules/multiformats/dist/src/bases/base.js ***! \**********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bases/interface.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/basics.js": -/*!*************************************************!*\ - !*** ./node_modules/multiformats/src/basics.js ***! - \*************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base10.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base10.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/multiformats/src/bases/identity.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/multiformats/src/bases/base2.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/multiformats/src/bases/base8.js\");\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/multiformats/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/multiformats/src/bases/base16.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/multiformats/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/multiformats/src/bases/base64.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/multiformats/src/bases/base256emoji.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/multiformats/src/hashes/identity.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/multiformats/src/codecs/raw.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/multiformats/src/index.js\");\n// @ts-check\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_3__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_9__ }\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_10__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_11__ }\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_12__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_13__ }\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/basics.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base10.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/bytes.js": -/*!************************************************!*\ - !*** ./node_modules/multiformats/src/bytes.js ***! - \************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base16.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base16.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0)\n\n/**\n * @param {Uint8Array} d\n */\nconst toHex = d => d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '')\n\n/**\n * @param {string} hex\n */\nconst fromHex = hex => {\n const hexes = hex.match(/../g)\n return hexes ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty\n}\n\n/**\n * @param {Uint8Array} aa\n * @param {Uint8Array} bb\n */\nconst equals = (aa, bb) => {\n if (aa === bb) return true\n if (aa.byteLength !== bb.byteLength) {\n return false\n }\n\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * @param {ArrayBufferView|ArrayBuffer|Uint8Array} o\n * @returns {Uint8Array}\n */\nconst coerce = o => {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') return o\n if (o instanceof ArrayBuffer) return new Uint8Array(o)\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength)\n }\n throw new Error('Unknown type, must be binary type')\n}\n\n/**\n * @param {any} o\n * @returns {o is ArrayBuffer|ArrayBufferView}\n */\nconst isBinary = o =>\n o instanceof ArrayBuffer || ArrayBuffer.isView(o)\n\n/**\n * @param {string} str\n * @returns {Uint8Array}\n */\nconst fromString = str => (new TextEncoder()).encode(str)\n\n/**\n * @param {Uint8Array} b\n * @returns {string}\n */\nconst toString = b => (new TextDecoder()).decode(b)\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/bytes.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base16.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/cid.js": -/*!**********************************************!*\ - !*** ./node_modules/multiformats/src/cid.js ***! - \**********************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base2.js": +/*!***********************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base2.js ***! + \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/multiformats/src/link/interface.js\");\n\n\n\n\n\n// Linter can see that API is used in types.\n// eslint-disable-next-line\n\n\n// This way TS will also expose all the types from module\n\n\n/**\n * @template {API.Link} T\n * @template {string} Prefix\n * @param {T} link\n * @param {API.MultibaseEncoder} [base]\n * @returns {API.ToString}\n */\nconst format = (link, base) => {\n const { bytes, version } = link\n switch (version) {\n case 0:\n return toStringV0(\n bytes,\n baseCache(link),\n /** @type {API.MultibaseEncoder<\"z\">} */ (base) || _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.encoder\n )\n default:\n return toStringV1(\n bytes,\n baseCache(link),\n /** @type {API.MultibaseEncoder} */ (base || _bases_base32_js__WEBPACK_IMPORTED_MODULE_3__.base32.encoder)\n )\n }\n}\n\n/**\n * @template {API.UnknownLink} Link\n * @param {Link} link\n * @returns {API.LinkJSON}\n */\nconst toJSON = (link) => ({\n '/': format(link)\n})\n\n/**\n * @template {API.UnknownLink} Link\n * @param {API.LinkJSON} json\n */\nconst fromJSON = (json) =>\n CID.parse(json['/'])\n\n/** @type {WeakMap>} */\nconst cache = new WeakMap()\n\n/**\n * @param {API.UnknownLink} cid\n * @returns {Map}\n */\nconst baseCache = cid => {\n const baseCache = cache.get(cid)\n if (baseCache == null) {\n const baseCache = new Map()\n cache.set(cid, baseCache)\n return baseCache\n }\n return baseCache\n}\n\n/**\n * @template {unknown} [Data=unknown]\n * @template {number} [Format=number]\n * @template {number} [Alg=number]\n * @template {API.Version} [Version=API.Version]\n * @implements {API.Link}\n */\n\nclass CID {\n /**\n * @param {Version} version - Version of the CID\n * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param {API.MultihashDigest} multihash - (Multi)hash of the of the content.\n * @param {Uint8Array} bytes\n *\n */\n constructor (version, code, multihash, bytes) {\n /** @readonly */\n this.code = code\n /** @readonly */\n this.version = version\n /** @readonly */\n this.multihash = multihash\n /** @readonly */\n this.bytes = bytes\n\n // flag to serializers that this is a CID and\n // should be treated specially\n /** @readonly */\n this['/'] = bytes\n }\n\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID () {\n return this\n }\n\n // ArrayBufferView\n get byteOffset () {\n return this.bytes.byteOffset\n }\n\n // ArrayBufferView\n get byteLength () {\n return this.bytes.byteLength\n }\n\n /**\n * @returns {CID}\n */\n toV0 () {\n switch (this.version) {\n case 0: {\n return /** @type {CID} */ (this)\n }\n case 1: {\n const { code, multihash } = this\n\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0')\n }\n\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0')\n }\n\n return /** @type {CID} */ (\n CID.createV0(\n /** @type {API.MultihashDigest} */ (multihash)\n )\n )\n }\n default: {\n throw Error(\n `Can not convert CID version ${this.version} to version 0. This is a bug please report`\n )\n }\n }\n }\n\n /**\n * @returns {CID}\n */\n toV1 () {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, digest)\n return /** @type {CID} */ (\n CID.createV1(this.code, multihash)\n )\n }\n case 1: {\n return /** @type {CID} */ (this)\n }\n default: {\n throw Error(\n `Can not convert CID version ${this.version} to version 1. This is a bug please report`\n )\n }\n }\n }\n\n /**\n * @param {unknown} other\n * @returns {other is CID}\n */\n equals (other) {\n return CID.equals(this, other)\n }\n\n /**\n * @template {unknown} Data\n * @template {number} Format\n * @template {number} Alg\n * @template {API.Version} Version\n * @param {API.Link} self\n * @param {unknown} other\n * @returns {other is CID}\n */\n static equals (self, other) {\n const unknown =\n /** @type {{code?:unknown, version?:unknown, multihash?:unknown}} */ (\n other\n )\n return (\n unknown &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__.equals(self.multihash, unknown.multihash)\n )\n }\n\n /**\n * @param {API.MultibaseEncoder} [base]\n * @returns {string}\n */\n toString (base) {\n return format(this, base)\n }\n\n toJSON () {\n return { '/': format(this) }\n }\n\n link () {\n return this\n }\n\n get [Symbol.toStringTag] () {\n return 'CID'\n }\n\n // Legacy\n\n [Symbol.for('nodejs.util.inspect.custom')] () {\n return `CID(${this.toString()})`\n }\n\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n *\n * @template {unknown} Data\n * @template {number} Format\n * @template {number} Alg\n * @template {API.Version} Version\n * @template {unknown} U\n * @param {API.Link|U} input\n * @returns {CID|null}\n */\n static asCID (input) {\n if (input == null) {\n return null\n }\n\n const value = /** @type {any} */ (input)\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value\n } else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value\n return new CID(\n version,\n code,\n /** @type {API.MultihashDigest} */ (multihash),\n bytes || encodeCID(version, code, multihash.bytes)\n )\n } else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value\n const digest =\n /** @type {API.MultihashDigest} */\n (_hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__.decode(multihash))\n return CID.create(version, code, digest)\n } else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null\n }\n }\n\n /**\n *\n * @template {unknown} Data\n * @template {number} Format\n * @template {number} Alg\n * @template {API.Version} Version\n * @param {Version} version - Version of the CID\n * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param {API.MultihashDigest} digest - (Multi)hash of the of the content.\n * @returns {CID}\n */\n static create (version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported')\n }\n\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest')\n }\n\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(\n `Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`\n )\n } else {\n return new CID(version, code, digest, digest.bytes)\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes)\n return new CID(version, code, digest, bytes)\n }\n default: {\n throw new Error('Invalid version')\n }\n }\n }\n\n /**\n * Simplified version of `create` for CIDv0.\n *\n * @template {unknown} [T=unknown]\n * @param {API.MultihashDigest} digest - Multihash.\n * @returns {CID}\n */\n static createV0 (digest) {\n return CID.create(0, DAG_PB_CODE, digest)\n }\n\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @template {unknown} Data\n * @template {number} Code\n * @template {number} Alg\n * @param {Code} code - Content encoding format code.\n * @param {API.MultihashDigest} digest - Miltihash of the content.\n * @returns {CID}\n */\n static createV1 (code, digest) {\n return CID.create(1, code, digest)\n }\n\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n *\n * @template {unknown} Data\n * @template {number} Code\n * @template {number} Alg\n * @template {API.Version} Ver\n * @param {API.ByteView>} bytes\n * @returns {CID}\n */\n static decode (bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes)\n if (remainder.length) {\n throw new Error('Incorrect length')\n }\n return cid\n }\n\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n *\n * @template {unknown} T\n * @template {number} C\n * @template {number} A\n * @template {API.Version} V\n * @param {API.ByteView>} bytes\n * @returns {[CID, Uint8Array]}\n */\n static decodeFirst (bytes) {\n const specs = CID.inspectBytes(bytes)\n const prefixSize = specs.size - specs.multihashSize\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_4__.coerce)(\n bytes.subarray(prefixSize, prefixSize + specs.multihashSize)\n )\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length')\n }\n const digestBytes = multihashBytes.subarray(\n specs.multihashSize - specs.digestSize\n )\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__.Digest(\n specs.multihashCode,\n specs.digestSize,\n digestBytes,\n multihashBytes\n )\n const cid =\n specs.version === 0\n ? CID.createV0(/** @type {API.MultihashDigest} */ (digest))\n : CID.createV1(specs.codec, digest)\n return [/** @type {CID} */(cid), bytes.subarray(specs.size)]\n }\n\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n *\n * @template {unknown} T\n * @template {number} C\n * @template {number} A\n * @template {API.Version} V\n * @param {API.ByteView>} initialBytes\n * @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }}\n */\n static inspectBytes (initialBytes) {\n let offset = 0\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_0__.decode(initialBytes.subarray(offset))\n offset += length\n return i\n }\n\n let version = /** @type {V} */ (next())\n let codec = /** @type {C} */ (DAG_PB_CODE)\n if (/** @type {number} */(version) === 18) {\n // CIDv0\n version = /** @type {V} */ (0)\n offset = 0\n } else {\n codec = /** @type {C} */ (next())\n }\n\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`)\n }\n\n const prefixSize = offset\n const multihashCode = /** @type {A} */ (next()) // multihash code\n const digestSize = next() // multihash length\n const size = offset + digestSize\n const multihashSize = size - prefixSize\n\n return { version, codec, multihashCode, digestSize, multihashSize, size }\n }\n\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n *\n * @template {string} Prefix\n * @template {unknown} Data\n * @template {number} Code\n * @template {number} Alg\n * @template {API.Version} Ver\n * @param {API.ToString, Prefix>} source\n * @param {API.MultibaseDecoder} [base]\n * @returns {CID}\n */\n static parse (source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base)\n\n const cid = CID.decode(bytes)\n\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix')\n }\n\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source)\n\n return cid\n }\n}\n\n/**\n * @template {string} Prefix\n * @template {unknown} Data\n * @template {number} Code\n * @template {number} Alg\n * @template {API.Version} Ver\n * @param {API.ToString, Prefix>} source\n * @param {API.MultibaseDecoder} [base]\n * @returns {[Prefix, API.ByteView>]}\n */\nconst parseCIDtoBytes = (source, base) => {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base || _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc\n return [\n /** @type {Prefix} */ (_bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.prefix),\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.prefix}${source}`)\n ]\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.prefix: {\n const decoder = base || _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc\n return [/** @type {Prefix} */(_bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.prefix), decoder.decode(source)]\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_3__.base32.prefix: {\n const decoder = base || _bases_base32_js__WEBPACK_IMPORTED_MODULE_3__.base32\n return [/** @type {Prefix} */(_bases_base32_js__WEBPACK_IMPORTED_MODULE_3__.base32.prefix), decoder.decode(source)]\n }\n default: {\n if (base == null) {\n throw Error(\n 'To parse non base32 or base58btc encoded CID multibase decoder must be provided'\n )\n }\n return [/** @type {Prefix} */(source[0]), base.decode(source)]\n }\n }\n}\n\n/**\n *\n * @param {Uint8Array} bytes\n * @param {Map} cache\n * @param {API.MultibaseEncoder<'z'>} base\n */\nconst toStringV0 = (bytes, cache, base) => {\n const { prefix } = base\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_2__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`)\n }\n\n const cid = cache.get(prefix)\n if (cid == null) {\n const cid = base.encode(bytes).slice(1)\n cache.set(prefix, cid)\n return cid\n } else {\n return cid\n }\n}\n\n/**\n * @template {string} Prefix\n * @param {Uint8Array} bytes\n * @param {Map} cache\n * @param {API.MultibaseEncoder} base\n */\nconst toStringV1 = (bytes, cache, base) => {\n const { prefix } = base\n const cid = cache.get(prefix)\n if (cid == null) {\n const cid = base.encode(bytes)\n cache.set(prefix, cid)\n return cid\n } else {\n return cid\n }\n}\n\nconst DAG_PB_CODE = 0x70\nconst SHA_256_CODE = 0x12\n\n/**\n * @param {API.Version} version\n * @param {number} code\n * @param {Uint8Array} multihash\n * @returns {Uint8Array}\n */\nconst encodeCID = (version, code, multihash) => {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_0__.encodingLength(version)\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_0__.encodingLength(code)\n const bytes = new Uint8Array(hashOffset + multihash.byteLength)\n _varint_js__WEBPACK_IMPORTED_MODULE_0__.encodeTo(version, bytes, 0)\n _varint_js__WEBPACK_IMPORTED_MODULE_0__.encodeTo(code, bytes, codeOffset)\n bytes.set(multihash, hashOffset)\n return bytes\n}\n\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID')\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/cid.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base2.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/codecs/json.js": -/*!******************************************************!*\ - !*** ./node_modules/multiformats/src/codecs/json.js ***! - \******************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base256emoji.js": +/*!******************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base256emoji.js ***! + \******************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n// @ts-check\n\n/**\n * @template T\n * @typedef {import('./interface.js').ByteView} ByteView\n */\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nconst name = 'json'\nconst code = 0x0200\n\n/**\n * @template T\n * @param {T} node\n * @returns {ByteView}\n */\nconst encode = (node) => textEncoder.encode(JSON.stringify(node))\n\n/**\n * @template T\n * @param {ByteView} data\n * @returns {T}\n */\nconst decode = (data) => JSON.parse(textDecoder.decode(data))\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/codecs/json.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base256emoji.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/codecs/raw.js": -/*!*****************************************************!*\ - !*** ./node_modules/multiformats/src/codecs/raw.js ***! - \*****************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base32.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base32.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n// @ts-check\n\n\n\n/**\n * @template T\n * @typedef {import('./interface.js').ByteView} ByteView\n */\n\nconst name = 'raw'\nconst code = 0x55\n\n/**\n * @param {Uint8Array} node\n * @returns {ByteView}\n */\nconst encode = (node) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node)\n\n/**\n * @param {ByteView} data\n * @returns {Uint8Array}\n */\nconst decode = (data) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data)\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/codecs/raw.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base32.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/hashes/digest.js": -/*!********************************************************!*\ - !*** ./node_modules/multiformats/src/hashes/digest.js ***! - \********************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base36.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base36.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/multiformats/src/varint.js\");\n\n\n\n/**\n * Creates a multihash digest.\n *\n * @template {number} Code\n * @param {Code} code\n * @param {Uint8Array} digest\n */\nconst create = (code, digest) => {\n const size = digest.byteLength\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code)\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size)\n\n const bytes = new Uint8Array(digestOffset + size)\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0)\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset)\n bytes.set(digest, digestOffset)\n\n return new Digest(code, size, digest, bytes)\n}\n\n/**\n * Turns bytes representation of multihash digest into an instance.\n *\n * @param {Uint8Array} multihash\n * @returns {MultihashDigest}\n */\nconst decode = (multihash) => {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash)\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes)\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset))\n const digest = bytes.subarray(sizeOffset + digestOffset)\n\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length')\n }\n\n return new Digest(code, size, digest, bytes)\n}\n\n/**\n * @param {MultihashDigest} a\n * @param {unknown} b\n * @returns {b is MultihashDigest}\n */\nconst equals = (a, b) => {\n if (a === b) {\n return true\n } else {\n const data = /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */(b)\n\n return (\n a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes)\n )\n }\n}\n\n/**\n * @typedef {import('./interface.js').MultihashDigest} MultihashDigest\n */\n\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n *\n * @template {number} Code\n * @template {number} Size\n * @class\n * @implements {MultihashDigest}\n */\nclass Digest {\n /**\n * Creates a multihash digest.\n *\n * @param {Code} code\n * @param {Size} size\n * @param {Uint8Array} digest\n * @param {Uint8Array} bytes\n */\n constructor (code, size, digest, bytes) {\n this.code = code\n this.size = size\n this.digest = digest\n this.bytes = bytes\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/hashes/digest.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base36.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/hashes/hasher.js": -/*!********************************************************!*\ - !*** ./node_modules/multiformats/src/hashes/hasher.js ***! - \********************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base58.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base58.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/multiformats/src/hashes/digest.js\");\n\n\n/**\n * @template {string} Name\n * @template {number} Code\n * @param {object} options\n * @param {Name} options.name\n * @param {Code} options.code\n * @param {(input: Uint8Array) => Await} options.encode\n */\nconst from = ({ name, code, encode }) => new Hasher(name, code, encode)\n\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n *\n * @template {string} Name\n * @template {number} Code\n * @class\n * @implements {MultihashHasher}\n */\nclass Hasher {\n /**\n *\n * @param {Name} name\n * @param {Code} code\n * @param {(input: Uint8Array) => Await} encode\n */\n constructor (name, code, encode) {\n this.name = name\n this.code = code\n this.encode = encode\n }\n\n /**\n * @param {Uint8Array} input\n * @returns {Await>}\n */\n digest (input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input)\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest))\n } else {\n throw Error('Unknown type, must be binary type')\n /* c8 ignore next 1 */\n }\n }\n}\n\n/**\n * @template {number} Alg\n * @typedef {import('./interface.js').MultihashHasher} MultihashHasher\n */\n\n/**\n * @template T\n * @typedef {Promise|T} Await\n */\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/hashes/hasher.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base58.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/hashes/identity.js": -/*!**********************************************************!*\ - !*** ./node_modules/multiformats/src/hashes/identity.js ***! - \**********************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/base64.js": +/*!************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base64.js ***! + \************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/multiformats/src/hashes/digest.js\");\n\n\n\nconst code = 0x0\nconst name = 'identity'\n\n/** @type {(input:Uint8Array) => Uint8Array} */\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce\n\n/**\n * @param {Uint8Array} input\n * @returns {Digest.Digest}\n */\nconst digest = (input) => _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input))\n\nconst identity = { code, name, encode, digest }\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/hashes/identity.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base64.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/hashes/sha2-browser.js": +/***/ "./node_modules/multiformats/dist/src/bases/base8.js": +/*!***********************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/base8.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/base8.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/bases/identity.js": /*!**************************************************************!*\ - !*** ./node_modules/multiformats/src/hashes/sha2-browser.js ***! + !*** ./node_modules/multiformats/dist/src/bases/identity.js ***! \**************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/multiformats/src/hashes/hasher.js\");\n/* global crypto */\n\n\n\n/**\n * @param {AlgorithmIdentifier} name\n */\nconst sha = name =>\n /**\n * @param {Uint8Array} data\n */\n async data => new Uint8Array(await crypto.subtle.digest(name, data))\n\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n})\n\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n})\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/hashes/sha2-browser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/identity.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/index.js": -/*!************************************************!*\ - !*** ./node_modules/multiformats/src/index.js ***! - \************************************************/ +/***/ "./node_modules/multiformats/dist/src/bases/interface.js": +/*!***************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bases/interface.js ***! + \***************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_0__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_1__)\n/* harmony export */ });\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/multiformats/src/hashes/hasher.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/multiformats/src/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bases/interface.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/interface.js": -/*!****************************************************!*\ - !*** ./node_modules/multiformats/src/interface.js ***! - \****************************************************/ +/***/ "./node_modules/multiformats/dist/src/basics.js": +/*!******************************************************!*\ + !*** ./node_modules/multiformats/dist/src/basics.js ***! + \******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/interface.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/basics.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/link/interface.js": +/***/ "./node_modules/multiformats/dist/src/block/interface.js": +/*!***************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/block/interface.js ***! + \***************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/block/interface.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/bytes.js": +/*!*****************************************************!*\ + !*** ./node_modules/multiformats/dist/src/bytes.js ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/bytes.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/cid.js": +/*!***************************************************!*\ + !*** ./node_modules/multiformats/dist/src/cid.js ***! + \***************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/cid.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/codecs/interface.js": +/*!****************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/codecs/interface.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/codecs/interface.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/codecs/json.js": +/*!***********************************************************!*\ + !*** ./node_modules/multiformats/dist/src/codecs/json.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/codecs/json.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/codecs/raw.js": +/*!**********************************************************!*\ + !*** ./node_modules/multiformats/dist/src/codecs/raw.js ***! + \**********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/codecs/raw.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/hashes/digest.js": +/*!*************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/hashes/digest.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/hashes/digest.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/hashes/hasher.js": +/*!*************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/hashes/hasher.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/hashes/hasher.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/hashes/identity.js": +/*!***************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/hashes/identity.js ***! + \***************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/hashes/identity.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/hashes/interface.js": +/*!****************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/hashes/interface.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/hashes/interface.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/hashes/sha2-browser.js": +/*!*******************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/index.js": +/*!*****************************************************!*\ + !*** ./node_modules/multiformats/dist/src/index.js ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/interface.js": /*!*********************************************************!*\ - !*** ./node_modules/multiformats/src/link/interface.js ***! + !*** ./node_modules/multiformats/dist/src/interface.js ***! \*********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/link/interface.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/interface.js?"); /***/ }), -/***/ "./node_modules/multiformats/src/varint.js": -/*!*************************************************!*\ - !*** ./node_modules/multiformats/src/varint.js ***! - \*************************************************/ +/***/ "./node_modules/multiformats/dist/src/link/interface.js": +/*!**************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/link/interface.js ***! + \**************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vendor/varint.js */ \"./node_modules/multiformats/vendor/varint.js\");\n\n\n/**\n * @param {Uint8Array} data\n * @param {number} [offset=0]\n * @returns {[number, number]}\n */\nconst decode = (data, offset = 0) => {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset)\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes]\n}\n\n/**\n * @param {number} int\n * @param {Uint8Array} target\n * @param {number} [offset=0]\n */\nconst encodeTo = (int, target, offset = 0) => {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset)\n return target\n}\n\n/**\n * @param {number} int\n * @returns {number}\n */\nconst encodingLength = (int) => {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int)\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/src/varint.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/link/interface.js?"); /***/ }), -/***/ "./node_modules/multiformats/vendor/base-x.js": -/*!****************************************************!*\ - !*** ./node_modules/multiformats/vendor/base-x.js ***! - \****************************************************/ +/***/ "./node_modules/multiformats/dist/src/varint.js": +/*!******************************************************!*\ + !*** ./node_modules/multiformats/dist/src/varint.js ***! + \******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET, name) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n function encode (source) {\n if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') { return }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) { return }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') { return }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch\n }\n function decode (string) {\n var buffer = decodeUnsafe(string);\n if (buffer) { return buffer }\n throw new Error(`Non-${name} character`)\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nvar src = base;\n\nvar _brrp__multiformats_scope_baseX = src;\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/vendor/base-x.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/varint.js?"); /***/ }), -/***/ "./node_modules/multiformats/vendor/varint.js": -/*!****************************************************!*\ - !*** ./node_modules/multiformats/vendor/varint.js ***! - \****************************************************/ +/***/ "./node_modules/multiformats/dist/src/vendor/base-x.js": +/*!*************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/vendor/base-x.js ***! + \*************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nvar encode_1 = encode;\n\nvar MSB = 0x80\n , REST = 0x7F\n , MSBALL = ~REST\n , INT = Math.pow(2, 31);\n\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n\n while(num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while(num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n \n encode.bytes = offset - oldOffset + 1;\n \n return out\n}\n\nvar decode = read;\n\nvar MSB$1 = 0x80\n , REST$1 = 0x7F;\n\nfunction read(buf, offset) {\n var res = 0\n , offset = offset || 0\n , shift = 0\n , counter = offset\n , b\n , l = buf.length;\n\n do {\n if (counter >= l) {\n read.bytes = 0;\n throw new RangeError('Could not decode varint')\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1)\n\n read.bytes = counter - offset;\n\n return res\n}\n\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\n\nvar length = function (value) {\n return (\n value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10\n )\n};\n\nvar varint = {\n encode: encode_1\n , decode: decode\n , encodingLength: length\n};\n\nvar _brrp_varint = varint;\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/vendor/varint.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/vendor/base-x.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/dist/src/vendor/varint.js": +/*!*************************************************************!*\ + !*** ./node_modules/multiformats/dist/src/vendor/varint.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/multiformats/dist/src/vendor/varint.js?"); /***/ }), @@ -8634,7 +8740,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-queue/node_modules/p-timeout/index.js\");\n/* harmony import */ var _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./priority-queue.js */ \"./node_modules/p-queue/dist/priority-queue.js\");\nvar __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n};\nvar __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar _PQueue_instances, _PQueue_carryoverConcurrencyCount, _PQueue_isIntervalIgnored, _PQueue_intervalCount, _PQueue_intervalCap, _PQueue_interval, _PQueue_intervalEnd, _PQueue_intervalId, _PQueue_timeoutId, _PQueue_queue, _PQueue_queueClass, _PQueue_pending, _PQueue_concurrency, _PQueue_isPaused, _PQueue_throwOnTimeout, _PQueue_doesIntervalAllowAnother_get, _PQueue_doesConcurrentAllowAnother_get, _PQueue_next, _PQueue_onResumeInterval, _PQueue_isIntervalPaused_get, _PQueue_tryToStartAnother, _PQueue_initializeIntervalIfNeeded, _PQueue_onInterval, _PQueue_processQueue, _PQueue_throwOnAbort, _PQueue_onEvent;\n\n\n\n/**\nThe error thrown by `queue.add()` when a job is aborted before it is run. See `signal`.\n*/\nclass AbortError extends Error {\n}\n/**\nPromise queue with concurrency control.\n*/\nclass PQueue extends eventemitter3__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`\n constructor(options) {\n var _a, _b, _c, _d;\n super();\n _PQueue_instances.add(this);\n _PQueue_carryoverConcurrencyCount.set(this, void 0);\n _PQueue_isIntervalIgnored.set(this, void 0);\n _PQueue_intervalCount.set(this, 0);\n _PQueue_intervalCap.set(this, void 0);\n _PQueue_interval.set(this, void 0);\n _PQueue_intervalEnd.set(this, 0);\n _PQueue_intervalId.set(this, void 0);\n _PQueue_timeoutId.set(this, void 0);\n _PQueue_queue.set(this, void 0);\n _PQueue_queueClass.set(this, void 0);\n _PQueue_pending.set(this, 0);\n // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n _PQueue_concurrency.set(this, void 0);\n _PQueue_isPaused.set(this, void 0);\n _PQueue_throwOnTimeout.set(this, void 0);\n /**\n Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.\n \n Applies to each future operation.\n */\n Object.defineProperty(this, \"timeout\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = {\n carryoverConcurrencyCount: false,\n intervalCap: Number.POSITIVE_INFINITY,\n interval: 0,\n concurrency: Number.POSITIVE_INFINITY,\n autoStart: true,\n queueClass: _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n ...options,\n };\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${(_b = (_a = options.intervalCap) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${(_d = (_c = options.interval) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ''}\\` (${typeof options.interval})`);\n }\n __classPrivateFieldSet(this, _PQueue_carryoverConcurrencyCount, options.carryoverConcurrencyCount, \"f\");\n __classPrivateFieldSet(this, _PQueue_isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0, \"f\");\n __classPrivateFieldSet(this, _PQueue_intervalCap, options.intervalCap, \"f\");\n __classPrivateFieldSet(this, _PQueue_interval, options.interval, \"f\");\n __classPrivateFieldSet(this, _PQueue_queue, new options.queueClass(), \"f\");\n __classPrivateFieldSet(this, _PQueue_queueClass, options.queueClass, \"f\");\n this.concurrency = options.concurrency;\n this.timeout = options.timeout;\n __classPrivateFieldSet(this, _PQueue_throwOnTimeout, options.throwOnTimeout === true, \"f\");\n __classPrivateFieldSet(this, _PQueue_isPaused, options.autoStart === false, \"f\");\n }\n get concurrency() {\n return __classPrivateFieldGet(this, _PQueue_concurrency, \"f\");\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n __classPrivateFieldSet(this, _PQueue_concurrency, newConcurrency, \"f\");\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_processQueue).call(this);\n }\n async add(function_, options = {}) {\n options = {\n timeout: this.timeout,\n throwOnTimeout: __classPrivateFieldGet(this, _PQueue_throwOnTimeout, \"f\"),\n ...options,\n };\n return new Promise((resolve, reject) => {\n __classPrivateFieldGet(this, _PQueue_queue, \"f\").enqueue(async () => {\n var _a;\n var _b, _c;\n __classPrivateFieldSet(this, _PQueue_pending, (_b = __classPrivateFieldGet(this, _PQueue_pending, \"f\"), _b++, _b), \"f\");\n __classPrivateFieldSet(this, _PQueue_intervalCount, (_c = __classPrivateFieldGet(this, _PQueue_intervalCount, \"f\"), _c++, _c), \"f\");\n try {\n // TODO: Use options.signal?.throwIfAborted() when targeting Node.js 18\n if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {\n // TODO: Use ABORT_ERR code when targeting Node.js 16 (https://nodejs.org/docs/latest-v16.x/api/errors.html#abort_err)\n throw new AbortError('The task was aborted.');\n }\n let operation = function_({ signal: options.signal });\n if (options.timeout) {\n operation = (0,p_timeout__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(Promise.resolve(operation), options.timeout);\n }\n if (options.signal) {\n operation = Promise.race([operation, __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_throwOnAbort).call(this, options.signal)]);\n }\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n if (error instanceof p_timeout__WEBPACK_IMPORTED_MODULE_1__.TimeoutError && !options.throwOnTimeout) {\n resolve();\n return;\n }\n reject(error);\n this.emit('error', error);\n }\n finally {\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_next).call(this);\n }\n }, options);\n this.emit('add');\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_tryToStartAnother).call(this);\n });\n }\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!__classPrivateFieldGet(this, _PQueue_isPaused, \"f\")) {\n return this;\n }\n __classPrivateFieldSet(this, _PQueue_isPaused, false, \"f\");\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_processQueue).call(this);\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n __classPrivateFieldSet(this, _PQueue_isPaused, true, \"f\");\n }\n /**\n Clear the queue.\n */\n clear() {\n __classPrivateFieldSet(this, _PQueue_queue, new (__classPrivateFieldGet(this, _PQueue_queueClass, \"f\"))(), \"f\");\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (__classPrivateFieldGet(this, _PQueue_queue, \"f\").size === 0) {\n return;\n }\n await __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onEvent).call(this, 'empty');\n }\n /**\n @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.\n\n If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n */\n async onSizeLessThan(limit) {\n // Instantly resolve if the queue is empty.\n if (__classPrivateFieldGet(this, _PQueue_queue, \"f\").size < limit) {\n return;\n }\n await __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onEvent).call(this, 'next', () => __classPrivateFieldGet(this, _PQueue_queue, \"f\").size < limit);\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (__classPrivateFieldGet(this, _PQueue_pending, \"f\") === 0 && __classPrivateFieldGet(this, _PQueue_queue, \"f\").size === 0) {\n return;\n }\n await __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onEvent).call(this, 'idle');\n }\n /**\n Size of the queue, the number of queued items waiting to run.\n */\n get size() {\n return __classPrivateFieldGet(this, _PQueue_queue, \"f\").size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n return __classPrivateFieldGet(this, _PQueue_queue, \"f\").filter(options).length;\n }\n /**\n Number of running items (no longer in the queue).\n */\n get pending() {\n return __classPrivateFieldGet(this, _PQueue_pending, \"f\");\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return __classPrivateFieldGet(this, _PQueue_isPaused, \"f\");\n }\n}\n_PQueue_carryoverConcurrencyCount = new WeakMap(), _PQueue_isIntervalIgnored = new WeakMap(), _PQueue_intervalCount = new WeakMap(), _PQueue_intervalCap = new WeakMap(), _PQueue_interval = new WeakMap(), _PQueue_intervalEnd = new WeakMap(), _PQueue_intervalId = new WeakMap(), _PQueue_timeoutId = new WeakMap(), _PQueue_queue = new WeakMap(), _PQueue_queueClass = new WeakMap(), _PQueue_pending = new WeakMap(), _PQueue_concurrency = new WeakMap(), _PQueue_isPaused = new WeakMap(), _PQueue_throwOnTimeout = new WeakMap(), _PQueue_instances = new WeakSet(), _PQueue_doesIntervalAllowAnother_get = function _PQueue_doesIntervalAllowAnother_get() {\n return __classPrivateFieldGet(this, _PQueue_isIntervalIgnored, \"f\") || __classPrivateFieldGet(this, _PQueue_intervalCount, \"f\") < __classPrivateFieldGet(this, _PQueue_intervalCap, \"f\");\n}, _PQueue_doesConcurrentAllowAnother_get = function _PQueue_doesConcurrentAllowAnother_get() {\n return __classPrivateFieldGet(this, _PQueue_pending, \"f\") < __classPrivateFieldGet(this, _PQueue_concurrency, \"f\");\n}, _PQueue_next = function _PQueue_next() {\n var _a;\n __classPrivateFieldSet(this, _PQueue_pending, (_a = __classPrivateFieldGet(this, _PQueue_pending, \"f\"), _a--, _a), \"f\");\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_tryToStartAnother).call(this);\n this.emit('next');\n}, _PQueue_onResumeInterval = function _PQueue_onResumeInterval() {\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onInterval).call(this);\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_initializeIntervalIfNeeded).call(this);\n __classPrivateFieldSet(this, _PQueue_timeoutId, undefined, \"f\");\n}, _PQueue_isIntervalPaused_get = function _PQueue_isIntervalPaused_get() {\n const now = Date.now();\n if (__classPrivateFieldGet(this, _PQueue_intervalId, \"f\") === undefined) {\n const delay = __classPrivateFieldGet(this, _PQueue_intervalEnd, \"f\") - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n __classPrivateFieldSet(this, _PQueue_intervalCount, (__classPrivateFieldGet(this, _PQueue_carryoverConcurrencyCount, \"f\")) ? __classPrivateFieldGet(this, _PQueue_pending, \"f\") : 0, \"f\");\n }\n else {\n // Act as the interval is pending\n if (__classPrivateFieldGet(this, _PQueue_timeoutId, \"f\") === undefined) {\n __classPrivateFieldSet(this, _PQueue_timeoutId, setTimeout(() => {\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onResumeInterval).call(this);\n }, delay), \"f\");\n }\n return true;\n }\n }\n return false;\n}, _PQueue_tryToStartAnother = function _PQueue_tryToStartAnother() {\n if (__classPrivateFieldGet(this, _PQueue_queue, \"f\").size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (__classPrivateFieldGet(this, _PQueue_intervalId, \"f\")) {\n clearInterval(__classPrivateFieldGet(this, _PQueue_intervalId, \"f\"));\n }\n __classPrivateFieldSet(this, _PQueue_intervalId, undefined, \"f\");\n this.emit('empty');\n if (__classPrivateFieldGet(this, _PQueue_pending, \"f\") === 0) {\n this.emit('idle');\n }\n return false;\n }\n if (!__classPrivateFieldGet(this, _PQueue_isPaused, \"f\")) {\n const canInitializeInterval = !__classPrivateFieldGet(this, _PQueue_instances, \"a\", _PQueue_isIntervalPaused_get);\n if (__classPrivateFieldGet(this, _PQueue_instances, \"a\", _PQueue_doesIntervalAllowAnother_get) && __classPrivateFieldGet(this, _PQueue_instances, \"a\", _PQueue_doesConcurrentAllowAnother_get)) {\n const job = __classPrivateFieldGet(this, _PQueue_queue, \"f\").dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_initializeIntervalIfNeeded).call(this);\n }\n return true;\n }\n }\n return false;\n}, _PQueue_initializeIntervalIfNeeded = function _PQueue_initializeIntervalIfNeeded() {\n if (__classPrivateFieldGet(this, _PQueue_isIntervalIgnored, \"f\") || __classPrivateFieldGet(this, _PQueue_intervalId, \"f\") !== undefined) {\n return;\n }\n __classPrivateFieldSet(this, _PQueue_intervalId, setInterval(() => {\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_onInterval).call(this);\n }, __classPrivateFieldGet(this, _PQueue_interval, \"f\")), \"f\");\n __classPrivateFieldSet(this, _PQueue_intervalEnd, Date.now() + __classPrivateFieldGet(this, _PQueue_interval, \"f\"), \"f\");\n}, _PQueue_onInterval = function _PQueue_onInterval() {\n if (__classPrivateFieldGet(this, _PQueue_intervalCount, \"f\") === 0 && __classPrivateFieldGet(this, _PQueue_pending, \"f\") === 0 && __classPrivateFieldGet(this, _PQueue_intervalId, \"f\")) {\n clearInterval(__classPrivateFieldGet(this, _PQueue_intervalId, \"f\"));\n __classPrivateFieldSet(this, _PQueue_intervalId, undefined, \"f\");\n }\n __classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet(this, _PQueue_carryoverConcurrencyCount, \"f\") ? __classPrivateFieldGet(this, _PQueue_pending, \"f\") : 0, \"f\");\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_processQueue).call(this);\n}, _PQueue_processQueue = function _PQueue_processQueue() {\n // eslint-disable-next-line no-empty\n while (__classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_tryToStartAnother).call(this)) { }\n}, _PQueue_throwOnAbort = async function _PQueue_throwOnAbort(signal) {\n return new Promise((_resolve, reject) => {\n signal.addEventListener('abort', () => {\n // TODO: Reject with signal.throwIfAborted() when targeting Node.js 18\n // TODO: Use ABORT_ERR code when targeting Node.js 16 (https://nodejs.org/docs/latest-v16.x/api/errors.html#abort_err)\n reject(new AbortError('The task was aborted.'));\n }, { once: true });\n });\n}, _PQueue_onEvent = async function _PQueue_onEvent(event, filter) {\n return new Promise(resolve => {\n const listener = () => {\n if (filter && !filter()) {\n return;\n }\n this.off(event, listener);\n resolve();\n };\n this.on(event, listener);\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PQueue);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PQueue)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.mjs\");\n/* harmony import */ var p_timeout__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-timeout */ \"./node_modules/p-timeout/index.js\");\n/* harmony import */ var _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./priority-queue.js */ \"./node_modules/p-queue/dist/priority-queue.js\");\n\n\n\n/**\nPromise queue with concurrency control.\n*/\nclass PQueue extends eventemitter3__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\n #carryoverConcurrencyCount;\n #isIntervalIgnored;\n #intervalCount = 0;\n #intervalCap;\n #interval;\n #intervalEnd = 0;\n #intervalId;\n #timeoutId;\n #queue;\n #queueClass;\n #pending = 0;\n // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n #concurrency;\n #isPaused;\n #throwOnTimeout;\n /**\n Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.\n\n Applies to each future operation.\n */\n timeout;\n // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`\n constructor(options) {\n super();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = {\n carryoverConcurrencyCount: false,\n intervalCap: Number.POSITIVE_INFINITY,\n interval: 0,\n concurrency: Number.POSITIVE_INFINITY,\n autoStart: true,\n queueClass: _priority_queue_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n ...options,\n };\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${options.intervalCap?.toString() ?? ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${options.interval?.toString() ?? ''}\\` (${typeof options.interval})`);\n }\n this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;\n this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;\n this.#intervalCap = options.intervalCap;\n this.#interval = options.interval;\n this.#queue = new options.queueClass();\n this.#queueClass = options.queueClass;\n this.concurrency = options.concurrency;\n this.timeout = options.timeout;\n this.#throwOnTimeout = options.throwOnTimeout === true;\n this.#isPaused = options.autoStart === false;\n }\n get #doesIntervalAllowAnother() {\n return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;\n }\n get #doesConcurrentAllowAnother() {\n return this.#pending < this.#concurrency;\n }\n #next() {\n this.#pending--;\n this.#tryToStartAnother();\n this.emit('next');\n }\n #onResumeInterval() {\n this.#onInterval();\n this.#initializeIntervalIfNeeded();\n this.#timeoutId = undefined;\n }\n get #isIntervalPaused() {\n const now = Date.now();\n if (this.#intervalId === undefined) {\n const delay = this.#intervalEnd - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n this.#intervalCount = (this.#carryoverConcurrencyCount) ? this.#pending : 0;\n }\n else {\n // Act as the interval is pending\n if (this.#timeoutId === undefined) {\n this.#timeoutId = setTimeout(() => {\n this.#onResumeInterval();\n }, delay);\n }\n return true;\n }\n }\n return false;\n }\n #tryToStartAnother() {\n if (this.#queue.size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (this.#intervalId) {\n clearInterval(this.#intervalId);\n }\n this.#intervalId = undefined;\n this.emit('empty');\n if (this.#pending === 0) {\n this.emit('idle');\n }\n return false;\n }\n if (!this.#isPaused) {\n const canInitializeInterval = !this.#isIntervalPaused;\n if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {\n const job = this.#queue.dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n this.#initializeIntervalIfNeeded();\n }\n return true;\n }\n }\n return false;\n }\n #initializeIntervalIfNeeded() {\n if (this.#isIntervalIgnored || this.#intervalId !== undefined) {\n return;\n }\n this.#intervalId = setInterval(() => {\n this.#onInterval();\n }, this.#interval);\n this.#intervalEnd = Date.now() + this.#interval;\n }\n #onInterval() {\n if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {\n clearInterval(this.#intervalId);\n this.#intervalId = undefined;\n }\n this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;\n this.#processQueue();\n }\n /**\n Executes all queued functions until it reaches the limit.\n */\n #processQueue() {\n // eslint-disable-next-line no-empty\n while (this.#tryToStartAnother()) { }\n }\n get concurrency() {\n return this.#concurrency;\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n this.#concurrency = newConcurrency;\n this.#processQueue();\n }\n async #throwOnAbort(signal) {\n return new Promise((_resolve, reject) => {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n }, { once: true });\n });\n }\n async add(function_, options = {}) {\n options = {\n timeout: this.timeout,\n throwOnTimeout: this.#throwOnTimeout,\n ...options,\n };\n return new Promise((resolve, reject) => {\n this.#queue.enqueue(async () => {\n this.#pending++;\n this.#intervalCount++;\n try {\n options.signal?.throwIfAborted();\n let operation = function_({ signal: options.signal });\n if (options.timeout) {\n operation = (0,p_timeout__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(Promise.resolve(operation), { milliseconds: options.timeout });\n }\n if (options.signal) {\n operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);\n }\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n if (error instanceof p_timeout__WEBPACK_IMPORTED_MODULE_1__.TimeoutError && !options.throwOnTimeout) {\n resolve();\n return;\n }\n reject(error);\n this.emit('error', error);\n }\n finally {\n this.#next();\n }\n }, options);\n this.emit('add');\n this.#tryToStartAnother();\n });\n }\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!this.#isPaused) {\n return this;\n }\n this.#isPaused = false;\n this.#processQueue();\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n this.#isPaused = true;\n }\n /**\n Clear the queue.\n */\n clear() {\n this.#queue = new this.#queueClass();\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('empty');\n }\n /**\n @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.\n\n If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n */\n async onSizeLessThan(limit) {\n // Instantly resolve if the queue is empty.\n if (this.#queue.size < limit) {\n return;\n }\n await this.#onEvent('next', () => this.#queue.size < limit);\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (this.#pending === 0 && this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('idle');\n }\n async #onEvent(event, filter) {\n return new Promise(resolve => {\n const listener = () => {\n if (filter && !filter()) {\n return;\n }\n this.off(event, listener);\n resolve();\n };\n this.on(event, listener);\n });\n }\n /**\n Size of the queue, the number of queued items waiting to run.\n */\n get size() {\n return this.#queue.size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n return this.#queue.filter(options).length;\n }\n /**\n Number of running items (no longer in the queue).\n */\n get pending() {\n return this.#pending;\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return this.#isPaused;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/dist/index.js?"); /***/ }), @@ -8656,18 +8762,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _lower_bound_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lower-bound.js */ \"./node_modules/p-queue/dist/lower-bound.js\");\nvar __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar _PriorityQueue_queue;\n\nclass PriorityQueue {\n constructor() {\n _PriorityQueue_queue.set(this, []);\n }\n enqueue(run, options) {\n options = {\n priority: 0,\n ...options,\n };\n const element = {\n priority: options.priority,\n run,\n };\n if (this.size && __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\")[this.size - 1].priority >= options.priority) {\n __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\").push(element);\n return;\n }\n const index = (0,_lower_bound_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(__classPrivateFieldGet(this, _PriorityQueue_queue, \"f\"), element, (a, b) => b.priority - a.priority);\n __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\").splice(index, 0, element);\n }\n dequeue() {\n const item = __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\").shift();\n return item === null || item === void 0 ? void 0 : item.run;\n }\n filter(options) {\n return __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\").filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return __classPrivateFieldGet(this, _PriorityQueue_queue, \"f\").length;\n }\n}\n_PriorityQueue_queue = new WeakMap();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PriorityQueue);\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/dist/priority-queue.js?"); - -/***/ }), - -/***/ "./node_modules/p-queue/node_modules/p-timeout/index.js": -/*!**************************************************************!*\ - !*** ./node_modules/p-queue/node_modules/p-timeout/index.js ***! - \**************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ TimeoutError: () => (/* binding */ TimeoutError),\n/* harmony export */ \"default\": () => (/* binding */ pTimeout)\n/* harmony export */ });\nclass TimeoutError extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = 'TimeoutError';\n\t}\n}\n\n/**\nAn error to be thrown when the request is aborted by AbortController.\nDOMException is thrown instead of this Error when DOMException is available.\n*/\nclass AbortError extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\t\tthis.name = 'AbortError';\n\t\tthis.message = message;\n\t}\n}\n\n/**\nTODO: Remove AbortError and just throw DOMException when targeting Node 18.\n*/\nconst getDOMException = errorMessage => globalThis.DOMException === undefined ?\n\tnew AbortError(errorMessage) :\n\tnew DOMException(errorMessage);\n\n/**\nTODO: Remove below function and just 'reject(signal.reason)' when targeting Node 18.\n*/\nconst getAbortedReason = signal => {\n\tconst reason = signal.reason === undefined ?\n\t\tgetDOMException('This operation was aborted.') :\n\t\tsignal.reason;\n\n\treturn reason instanceof Error ? reason : getDOMException(reason);\n};\n\nfunction pTimeout(promise, milliseconds, fallback, options) {\n\tlet timer;\n\n\tconst cancelablePromise = new Promise((resolve, reject) => {\n\t\tif (typeof milliseconds !== 'number' || Math.sign(milliseconds) !== 1) {\n\t\t\tthrow new TypeError(`Expected \\`milliseconds\\` to be a positive number, got \\`${milliseconds}\\``);\n\t\t}\n\n\t\tif (milliseconds === Number.POSITIVE_INFINITY) {\n\t\t\tresolve(promise);\n\t\t\treturn;\n\t\t}\n\n\t\toptions = {\n\t\t\tcustomTimers: {setTimeout, clearTimeout},\n\t\t\t...options\n\t\t};\n\n\t\tif (options.signal) {\n\t\t\tconst {signal} = options;\n\t\t\tif (signal.aborted) {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t}\n\n\t\t\tsignal.addEventListener('abort', () => {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t});\n\t\t}\n\n\t\ttimer = options.customTimers.setTimeout.call(undefined, () => {\n\t\t\tif (typeof fallback === 'function') {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(fallback());\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst message = typeof fallback === 'string' ? fallback : `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\tconst timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);\n\n\t\t\tif (typeof promise.cancel === 'function') {\n\t\t\t\tpromise.cancel();\n\t\t\t}\n\n\t\t\treject(timeoutError);\n\t\t}, milliseconds);\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tresolve(await promise);\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t} finally {\n\t\t\t\toptions.customTimers.clearTimeout.call(undefined, timer);\n\t\t\t}\n\t\t})();\n\t});\n\n\tcancelablePromise.clear = () => {\n\t\tclearTimeout(timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/node_modules/p-timeout/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PriorityQueue)\n/* harmony export */ });\n/* harmony import */ var _lower_bound_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lower-bound.js */ \"./node_modules/p-queue/dist/lower-bound.js\");\n\nclass PriorityQueue {\n #queue = [];\n enqueue(run, options) {\n options = {\n priority: 0,\n ...options,\n };\n const element = {\n priority: options.priority,\n run,\n };\n if (this.size && this.#queue[this.size - 1].priority >= options.priority) {\n this.#queue.push(element);\n return;\n }\n const index = (0,_lower_bound_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/dist/priority-queue.js?"); /***/ }), @@ -8682,28 +8777,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/private-ip/index.js": -/*!******************************************!*\ - !*** ./node_modules/private-ip/index.js ***! - \******************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/index.js */ \"./node_modules/private-ip/lib/index.js\");\n\n\n;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lib_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/private-ip/index.js?"); - -/***/ }), - -/***/ "./node_modules/private-ip/lib/index.js": -/*!**********************************************!*\ - !*** ./node_modules/private-ip/lib/index.js ***! - \**********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var netmask__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! netmask */ \"./node_modules/netmask/lib/netmask.js\");\n/* harmony import */ var ip_regex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ip-regex */ \"./node_modules/ip-regex/index.js\");\n/* harmony import */ var _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @chainsafe/is-ip */ \"./node_modules/@chainsafe/is-ip/lib/is-ip.js\");\n/* harmony import */ var ipaddr_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ipaddr.js */ \"./node_modules/ipaddr.js/lib/ipaddr.js\");\n\n\n\n\nconst { isValid: is_valid, parse } = ipaddr_js__WEBPACK_IMPORTED_MODULE_3__;\nconst PRIVATE_IP_RANGES = [\n '0.0.0.0/8',\n '10.0.0.0/8',\n '100.64.0.0/10',\n '127.0.0.0/8',\n '169.254.0.0/16',\n '172.16.0.0/12',\n '192.0.0.0/24',\n '192.0.0.0/29',\n '192.0.0.8/32',\n '192.0.0.9/32',\n '192.0.0.10/32',\n '192.0.0.170/32',\n '192.0.0.171/32',\n '192.0.2.0/24',\n '192.31.196.0/24',\n '192.52.193.0/24',\n '192.88.99.0/24',\n '192.168.0.0/16',\n '192.175.48.0/24',\n '198.18.0.0/15',\n '198.51.100.0/24',\n '203.0.113.0/24',\n '240.0.0.0/4',\n '255.255.255.255/32'\n];\nconst NETMASK_RANGES = PRIVATE_IP_RANGES.map(ip_range => new netmask__WEBPACK_IMPORTED_MODULE_0__.Netmask(ip_range));\nfunction ipv4_check(ip_addr) {\n for (let r of NETMASK_RANGES) {\n if (r.contains(ip_addr))\n return true;\n }\n return false;\n}\nfunction ipv6_check(ip_addr) {\n return /^::$/.test(ip_addr) ||\n /^::1$/.test(ip_addr) ||\n /^::f{4}:([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip_addr) ||\n /^::f{4}:0.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip_addr) ||\n /^64:ff9b::([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip_addr) ||\n /^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) ||\n /^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) ||\n /^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) ||\n /^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) ||\n /^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) ||\n /^f[c-d]([0-9a-fA-F]{2,2}):/i.test(ip_addr) ||\n /^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(ip_addr) ||\n /^ff([0-9a-fA-F]{2,2}):/i.test(ip_addr);\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((ip) => {\n if (is_valid(ip)) {\n const parsed = parse(ip);\n if (parsed.kind() === 'ipv4')\n return ipv4_check(parsed.toNormalizedString());\n else if (parsed.kind() === 'ipv6')\n return ipv6_check(ip);\n }\n else if ((0,_chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_2__.isIP)(ip) && ip_regex__WEBPACK_IMPORTED_MODULE_1__[\"default\"].v6().test(ip))\n return ipv6_check(ip);\n return undefined;\n});\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/private-ip/lib/index.js?"); - -/***/ }), - /***/ "./node_modules/progress-events/dist/src/index.js": /*!********************************************************!*\ !*** ./node_modules/progress-events/dist/src/index.js ***! @@ -8821,7 +8894,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Uint8ArrayReader: () => (/* binding */ Uint8ArrayReader),\n/* harmony export */ createReader: () => (/* binding */ createReader)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/protons-runtime/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var _float_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./float.js */ \"./node_modules/protons-runtime/dist/src/utils/float.js\");\n/* harmony import */ var _longbits_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./longbits.js */ \"./node_modules/protons-runtime/dist/src/utils/longbits.js\");\n/* harmony import */ var _utf8_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utf8.js */ \"./node_modules/protons-runtime/dist/src/utils/utf8.js\");\n\n\n\n\n/* istanbul ignore next */\nfunction indexOutOfRange(reader, writeLength) {\n return RangeError(`index out of range: ${reader.pos} + ${writeLength ?? 1} > ${reader.len}`);\n}\nfunction readFixed32End(buf, end) {\n return (buf[end - 4] |\n buf[end - 3] << 8 |\n buf[end - 2] << 16 |\n buf[end - 1] << 24) >>> 0;\n}\n/**\n * Constructs a new reader instance using the specified buffer.\n */\nclass Uint8ArrayReader {\n buf;\n pos;\n len;\n _slice = Uint8Array.prototype.subarray;\n constructor(buffer) {\n /**\n * Read buffer\n */\n this.buf = buffer;\n /**\n * Read buffer position\n */\n this.pos = 0;\n /**\n * Read buffer length\n */\n this.len = buffer.length;\n }\n /**\n * Reads a varint as an unsigned 32 bit value\n */\n uint32() {\n let value = 4294967295;\n value = (this.buf[this.pos] & 127) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n if ((this.pos += 5) > this.len) {\n this.pos = this.len;\n throw indexOutOfRange(this, 10);\n }\n return value;\n }\n /**\n * Reads a varint as a signed 32 bit value\n */\n int32() {\n return this.uint32() | 0;\n }\n /**\n * Reads a zig-zag encoded varint as a signed 32 bit value\n */\n sint32() {\n const value = this.uint32();\n return value >>> 1 ^ -(value & 1) | 0;\n }\n /**\n * Reads a varint as a boolean\n */\n bool() {\n return this.uint32() !== 0;\n }\n /**\n * Reads fixed 32 bits as an unsigned 32 bit integer\n */\n fixed32() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const res = readFixed32End(this.buf, this.pos += 4);\n return res;\n }\n /**\n * Reads fixed 32 bits as a signed 32 bit integer\n */\n sfixed32() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const res = readFixed32End(this.buf, this.pos += 4) | 0;\n return res;\n }\n /**\n * Reads a float (32 bit) as a number\n */\n float() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const value = (0,_float_js__WEBPACK_IMPORTED_MODULE_1__.readFloatLE)(this.buf, this.pos);\n this.pos += 4;\n return value;\n }\n /**\n * Reads a double (64 bit float) as a number\n */\n double() {\n /* istanbul ignore if */\n if (this.pos + 8 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const value = (0,_float_js__WEBPACK_IMPORTED_MODULE_1__.readDoubleLE)(this.buf, this.pos);\n this.pos += 8;\n return value;\n }\n /**\n * Reads a sequence of bytes preceded by its length as a varint\n */\n bytes() {\n const length = this.uint32();\n const start = this.pos;\n const end = this.pos + length;\n /* istanbul ignore if */\n if (end > this.len) {\n throw indexOutOfRange(this, length);\n }\n this.pos += length;\n return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1\n ? new Uint8Array(0)\n : this.buf.subarray(start, end);\n }\n /**\n * Reads a string preceded by its byte length as a varint\n */\n string() {\n const bytes = this.bytes();\n return _utf8_js__WEBPACK_IMPORTED_MODULE_3__.read(bytes, 0, bytes.length);\n }\n /**\n * Skips the specified number of bytes if specified, otherwise skips a varint\n */\n skip(length) {\n if (typeof length === 'number') {\n /* istanbul ignore if */\n if (this.pos + length > this.len) {\n throw indexOutOfRange(this, length);\n }\n this.pos += length;\n }\n else {\n do {\n /* istanbul ignore if */\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n } while ((this.buf[this.pos++] & 128) !== 0);\n }\n return this;\n }\n /**\n * Skips the next element of the specified wire type\n */\n skipType(wireType) {\n switch (wireType) {\n case 0:\n this.skip();\n break;\n case 1:\n this.skip(8);\n break;\n case 2:\n this.skip(this.uint32());\n break;\n case 3:\n while ((wireType = this.uint32() & 7) !== 4) {\n this.skipType(wireType);\n }\n break;\n case 5:\n this.skip(4);\n break;\n /* istanbul ignore next */\n default:\n throw Error(`invalid wire type ${wireType} at offset ${this.pos}`);\n }\n return this;\n }\n readLongVarint() {\n // tends to deopt with local vars for octet etc.\n const bits = new _longbits_js__WEBPACK_IMPORTED_MODULE_2__.LongBits(0, 0);\n let i = 0;\n if (this.len - this.pos > 4) { // fast route (lo)\n for (; i < 4; ++i) {\n // 1st..4th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n // 5th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n i = 0;\n }\n else {\n for (; i < 3; ++i) {\n /* istanbul ignore if */\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n // 1st..3th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n // 4th\n bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;\n return bits;\n }\n if (this.len - this.pos > 4) { // fast route (hi)\n for (; i < 5; ++i) {\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n }\n else {\n for (; i < 5; ++i) {\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n }\n throw Error('invalid varint encoding');\n }\n readFixed64() {\n if (this.pos + 8 > this.len) {\n throw indexOutOfRange(this, 8);\n }\n const lo = readFixed32End(this.buf, this.pos += 4);\n const hi = readFixed32End(this.buf, this.pos += 4);\n return new _longbits_js__WEBPACK_IMPORTED_MODULE_2__.LongBits(lo, hi);\n }\n /**\n * Reads a varint as a signed 64 bit value\n */\n int64() {\n return this.readLongVarint().toBigInt();\n }\n /**\n * Reads a varint as a signed 64 bit value returned as a possibly unsafe\n * JavaScript number\n */\n int64Number() {\n return this.readLongVarint().toNumber();\n }\n /**\n * Reads a varint as a signed 64 bit value returned as a string\n */\n int64String() {\n return this.readLongVarint().toString();\n }\n /**\n * Reads a varint as an unsigned 64 bit value\n */\n uint64() {\n return this.readLongVarint().toBigInt(true);\n }\n /**\n * Reads a varint as an unsigned 64 bit value returned as a possibly unsafe\n * JavaScript number\n */\n uint64Number() {\n const value = (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decodeUint8Array)(this.buf, this.pos);\n this.pos += (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength)(value);\n return value;\n }\n /**\n * Reads a varint as an unsigned 64 bit value returned as a string\n */\n uint64String() {\n return this.readLongVarint().toString(true);\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value\n */\n sint64() {\n return this.readLongVarint().zzDecode().toBigInt();\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value returned as a\n * possibly unsafe JavaScript number\n */\n sint64Number() {\n return this.readLongVarint().zzDecode().toNumber();\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value returned as a\n * string\n */\n sint64String() {\n return this.readLongVarint().zzDecode().toString();\n }\n /**\n * Reads fixed 64 bits\n */\n fixed64() {\n return this.readFixed64().toBigInt();\n }\n /**\n * Reads fixed 64 bits returned as a possibly unsafe JavaScript number\n */\n fixed64Number() {\n return this.readFixed64().toNumber();\n }\n /**\n * Reads fixed 64 bits returned as a string\n */\n fixed64String() {\n return this.readFixed64().toString();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits\n */\n sfixed64() {\n return this.readFixed64().toBigInt();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits returned as a possibly unsafe\n * JavaScript number\n */\n sfixed64Number() {\n return this.readFixed64().toNumber();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits returned as a string\n */\n sfixed64String() {\n return this.readFixed64().toString();\n }\n}\nfunction createReader(buf) {\n return new Uint8ArrayReader(buf instanceof Uint8Array ? buf : buf.subarray());\n}\n//# sourceMappingURL=reader.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/utils/reader.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Uint8ArrayReader: () => (/* binding */ Uint8ArrayReader),\n/* harmony export */ createReader: () => (/* binding */ createReader)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var _float_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./float.js */ \"./node_modules/protons-runtime/dist/src/utils/float.js\");\n/* harmony import */ var _longbits_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./longbits.js */ \"./node_modules/protons-runtime/dist/src/utils/longbits.js\");\n/* harmony import */ var _utf8_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utf8.js */ \"./node_modules/protons-runtime/dist/src/utils/utf8.js\");\n\n\n\n\n/* istanbul ignore next */\nfunction indexOutOfRange(reader, writeLength) {\n return RangeError(`index out of range: ${reader.pos} + ${writeLength ?? 1} > ${reader.len}`);\n}\nfunction readFixed32End(buf, end) {\n return (buf[end - 4] |\n buf[end - 3] << 8 |\n buf[end - 2] << 16 |\n buf[end - 1] << 24) >>> 0;\n}\n/**\n * Constructs a new reader instance using the specified buffer.\n */\nclass Uint8ArrayReader {\n buf;\n pos;\n len;\n _slice = Uint8Array.prototype.subarray;\n constructor(buffer) {\n /**\n * Read buffer\n */\n this.buf = buffer;\n /**\n * Read buffer position\n */\n this.pos = 0;\n /**\n * Read buffer length\n */\n this.len = buffer.length;\n }\n /**\n * Reads a varint as an unsigned 32 bit value\n */\n uint32() {\n let value = 4294967295;\n value = (this.buf[this.pos] & 127) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;\n if (this.buf[this.pos++] < 128)\n return value;\n if ((this.pos += 5) > this.len) {\n this.pos = this.len;\n throw indexOutOfRange(this, 10);\n }\n return value;\n }\n /**\n * Reads a varint as a signed 32 bit value\n */\n int32() {\n return this.uint32() | 0;\n }\n /**\n * Reads a zig-zag encoded varint as a signed 32 bit value\n */\n sint32() {\n const value = this.uint32();\n return value >>> 1 ^ -(value & 1) | 0;\n }\n /**\n * Reads a varint as a boolean\n */\n bool() {\n return this.uint32() !== 0;\n }\n /**\n * Reads fixed 32 bits as an unsigned 32 bit integer\n */\n fixed32() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const res = readFixed32End(this.buf, this.pos += 4);\n return res;\n }\n /**\n * Reads fixed 32 bits as a signed 32 bit integer\n */\n sfixed32() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const res = readFixed32End(this.buf, this.pos += 4) | 0;\n return res;\n }\n /**\n * Reads a float (32 bit) as a number\n */\n float() {\n if (this.pos + 4 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const value = (0,_float_js__WEBPACK_IMPORTED_MODULE_1__.readFloatLE)(this.buf, this.pos);\n this.pos += 4;\n return value;\n }\n /**\n * Reads a double (64 bit float) as a number\n */\n double() {\n /* istanbul ignore if */\n if (this.pos + 8 > this.len) {\n throw indexOutOfRange(this, 4);\n }\n const value = (0,_float_js__WEBPACK_IMPORTED_MODULE_1__.readDoubleLE)(this.buf, this.pos);\n this.pos += 8;\n return value;\n }\n /**\n * Reads a sequence of bytes preceded by its length as a varint\n */\n bytes() {\n const length = this.uint32();\n const start = this.pos;\n const end = this.pos + length;\n /* istanbul ignore if */\n if (end > this.len) {\n throw indexOutOfRange(this, length);\n }\n this.pos += length;\n return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1\n ? new Uint8Array(0)\n : this.buf.subarray(start, end);\n }\n /**\n * Reads a string preceded by its byte length as a varint\n */\n string() {\n const bytes = this.bytes();\n return _utf8_js__WEBPACK_IMPORTED_MODULE_3__.read(bytes, 0, bytes.length);\n }\n /**\n * Skips the specified number of bytes if specified, otherwise skips a varint\n */\n skip(length) {\n if (typeof length === 'number') {\n /* istanbul ignore if */\n if (this.pos + length > this.len) {\n throw indexOutOfRange(this, length);\n }\n this.pos += length;\n }\n else {\n do {\n /* istanbul ignore if */\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n } while ((this.buf[this.pos++] & 128) !== 0);\n }\n return this;\n }\n /**\n * Skips the next element of the specified wire type\n */\n skipType(wireType) {\n switch (wireType) {\n case 0:\n this.skip();\n break;\n case 1:\n this.skip(8);\n break;\n case 2:\n this.skip(this.uint32());\n break;\n case 3:\n while ((wireType = this.uint32() & 7) !== 4) {\n this.skipType(wireType);\n }\n break;\n case 5:\n this.skip(4);\n break;\n /* istanbul ignore next */\n default:\n throw Error(`invalid wire type ${wireType} at offset ${this.pos}`);\n }\n return this;\n }\n readLongVarint() {\n // tends to deopt with local vars for octet etc.\n const bits = new _longbits_js__WEBPACK_IMPORTED_MODULE_2__.LongBits(0, 0);\n let i = 0;\n if (this.len - this.pos > 4) { // fast route (lo)\n for (; i < 4; ++i) {\n // 1st..4th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n // 5th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n i = 0;\n }\n else {\n for (; i < 3; ++i) {\n /* istanbul ignore if */\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n // 1st..3th\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n // 4th\n bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;\n return bits;\n }\n if (this.len - this.pos > 4) { // fast route (hi)\n for (; i < 5; ++i) {\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n }\n else {\n for (; i < 5; ++i) {\n if (this.pos >= this.len) {\n throw indexOutOfRange(this);\n }\n // 6th..10th\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\n if (this.buf[this.pos++] < 128) {\n return bits;\n }\n }\n }\n throw Error('invalid varint encoding');\n }\n readFixed64() {\n if (this.pos + 8 > this.len) {\n throw indexOutOfRange(this, 8);\n }\n const lo = readFixed32End(this.buf, this.pos += 4);\n const hi = readFixed32End(this.buf, this.pos += 4);\n return new _longbits_js__WEBPACK_IMPORTED_MODULE_2__.LongBits(lo, hi);\n }\n /**\n * Reads a varint as a signed 64 bit value\n */\n int64() {\n return this.readLongVarint().toBigInt();\n }\n /**\n * Reads a varint as a signed 64 bit value returned as a possibly unsafe\n * JavaScript number\n */\n int64Number() {\n return this.readLongVarint().toNumber();\n }\n /**\n * Reads a varint as a signed 64 bit value returned as a string\n */\n int64String() {\n return this.readLongVarint().toString();\n }\n /**\n * Reads a varint as an unsigned 64 bit value\n */\n uint64() {\n return this.readLongVarint().toBigInt(true);\n }\n /**\n * Reads a varint as an unsigned 64 bit value returned as a possibly unsafe\n * JavaScript number\n */\n uint64Number() {\n const value = (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.decodeUint8Array)(this.buf, this.pos);\n this.pos += (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength)(value);\n return value;\n }\n /**\n * Reads a varint as an unsigned 64 bit value returned as a string\n */\n uint64String() {\n return this.readLongVarint().toString(true);\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value\n */\n sint64() {\n return this.readLongVarint().zzDecode().toBigInt();\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value returned as a\n * possibly unsafe JavaScript number\n */\n sint64Number() {\n return this.readLongVarint().zzDecode().toNumber();\n }\n /**\n * Reads a zig-zag encoded varint as a signed 64 bit value returned as a\n * string\n */\n sint64String() {\n return this.readLongVarint().zzDecode().toString();\n }\n /**\n * Reads fixed 64 bits\n */\n fixed64() {\n return this.readFixed64().toBigInt();\n }\n /**\n * Reads fixed 64 bits returned as a possibly unsafe JavaScript number\n */\n fixed64Number() {\n return this.readFixed64().toNumber();\n }\n /**\n * Reads fixed 64 bits returned as a string\n */\n fixed64String() {\n return this.readFixed64().toString();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits\n */\n sfixed64() {\n return this.readFixed64().toBigInt();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits returned as a possibly unsafe\n * JavaScript number\n */\n sfixed64Number() {\n return this.readFixed64().toNumber();\n }\n /**\n * Reads zig-zag encoded fixed 64 bits returned as a string\n */\n sfixed64String() {\n return this.readFixed64().toString();\n }\n}\nfunction createReader(buf) {\n return new Uint8ArrayReader(buf instanceof Uint8Array ? buf : buf.subarray());\n}\n//# sourceMappingURL=reader.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/utils/reader.js?"); /***/ }), @@ -8843,348 +8916,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createWriter: () => (/* binding */ createWriter)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/protons-runtime/node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _float_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./float.js */ \"./node_modules/protons-runtime/dist/src/utils/float.js\");\n/* harmony import */ var _longbits_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./longbits.js */ \"./node_modules/protons-runtime/dist/src/utils/longbits.js\");\n/* harmony import */ var _pool_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pool.js */ \"./node_modules/protons-runtime/dist/src/utils/pool.js\");\n/* harmony import */ var _utf8_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utf8.js */ \"./node_modules/protons-runtime/dist/src/utils/utf8.js\");\n\n\n\n\n\n\n\n/**\n * Constructs a new writer operation instance.\n *\n * @classdesc Scheduled writer operation\n */\nclass Op {\n /**\n * Function to call\n */\n fn;\n /**\n * Value byte length\n */\n len;\n /**\n * Next operation\n */\n next;\n /**\n * Value to write\n */\n val;\n constructor(fn, len, val) {\n this.fn = fn;\n this.len = len;\n this.next = undefined;\n this.val = val; // type varies\n }\n}\n/* istanbul ignore next */\nfunction noop() { } // eslint-disable-line no-empty-function\n/**\n * Constructs a new writer state instance\n */\nclass State {\n /**\n * Current head\n */\n head;\n /**\n * Current tail\n */\n tail;\n /**\n * Current buffer length\n */\n len;\n /**\n * Next state\n */\n next;\n constructor(writer) {\n this.head = writer.head;\n this.tail = writer.tail;\n this.len = writer.len;\n this.next = writer.states;\n }\n}\nconst bufferPool = (0,_pool_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"])();\n/**\n * Allocates a buffer of the specified size\n */\nfunction alloc(size) {\n if (globalThis.Buffer != null) {\n return (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(size);\n }\n return bufferPool(size);\n}\n/**\n * When a value is written, the writer calculates its byte length and puts it into a linked\n * list of operations to perform when finish() is called. This both allows us to allocate\n * buffers of the exact required size and reduces the amount of work we have to do compared\n * to first calculating over objects and then encoding over objects. In our case, the encoding\n * part is just a linked list walk calling operations with already prepared values.\n */\nclass Uint8ArrayWriter {\n /**\n * Current length\n */\n len;\n /**\n * Operations head\n */\n head;\n /**\n * Operations tail\n */\n tail;\n /**\n * Linked forked states\n */\n states;\n constructor() {\n this.len = 0;\n this.head = new Op(noop, 0, 0);\n this.tail = this.head;\n this.states = null;\n }\n /**\n * Pushes a new operation to the queue\n */\n _push(fn, len, val) {\n this.tail = this.tail.next = new Op(fn, len, val);\n this.len += len;\n return this;\n }\n /**\n * Writes an unsigned 32 bit value as a varint\n */\n uint32(value) {\n // here, the call to this.push has been inlined and a varint specific Op subclass is used.\n // uint32 is by far the most frequently used operation and benefits significantly from this.\n this.len += (this.tail = this.tail.next = new VarintOp((value = value >>> 0) <\n 128\n ? 1\n : value < 16384\n ? 2\n : value < 2097152\n ? 3\n : value < 268435456\n ? 4\n : 5, value)).len;\n return this;\n }\n /**\n * Writes a signed 32 bit value as a varint`\n */\n int32(value) {\n return value < 0\n ? this._push(writeVarint64, 10, _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value)) // 10 bytes per spec\n : this.uint32(value);\n }\n /**\n * Writes a 32 bit value as a varint, zig-zag encoded\n */\n sint32(value) {\n return this.uint32((value << 1 ^ value >> 31) >>> 0);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value);\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64Number(value) {\n return this._push(uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodeUint8Array, (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength)(value), value);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64String(value) {\n return this.uint64(BigInt(value));\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64(value) {\n return this.uint64(value);\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64Number(value) {\n return this.uint64Number(value);\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64String(value) {\n return this.uint64String(value);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value).zzEncode();\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64Number(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value).zzEncode();\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64String(value) {\n return this.sint64(BigInt(value));\n }\n /**\n * Writes a boolish value as a varint\n */\n bool(value) {\n return this._push(writeByte, 1, value ? 1 : 0);\n }\n /**\n * Writes an unsigned 32 bit value as fixed 32 bits\n */\n fixed32(value) {\n return this._push(writeFixed32, 4, value >>> 0);\n }\n /**\n * Writes a signed 32 bit value as fixed 32 bits\n */\n sfixed32(value) {\n return this.fixed32(value);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value);\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64Number(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value);\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64String(value) {\n return this.fixed64(BigInt(value));\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64(value) {\n return this.fixed64(value);\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64Number(value) {\n return this.fixed64Number(value);\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64String(value) {\n return this.fixed64String(value);\n }\n /**\n * Writes a float (32 bit)\n */\n float(value) {\n return this._push(_float_js__WEBPACK_IMPORTED_MODULE_3__.writeFloatLE, 4, value);\n }\n /**\n * Writes a double (64 bit float).\n *\n * @function\n * @param {number} value - Value to write\n * @returns {Writer} `this`\n */\n double(value) {\n return this._push(_float_js__WEBPACK_IMPORTED_MODULE_3__.writeDoubleLE, 8, value);\n }\n /**\n * Writes a sequence of bytes\n */\n bytes(value) {\n const len = value.length >>> 0;\n if (len === 0) {\n return this._push(writeByte, 1, 0);\n }\n return this.uint32(len)._push(writeBytes, len, value);\n }\n /**\n * Writes a string\n */\n string(value) {\n const len = _utf8_js__WEBPACK_IMPORTED_MODULE_6__.length(value);\n return len !== 0\n ? this.uint32(len)._push(_utf8_js__WEBPACK_IMPORTED_MODULE_6__.write, len, value)\n : this._push(writeByte, 1, 0);\n }\n /**\n * Forks this writer's state by pushing it to a stack.\n * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.\n */\n fork() {\n this.states = new State(this);\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n return this;\n }\n /**\n * Resets this instance to the last state\n */\n reset() {\n if (this.states != null) {\n this.head = this.states.head;\n this.tail = this.states.tail;\n this.len = this.states.len;\n this.states = this.states.next;\n }\n else {\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n }\n return this;\n }\n /**\n * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.\n */\n ldelim() {\n const head = this.head;\n const tail = this.tail;\n const len = this.len;\n this.reset().uint32(len);\n if (len !== 0) {\n this.tail.next = head.next; // skip noop\n this.tail = tail;\n this.len += len;\n }\n return this;\n }\n /**\n * Finishes the write operation\n */\n finish() {\n let head = this.head.next; // skip noop\n const buf = alloc(this.len);\n let pos = 0;\n while (head != null) {\n head.fn(head.val, buf, pos);\n pos += head.len;\n head = head.next;\n }\n // this.head = this.tail = null;\n return buf;\n }\n}\nfunction writeByte(val, buf, pos) {\n buf[pos] = val & 255;\n}\nfunction writeVarint32(val, buf, pos) {\n while (val > 127) {\n buf[pos++] = val & 127 | 128;\n val >>>= 7;\n }\n buf[pos] = val;\n}\n/**\n * Constructs a new varint writer operation instance.\n *\n * @classdesc Scheduled varint writer operation\n */\nclass VarintOp extends Op {\n next;\n constructor(len, val) {\n super(writeVarint32, len, val);\n this.next = undefined;\n }\n}\nfunction writeVarint64(val, buf, pos) {\n while (val.hi !== 0) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;\n val.hi >>>= 7;\n }\n while (val.lo > 127) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = val.lo >>> 7;\n }\n buf[pos++] = val.lo;\n}\nfunction writeFixed32(val, buf, pos) {\n buf[pos] = val & 255;\n buf[pos + 1] = val >>> 8 & 255;\n buf[pos + 2] = val >>> 16 & 255;\n buf[pos + 3] = val >>> 24;\n}\nfunction writeBytes(val, buf, pos) {\n buf.set(val, pos);\n}\nif (globalThis.Buffer != null) {\n Uint8ArrayWriter.prototype.bytes = function (value) {\n const len = value.length >>> 0;\n this.uint32(len);\n if (len > 0) {\n this._push(writeBytesBuffer, len, value);\n }\n return this;\n };\n Uint8ArrayWriter.prototype.string = function (value) {\n const len = globalThis.Buffer.byteLength(value);\n this.uint32(len);\n if (len > 0) {\n this._push(writeStringBuffer, len, value);\n }\n return this;\n };\n}\nfunction writeBytesBuffer(val, buf, pos) {\n buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)\n // also works for plain array values\n}\nfunction writeStringBuffer(val, buf, pos) {\n if (val.length < 40) {\n // plain js is faster for short strings (probably due to redundant assertions)\n _utf8_js__WEBPACK_IMPORTED_MODULE_6__.write(val, buf, pos);\n // @ts-expect-error buf isn't a Uint8Array?\n }\n else if (buf.utf8Write != null) {\n // @ts-expect-error buf isn't a Uint8Array?\n buf.utf8Write(val, pos);\n }\n else {\n buf.set((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(val), pos);\n }\n}\n/**\n * Creates a new writer\n */\nfunction createWriter() {\n return new Uint8ArrayWriter();\n}\n//# sourceMappingURL=writer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/utils/writer.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Codec: () => (/* binding */ Codec),\n/* harmony export */ baseX: () => (/* binding */ baseX),\n/* harmony export */ from: () => (/* binding */ from),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ rfc4648: () => (/* binding */ rfc4648)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/base-x.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/base-x.js\");\n\n\n/**\n * Class represents both BaseEncoder and MultibaseEncoder meaning it\n * can be used to encode to multibase or base encode without multibase\n * prefix.\n */\nclass Encoder {\n name;\n prefix;\n baseEncode;\n constructor(name, prefix, baseEncode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n }\n encode(bytes) {\n if (bytes instanceof Uint8Array) {\n return `${this.prefix}${this.baseEncode(bytes)}`;\n }\n else {\n throw Error('Unknown type, must be binary type');\n }\n }\n}\n/**\n * Class represents both BaseDecoder and MultibaseDecoder so it could be used\n * to decode multibases (with matching prefix) or just base decode strings\n * with corresponding base encoding.\n */\nclass Decoder {\n name;\n prefix;\n baseDecode;\n prefixCodePoint;\n constructor(name, prefix, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n /* c8 ignore next 3 */\n if (prefix.codePointAt(0) === undefined) {\n throw new Error('Invalid prefix character');\n }\n this.prefixCodePoint = prefix.codePointAt(0);\n this.baseDecode = baseDecode;\n }\n decode(text) {\n if (typeof text === 'string') {\n if (text.codePointAt(0) !== this.prefixCodePoint) {\n throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);\n }\n return this.baseDecode(text.slice(this.prefix.length));\n }\n else {\n throw Error('Can only multibase decode strings');\n }\n }\n or(decoder) {\n return or(this, decoder);\n }\n}\nclass ComposedDecoder {\n decoders;\n constructor(decoders) {\n this.decoders = decoders;\n }\n or(decoder) {\n return or(this, decoder);\n }\n decode(input) {\n const prefix = input[0];\n const decoder = this.decoders[prefix];\n if (decoder != null) {\n return decoder.decode(input);\n }\n else {\n throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);\n }\n }\n}\nfunction or(left, right) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return new ComposedDecoder({\n ...(left.decoders ?? { [left.prefix]: left }),\n ...(right.decoders ?? { [right.prefix]: right })\n });\n}\nclass Codec {\n name;\n prefix;\n baseEncode;\n baseDecode;\n encoder;\n decoder;\n constructor(name, prefix, baseEncode, baseDecode) {\n this.name = name;\n this.prefix = prefix;\n this.baseEncode = baseEncode;\n this.baseDecode = baseDecode;\n this.encoder = new Encoder(name, prefix, baseEncode);\n this.decoder = new Decoder(name, prefix, baseDecode);\n }\n encode(input) {\n return this.encoder.encode(input);\n }\n decode(input) {\n return this.decoder.decode(input);\n }\n}\nfunction from({ name, prefix, encode, decode }) {\n return new Codec(name, prefix, encode, decode);\n}\nfunction baseX({ name, prefix, alphabet }) {\n const { encode, decode } = (0,_vendor_base_x_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(alphabet, name);\n return from({\n prefix,\n name,\n encode,\n decode: (text) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(decode(text))\n });\n}\nfunction decode(string, alphabet, bitsPerChar, name) {\n // Build the character lookup table:\n const codes = {};\n for (let i = 0; i < alphabet.length; ++i) {\n codes[alphabet[i]] = i;\n }\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n }\n // Allocate the output:\n const out = new Uint8Array((end * bitsPerChar / 8) | 0);\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError(`Non-${name} character`);\n }\n // Append the bits to the buffer:\n buffer = (buffer << bitsPerChar) | value;\n bits += bitsPerChar;\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n // Verify that we have received just enough bits:\n if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {\n throw new SyntaxError('Unexpected end of data');\n }\n return out;\n}\nfunction encode(data, alphabet, bitsPerChar) {\n const pad = alphabet[alphabet.length - 1] === '=';\n const mask = (1 << bitsPerChar) - 1;\n let out = '';\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | data[i];\n bits += 8;\n // Write out as much as we can:\n while (bits > bitsPerChar) {\n bits -= bitsPerChar;\n out += alphabet[mask & (buffer >> bits)];\n }\n }\n // Partial character:\n if (bits !== 0) {\n out += alphabet[mask & (buffer << (bitsPerChar - bits))];\n }\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while (((out.length * bitsPerChar) & 7) !== 0) {\n out += '=';\n }\n }\n return out;\n}\n/**\n * RFC4648 Factory\n */\nfunction rfc4648({ name, prefix, bitsPerChar, alphabet }) {\n return from({\n prefix,\n name,\n encode(input) {\n return encode(input, alphabet, bitsPerChar);\n },\n decode(input) {\n return decode(input, alphabet, bitsPerChar, name);\n }\n });\n}\n//# sourceMappingURL=base.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base10.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base10.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base10: () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base10 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: '9',\n name: 'base10',\n alphabet: '0123456789'\n});\n//# sourceMappingURL=base10.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base16.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base16.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base16: () => (/* binding */ base16),\n/* harmony export */ base16upper: () => (/* binding */ base16upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base16 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'f',\n name: 'base16',\n alphabet: '0123456789abcdef',\n bitsPerChar: 4\n});\nconst base16upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'F',\n name: 'base16upper',\n alphabet: '0123456789ABCDEF',\n bitsPerChar: 4\n});\n//# sourceMappingURL=base16.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base2.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base2.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base2: () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base2 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '0',\n name: 'base2',\n alphabet: '01',\n bitsPerChar: 1\n});\n//# sourceMappingURL=base2.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base256emoji.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base256emoji.js ***! - \***********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base256emoji: () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');\nconst alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));\nconst alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));\nfunction encode(data) {\n return data.reduce((p, c) => {\n p += alphabetBytesToChars[c];\n return p;\n }, '');\n}\nfunction decode(str) {\n const byts = [];\n for (const char of str) {\n const byt = alphabetCharsToBytes[char.codePointAt(0)];\n if (byt === undefined) {\n throw new Error(`Non-base256emoji character: ${char}`);\n }\n byts.push(byt);\n }\n return new Uint8Array(byts);\n}\nconst base256emoji = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n prefix: '🚀',\n name: 'base256emoji',\n encode,\n decode\n});\n//# sourceMappingURL=base256emoji.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base32.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base32.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base32: () => (/* binding */ base32),\n/* harmony export */ base32hex: () => (/* binding */ base32hex),\n/* harmony export */ base32hexpad: () => (/* binding */ base32hexpad),\n/* harmony export */ base32hexpadupper: () => (/* binding */ base32hexpadupper),\n/* harmony export */ base32hexupper: () => (/* binding */ base32hexupper),\n/* harmony export */ base32pad: () => (/* binding */ base32pad),\n/* harmony export */ base32padupper: () => (/* binding */ base32padupper),\n/* harmony export */ base32upper: () => (/* binding */ base32upper),\n/* harmony export */ base32z: () => (/* binding */ base32z)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base32 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'b',\n name: 'base32',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567',\n bitsPerChar: 5\n});\nconst base32upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'B',\n name: 'base32upper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n bitsPerChar: 5\n});\nconst base32pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'c',\n name: 'base32pad',\n alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',\n bitsPerChar: 5\n});\nconst base32padupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'C',\n name: 'base32padupper',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',\n bitsPerChar: 5\n});\nconst base32hex = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'v',\n name: 'base32hex',\n alphabet: '0123456789abcdefghijklmnopqrstuv',\n bitsPerChar: 5\n});\nconst base32hexupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'V',\n name: 'base32hexupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',\n bitsPerChar: 5\n});\nconst base32hexpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 't',\n name: 'base32hexpad',\n alphabet: '0123456789abcdefghijklmnopqrstuv=',\n bitsPerChar: 5\n});\nconst base32hexpadupper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'T',\n name: 'base32hexpadupper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',\n bitsPerChar: 5\n});\nconst base32z = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'h',\n name: 'base32z',\n alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',\n bitsPerChar: 5\n});\n//# sourceMappingURL=base32.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base36.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base36.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base36: () => (/* binding */ base36),\n/* harmony export */ base36upper: () => (/* binding */ base36upper)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base36 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'k',\n name: 'base36',\n alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'\n});\nconst base36upper = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n prefix: 'K',\n name: 'base36upper',\n alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base36.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base58.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base58.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base58btc: () => (/* binding */ base58btc),\n/* harmony export */ base58flickr: () => (/* binding */ base58flickr)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base58btc = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58btc',\n prefix: 'z',\n alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n});\nconst base58flickr = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.baseX)({\n name: 'base58flickr',\n prefix: 'Z',\n alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n});\n//# sourceMappingURL=base58.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base64.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base64.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base64: () => (/* binding */ base64),\n/* harmony export */ base64pad: () => (/* binding */ base64pad),\n/* harmony export */ base64url: () => (/* binding */ base64url),\n/* harmony export */ base64urlpad: () => (/* binding */ base64urlpad)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base64 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'm',\n name: 'base64',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n bitsPerChar: 6\n});\nconst base64pad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'M',\n name: 'base64pad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n bitsPerChar: 6\n});\nconst base64url = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'u',\n name: 'base64url',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bitsPerChar: 6\n});\nconst base64urlpad = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: 'U',\n name: 'base64urlpad',\n alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',\n bitsPerChar: 6\n});\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base8.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base8.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ base8: () => (/* binding */ base8)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\nconst base8 = (0,_base_js__WEBPACK_IMPORTED_MODULE_0__.rfc4648)({\n prefix: '7',\n name: 'base8',\n alphabet: '01234567',\n bitsPerChar: 3\n});\n//# sourceMappingURL=base8.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/identity.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/identity.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base.js\");\n\n\nconst identity = (0,_base_js__WEBPACK_IMPORTED_MODULE_1__.from)({\n prefix: '\\x00',\n name: 'identity',\n encode: (buf) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.toString)(buf),\n decode: (str) => (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.fromString)(str)\n});\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/interface.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/interface.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// Base encoders / decoders just base encode / decode between binary and\n// textual representation. They are unaware of multibase.\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/basics.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/basics.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.CID),\n/* harmony export */ bases: () => (/* binding */ bases),\n/* harmony export */ bytes: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.bytes),\n/* harmony export */ codecs: () => (/* binding */ codecs),\n/* harmony export */ digest: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.digest),\n/* harmony export */ hasher: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.hasher),\n/* harmony export */ hashes: () => (/* binding */ hashes),\n/* harmony export */ varint: () => (/* reexport safe */ _index_js__WEBPACK_IMPORTED_MODULE_14__.varint)\n/* harmony export */ });\n/* harmony import */ var _bases_base10_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base10.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base10.js\");\n/* harmony import */ var _bases_base16_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base16.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base16.js\");\n/* harmony import */ var _bases_base2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bases/base2.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base2.js\");\n/* harmony import */ var _bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bases/base256emoji.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base256emoji.js\");\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base36_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bases/base36.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base36.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bases_base64_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./bases/base64.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base64.js\");\n/* harmony import */ var _bases_base8_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bases/base8.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base8.js\");\n/* harmony import */ var _bases_identity_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/identity.js\");\n/* harmony import */ var _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./codecs/json.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/json.js\");\n/* harmony import */ var _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./codecs/raw.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/raw.js\");\n/* harmony import */ var _hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hashes/identity.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/identity.js\");\n/* harmony import */ var _hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./hashes/sha2.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/sha2-browser.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst bases = { ..._bases_identity_js__WEBPACK_IMPORTED_MODULE_9__, ..._bases_base2_js__WEBPACK_IMPORTED_MODULE_2__, ..._bases_base8_js__WEBPACK_IMPORTED_MODULE_8__, ..._bases_base10_js__WEBPACK_IMPORTED_MODULE_0__, ..._bases_base16_js__WEBPACK_IMPORTED_MODULE_1__, ..._bases_base32_js__WEBPACK_IMPORTED_MODULE_4__, ..._bases_base36_js__WEBPACK_IMPORTED_MODULE_5__, ..._bases_base58_js__WEBPACK_IMPORTED_MODULE_6__, ..._bases_base64_js__WEBPACK_IMPORTED_MODULE_7__, ..._bases_base256emoji_js__WEBPACK_IMPORTED_MODULE_3__ };\nconst hashes = { ..._hashes_sha2_js__WEBPACK_IMPORTED_MODULE_13__, ..._hashes_identity_js__WEBPACK_IMPORTED_MODULE_12__ };\nconst codecs = { raw: _codecs_raw_js__WEBPACK_IMPORTED_MODULE_11__, json: _codecs_json_js__WEBPACK_IMPORTED_MODULE_10__ };\n\n//# sourceMappingURL=basics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/block/interface.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/block/interface.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/block/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ coerce: () => (/* binding */ coerce),\n/* harmony export */ empty: () => (/* binding */ empty),\n/* harmony export */ equals: () => (/* binding */ equals),\n/* harmony export */ fromHex: () => (/* binding */ fromHex),\n/* harmony export */ fromString: () => (/* binding */ fromString),\n/* harmony export */ isBinary: () => (/* binding */ isBinary),\n/* harmony export */ toHex: () => (/* binding */ toHex),\n/* harmony export */ toString: () => (/* binding */ toString)\n/* harmony export */ });\nconst empty = new Uint8Array(0);\nfunction toHex(d) {\n return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');\n}\nfunction fromHex(hex) {\n const hexes = hex.match(/../g);\n return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;\n}\nfunction equals(aa, bb) {\n if (aa === bb)\n return true;\n if (aa.byteLength !== bb.byteLength) {\n return false;\n }\n for (let ii = 0; ii < aa.byteLength; ii++) {\n if (aa[ii] !== bb[ii]) {\n return false;\n }\n }\n return true;\n}\nfunction coerce(o) {\n if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')\n return o;\n if (o instanceof ArrayBuffer)\n return new Uint8Array(o);\n if (ArrayBuffer.isView(o)) {\n return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);\n }\n throw new Error('Unknown type, must be binary type');\n}\nfunction isBinary(o) {\n return o instanceof ArrayBuffer || ArrayBuffer.isView(o);\n}\nfunction fromString(str) {\n return new TextEncoder().encode(str);\n}\nfunction toString(b) {\n return new TextDecoder().decode(b);\n}\n//# sourceMappingURL=bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/cid.js": -/*!********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/cid.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* binding */ CID),\n/* harmony export */ format: () => (/* binding */ format),\n/* harmony export */ fromJSON: () => (/* binding */ fromJSON),\n/* harmony export */ toJSON: () => (/* binding */ toJSON)\n/* harmony export */ });\n/* harmony import */ var _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/base32.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base32.js\");\n/* harmony import */ var _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bases/base58.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/base58.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/link/interface.js\");\n\n\n\n\n\n// This way TS will also expose all the types from module\n\nfunction format(link, base) {\n const { bytes, version } = link;\n switch (version) {\n case 0:\n return toStringV0(bytes, baseCache(link), base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.encoder);\n default:\n return toStringV1(bytes, baseCache(link), (base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.encoder));\n }\n}\nfunction toJSON(link) {\n return {\n '/': format(link)\n };\n}\nfunction fromJSON(json) {\n return CID.parse(json['/']);\n}\nconst cache = new WeakMap();\nfunction baseCache(cid) {\n const baseCache = cache.get(cid);\n if (baseCache == null) {\n const baseCache = new Map();\n cache.set(cid, baseCache);\n return baseCache;\n }\n return baseCache;\n}\nclass CID {\n code;\n version;\n multihash;\n bytes;\n '/';\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param multihash - (Multi)hash of the of the content.\n */\n constructor(version, code, multihash, bytes) {\n this.code = code;\n this.version = version;\n this.multihash = multihash;\n this.bytes = bytes;\n // flag to serializers that this is a CID and\n // should be treated specially\n this['/'] = bytes;\n }\n /**\n * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`\n * please either use `CID.asCID(cid)` or switch to new signalling mechanism\n *\n * @deprecated\n */\n get asCID() {\n return this;\n }\n // ArrayBufferView\n get byteOffset() {\n return this.bytes.byteOffset;\n }\n // ArrayBufferView\n get byteLength() {\n return this.bytes.byteLength;\n }\n toV0() {\n switch (this.version) {\n case 0: {\n return this;\n }\n case 1: {\n const { code, multihash } = this;\n if (code !== DAG_PB_CODE) {\n throw new Error('Cannot convert a non dag-pb CID to CIDv0');\n }\n // sha2-256\n if (multihash.code !== SHA_256_CODE) {\n throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');\n }\n return (CID.createV0(multihash));\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);\n }\n }\n }\n toV1() {\n switch (this.version) {\n case 0: {\n const { code, digest } = this.multihash;\n const multihash = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.create(code, digest);\n return (CID.createV1(this.code, multihash));\n }\n case 1: {\n return this;\n }\n default: {\n throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);\n }\n }\n }\n equals(other) {\n return CID.equals(this, other);\n }\n static equals(self, other) {\n const unknown = other;\n return (unknown != null &&\n self.code === unknown.code &&\n self.version === unknown.version &&\n _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.equals(self.multihash, unknown.multihash));\n }\n toString(base) {\n return format(this, base);\n }\n toJSON() {\n return { '/': format(this) };\n }\n link() {\n return this;\n }\n [Symbol.toStringTag] = 'CID';\n // Legacy\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return `CID(${this.toString()})`;\n }\n /**\n * Takes any input `value` and returns a `CID` instance if it was\n * a `CID` otherwise returns `null`. If `value` is instanceof `CID`\n * it will return value back. If `value` is not instance of this CID\n * class, but is compatible CID it will return new instance of this\n * `CID` class. Otherwise returns null.\n *\n * This allows two different incompatible versions of CID library to\n * co-exist and interop as long as binary interface is compatible.\n */\n static asCID(input) {\n if (input == null) {\n return null;\n }\n const value = input;\n if (value instanceof CID) {\n // If value is instance of CID then we're all set.\n return value;\n }\n else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {\n // If value isn't instance of this CID class but `this.asCID === this` or\n // `value['/'] === value.bytes` is true it is CID instance coming from a\n // different implementation (diff version or duplicate). In that case we\n // rebase it to this `CID` implementation so caller is guaranteed to get\n // instance with expected API.\n const { version, code, multihash, bytes } = value;\n return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));\n }\n else if (value[cidSymbol] === true) {\n // If value is a CID from older implementation that used to be tagged via\n // symbol we still rebase it to the this `CID` implementation by\n // delegating that to a constructor.\n const { version, multihash, code } = value;\n const digest = _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.decode(multihash);\n return CID.create(version, code, digest);\n }\n else {\n // Otherwise value is not a CID (or an incompatible version of it) in\n // which case we return `null`.\n return null;\n }\n }\n /**\n * @param version - Version of the CID\n * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv\n * @param digest - (Multi)hash of the of the content.\n */\n static create(version, code, digest) {\n if (typeof code !== 'number') {\n throw new Error('String codecs are no longer supported');\n }\n if (!(digest.bytes instanceof Uint8Array)) {\n throw new Error('Invalid digest');\n }\n switch (version) {\n case 0: {\n if (code !== DAG_PB_CODE) {\n throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);\n }\n else {\n return new CID(version, code, digest, digest.bytes);\n }\n }\n case 1: {\n const bytes = encodeCID(version, code, digest.bytes);\n return new CID(version, code, digest, bytes);\n }\n default: {\n throw new Error('Invalid version');\n }\n }\n }\n /**\n * Simplified version of `create` for CIDv0.\n */\n static createV0(digest) {\n return CID.create(0, DAG_PB_CODE, digest);\n }\n /**\n * Simplified version of `create` for CIDv1.\n *\n * @param code - Content encoding format code.\n * @param digest - Multihash of the content.\n */\n static createV1(code, digest) {\n return CID.create(1, code, digest);\n }\n /**\n * Decoded a CID from its binary representation. The byte array must contain\n * only the CID with no additional bytes.\n *\n * An error will be thrown if the bytes provided do not contain a valid\n * binary representation of a CID.\n */\n static decode(bytes) {\n const [cid, remainder] = CID.decodeFirst(bytes);\n if (remainder.length !== 0) {\n throw new Error('Incorrect length');\n }\n return cid;\n }\n /**\n * Decoded a CID from its binary representation at the beginning of a byte\n * array.\n *\n * Returns an array with the first element containing the CID and the second\n * element containing the remainder of the original byte array. The remainder\n * will be a zero-length byte array if the provided bytes only contained a\n * binary CID representation.\n */\n static decodeFirst(bytes) {\n const specs = CID.inspectBytes(bytes);\n const prefixSize = specs.size - specs.multihashSize;\n const multihashBytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_2__.coerce)(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));\n if (multihashBytes.byteLength !== specs.multihashSize) {\n throw new Error('Incorrect length');\n }\n const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);\n const digest = new _hashes_digest_js__WEBPACK_IMPORTED_MODULE_3__.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);\n const cid = specs.version === 0\n ? CID.createV0(digest)\n : CID.createV1(specs.codec, digest);\n return [cid, bytes.subarray(specs.size)];\n }\n /**\n * Inspect the initial bytes of a CID to determine its properties.\n *\n * Involves decoding up to 4 varints. Typically this will require only 4 to 6\n * bytes but for larger multicodec code values and larger multihash digest\n * lengths these varints can be quite large. It is recommended that at least\n * 10 bytes be made available in the `initialBytes` argument for a complete\n * inspection.\n */\n static inspectBytes(initialBytes) {\n let offset = 0;\n const next = () => {\n const [i, length] = _varint_js__WEBPACK_IMPORTED_MODULE_4__.decode(initialBytes.subarray(offset));\n offset += length;\n return i;\n };\n let version = next();\n let codec = DAG_PB_CODE;\n if (version === 18) {\n // CIDv0\n version = 0;\n offset = 0;\n }\n else {\n codec = next();\n }\n if (version !== 0 && version !== 1) {\n throw new RangeError(`Invalid CID version ${version}`);\n }\n const prefixSize = offset;\n const multihashCode = next(); // multihash code\n const digestSize = next(); // multihash length\n const size = offset + digestSize;\n const multihashSize = size - prefixSize;\n return { version, codec, multihashCode, digestSize, multihashSize, size };\n }\n /**\n * Takes cid in a string representation and creates an instance. If `base`\n * decoder is not provided will use a default from the configuration. It will\n * throw an error if encoding of the CID is not compatible with supplied (or\n * a default decoder).\n */\n static parse(source, base) {\n const [prefix, bytes] = parseCIDtoBytes(source, base);\n const cid = CID.decode(bytes);\n if (cid.version === 0 && source[0] !== 'Q') {\n throw Error('Version 0 CID string must not include multibase prefix');\n }\n // Cache string representation to avoid computing it on `this.toString()`\n baseCache(cid).set(prefix, source);\n return cid;\n }\n}\nfunction parseCIDtoBytes(source, base) {\n switch (source[0]) {\n // CIDv0 is parsed differently\n case 'Q': {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [\n _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix,\n decoder.decode(`${_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix}${source}`)\n ];\n }\n case _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix: {\n const decoder = base ?? _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc;\n return [_bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix, decoder.decode(source)];\n }\n case _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix: {\n const decoder = base ?? _bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32;\n return [_bases_base32_js__WEBPACK_IMPORTED_MODULE_0__.base32.prefix, decoder.decode(source)];\n }\n default: {\n if (base == null) {\n throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided');\n }\n return [source[0], base.decode(source)];\n }\n }\n}\nfunction toStringV0(bytes, cache, base) {\n const { prefix } = base;\n if (prefix !== _bases_base58_js__WEBPACK_IMPORTED_MODULE_1__.base58btc.prefix) {\n throw Error(`Cannot string encode V0 in ${base.name} encoding`);\n }\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes).slice(1);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nfunction toStringV1(bytes, cache, base) {\n const { prefix } = base;\n const cid = cache.get(prefix);\n if (cid == null) {\n const cid = base.encode(bytes);\n cache.set(prefix, cid);\n return cid;\n }\n else {\n return cid;\n }\n}\nconst DAG_PB_CODE = 0x70;\nconst SHA_256_CODE = 0x12;\nfunction encodeCID(version, code, multihash) {\n const codeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(version);\n const hashOffset = codeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodingLength(code);\n const bytes = new Uint8Array(hashOffset + multihash.byteLength);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(version, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_4__.encodeTo(code, bytes, codeOffset);\n bytes.set(multihash, hashOffset);\n return bytes;\n}\nconst cidSymbol = Symbol.for('@ipld/js-cid/CID');\n//# sourceMappingURL=cid.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/interface.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/interface.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/json.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/json.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\nconst name = 'json';\nconst code = 0x0200;\nfunction encode(node) {\n return textEncoder.encode(JSON.stringify(node));\n}\nfunction decode(data) {\n return JSON.parse(textDecoder.decode(data));\n}\n//# sourceMappingURL=json.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/raw.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/raw.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ code: () => (/* binding */ code),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ name: () => (/* binding */ name)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n\nconst name = 'raw';\nconst code = 0x55;\nfunction encode(node) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(node);\n}\nfunction decode(data) {\n return (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(data);\n}\n//# sourceMappingURL=raw.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Digest: () => (/* binding */ Digest),\n/* harmony export */ create: () => (/* binding */ create),\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ equals: () => (/* binding */ equals)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js\");\n\n\n/**\n * Creates a multihash digest.\n */\nfunction create(code, digest) {\n const size = digest.byteLength;\n const sizeOffset = _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(code);\n const digestOffset = sizeOffset + _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodingLength(size);\n const bytes = new Uint8Array(digestOffset + size);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(code, bytes, 0);\n _varint_js__WEBPACK_IMPORTED_MODULE_1__.encodeTo(size, bytes, sizeOffset);\n bytes.set(digest, digestOffset);\n return new Digest(code, size, digest, bytes);\n}\n/**\n * Turns bytes representation of multihash digest into an instance.\n */\nfunction decode(multihash) {\n const bytes = (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce)(multihash);\n const [code, sizeOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes);\n const [size, digestOffset] = _varint_js__WEBPACK_IMPORTED_MODULE_1__.decode(bytes.subarray(sizeOffset));\n const digest = bytes.subarray(sizeOffset + digestOffset);\n if (digest.byteLength !== size) {\n throw new Error('Incorrect length');\n }\n return new Digest(code, size, digest, bytes);\n}\nfunction equals(a, b) {\n if (a === b) {\n return true;\n }\n else {\n const data = b;\n return (a.code === data.code &&\n a.size === data.size &&\n data.bytes instanceof Uint8Array &&\n (0,_bytes_js__WEBPACK_IMPORTED_MODULE_0__.equals)(a.bytes, data.bytes));\n }\n}\n/**\n * Represents a multihash digest which carries information about the\n * hashing algorithm and an actual hash digest.\n */\nclass Digest {\n code;\n size;\n digest;\n bytes;\n /**\n * Creates a multihash digest.\n */\n constructor(code, size, digest, bytes) {\n this.code = code;\n this.size = size;\n this.digest = digest;\n this.bytes = bytes;\n }\n}\n//# sourceMappingURL=digest.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/hasher.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/hasher.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hasher: () => (/* binding */ Hasher),\n/* harmony export */ from: () => (/* binding */ from)\n/* harmony export */ });\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js\");\n\nfunction from({ name, code, encode }) {\n return new Hasher(name, code, encode);\n}\n/**\n * Hasher represents a hashing algorithm implementation that produces as\n * `MultihashDigest`.\n */\nclass Hasher {\n name;\n code;\n encode;\n constructor(name, code, encode) {\n this.name = name;\n this.code = code;\n this.encode = encode;\n }\n digest(input) {\n if (input instanceof Uint8Array) {\n const result = this.encode(input);\n return result instanceof Uint8Array\n ? _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, result)\n /* c8 ignore next 1 */\n : result.then(digest => _digest_js__WEBPACK_IMPORTED_MODULE_0__.create(this.code, digest));\n }\n else {\n throw Error('Unknown type, must be binary type');\n /* c8 ignore next 1 */\n }\n }\n}\n//# sourceMappingURL=hasher.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/identity.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/identity.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ identity: () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js\");\n\n\nconst code = 0x0;\nconst name = 'identity';\nconst encode = _bytes_js__WEBPACK_IMPORTED_MODULE_0__.coerce;\nfunction digest(input) {\n return _digest_js__WEBPACK_IMPORTED_MODULE_1__.create(code, encode(input));\n}\nconst identity = { code, name, encode, digest };\n//# sourceMappingURL=identity.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/interface.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/interface.js ***! - \*********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n// # Multihash\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/sha2-browser.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/sha2-browser.js ***! - \************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ sha256: () => (/* binding */ sha256),\n/* harmony export */ sha512: () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _hasher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasher.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* global crypto */\n\nfunction sha(name) {\n return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));\n}\nconst sha256 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-256',\n code: 0x12,\n encode: sha('SHA-256')\n});\nconst sha512 = (0,_hasher_js__WEBPACK_IMPORTED_MODULE_0__.from)({\n name: 'sha2-512',\n code: 0x13,\n encode: sha('SHA-512')\n});\n//# sourceMappingURL=sha2-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/index.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CID: () => (/* reexport safe */ _cid_js__WEBPACK_IMPORTED_MODULE_1__.CID),\n/* harmony export */ bytes: () => (/* reexport module object */ _bytes_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ digest: () => (/* reexport module object */ _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__),\n/* harmony export */ hasher: () => (/* reexport module object */ _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__),\n/* harmony export */ varint: () => (/* reexport module object */ _varint_js__WEBPACK_IMPORTED_MODULE_4__)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bytes.js\");\n/* harmony import */ var _cid_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cid.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/cid.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/digest.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/hasher.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/interface.js\");\n/**\n * @packageDocumentation\n *\n * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.\n *\n * This library provides implementations for most basics and many others can be found in linked repositories.\n *\n * ```TypeScript\n * import { CID } from 'multiformats/cid'\n * import * as json from 'multiformats/codecs/json'\n * import { sha256 } from 'multiformats/hashes/sha2'\n *\n * const bytes = json.encode({ hello: 'world' })\n *\n * const hash = await sha256.digest(bytes)\n * const cid = CID.create(1, json.code, hash)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Creating Blocks\n *\n * ```TypeScript\n * import * as Block from 'multiformats/block'\n * import * as codec from '@ipld/dag-cbor'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * const value = { hello: 'world' }\n *\n * // encode a block\n * let block = await Block.encode({ value, codec, hasher })\n *\n * block.value // { hello: 'world' }\n * block.bytes // Uint8Array\n * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec\n *\n * // you can also decode blocks from their binary state\n * block = await Block.decode({ bytes: block.bytes, codec, hasher })\n *\n * // if you have the cid you can also verify the hash on decode\n * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })\n * ```\n *\n * ## Multibase Encoders / Decoders / Codecs\n *\n * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:\n *\n * ```TypeScript\n * import { base64 } from \"multiformats/bases/base64\"\n * cid.toString(base64.encoder)\n * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'\n * ```\n *\n * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:\n *\n * ```TypeScript\n * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * Dual of multibase encoder & decoder is defined as multibase codec and it exposes\n * them as `encoder` and `decoder` properties. For added convenience codecs also\n * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be\n * used as either or both:\n *\n * ```TypeScript\n * cid.toString(base64)\n * CID.parse(cid.toString(base64), base64)\n * ```\n *\n * **Note:** CID implementation comes bundled with `base32` and `base58btc`\n * multibase codecs so that CIDs can be base serialized to (version specific)\n * default base encoding and parsed without having to supply base encoders/decoders:\n *\n * ```TypeScript\n * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')\n * v1.toString()\n * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'\n *\n * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')\n * v0.toString()\n * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'\n * v0.toV1().toString()\n * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'\n * ```\n *\n * ## Multicodec Encoders / Decoders / Codecs\n *\n * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).\n * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.\n * Here is an example implementation of JSON `BlockCodec`.\n *\n * ```TypeScript\n * export const { name, code, encode, decode } = {\n * name: 'json',\n * code: 0x0200,\n * encode: json => new TextEncoder().encode(JSON.stringify(json)),\n * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))\n * }\n * ```\n *\n * ## Multihash Hashers\n *\n * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:\n *\n * ```TypeScript\n * import * as hasher from 'multiformats/hashes/hasher'\n *\n * const sha256 = hasher.from({\n * // As per multiformats table\n * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9\n * name: 'sha2-256',\n * code: 0x12,\n *\n * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())\n * })\n *\n * const hash = await sha256.digest(json.encode({ hello: 'world' }))\n * CID.create(1, json.code, hash)\n *\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n * ```\n *\n * ## Traversal\n *\n * This library contains higher-order functions for traversing graphs of data easily.\n *\n * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.\n *\n * ```TypeScript\n * import { walk } from 'multiformats/traversal'\n * import * as Block from 'multiformats/block'\n * import * as codec from 'multiformats/codecs/json'\n * import { sha256 as hasher } from 'multiformats/hashes/sha2'\n *\n * // build a DAG (a single block for this simple example)\n * const value = { hello: 'world' }\n * const block = await Block.encode({ value, codec, hasher })\n * const { cid } = block\n * console.log(cid)\n * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)\n *\n * // create a loader function that also collects CIDs of blocks in\n * // their traversal order\n * const load = (cid, blocks) => async (cid) => {\n * // fetch a block using its cid\n * // e.g.: const block = await fetchBlockByCID(cid)\n * blocks.push(cid)\n * return block\n * }\n *\n * // collect blocks in this DAG starting from the root `cid`\n * const blocks = []\n * await walk({ cid, load: load(cid, blocks) })\n *\n * console.log(blocks)\n * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]\n * ```\n *\n * ## Legacy interface\n *\n * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an\n * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.\n *\n * ## Implementations\n *\n * By default, no base encodings (other than base32 & base58btc), hash functions,\n * or codec implementations are exposed by `multiformats`, you need to\n * import the ones you need yourself.\n *\n * ### Multibase codecs\n *\n * | bases | import | repo |\n * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |\n * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |\n *\n * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.\n *\n * ### Multihash hashers\n *\n * | hashes | import | repo |\n * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |\n * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |\n * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |\n * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |\n * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |\n * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |\n *\n * ### IPLD codecs (multicodec)\n *\n * | codec | import | repo |\n * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |\n * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |\n * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |\n * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |\n * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |\n * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |\n */\n\n\n\n\n\n// This way TS will also expose all the types from module\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/interface.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/interface.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bases_interface_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/bases/interface.js\");\n/* harmony import */ var _hashes_interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/hashes/interface.js\");\n/* harmony import */ var _codecs_interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/codecs/interface.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/link/interface.js\");\n/* harmony import */ var _block_interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block/interface.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/block/interface.js\");\n\n\n\n\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/link/interface.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/link/interface.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */\n/* eslint-disable no-use-before-define */\n\n//# sourceMappingURL=interface.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ encodeTo: () => (/* binding */ encodeTo),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/varint.js */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/varint.js\");\n\nfunction decode(data, offset = 0) {\n const code = _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode(data, offset);\n return [code, _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].decode.bytes];\n}\nfunction encodeTo(int, target, offset = 0) {\n _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encode(int, target, offset);\n return target;\n}\nfunction encodingLength(int) {\n return _vendor_varint_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].encodingLength(int);\n}\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/base-x.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/base-x.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n/**\n * @param {string} ALPHABET\n * @param {any} name\n */\nfunction base(ALPHABET, name) {\n if (ALPHABET.length >= 255) {\n throw new TypeError('Alphabet too long');\n }\n var BASE_MAP = new Uint8Array(256);\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) {\n throw new TypeError(x + ' is ambiguous');\n }\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n /**\n * @param {any[] | Iterable} source\n */\n function encode(source) {\n // @ts-ignore\n if (source instanceof Uint8Array)\n ;\n else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n }\n else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) {\n throw new TypeError('Expected Uint8Array');\n }\n if (source.length === 0) {\n return '';\n }\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) {\n str += ALPHABET.charAt(b58[it2]);\n }\n return str;\n }\n /**\n * @param {string | string[]} source\n */\n function decodeUnsafe(source) {\n if (typeof source !== 'string') {\n throw new TypeError('Expected String');\n }\n if (source.length === 0) {\n return new Uint8Array();\n }\n var psz = 0;\n // Skip leading spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size);\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) {\n return;\n }\n var i = 0;\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) {\n throw new Error('Non-zero carry');\n }\n length = i;\n psz++;\n }\n // Skip trailing spaces.\n if (source[psz] === ' ') {\n return;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n var vch = new Uint8Array(zeroes + (size - it4));\n var j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch;\n }\n /**\n * @param {string | string[]} string\n */\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) {\n return buffer;\n }\n throw new Error(`Non-${name} character`);\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nvar src = base;\nvar _brrp__multiformats_scope_baseX = src;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp__multiformats_scope_baseX);\n//# sourceMappingURL=base-x.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/varint.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/varint.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* eslint-disable */\nvar encode_1 = encode;\nvar MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);\n/**\n * @param {number} num\n * @param {number[]} out\n * @param {number} offset\n */\nfunction encode(num, out, offset) {\n out = out || [];\n offset = offset || 0;\n var oldOffset = offset;\n while (num >= INT) {\n out[offset++] = (num & 0xFF) | MSB;\n num /= 128;\n }\n while (num & MSBALL) {\n out[offset++] = (num & 0xFF) | MSB;\n num >>>= 7;\n }\n out[offset] = num | 0;\n // @ts-ignore\n encode.bytes = offset - oldOffset + 1;\n return out;\n}\nvar decode = read;\nvar MSB$1 = 0x80, REST$1 = 0x7F;\n/**\n * @param {string | any[]} buf\n * @param {number} offset\n */\nfunction read(buf, offset) {\n var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;\n do {\n if (counter >= l) {\n // @ts-ignore\n read.bytes = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf[counter++];\n res += shift < 28\n ? (b & REST$1) << shift\n : (b & REST$1) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB$1);\n // @ts-ignore\n read.bytes = counter - offset;\n return res;\n}\nvar N1 = Math.pow(2, 7);\nvar N2 = Math.pow(2, 14);\nvar N3 = Math.pow(2, 21);\nvar N4 = Math.pow(2, 28);\nvar N5 = Math.pow(2, 35);\nvar N6 = Math.pow(2, 42);\nvar N7 = Math.pow(2, 49);\nvar N8 = Math.pow(2, 56);\nvar N9 = Math.pow(2, 63);\nvar length = function (/** @type {number} */ value) {\n return (value < N1 ? 1\n : value < N2 ? 2\n : value < N3 ? 3\n : value < N4 ? 4\n : value < N5 ? 5\n : value < N6 ? 6\n : value < N7 ? 7\n : value < N8 ? 8\n : value < N9 ? 9\n : 10);\n};\nvar varint = {\n encode: encode_1,\n decode: decode,\n encodingLength: length\n};\nvar _brrp_varint = varint;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_brrp_varint);\n//# sourceMappingURL=varint.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/multiformats/dist/src/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/protons-runtime/node_modules/uint8-varint/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/protons-runtime/node_modules/uint8-varint/dist/src/index.js ***! - \**********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ decodeUint8Array: () => (/* binding */ decodeUint8Array),\n/* harmony export */ decodeUint8ArrayList: () => (/* binding */ decodeUint8ArrayList),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ encodeUint8Array: () => (/* binding */ encodeUint8Array),\n/* harmony export */ encodeUint8ArrayList: () => (/* binding */ encodeUint8ArrayList),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable no-fallthrough */\n\nconst N1 = Math.pow(2, 7);\nconst N2 = Math.pow(2, 14);\nconst N3 = Math.pow(2, 21);\nconst N4 = Math.pow(2, 28);\nconst N5 = Math.pow(2, 35);\nconst N6 = Math.pow(2, 42);\nconst N7 = Math.pow(2, 49);\n/** Most significant bit of a byte */\nconst MSB = 0x80;\n/** Rest of the bits in a byte */\nconst REST = 0x7f;\nfunction encodingLength(value) {\n if (value < N1) {\n return 1;\n }\n if (value < N2) {\n return 2;\n }\n if (value < N3) {\n return 3;\n }\n if (value < N4) {\n return 4;\n }\n if (value < N5) {\n return 5;\n }\n if (value < N6) {\n return 6;\n }\n if (value < N7) {\n return 7;\n }\n if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {\n throw new RangeError('Could not encode varint');\n }\n return 8;\n}\nfunction encodeUint8Array(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 7: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 6: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 5: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 4: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 3: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 2: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 1: {\n buf[offset++] = (value & 0xFF);\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction encodeUint8ArrayList(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 7: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 6: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 5: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 4: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 3: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 2: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 1: {\n buf.set(offset++, (value & 0xFF));\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction decodeUint8Array(buf, offset) {\n let b = buf[offset];\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 1];\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 2];\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 3];\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 4];\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 5];\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 6];\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 7];\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction decodeUint8ArrayList(buf, offset) {\n let b = buf.get(offset);\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 1);\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 2);\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 3);\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 4);\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 5);\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 6);\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 7);\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction encode(value, buf, offset = 0) {\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(encodingLength(value));\n }\n if (buf instanceof Uint8Array) {\n return encodeUint8Array(value, buf, offset);\n }\n else {\n return encodeUint8ArrayList(value, buf, offset);\n }\n}\nfunction decode(buf, offset = 0) {\n if (buf instanceof Uint8Array) {\n return decodeUint8Array(buf, offset);\n }\n else {\n return decodeUint8ArrayList(buf, offset);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/uint8-varint/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createWriter: () => (/* binding */ createWriter)\n/* harmony export */ });\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _float_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./float.js */ \"./node_modules/protons-runtime/dist/src/utils/float.js\");\n/* harmony import */ var _longbits_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./longbits.js */ \"./node_modules/protons-runtime/dist/src/utils/longbits.js\");\n/* harmony import */ var _pool_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pool.js */ \"./node_modules/protons-runtime/dist/src/utils/pool.js\");\n/* harmony import */ var _utf8_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utf8.js */ \"./node_modules/protons-runtime/dist/src/utils/utf8.js\");\n\n\n\n\n\n\n\n/**\n * Constructs a new writer operation instance.\n *\n * @classdesc Scheduled writer operation\n */\nclass Op {\n /**\n * Function to call\n */\n fn;\n /**\n * Value byte length\n */\n len;\n /**\n * Next operation\n */\n next;\n /**\n * Value to write\n */\n val;\n constructor(fn, len, val) {\n this.fn = fn;\n this.len = len;\n this.next = undefined;\n this.val = val; // type varies\n }\n}\n/* istanbul ignore next */\nfunction noop() { } // eslint-disable-line no-empty-function\n/**\n * Constructs a new writer state instance\n */\nclass State {\n /**\n * Current head\n */\n head;\n /**\n * Current tail\n */\n tail;\n /**\n * Current buffer length\n */\n len;\n /**\n * Next state\n */\n next;\n constructor(writer) {\n this.head = writer.head;\n this.tail = writer.tail;\n this.len = writer.len;\n this.next = writer.states;\n }\n}\nconst bufferPool = (0,_pool_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"])();\n/**\n * Allocates a buffer of the specified size\n */\nfunction alloc(size) {\n if (globalThis.Buffer != null) {\n return (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(size);\n }\n return bufferPool(size);\n}\n/**\n * When a value is written, the writer calculates its byte length and puts it into a linked\n * list of operations to perform when finish() is called. This both allows us to allocate\n * buffers of the exact required size and reduces the amount of work we have to do compared\n * to first calculating over objects and then encoding over objects. In our case, the encoding\n * part is just a linked list walk calling operations with already prepared values.\n */\nclass Uint8ArrayWriter {\n /**\n * Current length\n */\n len;\n /**\n * Operations head\n */\n head;\n /**\n * Operations tail\n */\n tail;\n /**\n * Linked forked states\n */\n states;\n constructor() {\n this.len = 0;\n this.head = new Op(noop, 0, 0);\n this.tail = this.head;\n this.states = null;\n }\n /**\n * Pushes a new operation to the queue\n */\n _push(fn, len, val) {\n this.tail = this.tail.next = new Op(fn, len, val);\n this.len += len;\n return this;\n }\n /**\n * Writes an unsigned 32 bit value as a varint\n */\n uint32(value) {\n // here, the call to this.push has been inlined and a varint specific Op subclass is used.\n // uint32 is by far the most frequently used operation and benefits significantly from this.\n this.len += (this.tail = this.tail.next = new VarintOp((value = value >>> 0) <\n 128\n ? 1\n : value < 16384\n ? 2\n : value < 2097152\n ? 3\n : value < 268435456\n ? 4\n : 5, value)).len;\n return this;\n }\n /**\n * Writes a signed 32 bit value as a varint`\n */\n int32(value) {\n return value < 0\n ? this._push(writeVarint64, 10, _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value)) // 10 bytes per spec\n : this.uint32(value);\n }\n /**\n * Writes a 32 bit value as a varint, zig-zag encoded\n */\n sint32(value) {\n return this.uint32((value << 1 ^ value >> 31) >>> 0);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value);\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64Number(value) {\n return this._push(uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodeUint8Array, (0,uint8_varint__WEBPACK_IMPORTED_MODULE_0__.encodingLength)(value), value);\n }\n /**\n * Writes an unsigned 64 bit value as a varint\n */\n uint64String(value) {\n return this.uint64(BigInt(value));\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64(value) {\n return this.uint64(value);\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64Number(value) {\n return this.uint64Number(value);\n }\n /**\n * Writes a signed 64 bit value as a varint\n */\n int64String(value) {\n return this.uint64String(value);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value).zzEncode();\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64Number(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value).zzEncode();\n return this._push(writeVarint64, bits.length(), bits);\n }\n /**\n * Writes a signed 64 bit value as a varint, zig-zag encoded\n */\n sint64String(value) {\n return this.sint64(BigInt(value));\n }\n /**\n * Writes a boolish value as a varint\n */\n bool(value) {\n return this._push(writeByte, 1, value ? 1 : 0);\n }\n /**\n * Writes an unsigned 32 bit value as fixed 32 bits\n */\n fixed32(value) {\n return this._push(writeFixed32, 4, value >>> 0);\n }\n /**\n * Writes a signed 32 bit value as fixed 32 bits\n */\n sfixed32(value) {\n return this.fixed32(value);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromBigInt(value);\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64Number(value) {\n const bits = _longbits_js__WEBPACK_IMPORTED_MODULE_4__.LongBits.fromNumber(value);\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\n }\n /**\n * Writes an unsigned 64 bit value as fixed 64 bits\n */\n fixed64String(value) {\n return this.fixed64(BigInt(value));\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64(value) {\n return this.fixed64(value);\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64Number(value) {\n return this.fixed64Number(value);\n }\n /**\n * Writes a signed 64 bit value as fixed 64 bits\n */\n sfixed64String(value) {\n return this.fixed64String(value);\n }\n /**\n * Writes a float (32 bit)\n */\n float(value) {\n return this._push(_float_js__WEBPACK_IMPORTED_MODULE_3__.writeFloatLE, 4, value);\n }\n /**\n * Writes a double (64 bit float).\n *\n * @function\n * @param {number} value - Value to write\n * @returns {Writer} `this`\n */\n double(value) {\n return this._push(_float_js__WEBPACK_IMPORTED_MODULE_3__.writeDoubleLE, 8, value);\n }\n /**\n * Writes a sequence of bytes\n */\n bytes(value) {\n const len = value.length >>> 0;\n if (len === 0) {\n return this._push(writeByte, 1, 0);\n }\n return this.uint32(len)._push(writeBytes, len, value);\n }\n /**\n * Writes a string\n */\n string(value) {\n const len = _utf8_js__WEBPACK_IMPORTED_MODULE_6__.length(value);\n return len !== 0\n ? this.uint32(len)._push(_utf8_js__WEBPACK_IMPORTED_MODULE_6__.write, len, value)\n : this._push(writeByte, 1, 0);\n }\n /**\n * Forks this writer's state by pushing it to a stack.\n * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.\n */\n fork() {\n this.states = new State(this);\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n return this;\n }\n /**\n * Resets this instance to the last state\n */\n reset() {\n if (this.states != null) {\n this.head = this.states.head;\n this.tail = this.states.tail;\n this.len = this.states.len;\n this.states = this.states.next;\n }\n else {\n this.head = this.tail = new Op(noop, 0, 0);\n this.len = 0;\n }\n return this;\n }\n /**\n * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.\n */\n ldelim() {\n const head = this.head;\n const tail = this.tail;\n const len = this.len;\n this.reset().uint32(len);\n if (len !== 0) {\n this.tail.next = head.next; // skip noop\n this.tail = tail;\n this.len += len;\n }\n return this;\n }\n /**\n * Finishes the write operation\n */\n finish() {\n let head = this.head.next; // skip noop\n const buf = alloc(this.len);\n let pos = 0;\n while (head != null) {\n head.fn(head.val, buf, pos);\n pos += head.len;\n head = head.next;\n }\n // this.head = this.tail = null;\n return buf;\n }\n}\nfunction writeByte(val, buf, pos) {\n buf[pos] = val & 255;\n}\nfunction writeVarint32(val, buf, pos) {\n while (val > 127) {\n buf[pos++] = val & 127 | 128;\n val >>>= 7;\n }\n buf[pos] = val;\n}\n/**\n * Constructs a new varint writer operation instance.\n *\n * @classdesc Scheduled varint writer operation\n */\nclass VarintOp extends Op {\n next;\n constructor(len, val) {\n super(writeVarint32, len, val);\n this.next = undefined;\n }\n}\nfunction writeVarint64(val, buf, pos) {\n while (val.hi !== 0) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;\n val.hi >>>= 7;\n }\n while (val.lo > 127) {\n buf[pos++] = val.lo & 127 | 128;\n val.lo = val.lo >>> 7;\n }\n buf[pos++] = val.lo;\n}\nfunction writeFixed32(val, buf, pos) {\n buf[pos] = val & 255;\n buf[pos + 1] = val >>> 8 & 255;\n buf[pos + 2] = val >>> 16 & 255;\n buf[pos + 3] = val >>> 24;\n}\nfunction writeBytes(val, buf, pos) {\n buf.set(val, pos);\n}\nif (globalThis.Buffer != null) {\n Uint8ArrayWriter.prototype.bytes = function (value) {\n const len = value.length >>> 0;\n this.uint32(len);\n if (len > 0) {\n this._push(writeBytesBuffer, len, value);\n }\n return this;\n };\n Uint8ArrayWriter.prototype.string = function (value) {\n const len = globalThis.Buffer.byteLength(value);\n this.uint32(len);\n if (len > 0) {\n this._push(writeStringBuffer, len, value);\n }\n return this;\n };\n}\nfunction writeBytesBuffer(val, buf, pos) {\n buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)\n // also works for plain array values\n}\nfunction writeStringBuffer(val, buf, pos) {\n if (val.length < 40) {\n // plain js is faster for short strings (probably due to redundant assertions)\n _utf8_js__WEBPACK_IMPORTED_MODULE_6__.write(val, buf, pos);\n // @ts-expect-error buf isn't a Uint8Array?\n }\n else if (buf.utf8Write != null) {\n // @ts-expect-error buf isn't a Uint8Array?\n buf.utf8Write(val, pos);\n }\n else {\n buf.set((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_2__.fromString)(val), pos);\n }\n}\n/**\n * Creates a new writer\n */\nfunction createWriter() {\n return new Uint8ArrayWriter();\n}\n//# sourceMappingURL=writer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/utils/writer.js?"); /***/ }), @@ -9217,7 +8949,29 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/protons-runtime/node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/util/bases.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/dist/src/basics.js\");\n/* harmony import */ var _alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #alloc */ \"./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nfunction createCodec(name, prefix, encode, decode) {\n return {\n name,\n prefix,\n encoder: {\n name,\n prefix,\n encode\n },\n decoder: {\n decode\n }\n };\n}\nconst string = createCodec('utf8', 'u', (buf) => {\n const decoder = new TextDecoder('utf8');\n return 'u' + decoder.decode(buf);\n}, (str) => {\n const encoder = new TextEncoder();\n return encoder.encode(str.substring(1));\n});\nconst ascii = createCodec('ascii', 'a', (buf) => {\n let string = 'a';\n for (let i = 0; i < buf.length; i++) {\n string += String.fromCharCode(buf[i]);\n }\n return string;\n}, (str) => {\n str = str.substring(1);\n const buf = (0,_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(str.length);\n for (let i = 0; i < str.length; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n});\nconst BASES = {\n utf8: string,\n 'utf-8': string,\n hex: multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases.base16,\n latin1: ascii,\n ascii,\n binary: ascii,\n ...multiformats_basics__WEBPACK_IMPORTED_MODULE_0__.bases\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BASES);\n//# sourceMappingURL=bases.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/node_modules/uint8arrays/dist/src/util/bases.js?"); + +/***/ }), + +/***/ "./node_modules/race-event/dist/src/index.js": +/*!***************************************************!*\ + !*** ./node_modules/race-event/dist/src/index.js ***! + \***************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ raceEvent: () => (/* binding */ raceEvent)\n/* harmony export */ });\n/**\n * @packageDocumentation\n *\n * Race an event against an AbortSignal, taking care to remove any event\n * listeners that were added.\n *\n * @example Getting started\n *\n * ```TypeScript\n * import { raceEvent } from 'race-event'\n *\n * const controller = new AbortController()\n * const emitter = new EventTarget()\n *\n * setTimeout(() => {\n * controller.abort()\n * }, 500)\n *\n * setTimeout(() => {\n * // too late\n * emitter.dispatchEvent(new CustomEvent('event'))\n * }, 1000)\n *\n * // throws an AbortError\n * const resolve = await raceEvent(emitter, 'event', controller.signal)\n * ```\n *\n * @example Customising the thrown AbortError\n *\n * The error message and `.code` property of the thrown `AbortError` can be\n * specified by passing options:\n *\n * ```TypeScript\n * import { raceEvent } from 'race-event'\n *\n * const controller = new AbortController()\n * const emitter = new EventTarget()\n *\n * setTimeout(() => {\n * controller.abort()\n * }, 500)\n *\n * // throws a Error: Oh no!\n * const resolve = await raceEvent(emitter, 'event', controller.signal, {\n * errorMessage: 'Oh no!',\n * errorCode: 'ERR_OH_NO'\n * })\n * ```\n *\n * @example Only resolving on specific events\n *\n * Where multiple events with the same type are emitted, a `filter` function can\n * be passed to only resolve on one of them:\n *\n * ```TypeScript\n * import { raceEvent } from 'race-event'\n *\n * const controller = new AbortController()\n * const emitter = new EventTarget()\n *\n * // throws a Error: Oh no!\n * const resolve = await raceEvent(emitter, 'event', controller.signal, {\n * filter: (evt: Event) => {\n * return evt.detail.foo === 'bar'\n * }\n * })\n * ```\n *\n * @example Terminating early by throwing from the filter\n *\n * You can cause listening for the event to cease and all event listeners to be\n * removed by throwing from the filter:\n *\n * ```TypeScript\n * import { raceEvent } from 'race-event'\n *\n * const controller = new AbortController()\n * const emitter = new EventTarget()\n *\n * // throws Error: Cannot continue\n * const resolve = await raceEvent(emitter, 'event', controller.signal, {\n * filter: (evt) => {\n * if (...reasons) {\n * throw new Error('Cannot continue')\n * }\n *\n * return true\n * }\n * })\n * ```\n */\n/**\n * An abort error class that extends error\n */\nclass AbortError extends Error {\n type;\n code;\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.name = 'AbortError';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n/**\n * Race a promise against an abort signal\n */\nasync function raceEvent(emitter, eventName, signal, opts) {\n // create the error here so we have more context in the stack trace\n const error = new AbortError(opts?.errorMessage, opts?.errorCode);\n if (signal?.aborted === true) {\n return Promise.reject(error);\n }\n return new Promise((resolve, reject) => {\n const eventListener = (evt) => {\n try {\n if (opts?.filter?.(evt) === false) {\n return;\n }\n }\n catch (err) {\n emitter.removeEventListener(eventName, eventListener);\n signal?.removeEventListener('abort', abortListener);\n reject(err);\n return;\n }\n emitter.removeEventListener(eventName, eventListener);\n signal?.removeEventListener('abort', abortListener);\n resolve(evt);\n };\n const abortListener = () => {\n emitter.removeEventListener(eventName, eventListener);\n signal?.removeEventListener('abort', abortListener);\n reject(error);\n };\n emitter.addEventListener(eventName, eventListener);\n signal?.addEventListener('abort', abortListener);\n });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/race-event/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/race-signal/dist/src/index.js": +/*!****************************************************!*\ + !*** ./node_modules/race-signal/dist/src/index.js ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AbortError: () => (/* binding */ AbortError),\n/* harmony export */ raceSignal: () => (/* binding */ raceSignal)\n/* harmony export */ });\n/**\n * An abort error class that extends error\n */\nclass AbortError extends Error {\n type;\n code;\n constructor(message, code) {\n super(message ?? 'The operation was aborted');\n this.type = 'aborted';\n this.name = 'AbortError';\n this.code = code ?? 'ABORT_ERR';\n }\n}\n/**\n * Race a promise against an abort signal\n */\nasync function raceSignal(promise, signal, opts) {\n if (signal == null) {\n return promise;\n }\n if (signal.aborted) {\n return Promise.reject(new AbortError(opts?.errorMessage, opts?.errorCode));\n }\n let listener;\n // create the error here so we have more context in the stack trace\n const error = new AbortError(opts?.errorMessage, opts?.errorCode);\n try {\n return await Promise.race([\n promise,\n new Promise((resolve, reject) => {\n listener = () => {\n reject(error);\n };\n signal.addEventListener('abort', listener);\n })\n ]);\n }\n finally {\n if (listener != null) {\n signal.removeEventListener('abort', listener);\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/race-signal/dist/src/index.js?"); /***/ }), @@ -9228,7 +8982,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ signed: () => (/* binding */ signed),\n/* harmony export */ unsigned: () => (/* binding */ unsigned),\n/* harmony export */ zigzag: () => (/* binding */ zigzag)\n/* harmony export */ });\n/* harmony import */ var longbits__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! longbits */ \"./node_modules/longbits/dist/src/index.js\");\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n\n\nconst N1 = Math.pow(2, 7);\nconst N2 = Math.pow(2, 14);\nconst N3 = Math.pow(2, 21);\nconst N4 = Math.pow(2, 28);\nconst N5 = Math.pow(2, 35);\nconst N6 = Math.pow(2, 42);\nconst N7 = Math.pow(2, 49);\nconst N8 = Math.pow(2, 56);\nconst N9 = Math.pow(2, 63);\nconst unsigned = {\n encodingLength(value) {\n if (value < N1) {\n return 1;\n }\n if (value < N2) {\n return 2;\n }\n if (value < N3) {\n return 3;\n }\n if (value < N4) {\n return 4;\n }\n if (value < N5) {\n return 5;\n }\n if (value < N6) {\n return 6;\n }\n if (value < N7) {\n return 7;\n }\n if (value < N8) {\n return 8;\n }\n if (value < N9) {\n return 9;\n }\n return 10;\n },\n encode(value, buf, offset = 0) {\n if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {\n throw new RangeError('Could not encode varint');\n }\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(unsigned.encodingLength(value));\n }\n longbits__WEBPACK_IMPORTED_MODULE_0__.LongBits.fromNumber(value).toBytes(buf, offset);\n return buf;\n },\n decode(buf, offset = 0) {\n return longbits__WEBPACK_IMPORTED_MODULE_0__.LongBits.fromBytes(buf, offset).toNumber(true);\n }\n};\nconst signed = {\n encodingLength(value) {\n if (value < 0) {\n return 10; // 10 bytes per spec - https://developers.google.com/protocol-buffers/docs/encoding#signed-ints\n }\n return unsigned.encodingLength(value);\n },\n encode(value, buf, offset) {\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_1__.allocUnsafe)(signed.encodingLength(value));\n }\n if (value < 0) {\n longbits__WEBPACK_IMPORTED_MODULE_0__.LongBits.fromNumber(value).toBytes(buf, offset);\n return buf;\n }\n return unsigned.encode(value, buf, offset);\n },\n decode(buf, offset = 0) {\n return longbits__WEBPACK_IMPORTED_MODULE_0__.LongBits.fromBytes(buf, offset).toNumber(false);\n }\n};\nconst zigzag = {\n encodingLength(value) {\n return unsigned.encodingLength(value >= 0 ? value * 2 : value * -2 - 1);\n },\n // @ts-expect-error types are wrong\n encode(value, buf, offset) {\n value = value >= 0 ? value * 2 : (value * -2) - 1;\n return unsigned.encode(value, buf, offset);\n },\n decode(buf, offset = 0) {\n const value = unsigned.decode(buf, offset);\n return (value & 1) !== 0 ? (value + 1) / -2 : value / 2;\n }\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uint8-varint/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decode: () => (/* binding */ decode),\n/* harmony export */ decodeUint8Array: () => (/* binding */ decodeUint8Array),\n/* harmony export */ decodeUint8ArrayList: () => (/* binding */ decodeUint8ArrayList),\n/* harmony export */ encode: () => (/* binding */ encode),\n/* harmony export */ encodeUint8Array: () => (/* binding */ encodeUint8Array),\n/* harmony export */ encodeUint8ArrayList: () => (/* binding */ encodeUint8ArrayList),\n/* harmony export */ encodingLength: () => (/* binding */ encodingLength)\n/* harmony export */ });\n/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8-varint/node_modules/uint8arrays/dist/src/alloc.js\");\n/* eslint-disable no-fallthrough */\n\nconst N1 = Math.pow(2, 7);\nconst N2 = Math.pow(2, 14);\nconst N3 = Math.pow(2, 21);\nconst N4 = Math.pow(2, 28);\nconst N5 = Math.pow(2, 35);\nconst N6 = Math.pow(2, 42);\nconst N7 = Math.pow(2, 49);\n/** Most significant bit of a byte */\nconst MSB = 0x80;\n/** Rest of the bits in a byte */\nconst REST = 0x7f;\nfunction encodingLength(value) {\n if (value < N1) {\n return 1;\n }\n if (value < N2) {\n return 2;\n }\n if (value < N3) {\n return 3;\n }\n if (value < N4) {\n return 4;\n }\n if (value < N5) {\n return 5;\n }\n if (value < N6) {\n return 6;\n }\n if (value < N7) {\n return 7;\n }\n if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {\n throw new RangeError('Could not encode varint');\n }\n return 8;\n}\nfunction encodeUint8Array(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 7: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 6: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 5: {\n buf[offset++] = (value & 0xFF) | MSB;\n value /= 128;\n }\n case 4: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 3: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 2: {\n buf[offset++] = (value & 0xFF) | MSB;\n value >>>= 7;\n }\n case 1: {\n buf[offset++] = (value & 0xFF);\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction encodeUint8ArrayList(value, buf, offset = 0) {\n switch (encodingLength(value)) {\n case 8: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 7: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 6: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 5: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value /= 128;\n }\n case 4: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 3: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 2: {\n buf.set(offset++, (value & 0xFF) | MSB);\n value >>>= 7;\n }\n case 1: {\n buf.set(offset++, (value & 0xFF));\n value >>>= 7;\n break;\n }\n default: throw new Error('unreachable');\n }\n return buf;\n}\nfunction decodeUint8Array(buf, offset) {\n let b = buf[offset];\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 1];\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 2];\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 3];\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 4];\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 5];\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 6];\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf[offset + 7];\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction decodeUint8ArrayList(buf, offset) {\n let b = buf.get(offset);\n let res = 0;\n res += b & REST;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 1);\n res += (b & REST) << 7;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 2);\n res += (b & REST) << 14;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 3);\n res += (b & REST) << 21;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 4);\n res += (b & REST) * N4;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 5);\n res += (b & REST) * N5;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 6);\n res += (b & REST) * N6;\n if (b < MSB) {\n return res;\n }\n b = buf.get(offset + 7);\n res += (b & REST) * N7;\n if (b < MSB) {\n return res;\n }\n throw new RangeError('Could not decode varint');\n}\nfunction encode(value, buf, offset = 0) {\n if (buf == null) {\n buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(encodingLength(value));\n }\n if (buf instanceof Uint8Array) {\n return encodeUint8Array(value, buf, offset);\n }\n else {\n return encodeUint8ArrayList(value, buf, offset);\n }\n}\nfunction decode(buf, offset = 0) {\n if (buf instanceof Uint8Array) {\n return decodeUint8Array(buf, offset);\n }\n else {\n return decodeUint8ArrayList(buf, offset);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uint8-varint/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/uint8-varint/node_modules/uint8arrays/dist/src/alloc.js": +/*!******************************************************************************!*\ + !*** ./node_modules/uint8-varint/node_modules/uint8arrays/dist/src/alloc.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alloc: () => (/* binding */ alloc),\n/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)\n/* harmony export */ });\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n return new Uint8Array(size);\n}\n/**\n * Where possible returns a Uint8Array of the requested size that references\n * uninitialized memory. Only use if you are certain you will immediately\n * overwrite every value in the returned `Uint8Array`.\n */\nfunction allocUnsafe(size = 0) {\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uint8-varint/node_modules/uint8arrays/dist/src/alloc.js?"); /***/ }),