diff --git a/noise-js/index.js b/noise-js/index.js index 852dbf8..fb5e68a 100644 --- a/noise-js/index.js +++ b/noise-js/index.js @@ -16,7 +16,128 @@ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _waku_create__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/create */ \"./node_modules/@waku/create/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_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_noise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/noise */ \"./node_modules/@waku/noise/dist/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! protobufjs */ \"./node_modules/protobufjs/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(protobufjs__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! qrcode */ \"./node_modules/qrcode/lib/browser.js\");\n\n\n\n\n\n\n\n\n// Protobuf\nconst ProtoChatMessage = new (protobufjs__WEBPACK_IMPORTED_MODULE_5___default().Type)(\"ChatMessage\")\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_5___default().Field)(\"timestamp\", 1, \"uint64\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_5___default().Field)(\"nick\", 2, \"string\"))\n .add(new (protobufjs__WEBPACK_IMPORTED_MODULE_5___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_create__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({\n defaultBootstrap: true,\n });\n\n try {\n await node.start();\n await (0,_waku_core__WEBPACK_IMPORTED_MODULE_2__.waitForRemotePeer)(node, [_waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.Protocols.Filter, _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.Protocols.LightPush]);\n\n ui.waku.connected();\n\n const responder = getResponder(node);\n const myStaticKey = _waku_noise__WEBPACK_IMPORTED_MODULE_4__.generateX25519KeyPair();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_4__.WakuPairing(\n node.lightPush,\n responder,\n myStaticKey,\n urlPairingInfo || new _waku_noise__WEBPACK_IMPORTED_MODULE_4__.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_4__.InitiatorParameters(\n decodeURIComponent(qrCodeString),\n _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(messageNameTag)\n );\n}\n\nfunction getResponder(node) {\n const msgQueue = new Array();\n const subscriptions = new Map();\n const intervals = new Map();\n\n const responder = {\n async subscribe(decoder) {\n const subscription = await node.filter.subscribe(\n [decoder],\n (wakuMessage) => {\n msgQueue.push(wakuMessage);\n }\n );\n subscriptions.set(decoder.contentTopic, subscription);\n },\n async nextMessage(contentTopic) {\n if (msgQueue.length != 0) {\n const oldestMsg = msgQueue.shift();\n if (oldestMsg.contentTopic === contentTopic) {\n return oldestMsg;\n }\n }\n\n return new Promise((resolve) => {\n const interval = setInterval(() => {\n if (msgQueue.length != 0) {\n clearInterval(interval);\n const oldestMsg = msgQueue.shift();\n if (oldestMsg.contentTopic === contentTopic) {\n resolve(oldestMsg);\n }\n }\n }, 100);\n intervals.set(contentTopic, interval);\n });\n },\n async stop(contentTopic) {\n if (intervals.has(contentTopic)) {\n clearInterval(intervals.get(contentTopic));\n intervals.delete(contentTopic);\n }\n if (subscriptions.has(contentTopic)) {\n await subscriptions.get(contentTopic)();\n subscriptions.delete(contentTopic);\n } else {\n console.log(\"Subscriptipon doesnt exist\");\n }\n },\n };\n\n return responder;\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_6__.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_create__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/create */ \"./node_modules/@waku/create/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_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/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\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_create__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({\n defaultBootstrap: true,\n });\n\n try {\n await node.start();\n await (0,_waku_core__WEBPACK_IMPORTED_MODULE_2__.waitForRemotePeer)(node, [\"filter\", \"lightpush\"]);\n\n ui.waku.connected();\n\n const myStaticKey = _waku_noise__WEBPACK_IMPORTED_MODULE_3__.generateX25519KeyPair();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.WakuPairing(\n node.lightPush,\n node.filter,\n myStaticKey,\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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js ***! + \*************************************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +eval("// minimal library entry point.\n\n\nmodule.exports = __webpack_require__(/*! ./src/index-minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js\");\nprotobuf.BufferWriter = __webpack_require__(/*! ./writer_buffer */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js\");\nprotobuf.Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js\");\nprotobuf.BufferReader = __webpack_require__(/*! ./reader_buffer */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js\");\n\n// Utility\nprotobuf.util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js\");\nprotobuf.rpc = __webpack_require__(/*! ./rpc */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js\");\nprotobuf.roots = __webpack_require__(/*! ./roots */ \"./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js\");\n(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/roots.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/roots.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/longbits.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/longbits.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js\");\n(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js?"); /***/ }), @@ -383,269 +504,6 @@ eval("\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protobufjs/minimal.js": -/*!********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protobufjs/minimal.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("// minimal library entry point.\n\n\nmodule.exports = __webpack_require__(/*! ./src/index-minimal */ \"./node_modules/@waku/core/node_modules/protobufjs/src/index-minimal.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protobufjs/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/index-minimal.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/protobufjs/src/writer.js\");\nprotobuf.BufferWriter = __webpack_require__(/*! ./writer_buffer */ \"./node_modules/@waku/core/node_modules/protobufjs/src/writer_buffer.js\");\nprotobuf.Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@waku/core/node_modules/protobufjs/src/reader.js\");\nprotobuf.BufferReader = __webpack_require__(/*! ./reader_buffer */ \"./node_modules/@waku/core/node_modules/protobufjs/src/reader_buffer.js\");\n\n// Utility\nprotobuf.util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/core/node_modules/protobufjs/src/util/minimal.js\");\nprotobuf.rpc = __webpack_require__(/*! ./rpc */ \"./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js\");\nprotobuf.roots = __webpack_require__(/*! ./roots */ \"./node_modules/@waku/core/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/core/node_modules/protobufjs/src/index-minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/reader.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/protobufjs/src/reader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/reader_buffer.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/node_modules/protobufjs/src/reader_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/roots.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/protobufjs/src/roots.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js": -/*!********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/protobufjs/src/rpc/service.js\");\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/rpc/service.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/protobufjs/src/rpc/service.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/util/longbits.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/protobufjs/src/util/longbits.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/util/minimal.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/protobufjs/src/util/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/writer.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/protobufjs/src/writer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/writer_buffer.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/node_modules/protobufjs/src/writer_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/longbits.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/longbits.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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, {\n constructor: {\n value: CustomError,\n writable: true,\n enumerable: false,\n configurable: true,\n },\n name: {\n get: function get() { return name; },\n set: undefined,\n enumerable: false,\n // configurable: false would accurately preserve the behavior of\n // the original, but I'm guessing that was not intentional.\n // For an actual error subclass, this property would\n // be configurable.\n configurable: true,\n },\n toString: {\n value: function value() { return this.name + \": \" + this.message; },\n writable: true,\n enumerable: false,\n configurable: true,\n },\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/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nconst randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n randomUUID\n});\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/regex.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/regex.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/regex.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/rng.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/rng.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 */ \"default\": () => (/* binding */ rng)\n/* harmony export */ });\n// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nfunction rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/rng.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/stringify.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/stringify.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ \"unsafeStringify\": () => (/* binding */ unsafeStringify)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/validate.js\");\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (stringify);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/stringify.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _native_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./native.js */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.js\");\n/* harmony import */ var _rng_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rng.js */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/rng.js\");\n/* harmony import */ var _stringify_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stringify.js */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/stringify.js\");\n\n\n\n\nfunction v4(options, buf, offset) {\n if (_native_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomUUID && !buf && !options) {\n return _native_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || _rng_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return (0,_stringify_js__WEBPACK_IMPORTED_MODULE_2__.unsafeStringify)(rnds);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (v4);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/validate.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/validate.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/regex.js\");\n\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && _regex_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].test(uuid);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/validate.js?"); - -/***/ }), - -/***/ "./node_modules/any-signal/index.js": -/*!******************************************!*\ - !*** ./node_modules/any-signal/index.js ***! - \******************************************/ -/***/ ((module) => { - -eval("/**\n * Takes an array of AbortSignals and returns a single signal.\n * If any signals are aborted, the returned signal will be aborted.\n * @param {Array} signals\n * @returns {AbortSignal}\n */\nfunction anySignal (signals) {\n const controller = new globalThis.AbortController()\n\n function onAbort () {\n controller.abort()\n\n for (const signal of signals) {\n if (!signal || !signal.removeEventListener) continue\n signal.removeEventListener('abort', onAbort)\n }\n }\n\n for (const signal of signals) {\n if (!signal || !signal.addEventListener) continue\n if (signal.aborted) {\n onAbort()\n break\n }\n signal.addEventListener('abort', onAbort)\n }\n\n return controller.signal\n}\n\nmodule.exports = anySignal\nmodule.exports.anySignal = anySignal\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/any-signal/index.js?"); - -/***/ }), - /***/ "./node_modules/bn.js/lib/bn.js": /*!**************************************!*\ !*** ./node_modules/bn.js/lib/bn.js ***! @@ -780,7 +638,7 @@ eval("module.exports = class FixedFIFO {\n constructor (hwm) {\n if (!(hwm > \*****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -eval("const FixedFIFO = __webpack_require__(/*! ./fixed-size */ \"./node_modules/fast-fifo/fixed-size.js\")\n\nmodule.exports = class FastFIFO {\n constructor (hwm) {\n this.hwm = hwm || 16\n this.head = new FixedFIFO(this.hwm)\n this.tail = this.head\n }\n\n push (val) {\n if (!this.head.push(val)) {\n const prev = this.head\n this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)\n this.head.push(val)\n }\n }\n\n shift () {\n const val = this.tail.shift()\n if (val === undefined && this.tail.next) {\n const next = this.tail.next\n this.tail.next = null\n this.tail = next\n return this.tail.shift()\n }\n return val\n }\n\n peek () {\n return this.tail.peek()\n }\n\n isEmpty () {\n return this.head.isEmpty()\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/fast-fifo/index.js?"); +eval("const FixedFIFO = __webpack_require__(/*! ./fixed-size */ \"./node_modules/fast-fifo/fixed-size.js\")\n\nmodule.exports = class FastFIFO {\n constructor (hwm) {\n this.hwm = hwm || 16\n this.head = new FixedFIFO(this.hwm)\n this.tail = this.head\n this.length = 0\n }\n\n push (val) {\n this.length++\n if (!this.head.push(val)) {\n const prev = this.head\n this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)\n this.head.push(val)\n }\n }\n\n shift () {\n if (this.length !== 0) this.length--\n const val = this.tail.shift()\n if (val === undefined && this.tail.next) {\n const next = this.tail.next\n this.tail.next = null\n this.tail = next\n return this.tail.shift()\n }\n\n return val\n }\n\n peek () {\n return this.tail.peek()\n }\n\n isEmpty () {\n return this.head.isEmpty()\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/fast-fifo/index.js?"); /***/ }), @@ -868,6 +726,16 @@ eval("var __WEBPACK_AMD_DEFINE_RESULT__;/**\n * [js-sha3]{@link https://github.c /***/ }), +/***/ "./node_modules/libp2p/node_modules/any-signal/index.js": +/*!**************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/any-signal/index.js ***! + \**************************************************************/ +/***/ ((module) => { + +eval("/**\n * Takes an array of AbortSignals and returns a single signal.\n * If any signals are aborted, the returned signal will be aborted.\n * @param {Array} signals\n * @returns {AbortSignal}\n */\nfunction anySignal (signals) {\n const controller = new globalThis.AbortController()\n\n function onAbort () {\n controller.abort()\n\n for (const signal of signals) {\n if (!signal || !signal.removeEventListener) continue\n signal.removeEventListener('abort', onAbort)\n }\n }\n\n for (const signal of signals) {\n if (!signal || !signal.addEventListener) continue\n if (signal.aborted) {\n onAbort()\n break\n }\n signal.addEventListener('abort', onAbort)\n }\n\n return controller.signal\n}\n\nmodule.exports = anySignal\nmodule.exports.anySignal = anySignal\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/any-signal/index.js?"); + +/***/ }), + /***/ "./node_modules/merge-options/index.js": /*!*********************************************!*\ !*** ./node_modules/merge-options/index.js ***! @@ -1424,7 +1292,7 @@ eval("\nmodule.exports = OneOf;\n\n// extends ReflectionObject\nvar ReflectionOb /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; -eval("\nmodule.exports = parse;\n\nparse.filename = null;\nparse.defaults = { keepCase: false };\n\nvar tokenize = __webpack_require__(/*! ./tokenize */ \"./node_modules/protobufjs/src/tokenize.js\"),\n Root = __webpack_require__(/*! ./root */ \"./node_modules/protobufjs/src/root.js\"),\n Type = __webpack_require__(/*! ./type */ \"./node_modules/protobufjs/src/type.js\"),\n Field = __webpack_require__(/*! ./field */ \"./node_modules/protobufjs/src/field.js\"),\n MapField = __webpack_require__(/*! ./mapfield */ \"./node_modules/protobufjs/src/mapfield.js\"),\n OneOf = __webpack_require__(/*! ./oneof */ \"./node_modules/protobufjs/src/oneof.js\"),\n Enum = __webpack_require__(/*! ./enum */ \"./node_modules/protobufjs/src/enum.js\"),\n Service = __webpack_require__(/*! ./service */ \"./node_modules/protobufjs/src/service.js\"),\n Method = __webpack_require__(/*! ./method */ \"./node_modules/protobufjs/src/method.js\"),\n types = __webpack_require__(/*! ./types */ \"./node_modules/protobufjs/src/types.js\"),\n util = __webpack_require__(/*! ./util */ \"./node_modules/protobufjs/src/util.js\");\n\nvar base10Re = /^[1-9][0-9]*$/,\n base10NegRe = /^-?[1-9][0-9]*$/,\n base16Re = /^0[x][0-9a-fA-F]+$/,\n base16NegRe = /^-?0[x][0-9a-fA-F]+$/,\n base8Re = /^0[0-7]+$/,\n base8NegRe = /^-?0[0-7]+$/,\n numberRe = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,\n nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,\n typeRefRe = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,\n fqTypeRefRe = /^(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;\n\n/**\n * Result object returned from {@link parse}.\n * @interface IParserResult\n * @property {string|undefined} package Package name, if declared\n * @property {string[]|undefined} imports Imports, if any\n * @property {string[]|undefined} weakImports Weak imports, if any\n * @property {string|undefined} syntax Syntax, if specified (either `\"proto2\"` or `\"proto3\"`)\n * @property {Root} root Populated root instance\n */\n\n/**\n * Options modifying the behavior of {@link parse}.\n * @interface IParseOptions\n * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case\n * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.\n * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.\n */\n\n/**\n * Options modifying the behavior of JSON serialization.\n * @interface IToJSONOptions\n * @property {boolean} [keepComments=false] Serializes comments.\n */\n\n/**\n * Parses the given .proto source and returns an object with the parsed contents.\n * @param {string} source Source contents\n * @param {Root} root Root to populate\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {IParserResult} Parser result\n * @property {string} filename=null Currently processing file name for error reporting, if known\n * @property {IParseOptions} defaults Default {@link IParseOptions}\n */\nfunction parse(source, root, options) {\n /* eslint-disable callback-return */\n if (!(root instanceof Root)) {\n options = root;\n root = new Root();\n }\n if (!options)\n options = parse.defaults;\n\n var preferTrailingComment = options.preferTrailingComment || false;\n var tn = tokenize(source, options.alternateCommentMode || false),\n next = tn.next,\n push = tn.push,\n peek = tn.peek,\n skip = tn.skip,\n cmnt = tn.cmnt;\n\n var head = true,\n pkg,\n imports,\n weakImports,\n syntax,\n isProto3 = false;\n\n var ptr = root;\n\n var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;\n\n /* istanbul ignore next */\n function illegal(token, name, insideTryCatch) {\n var filename = parse.filename;\n if (!insideTryCatch)\n parse.filename = null;\n return Error(\"illegal \" + (name || \"token\") + \" '\" + token + \"' (\" + (filename ? filename + \", \" : \"\") + \"line \" + tn.line + \")\");\n }\n\n function readString() {\n var values = [],\n token;\n do {\n /* istanbul ignore if */\n if ((token = next()) !== \"\\\"\" && token !== \"'\")\n throw illegal(token);\n\n values.push(next());\n skip(token);\n token = peek();\n } while (token === \"\\\"\" || token === \"'\");\n return values.join(\"\");\n }\n\n function readValue(acceptTypeRef) {\n var token = next();\n switch (token) {\n case \"'\":\n case \"\\\"\":\n push(token);\n return readString();\n case \"true\": case \"TRUE\":\n return true;\n case \"false\": case \"FALSE\":\n return false;\n }\n try {\n return parseNumber(token, /* insideTryCatch */ true);\n } catch (e) {\n\n /* istanbul ignore else */\n if (acceptTypeRef && typeRefRe.test(token))\n return token;\n\n /* istanbul ignore next */\n throw illegal(token, \"value\");\n }\n }\n\n function readRanges(target, acceptStrings) {\n var token, start;\n do {\n if (acceptStrings && ((token = peek()) === \"\\\"\" || token === \"'\"))\n target.push(readString());\n else\n target.push([ start = parseId(next()), skip(\"to\", true) ? parseId(next()) : start ]);\n } while (skip(\",\", true));\n skip(\";\");\n }\n\n function parseNumber(token, insideTryCatch) {\n var sign = 1;\n if (token.charAt(0) === \"-\") {\n sign = -1;\n token = token.substring(1);\n }\n switch (token) {\n case \"inf\": case \"INF\": case \"Inf\":\n return sign * Infinity;\n case \"nan\": case \"NAN\": case \"Nan\": case \"NaN\":\n return NaN;\n case \"0\":\n return 0;\n }\n if (base10Re.test(token))\n return sign * parseInt(token, 10);\n if (base16Re.test(token))\n return sign * parseInt(token, 16);\n if (base8Re.test(token))\n return sign * parseInt(token, 8);\n\n /* istanbul ignore else */\n if (numberRe.test(token))\n return sign * parseFloat(token);\n\n /* istanbul ignore next */\n throw illegal(token, \"number\", insideTryCatch);\n }\n\n function parseId(token, acceptNegative) {\n switch (token) {\n case \"max\": case \"MAX\": case \"Max\":\n return 536870911;\n case \"0\":\n return 0;\n }\n\n /* istanbul ignore if */\n if (!acceptNegative && token.charAt(0) === \"-\")\n throw illegal(token, \"id\");\n\n if (base10NegRe.test(token))\n return parseInt(token, 10);\n if (base16NegRe.test(token))\n return parseInt(token, 16);\n\n /* istanbul ignore else */\n if (base8NegRe.test(token))\n return parseInt(token, 8);\n\n /* istanbul ignore next */\n throw illegal(token, \"id\");\n }\n\n function parsePackage() {\n\n /* istanbul ignore if */\n if (pkg !== undefined)\n throw illegal(\"package\");\n\n pkg = next();\n\n /* istanbul ignore if */\n if (!typeRefRe.test(pkg))\n throw illegal(pkg, \"name\");\n\n ptr = ptr.define(pkg);\n skip(\";\");\n }\n\n function parseImport() {\n var token = peek();\n var whichImports;\n switch (token) {\n case \"weak\":\n whichImports = weakImports || (weakImports = []);\n next();\n break;\n case \"public\":\n next();\n // eslint-disable-line no-fallthrough\n default:\n whichImports = imports || (imports = []);\n break;\n }\n token = readString();\n skip(\";\");\n whichImports.push(token);\n }\n\n function parseSyntax() {\n skip(\"=\");\n syntax = readString();\n isProto3 = syntax === \"proto3\";\n\n /* istanbul ignore if */\n if (!isProto3 && syntax !== \"proto2\")\n throw illegal(syntax, \"syntax\");\n\n skip(\";\");\n }\n\n function parseCommon(parent, token) {\n switch (token) {\n\n case \"option\":\n parseOption(parent, token);\n skip(\";\");\n return true;\n\n case \"message\":\n parseType(parent, token);\n return true;\n\n case \"enum\":\n parseEnum(parent, token);\n return true;\n\n case \"service\":\n parseService(parent, token);\n return true;\n\n case \"extend\":\n parseExtension(parent, token);\n return true;\n }\n return false;\n }\n\n function ifBlock(obj, fnIf, fnElse) {\n var trailingLine = tn.line;\n if (obj) {\n if(typeof obj.comment !== \"string\") {\n obj.comment = cmnt(); // try block-type comment\n }\n obj.filename = parse.filename;\n }\n if (skip(\"{\", true)) {\n var token;\n while ((token = next()) !== \"}\")\n fnIf(token);\n skip(\";\", true);\n } else {\n if (fnElse)\n fnElse();\n skip(\";\");\n if (obj && (typeof obj.comment !== \"string\" || preferTrailingComment))\n obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment\n }\n }\n\n function parseType(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"type name\");\n\n var type = new Type(token);\n ifBlock(type, function parseType_block(token) {\n if (parseCommon(type, token))\n return;\n\n switch (token) {\n\n case \"map\":\n parseMapField(type, token);\n break;\n\n case \"required\":\n case \"repeated\":\n parseField(type, token);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(type, \"proto3_optional\");\n } else {\n parseField(type, \"optional\");\n }\n break;\n\n case \"oneof\":\n parseOneOf(type, token);\n break;\n\n case \"extensions\":\n readRanges(type.extensions || (type.extensions = []));\n break;\n\n case \"reserved\":\n readRanges(type.reserved || (type.reserved = []), true);\n break;\n\n default:\n /* istanbul ignore if */\n if (!isProto3 || !typeRefRe.test(token))\n throw illegal(token);\n\n push(token);\n parseField(type, \"optional\");\n break;\n }\n });\n parent.add(type);\n }\n\n function parseField(parent, rule, extend) {\n var type = next();\n if (type === \"group\") {\n parseGroup(parent, rule);\n return;\n }\n\n /* istanbul ignore if */\n if (!typeRefRe.test(type))\n throw illegal(type, \"type\");\n\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n name = applyCase(name);\n skip(\"=\");\n\n var field = new Field(name, parseId(next()), type, rule, extend);\n ifBlock(field, function parseField_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(field, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseField_line() {\n parseInlineOptions(field);\n });\n\n if (rule === \"proto3_optional\") {\n // for proto3 optional fields, we create a single-member Oneof to mimic \"optional\" behavior\n var oneof = new OneOf(\"_\" + name);\n field.setOption(\"proto3_optional\", true);\n oneof.add(field);\n parent.add(oneof);\n } else {\n parent.add(field);\n }\n\n // JSON defaults to packed=true if not set so we have to set packed=false explicity when\n // parsing proto2 descriptors without the option, where applicable. This must be done for\n // all known packable types and anything that could be an enum (= is not a basic type).\n if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))\n field.setOption(\"packed\", false, /* ifNotSet */ true);\n }\n\n function parseGroup(parent, rule) {\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n var fieldName = util.lcFirst(name);\n if (name === fieldName)\n name = util.ucFirst(name);\n skip(\"=\");\n var id = parseId(next());\n var type = new Type(name);\n type.group = true;\n var field = new Field(fieldName, id, name, rule);\n field.filename = parse.filename;\n ifBlock(type, function parseGroup_block(token) {\n switch (token) {\n\n case \"option\":\n parseOption(type, token);\n skip(\";\");\n break;\n\n case \"required\":\n case \"repeated\":\n parseField(type, token);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(type, \"proto3_optional\");\n } else {\n parseField(type, \"optional\");\n }\n break;\n\n case \"message\":\n parseType(type, token);\n break;\n\n case \"enum\":\n parseEnum(type, token);\n break;\n\n /* istanbul ignore next */\n default:\n throw illegal(token); // there are no groups with proto3 semantics\n }\n });\n parent.add(type)\n .add(field);\n }\n\n function parseMapField(parent) {\n skip(\"<\");\n var keyType = next();\n\n /* istanbul ignore if */\n if (types.mapKey[keyType] === undefined)\n throw illegal(keyType, \"type\");\n\n skip(\",\");\n var valueType = next();\n\n /* istanbul ignore if */\n if (!typeRefRe.test(valueType))\n throw illegal(valueType, \"type\");\n\n skip(\">\");\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n skip(\"=\");\n var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);\n ifBlock(field, function parseMapField_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(field, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseMapField_line() {\n parseInlineOptions(field);\n });\n parent.add(field);\n }\n\n function parseOneOf(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var oneof = new OneOf(applyCase(token));\n ifBlock(oneof, function parseOneOf_block(token) {\n if (token === \"option\") {\n parseOption(oneof, token);\n skip(\";\");\n } else {\n push(token);\n parseField(oneof, \"optional\");\n }\n });\n parent.add(oneof);\n }\n\n function parseEnum(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var enm = new Enum(token);\n ifBlock(enm, function parseEnum_block(token) {\n switch(token) {\n case \"option\":\n parseOption(enm, token);\n skip(\";\");\n break;\n\n case \"reserved\":\n readRanges(enm.reserved || (enm.reserved = []), true);\n break;\n\n default:\n parseEnumValue(enm, token);\n }\n });\n parent.add(enm);\n }\n\n function parseEnumValue(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token))\n throw illegal(token, \"name\");\n\n skip(\"=\");\n var value = parseId(next(), true),\n dummy = {\n options: undefined\n };\n dummy.setOption = function(name, value) {\n if (this.options === undefined)\n this.options = {};\n this.options[name] = value;\n };\n ifBlock(dummy, function parseEnumValue_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(dummy, token); // skip\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseEnumValue_line() {\n parseInlineOptions(dummy); // skip\n });\n parent.add(token, value, dummy.comment, dummy.options);\n }\n\n function parseOption(parent, token) {\n var isCustom = skip(\"(\", true);\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var name = token;\n var option = name;\n var propName;\n\n if (isCustom) {\n skip(\")\");\n name = \"(\" + name + \")\";\n option = name;\n token = peek();\n if (fqTypeRefRe.test(token)) {\n propName = token.slice(1); //remove '.' before property name\n name += token;\n next();\n }\n }\n skip(\"=\");\n var optionValue = parseOptionValue(parent, name);\n setParsedOption(parent, option, optionValue, propName);\n }\n\n function parseOptionValue(parent, name) {\n // { a: \"foo\" b { c: \"bar\" } }\n if (skip(\"{\", true)) {\n var objectResult = {};\n\n while (!skip(\"}\", true)) {\n /* istanbul ignore if */\n if (!nameRe.test(token = next())) {\n throw illegal(token, \"name\");\n }\n\n var value;\n var propName = token;\n\n skip(\":\", true);\n\n if (peek() === \"{\")\n value = parseOptionValue(parent, name + \".\" + token);\n else if (peek() === \"[\") {\n // option (my_option) = {\n // repeated_value: [ \"foo\", \"bar\" ]\n // };\n value = [];\n var lastValue;\n if (skip(\"[\", true)) {\n do {\n lastValue = readValue(true);\n value.push(lastValue);\n } while (skip(\",\", true));\n skip(\"]\");\n if (typeof lastValue !== \"undefined\") {\n setOption(parent, name + \".\" + token, lastValue);\n }\n }\n } else {\n value = readValue(true);\n setOption(parent, name + \".\" + token, value);\n }\n\n var prevValue = objectResult[propName];\n\n if (prevValue)\n value = [].concat(prevValue).concat(value);\n\n objectResult[propName] = value;\n\n // Semicolons and commas can be optional\n skip(\",\", true);\n skip(\";\", true);\n }\n\n return objectResult;\n }\n\n var simpleValue = readValue(true);\n setOption(parent, name, simpleValue);\n return simpleValue;\n // Does not enforce a delimiter to be universal\n }\n\n function setOption(parent, name, value) {\n if (parent.setOption)\n parent.setOption(name, value);\n }\n\n function setParsedOption(parent, name, value, propName) {\n if (parent.setParsedOption)\n parent.setParsedOption(name, value, propName);\n }\n\n function parseInlineOptions(parent) {\n if (skip(\"[\", true)) {\n do {\n parseOption(parent, \"option\");\n } while (skip(\",\", true));\n skip(\"]\");\n }\n return parent;\n }\n\n function parseService(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"service name\");\n\n var service = new Service(token);\n ifBlock(service, function parseService_block(token) {\n if (parseCommon(service, token))\n return;\n\n /* istanbul ignore else */\n if (token === \"rpc\")\n parseMethod(service, token);\n else\n throw illegal(token);\n });\n parent.add(service);\n }\n\n function parseMethod(parent, token) {\n // Get the comment of the preceding line now (if one exists) in case the\n // method is defined across multiple lines.\n var commentText = cmnt();\n\n var type = token;\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var name = token,\n requestType, requestStream,\n responseType, responseStream;\n\n skip(\"(\");\n if (skip(\"stream\", true))\n requestStream = true;\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token);\n\n requestType = token;\n skip(\")\"); skip(\"returns\"); skip(\"(\");\n if (skip(\"stream\", true))\n responseStream = true;\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token);\n\n responseType = token;\n skip(\")\");\n\n var method = new Method(name, type, requestType, responseType, requestStream, responseStream);\n method.comment = commentText;\n ifBlock(method, function parseMethod_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(method, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n });\n parent.add(method);\n }\n\n function parseExtension(parent, token) {\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token, \"reference\");\n\n var reference = token;\n ifBlock(null, function parseExtension_block(token) {\n switch (token) {\n\n case \"required\":\n case \"repeated\":\n parseField(parent, token, reference);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(parent, \"proto3_optional\", reference);\n } else {\n parseField(parent, \"optional\", reference);\n }\n break;\n\n default:\n /* istanbul ignore if */\n if (!isProto3 || !typeRefRe.test(token))\n throw illegal(token);\n push(token);\n parseField(parent, \"optional\", reference);\n break;\n }\n });\n }\n\n var token;\n while ((token = next()) !== null) {\n switch (token) {\n\n case \"package\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parsePackage();\n break;\n\n case \"import\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parseImport();\n break;\n\n case \"syntax\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parseSyntax();\n break;\n\n case \"option\":\n\n parseOption(ptr, token);\n skip(\";\");\n break;\n\n default:\n\n /* istanbul ignore else */\n if (parseCommon(ptr, token)) {\n head = false;\n continue;\n }\n\n /* istanbul ignore next */\n throw illegal(token);\n }\n }\n\n parse.filename = null;\n return {\n \"package\" : pkg,\n \"imports\" : imports,\n weakImports : weakImports,\n syntax : syntax,\n root : root\n };\n}\n\n/**\n * Parses the given .proto source and returns an object with the parsed contents.\n * @name parse\n * @function\n * @param {string} source Source contents\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {IParserResult} Parser result\n * @property {string} filename=null Currently processing file name for error reporting, if known\n * @property {IParseOptions} defaults Default {@link IParseOptions}\n * @variation 2\n */\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protobufjs/src/parse.js?"); +eval("\nmodule.exports = parse;\n\nparse.filename = null;\nparse.defaults = { keepCase: false };\n\nvar tokenize = __webpack_require__(/*! ./tokenize */ \"./node_modules/protobufjs/src/tokenize.js\"),\n Root = __webpack_require__(/*! ./root */ \"./node_modules/protobufjs/src/root.js\"),\n Type = __webpack_require__(/*! ./type */ \"./node_modules/protobufjs/src/type.js\"),\n Field = __webpack_require__(/*! ./field */ \"./node_modules/protobufjs/src/field.js\"),\n MapField = __webpack_require__(/*! ./mapfield */ \"./node_modules/protobufjs/src/mapfield.js\"),\n OneOf = __webpack_require__(/*! ./oneof */ \"./node_modules/protobufjs/src/oneof.js\"),\n Enum = __webpack_require__(/*! ./enum */ \"./node_modules/protobufjs/src/enum.js\"),\n Service = __webpack_require__(/*! ./service */ \"./node_modules/protobufjs/src/service.js\"),\n Method = __webpack_require__(/*! ./method */ \"./node_modules/protobufjs/src/method.js\"),\n types = __webpack_require__(/*! ./types */ \"./node_modules/protobufjs/src/types.js\"),\n util = __webpack_require__(/*! ./util */ \"./node_modules/protobufjs/src/util.js\");\n\nvar base10Re = /^[1-9][0-9]*$/,\n base10NegRe = /^-?[1-9][0-9]*$/,\n base16Re = /^0[x][0-9a-fA-F]+$/,\n base16NegRe = /^-?0[x][0-9a-fA-F]+$/,\n base8Re = /^0[0-7]+$/,\n base8NegRe = /^-?0[0-7]+$/,\n numberRe = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,\n nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,\n typeRefRe = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,\n fqTypeRefRe = /^(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;\n\n/**\n * Result object returned from {@link parse}.\n * @interface IParserResult\n * @property {string|undefined} package Package name, if declared\n * @property {string[]|undefined} imports Imports, if any\n * @property {string[]|undefined} weakImports Weak imports, if any\n * @property {string|undefined} syntax Syntax, if specified (either `\"proto2\"` or `\"proto3\"`)\n * @property {Root} root Populated root instance\n */\n\n/**\n * Options modifying the behavior of {@link parse}.\n * @interface IParseOptions\n * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case\n * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.\n * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.\n */\n\n/**\n * Options modifying the behavior of JSON serialization.\n * @interface IToJSONOptions\n * @property {boolean} [keepComments=false] Serializes comments.\n */\n\n/**\n * Parses the given .proto source and returns an object with the parsed contents.\n * @param {string} source Source contents\n * @param {Root} root Root to populate\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {IParserResult} Parser result\n * @property {string} filename=null Currently processing file name for error reporting, if known\n * @property {IParseOptions} defaults Default {@link IParseOptions}\n */\nfunction parse(source, root, options) {\n /* eslint-disable callback-return */\n if (!(root instanceof Root)) {\n options = root;\n root = new Root();\n }\n if (!options)\n options = parse.defaults;\n\n var preferTrailingComment = options.preferTrailingComment || false;\n var tn = tokenize(source, options.alternateCommentMode || false),\n next = tn.next,\n push = tn.push,\n peek = tn.peek,\n skip = tn.skip,\n cmnt = tn.cmnt;\n\n var head = true,\n pkg,\n imports,\n weakImports,\n syntax,\n isProto3 = false;\n\n var ptr = root;\n\n var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;\n\n /* istanbul ignore next */\n function illegal(token, name, insideTryCatch) {\n var filename = parse.filename;\n if (!insideTryCatch)\n parse.filename = null;\n return Error(\"illegal \" + (name || \"token\") + \" '\" + token + \"' (\" + (filename ? filename + \", \" : \"\") + \"line \" + tn.line + \")\");\n }\n\n function readString() {\n var values = [],\n token;\n do {\n /* istanbul ignore if */\n if ((token = next()) !== \"\\\"\" && token !== \"'\")\n throw illegal(token);\n\n values.push(next());\n skip(token);\n token = peek();\n } while (token === \"\\\"\" || token === \"'\");\n return values.join(\"\");\n }\n\n function readValue(acceptTypeRef) {\n var token = next();\n switch (token) {\n case \"'\":\n case \"\\\"\":\n push(token);\n return readString();\n case \"true\": case \"TRUE\":\n return true;\n case \"false\": case \"FALSE\":\n return false;\n }\n try {\n return parseNumber(token, /* insideTryCatch */ true);\n } catch (e) {\n\n /* istanbul ignore else */\n if (acceptTypeRef && typeRefRe.test(token))\n return token;\n\n /* istanbul ignore next */\n throw illegal(token, \"value\");\n }\n }\n\n function readRanges(target, acceptStrings) {\n var token, start;\n do {\n if (acceptStrings && ((token = peek()) === \"\\\"\" || token === \"'\"))\n target.push(readString());\n else\n target.push([ start = parseId(next()), skip(\"to\", true) ? parseId(next()) : start ]);\n } while (skip(\",\", true));\n skip(\";\");\n }\n\n function parseNumber(token, insideTryCatch) {\n var sign = 1;\n if (token.charAt(0) === \"-\") {\n sign = -1;\n token = token.substring(1);\n }\n switch (token) {\n case \"inf\": case \"INF\": case \"Inf\":\n return sign * Infinity;\n case \"nan\": case \"NAN\": case \"Nan\": case \"NaN\":\n return NaN;\n case \"0\":\n return 0;\n }\n if (base10Re.test(token))\n return sign * parseInt(token, 10);\n if (base16Re.test(token))\n return sign * parseInt(token, 16);\n if (base8Re.test(token))\n return sign * parseInt(token, 8);\n\n /* istanbul ignore else */\n if (numberRe.test(token))\n return sign * parseFloat(token);\n\n /* istanbul ignore next */\n throw illegal(token, \"number\", insideTryCatch);\n }\n\n function parseId(token, acceptNegative) {\n switch (token) {\n case \"max\": case \"MAX\": case \"Max\":\n return 536870911;\n case \"0\":\n return 0;\n }\n\n /* istanbul ignore if */\n if (!acceptNegative && token.charAt(0) === \"-\")\n throw illegal(token, \"id\");\n\n if (base10NegRe.test(token))\n return parseInt(token, 10);\n if (base16NegRe.test(token))\n return parseInt(token, 16);\n\n /* istanbul ignore else */\n if (base8NegRe.test(token))\n return parseInt(token, 8);\n\n /* istanbul ignore next */\n throw illegal(token, \"id\");\n }\n\n function parsePackage() {\n\n /* istanbul ignore if */\n if (pkg !== undefined)\n throw illegal(\"package\");\n\n pkg = next();\n\n /* istanbul ignore if */\n if (!typeRefRe.test(pkg))\n throw illegal(pkg, \"name\");\n\n ptr = ptr.define(pkg);\n skip(\";\");\n }\n\n function parseImport() {\n var token = peek();\n var whichImports;\n switch (token) {\n case \"weak\":\n whichImports = weakImports || (weakImports = []);\n next();\n break;\n case \"public\":\n next();\n // eslint-disable-line no-fallthrough\n default:\n whichImports = imports || (imports = []);\n break;\n }\n token = readString();\n skip(\";\");\n whichImports.push(token);\n }\n\n function parseSyntax() {\n skip(\"=\");\n syntax = readString();\n isProto3 = syntax === \"proto3\";\n\n /* istanbul ignore if */\n if (!isProto3 && syntax !== \"proto2\")\n throw illegal(syntax, \"syntax\");\n\n skip(\";\");\n }\n\n function parseCommon(parent, token) {\n switch (token) {\n\n case \"option\":\n parseOption(parent, token);\n skip(\";\");\n return true;\n\n case \"message\":\n parseType(parent, token);\n return true;\n\n case \"enum\":\n parseEnum(parent, token);\n return true;\n\n case \"service\":\n parseService(parent, token);\n return true;\n\n case \"extend\":\n parseExtension(parent, token);\n return true;\n }\n return false;\n }\n\n function ifBlock(obj, fnIf, fnElse) {\n var trailingLine = tn.line;\n if (obj) {\n if(typeof obj.comment !== \"string\") {\n obj.comment = cmnt(); // try block-type comment\n }\n obj.filename = parse.filename;\n }\n if (skip(\"{\", true)) {\n var token;\n while ((token = next()) !== \"}\")\n fnIf(token);\n skip(\";\", true);\n } else {\n if (fnElse)\n fnElse();\n skip(\";\");\n if (obj && (typeof obj.comment !== \"string\" || preferTrailingComment))\n obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment\n }\n }\n\n function parseType(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"type name\");\n\n var type = new Type(token);\n ifBlock(type, function parseType_block(token) {\n if (parseCommon(type, token))\n return;\n\n switch (token) {\n\n case \"map\":\n parseMapField(type, token);\n break;\n\n case \"required\":\n case \"repeated\":\n parseField(type, token);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(type, \"proto3_optional\");\n } else {\n parseField(type, \"optional\");\n }\n break;\n\n case \"oneof\":\n parseOneOf(type, token);\n break;\n\n case \"extensions\":\n readRanges(type.extensions || (type.extensions = []));\n break;\n\n case \"reserved\":\n readRanges(type.reserved || (type.reserved = []), true);\n break;\n\n default:\n /* istanbul ignore if */\n if (!isProto3 || !typeRefRe.test(token))\n throw illegal(token);\n\n push(token);\n parseField(type, \"optional\");\n break;\n }\n });\n parent.add(type);\n }\n\n function parseField(parent, rule, extend) {\n var type = next();\n if (type === \"group\") {\n parseGroup(parent, rule);\n return;\n }\n // Type names can consume multiple tokens, in multiple variants:\n // package.subpackage field tokens: \"package.subpackage\" [TYPE NAME ENDS HERE] \"field\"\n // package . subpackage field tokens: \"package\" \".\" \"subpackage\" [TYPE NAME ENDS HERE] \"field\"\n // package. subpackage field tokens: \"package.\" \"subpackage\" [TYPE NAME ENDS HERE] \"field\"\n // package .subpackage field tokens: \"package\" \".subpackage\" [TYPE NAME ENDS HERE] \"field\"\n // Keep reading tokens until we get a type name with no period at the end,\n // and the next token does not start with a period.\n while (type.endsWith(\".\") || peek().startsWith(\".\")) {\n type += next();\n }\n\n /* istanbul ignore if */\n if (!typeRefRe.test(type))\n throw illegal(type, \"type\");\n\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n name = applyCase(name);\n skip(\"=\");\n\n var field = new Field(name, parseId(next()), type, rule, extend);\n ifBlock(field, function parseField_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(field, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseField_line() {\n parseInlineOptions(field);\n });\n\n if (rule === \"proto3_optional\") {\n // for proto3 optional fields, we create a single-member Oneof to mimic \"optional\" behavior\n var oneof = new OneOf(\"_\" + name);\n field.setOption(\"proto3_optional\", true);\n oneof.add(field);\n parent.add(oneof);\n } else {\n parent.add(field);\n }\n\n // JSON defaults to packed=true if not set so we have to set packed=false explicity when\n // parsing proto2 descriptors without the option, where applicable. This must be done for\n // all known packable types and anything that could be an enum (= is not a basic type).\n if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))\n field.setOption(\"packed\", false, /* ifNotSet */ true);\n }\n\n function parseGroup(parent, rule) {\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n var fieldName = util.lcFirst(name);\n if (name === fieldName)\n name = util.ucFirst(name);\n skip(\"=\");\n var id = parseId(next());\n var type = new Type(name);\n type.group = true;\n var field = new Field(fieldName, id, name, rule);\n field.filename = parse.filename;\n ifBlock(type, function parseGroup_block(token) {\n switch (token) {\n\n case \"option\":\n parseOption(type, token);\n skip(\";\");\n break;\n\n case \"required\":\n case \"repeated\":\n parseField(type, token);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(type, \"proto3_optional\");\n } else {\n parseField(type, \"optional\");\n }\n break;\n\n case \"message\":\n parseType(type, token);\n break;\n\n case \"enum\":\n parseEnum(type, token);\n break;\n\n /* istanbul ignore next */\n default:\n throw illegal(token); // there are no groups with proto3 semantics\n }\n });\n parent.add(type)\n .add(field);\n }\n\n function parseMapField(parent) {\n skip(\"<\");\n var keyType = next();\n\n /* istanbul ignore if */\n if (types.mapKey[keyType] === undefined)\n throw illegal(keyType, \"type\");\n\n skip(\",\");\n var valueType = next();\n\n /* istanbul ignore if */\n if (!typeRefRe.test(valueType))\n throw illegal(valueType, \"type\");\n\n skip(\">\");\n var name = next();\n\n /* istanbul ignore if */\n if (!nameRe.test(name))\n throw illegal(name, \"name\");\n\n skip(\"=\");\n var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);\n ifBlock(field, function parseMapField_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(field, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseMapField_line() {\n parseInlineOptions(field);\n });\n parent.add(field);\n }\n\n function parseOneOf(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var oneof = new OneOf(applyCase(token));\n ifBlock(oneof, function parseOneOf_block(token) {\n if (token === \"option\") {\n parseOption(oneof, token);\n skip(\";\");\n } else {\n push(token);\n parseField(oneof, \"optional\");\n }\n });\n parent.add(oneof);\n }\n\n function parseEnum(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var enm = new Enum(token);\n ifBlock(enm, function parseEnum_block(token) {\n switch(token) {\n case \"option\":\n parseOption(enm, token);\n skip(\";\");\n break;\n\n case \"reserved\":\n readRanges(enm.reserved || (enm.reserved = []), true);\n break;\n\n default:\n parseEnumValue(enm, token);\n }\n });\n parent.add(enm);\n }\n\n function parseEnumValue(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token))\n throw illegal(token, \"name\");\n\n skip(\"=\");\n var value = parseId(next(), true),\n dummy = {\n options: undefined\n };\n dummy.setOption = function(name, value) {\n if (this.options === undefined)\n this.options = {};\n this.options[name] = value;\n };\n ifBlock(dummy, function parseEnumValue_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(dummy, token); // skip\n skip(\";\");\n } else\n throw illegal(token);\n\n }, function parseEnumValue_line() {\n parseInlineOptions(dummy); // skip\n });\n parent.add(token, value, dummy.comment, dummy.options);\n }\n\n function parseOption(parent, token) {\n var isCustom = skip(\"(\", true);\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var name = token;\n var option = name;\n var propName;\n\n if (isCustom) {\n skip(\")\");\n name = \"(\" + name + \")\";\n option = name;\n token = peek();\n if (fqTypeRefRe.test(token)) {\n propName = token.slice(1); //remove '.' before property name\n name += token;\n next();\n }\n }\n skip(\"=\");\n var optionValue = parseOptionValue(parent, name);\n setParsedOption(parent, option, optionValue, propName);\n }\n\n function parseOptionValue(parent, name) {\n // { a: \"foo\" b { c: \"bar\" } }\n if (skip(\"{\", true)) {\n var objectResult = {};\n\n while (!skip(\"}\", true)) {\n /* istanbul ignore if */\n if (!nameRe.test(token = next())) {\n throw illegal(token, \"name\");\n }\n\n var value;\n var propName = token;\n\n skip(\":\", true);\n\n if (peek() === \"{\")\n value = parseOptionValue(parent, name + \".\" + token);\n else if (peek() === \"[\") {\n // option (my_option) = {\n // repeated_value: [ \"foo\", \"bar\" ]\n // };\n value = [];\n var lastValue;\n if (skip(\"[\", true)) {\n do {\n lastValue = readValue(true);\n value.push(lastValue);\n } while (skip(\",\", true));\n skip(\"]\");\n if (typeof lastValue !== \"undefined\") {\n setOption(parent, name + \".\" + token, lastValue);\n }\n }\n } else {\n value = readValue(true);\n setOption(parent, name + \".\" + token, value);\n }\n\n var prevValue = objectResult[propName];\n\n if (prevValue)\n value = [].concat(prevValue).concat(value);\n\n objectResult[propName] = value;\n\n // Semicolons and commas can be optional\n skip(\",\", true);\n skip(\";\", true);\n }\n\n return objectResult;\n }\n\n var simpleValue = readValue(true);\n setOption(parent, name, simpleValue);\n return simpleValue;\n // Does not enforce a delimiter to be universal\n }\n\n function setOption(parent, name, value) {\n if (parent.setOption)\n parent.setOption(name, value);\n }\n\n function setParsedOption(parent, name, value, propName) {\n if (parent.setParsedOption)\n parent.setParsedOption(name, value, propName);\n }\n\n function parseInlineOptions(parent) {\n if (skip(\"[\", true)) {\n do {\n parseOption(parent, \"option\");\n } while (skip(\",\", true));\n skip(\"]\");\n }\n return parent;\n }\n\n function parseService(parent, token) {\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"service name\");\n\n var service = new Service(token);\n ifBlock(service, function parseService_block(token) {\n if (parseCommon(service, token))\n return;\n\n /* istanbul ignore else */\n if (token === \"rpc\")\n parseMethod(service, token);\n else\n throw illegal(token);\n });\n parent.add(service);\n }\n\n function parseMethod(parent, token) {\n // Get the comment of the preceding line now (if one exists) in case the\n // method is defined across multiple lines.\n var commentText = cmnt();\n\n var type = token;\n\n /* istanbul ignore if */\n if (!nameRe.test(token = next()))\n throw illegal(token, \"name\");\n\n var name = token,\n requestType, requestStream,\n responseType, responseStream;\n\n skip(\"(\");\n if (skip(\"stream\", true))\n requestStream = true;\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token);\n\n requestType = token;\n skip(\")\"); skip(\"returns\"); skip(\"(\");\n if (skip(\"stream\", true))\n responseStream = true;\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token);\n\n responseType = token;\n skip(\")\");\n\n var method = new Method(name, type, requestType, responseType, requestStream, responseStream);\n method.comment = commentText;\n ifBlock(method, function parseMethod_block(token) {\n\n /* istanbul ignore else */\n if (token === \"option\") {\n parseOption(method, token);\n skip(\";\");\n } else\n throw illegal(token);\n\n });\n parent.add(method);\n }\n\n function parseExtension(parent, token) {\n\n /* istanbul ignore if */\n if (!typeRefRe.test(token = next()))\n throw illegal(token, \"reference\");\n\n var reference = token;\n ifBlock(null, function parseExtension_block(token) {\n switch (token) {\n\n case \"required\":\n case \"repeated\":\n parseField(parent, token, reference);\n break;\n\n case \"optional\":\n /* istanbul ignore if */\n if (isProto3) {\n parseField(parent, \"proto3_optional\", reference);\n } else {\n parseField(parent, \"optional\", reference);\n }\n break;\n\n default:\n /* istanbul ignore if */\n if (!isProto3 || !typeRefRe.test(token))\n throw illegal(token);\n push(token);\n parseField(parent, \"optional\", reference);\n break;\n }\n });\n }\n\n var token;\n while ((token = next()) !== null) {\n switch (token) {\n\n case \"package\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parsePackage();\n break;\n\n case \"import\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parseImport();\n break;\n\n case \"syntax\":\n\n /* istanbul ignore if */\n if (!head)\n throw illegal(token);\n\n parseSyntax();\n break;\n\n case \"option\":\n\n parseOption(ptr, token);\n skip(\";\");\n break;\n\n default:\n\n /* istanbul ignore else */\n if (parseCommon(ptr, token)) {\n head = false;\n continue;\n }\n\n /* istanbul ignore next */\n throw illegal(token);\n }\n }\n\n parse.filename = null;\n return {\n \"package\" : pkg,\n \"imports\" : imports,\n weakImports : weakImports,\n syntax : syntax,\n root : root\n };\n}\n\n/**\n * Parses the given .proto source and returns an object with the parsed contents.\n * @name parse\n * @function\n * @param {string} source Source contents\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {IParserResult} Parser result\n * @property {string} filename=null Currently processing file name for error reporting, if known\n * @property {IParseOptions} defaults Default {@link IParseOptions}\n * @variation 2\n */\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protobufjs/src/parse.js?"); /***/ }), @@ -1457,7 +1325,7 @@ eval("\nmodule.exports = BufferReader;\n\n// extends Reader\nvar Reader = __webp /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; -eval("\nmodule.exports = Root;\n\n// extends Namespace\nvar Namespace = __webpack_require__(/*! ./namespace */ \"./node_modules/protobufjs/src/namespace.js\");\n((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = \"Root\";\n\nvar Field = __webpack_require__(/*! ./field */ \"./node_modules/protobufjs/src/field.js\"),\n Enum = __webpack_require__(/*! ./enum */ \"./node_modules/protobufjs/src/enum.js\"),\n OneOf = __webpack_require__(/*! ./oneof */ \"./node_modules/protobufjs/src/oneof.js\"),\n util = __webpack_require__(/*! ./util */ \"./node_modules/protobufjs/src/util.js\");\n\nvar Type, // cyclic\n parse, // might be excluded\n common; // \"\n\n/**\n * Constructs a new root namespace instance.\n * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together.\n * @extends NamespaceBase\n * @constructor\n * @param {Object.} [options] Top level options\n */\nfunction Root(options) {\n Namespace.call(this, \"\", options);\n\n /**\n * Deferred extension fields.\n * @type {Field[]}\n */\n this.deferred = [];\n\n /**\n * Resolved file names of loaded files.\n * @type {string[]}\n */\n this.files = [];\n}\n\n/**\n * Loads a namespace descriptor into a root namespace.\n * @param {INamespace} json Nameespace descriptor\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted\n * @returns {Root} Root namespace\n */\nRoot.fromJSON = function fromJSON(json, root) {\n if (!root)\n root = new Root();\n if (json.options)\n root.setOptions(json.options);\n return root.addJSON(json.nested);\n};\n\n/**\n * Resolves the path of an imported file, relative to the importing origin.\n * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.\n * @function\n * @param {string} origin The file name of the importing file\n * @param {string} target The file name being imported\n * @returns {string|null} Resolved path to `target` or `null` to skip the file\n */\nRoot.prototype.resolvePath = util.path.resolve;\n\n/**\n * Fetch content from file path or url\n * This method exists so you can override it with your own logic.\n * @function\n * @param {string} path File path or url\n * @param {FetchCallback} callback Callback function\n * @returns {undefined}\n */\nRoot.prototype.fetch = util.fetch;\n\n// A symbol-like function to safely signal synchronous loading\n/* istanbul ignore next */\nfunction SYNC() {} // eslint-disable-line no-empty-function\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} options Parse options\n * @param {LoadCallback} callback Callback function\n * @returns {undefined}\n */\nRoot.prototype.load = function load(filename, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = undefined;\n }\n var self = this;\n if (!callback)\n return util.asPromise(load, self, filename, options);\n\n var sync = callback === SYNC; // undocumented\n\n // Finishes loading by calling the callback (exactly once)\n function finish(err, root) {\n /* istanbul ignore if */\n if (!callback)\n return;\n var cb = callback;\n callback = null;\n if (sync)\n throw err;\n cb(err, root);\n }\n\n // Bundled definition existence checking\n function getBundledFileName(filename) {\n var idx = filename.lastIndexOf(\"google/protobuf/\");\n if (idx > -1) {\n var altname = filename.substring(idx);\n if (altname in common) return altname;\n }\n return null;\n }\n\n // Processes a single file\n function process(filename, source) {\n try {\n if (util.isString(source) && source.charAt(0) === \"{\")\n source = JSON.parse(source);\n if (!util.isString(source))\n self.setOptions(source.options).addJSON(source.nested);\n else {\n parse.filename = filename;\n var parsed = parse(source, self, options),\n resolved,\n i = 0;\n if (parsed.imports)\n for (; i < parsed.imports.length; ++i)\n if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))\n fetch(resolved);\n if (parsed.weakImports)\n for (i = 0; i < parsed.weakImports.length; ++i)\n if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))\n fetch(resolved, true);\n }\n } catch (err) {\n finish(err);\n }\n if (!sync && !queued)\n finish(null, self); // only once anyway\n }\n\n // Fetches a single file\n function fetch(filename, weak) {\n\n // Skip if already loaded / attempted\n if (self.files.indexOf(filename) > -1)\n return;\n self.files.push(filename);\n\n // Shortcut bundled definitions\n if (filename in common) {\n if (sync)\n process(filename, common[filename]);\n else {\n ++queued;\n setTimeout(function() {\n --queued;\n process(filename, common[filename]);\n });\n }\n return;\n }\n\n // Otherwise fetch from disk or network\n if (sync) {\n var source;\n try {\n source = util.fs.readFileSync(filename).toString(\"utf8\");\n } catch (err) {\n if (!weak)\n finish(err);\n return;\n }\n process(filename, source);\n } else {\n ++queued;\n self.fetch(filename, function(err, source) {\n --queued;\n /* istanbul ignore if */\n if (!callback)\n return; // terminated meanwhile\n if (err) {\n /* istanbul ignore else */\n if (!weak)\n finish(err);\n else if (!queued) // can't be covered reliably\n finish(null, self);\n return;\n }\n process(filename, source);\n });\n }\n }\n var queued = 0;\n\n // Assembling the root namespace doesn't require working type\n // references anymore, so we can load everything in parallel\n if (util.isString(filename))\n filename = [ filename ];\n for (var i = 0, resolved; i < filename.length; ++i)\n if (resolved = self.resolvePath(\"\", filename[i]))\n fetch(resolved);\n\n if (sync)\n return self;\n if (!queued)\n finish(null, self);\n return undefined;\n};\n// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\n * @function Root#load\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {LoadCallback} callback Callback function\n * @returns {undefined}\n * @variation 2\n */\n// function load(filename:string, callback:LoadCallback):undefined\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.\n * @function Root#load\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {Promise} Promise\n * @variation 3\n */\n// function load(filename:string, [options:IParseOptions]):Promise\n\n/**\n * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).\n * @function Root#loadSync\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {Root} Root namespace\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\n */\nRoot.prototype.loadSync = function loadSync(filename, options) {\n if (!util.isNode)\n throw Error(\"not supported\");\n return this.load(filename, options, SYNC);\n};\n\n/**\n * @override\n */\nRoot.prototype.resolveAll = function resolveAll() {\n if (this.deferred.length)\n throw Error(\"unresolvable extensions: \" + this.deferred.map(function(field) {\n return \"'extend \" + field.extend + \"' in \" + field.parent.fullName;\n }).join(\", \"));\n return Namespace.prototype.resolveAll.call(this);\n};\n\n// only uppercased (and thus conflict-free) children are exposed, see below\nvar exposeRe = /^[A-Z]/;\n\n/**\n * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.\n * @param {Root} root Root instance\n * @param {Field} field Declaring extension field witin the declaring type\n * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise\n * @inner\n * @ignore\n */\nfunction tryHandleExtension(root, field) {\n var extendedType = field.parent.lookup(field.extend);\n if (extendedType) {\n var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);\n sisterField.declaringField = field;\n field.extensionField = sisterField;\n extendedType.add(sisterField);\n return true;\n }\n return false;\n}\n\n/**\n * Called when any object is added to this root or its sub-namespaces.\n * @param {ReflectionObject} object Object added\n * @returns {undefined}\n * @private\n */\nRoot.prototype._handleAdd = function _handleAdd(object) {\n if (object instanceof Field) {\n\n if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField)\n if (!tryHandleExtension(this, object))\n this.deferred.push(object);\n\n } else if (object instanceof Enum) {\n\n if (exposeRe.test(object.name))\n object.parent[object.name] = object.values; // expose enum values as property of its parent\n\n } else if (!(object instanceof OneOf)) /* everything else is a namespace */ {\n\n if (object instanceof Type) // Try to handle any deferred extensions\n for (var i = 0; i < this.deferred.length;)\n if (tryHandleExtension(this, this.deferred[i]))\n this.deferred.splice(i, 1);\n else\n ++i;\n for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace\n this._handleAdd(object._nestedArray[j]);\n if (exposeRe.test(object.name))\n object.parent[object.name] = object; // expose namespace as property of its parent\n }\n\n // The above also adds uppercased (and thus conflict-free) nested types, services and enums as\n // properties of namespaces just like static code does. This allows using a .d.ts generated for\n // a static module with reflection-based solutions where the condition is met.\n};\n\n/**\n * Called when any object is removed from this root or its sub-namespaces.\n * @param {ReflectionObject} object Object removed\n * @returns {undefined}\n * @private\n */\nRoot.prototype._handleRemove = function _handleRemove(object) {\n if (object instanceof Field) {\n\n if (/* an extension field */ object.extend !== undefined) {\n if (/* already handled */ object.extensionField) { // remove its sister field\n object.extensionField.parent.remove(object.extensionField);\n object.extensionField = null;\n } else { // cancel the extension\n var index = this.deferred.indexOf(object);\n /* istanbul ignore else */\n if (index > -1)\n this.deferred.splice(index, 1);\n }\n }\n\n } else if (object instanceof Enum) {\n\n if (exposeRe.test(object.name))\n delete object.parent[object.name]; // unexpose enum values\n\n } else if (object instanceof Namespace) {\n\n for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace\n this._handleRemove(object._nestedArray[i]);\n\n if (exposeRe.test(object.name))\n delete object.parent[object.name]; // unexpose namespaces\n\n }\n};\n\n// Sets up cyclic dependencies (called in index-light)\nRoot._configure = function(Type_, parse_, common_) {\n Type = Type_;\n parse = parse_;\n common = common_;\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protobufjs/src/root.js?"); +eval("\nmodule.exports = Root;\n\n// extends Namespace\nvar Namespace = __webpack_require__(/*! ./namespace */ \"./node_modules/protobufjs/src/namespace.js\");\n((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = \"Root\";\n\nvar Field = __webpack_require__(/*! ./field */ \"./node_modules/protobufjs/src/field.js\"),\n Enum = __webpack_require__(/*! ./enum */ \"./node_modules/protobufjs/src/enum.js\"),\n OneOf = __webpack_require__(/*! ./oneof */ \"./node_modules/protobufjs/src/oneof.js\"),\n util = __webpack_require__(/*! ./util */ \"./node_modules/protobufjs/src/util.js\");\n\nvar Type, // cyclic\n parse, // might be excluded\n common; // \"\n\n/**\n * Constructs a new root namespace instance.\n * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together.\n * @extends NamespaceBase\n * @constructor\n * @param {Object.} [options] Top level options\n */\nfunction Root(options) {\n Namespace.call(this, \"\", options);\n\n /**\n * Deferred extension fields.\n * @type {Field[]}\n */\n this.deferred = [];\n\n /**\n * Resolved file names of loaded files.\n * @type {string[]}\n */\n this.files = [];\n}\n\n/**\n * Loads a namespace descriptor into a root namespace.\n * @param {INamespace} json Nameespace descriptor\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted\n * @returns {Root} Root namespace\n */\nRoot.fromJSON = function fromJSON(json, root) {\n if (!root)\n root = new Root();\n if (json.options)\n root.setOptions(json.options);\n return root.addJSON(json.nested);\n};\n\n/**\n * Resolves the path of an imported file, relative to the importing origin.\n * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.\n * @function\n * @param {string} origin The file name of the importing file\n * @param {string} target The file name being imported\n * @returns {string|null} Resolved path to `target` or `null` to skip the file\n */\nRoot.prototype.resolvePath = util.path.resolve;\n\n/**\n * Fetch content from file path or url\n * This method exists so you can override it with your own logic.\n * @function\n * @param {string} path File path or url\n * @param {FetchCallback} callback Callback function\n * @returns {undefined}\n */\nRoot.prototype.fetch = util.fetch;\n\n// A symbol-like function to safely signal synchronous loading\n/* istanbul ignore next */\nfunction SYNC() {} // eslint-disable-line no-empty-function\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} options Parse options\n * @param {LoadCallback} callback Callback function\n * @returns {undefined}\n */\nRoot.prototype.load = function load(filename, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = undefined;\n }\n var self = this;\n if (!callback)\n return util.asPromise(load, self, filename, options);\n\n var sync = callback === SYNC; // undocumented\n\n // Finishes loading by calling the callback (exactly once)\n function finish(err, root) {\n /* istanbul ignore if */\n if (!callback)\n return;\n var cb = callback;\n callback = null;\n if (sync)\n throw err;\n cb(err, root);\n }\n\n // Bundled definition existence checking\n function getBundledFileName(filename) {\n var idx = filename.lastIndexOf(\"google/protobuf/\");\n if (idx > -1) {\n var altname = filename.substring(idx);\n if (altname in common) return altname;\n }\n return null;\n }\n\n // Processes a single file\n function process(filename, source) {\n try {\n if (util.isString(source) && source.charAt(0) === \"{\")\n source = JSON.parse(source);\n if (!util.isString(source))\n self.setOptions(source.options).addJSON(source.nested);\n else {\n parse.filename = filename;\n var parsed = parse(source, self, options),\n resolved,\n i = 0;\n if (parsed.imports)\n for (; i < parsed.imports.length; ++i)\n if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))\n fetch(resolved);\n if (parsed.weakImports)\n for (i = 0; i < parsed.weakImports.length; ++i)\n if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))\n fetch(resolved, true);\n }\n } catch (err) {\n finish(err);\n }\n if (!sync && !queued)\n finish(null, self); // only once anyway\n }\n\n // Fetches a single file\n function fetch(filename, weak) {\n filename = getBundledFileName(filename) || filename;\n\n // Skip if already loaded / attempted\n if (self.files.indexOf(filename) > -1)\n return;\n self.files.push(filename);\n\n // Shortcut bundled definitions\n if (filename in common) {\n if (sync)\n process(filename, common[filename]);\n else {\n ++queued;\n setTimeout(function() {\n --queued;\n process(filename, common[filename]);\n });\n }\n return;\n }\n\n // Otherwise fetch from disk or network\n if (sync) {\n var source;\n try {\n source = util.fs.readFileSync(filename).toString(\"utf8\");\n } catch (err) {\n if (!weak)\n finish(err);\n return;\n }\n process(filename, source);\n } else {\n ++queued;\n self.fetch(filename, function(err, source) {\n --queued;\n /* istanbul ignore if */\n if (!callback)\n return; // terminated meanwhile\n if (err) {\n /* istanbul ignore else */\n if (!weak)\n finish(err);\n else if (!queued) // can't be covered reliably\n finish(null, self);\n return;\n }\n process(filename, source);\n });\n }\n }\n var queued = 0;\n\n // Assembling the root namespace doesn't require working type\n // references anymore, so we can load everything in parallel\n if (util.isString(filename))\n filename = [ filename ];\n for (var i = 0, resolved; i < filename.length; ++i)\n if (resolved = self.resolvePath(\"\", filename[i]))\n fetch(resolved);\n\n if (sync)\n return self;\n if (!queued)\n finish(null, self);\n return undefined;\n};\n// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\n * @function Root#load\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {LoadCallback} callback Callback function\n * @returns {undefined}\n * @variation 2\n */\n// function load(filename:string, callback:LoadCallback):undefined\n\n/**\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.\n * @function Root#load\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {Promise} Promise\n * @variation 3\n */\n// function load(filename:string, [options:IParseOptions]):Promise\n\n/**\n * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).\n * @function Root#loadSync\n * @param {string|string[]} filename Names of one or multiple files to load\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\n * @returns {Root} Root namespace\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\n */\nRoot.prototype.loadSync = function loadSync(filename, options) {\n if (!util.isNode)\n throw Error(\"not supported\");\n return this.load(filename, options, SYNC);\n};\n\n/**\n * @override\n */\nRoot.prototype.resolveAll = function resolveAll() {\n if (this.deferred.length)\n throw Error(\"unresolvable extensions: \" + this.deferred.map(function(field) {\n return \"'extend \" + field.extend + \"' in \" + field.parent.fullName;\n }).join(\", \"));\n return Namespace.prototype.resolveAll.call(this);\n};\n\n// only uppercased (and thus conflict-free) children are exposed, see below\nvar exposeRe = /^[A-Z]/;\n\n/**\n * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.\n * @param {Root} root Root instance\n * @param {Field} field Declaring extension field witin the declaring type\n * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise\n * @inner\n * @ignore\n */\nfunction tryHandleExtension(root, field) {\n var extendedType = field.parent.lookup(field.extend);\n if (extendedType) {\n var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);\n //do not allow to extend same field twice to prevent the error\n if (extendedType.get(sisterField.name)) {\n return true;\n }\n sisterField.declaringField = field;\n field.extensionField = sisterField;\n extendedType.add(sisterField);\n return true;\n }\n return false;\n}\n\n/**\n * Called when any object is added to this root or its sub-namespaces.\n * @param {ReflectionObject} object Object added\n * @returns {undefined}\n * @private\n */\nRoot.prototype._handleAdd = function _handleAdd(object) {\n if (object instanceof Field) {\n\n if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField)\n if (!tryHandleExtension(this, object))\n this.deferred.push(object);\n\n } else if (object instanceof Enum) {\n\n if (exposeRe.test(object.name))\n object.parent[object.name] = object.values; // expose enum values as property of its parent\n\n } else if (!(object instanceof OneOf)) /* everything else is a namespace */ {\n\n if (object instanceof Type) // Try to handle any deferred extensions\n for (var i = 0; i < this.deferred.length;)\n if (tryHandleExtension(this, this.deferred[i]))\n this.deferred.splice(i, 1);\n else\n ++i;\n for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace\n this._handleAdd(object._nestedArray[j]);\n if (exposeRe.test(object.name))\n object.parent[object.name] = object; // expose namespace as property of its parent\n }\n\n // The above also adds uppercased (and thus conflict-free) nested types, services and enums as\n // properties of namespaces just like static code does. This allows using a .d.ts generated for\n // a static module with reflection-based solutions where the condition is met.\n};\n\n/**\n * Called when any object is removed from this root or its sub-namespaces.\n * @param {ReflectionObject} object Object removed\n * @returns {undefined}\n * @private\n */\nRoot.prototype._handleRemove = function _handleRemove(object) {\n if (object instanceof Field) {\n\n if (/* an extension field */ object.extend !== undefined) {\n if (/* already handled */ object.extensionField) { // remove its sister field\n object.extensionField.parent.remove(object.extensionField);\n object.extensionField = null;\n } else { // cancel the extension\n var index = this.deferred.indexOf(object);\n /* istanbul ignore else */\n if (index > -1)\n this.deferred.splice(index, 1);\n }\n }\n\n } else if (object instanceof Enum) {\n\n if (exposeRe.test(object.name))\n delete object.parent[object.name]; // unexpose enum values\n\n } else if (object instanceof Namespace) {\n\n for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace\n this._handleRemove(object._nestedArray[i]);\n\n if (exposeRe.test(object.name))\n delete object.parent[object.name]; // unexpose namespaces\n\n }\n};\n\n// Sets up cyclic dependencies (called in index-light)\nRoot._configure = function(Type_, parse_, common_) {\n Type = Type_;\n parse = parse_;\n common = common_;\n};\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protobufjs/src/root.js?"); /***/ }), @@ -1567,7 +1435,7 @@ eval("\nmodule.exports = LongBits;\n\nvar util = __webpack_require__(/*! ../util /***/ (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/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, {\n constructor: {\n value: CustomError,\n writable: true,\n enumerable: false,\n configurable: true,\n },\n name: {\n get() { return name; },\n set: undefined,\n enumerable: false,\n // configurable: false would accurately preserve the behavior of\n // the original, but I'm guessing that was not intentional.\n // For an actual error subclass, this property would\n // be configurable.\n configurable: true,\n },\n toString: {\n value() { return this.name + \": \" + this.message; },\n writable: true,\n enumerable: false,\n configurable: true,\n },\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/protobufjs/src/util/minimal.js?"); +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/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, {\n constructor: {\n value: CustomError,\n writable: true,\n enumerable: false,\n configurable: true,\n },\n name: {\n get: function get() { return name; },\n set: undefined,\n enumerable: false,\n // configurable: false would accurately preserve the behavior of\n // the original, but I'm guessing that was not intentional.\n // For an actual error subclass, this property would\n // be configurable.\n configurable: true,\n },\n toString: {\n value: function value() { return this.name + \": \" + this.message; },\n writable: true,\n enumerable: false,\n configurable: true,\n },\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/protobufjs/src/util/minimal.js?"); /***/ }), @@ -2184,6 +2052,72 @@ eval("\n\nfunction isHighSurrogate(codePoint) {\n return codePoint >= 0xd800 && /***/ }), +/***/ "./node_modules/uuid/dist/esm-browser/native.js": +/*!******************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/native.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nconst randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n randomUUID\n});\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/native.js?"); + +/***/ }), + +/***/ "./node_modules/uuid/dist/esm-browser/regex.js": +/*!*****************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/regex.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/regex.js?"); + +/***/ }), + +/***/ "./node_modules/uuid/dist/esm-browser/rng.js": +/*!***************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/rng.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 */ \"default\": () => (/* binding */ rng)\n/* harmony export */ });\n// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nfunction rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/rng.js?"); + +/***/ }), + +/***/ "./node_modules/uuid/dist/esm-browser/stringify.js": +/*!*********************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/stringify.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ \"unsafeStringify\": () => (/* binding */ unsafeStringify)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"./node_modules/uuid/dist/esm-browser/validate.js\");\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (stringify);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/stringify.js?"); + +/***/ }), + +/***/ "./node_modules/uuid/dist/esm-browser/v4.js": +/*!**************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/v4.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _native_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./native.js */ \"./node_modules/uuid/dist/esm-browser/native.js\");\n/* harmony import */ var _rng_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rng.js */ \"./node_modules/uuid/dist/esm-browser/rng.js\");\n/* harmony import */ var _stringify_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stringify.js */ \"./node_modules/uuid/dist/esm-browser/stringify.js\");\n\n\n\n\nfunction v4(options, buf, offset) {\n if (_native_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomUUID && !buf && !options) {\n return _native_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || _rng_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return (0,_stringify_js__WEBPACK_IMPORTED_MODULE_2__.unsafeStringify)(rnds);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (v4);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/v4.js?"); + +/***/ }), + +/***/ "./node_modules/uuid/dist/esm-browser/validate.js": +/*!********************************************************!*\ + !*** ./node_modules/uuid/dist/esm-browser/validate.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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ \"./node_modules/uuid/dist/esm-browser/regex.js\");\n\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && _regex_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].test(uuid);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/uuid/dist/esm-browser/validate.js?"); + +/***/ }), + /***/ "./node_modules/varint/decode.js": /*!***************************************!*\ !*** ./node_modules/varint/decode.js ***! @@ -2294,13 +2228,13 @@ eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-example/crypto_(ign /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs ***! - \***************************************************************************************************/ +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs": +/*!***************************************************************************!*\ + !*** ./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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs?"); +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/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs?"); /***/ }), @@ -2348,6 +2282,545 @@ 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 */ \"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 */ \"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 * 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//# 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 it_pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/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 _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_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_topology__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/topology */ \"./node_modules/@libp2p/topology/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-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 _types_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./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\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_5__.EventEmitter {\n constructor(components, options = {}) {\n super();\n this.multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_21__.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_8__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPruneBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.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_8__.FloodsubID);\n }\n // From pubsub\n this.log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.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_12__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__.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_19__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.msgIdFnStrictSign;\n break;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.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_12__.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_9__.messageIdToString;\n this.mcache = options.messageCache || new _message_cache_js__WEBPACK_IMPORTED_MODULE_6__.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_8__.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_11__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_10__.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_2__.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_18__.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_21__.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.addressBook.add(p.id, p.addrs);\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_4__.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_8__.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_8__.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_8__.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 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_22__.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_8__.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_22__.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_24__.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_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 ? 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_2__.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_23__.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_5__.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_14__.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_14__.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_14__.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_5__.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_5__.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_14__.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_15__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.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_8__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_8__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_8__.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_8__.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_8__.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_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_8__.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_8__.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 || !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_8__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_9__.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_8__.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_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)) {\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) {\n return [];\n }\n return await Promise.all(prune.map((topic) => this.makePrune(id, topic, doPX)));\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_13__.ChurnReason.Unsub, 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 interval - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, interval) {\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() + interval;\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_8__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n if (expire < 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_9__.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 p = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(pi.peerID).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 const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.openAndCertify(pi.signedPeerRecord, 'libp2p-peer-record');\n const eid = envelope.peerId;\n if (!envelope.peerId.equals(p)) {\n this.log(\"bogus peer record obtained through px: peer ID %p doesn't match expected peer %p\", eid, p);\n return;\n }\n if (!(await this.components.peerStore.addressBook.consumePeerRecord(envelope))) {\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_2__.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 // 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 // TODO:rust-libp2p checks `self.backoffs.is_backoff_with_slack()`\n if (!this.direct.has(id) && this.score.score(id) >= 0) {\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);\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) {\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_15__.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_5__.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_5__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 if (acceptance === _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n const cacheEntry = this.mcache.validate(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource.toString(), msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource.toString(), originatingPeers);\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\n // Not valid\n else {\n const cacheEntry = this.mcache.remove(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.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.toString(), msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\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 const prune = [await this.makePrune(id, topic, this.opts.doPX)];\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_7__.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 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))));\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))));\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_9__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_8__.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_9__.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_8__.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_9__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id).protocol === _constants_js__WEBPACK_IMPORTED_MODULE_8__.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 is measured in milliseconds\n // The protobuf has it as a uint64\n const backoff = this.opts.pruneBackoff / 1000;\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_2__.peerIdFromString)(peerId);\n return {\n peerID: id.toBytes(),\n signedPeerRecord: await this.components.peerStore.addressBook.getRawEnvelope(id)\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_9__.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_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_20__.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_9__.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_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)) {\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_20__.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_20__.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) || 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_9__.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_5__.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_9__.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 for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\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_17__.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_8__.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/@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 /**\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/@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 */ \"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/@chainsafe/libp2p-gossipsub/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/@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 _rpc_cjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.cjs */ \"./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/@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 _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ \"./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 /// Peer unsubscribed.\n ChurnReason[\"Unsub\"] = \"unsubscribed\";\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 */\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: ['topic', 'reason']\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: ['topic', 'reason']\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 for each topic',\n labelNames: ['topic', 'acceptance']\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 // 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 msgPublishPeers: 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: ['topic', '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: ['topic', 'status']\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: ['topic', 'error']\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 labelNames: ['topic', 'p']\n }),\n /** Separate score weights */\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 /* 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({ topic, reason }, 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({ topic, reason }, count);\n },\n onReportValidationMcacheHit(hit) {\n this.asyncValidationMcacheHit.inc({ hit: hit ? 'hit' : 'miss' });\n },\n onReportValidation(topicStr, acceptance) {\n const topic = this.toTopic(topicStr);\n this.asyncValidationResult.inc({ topic: topic, acceptance });\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.msgPublishPeers.inc({ topic }, tosendCount);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'direct' }, tosendGroupCount.direct);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'floodsub' }, tosendGroupCount.floodsub);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'mesh' }, tosendGroupCount.mesh);\n this.msgPublishPeersByGroup.inc({ topic, 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.msgReceivedStatus.inc({ topic, 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({ topic, error }, 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/@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 ? 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/index.js": +/*!**************************************************************************!*\ + !*** ./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/@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/@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/@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/@chainsafe/libp2p-gossipsub/dist/src/score/index.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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants.js */ \"./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 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 firstSeen: 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/@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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./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/@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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./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/@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 _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./peer-score-params.js */ \"./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/@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/@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/@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/@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 /**\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.firstSeen, _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.firstSeen, _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/@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) {\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/@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 abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/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 it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/@chainsafe/libp2p-gossipsub/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 }), (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode)(), 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, (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)(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/@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 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/@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_pubsub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./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/@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 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/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../types.js */ \"./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/@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/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js": +/*!**************************************************************************!*\ + !*** ./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/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js\");\n/* harmony import */ var _messageIdToString_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./messageIdToString.js */ \"./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/@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/@chainsafe/libp2p-gossipsub/dist/src/utils/index.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/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 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/@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/@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 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/@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_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/@libp2p/interface-pubsub/dist/src/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_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/@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 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 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/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/alloc.js": +/*!****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/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 */ });\nfunction alloc(len) {\n return new Uint8Array(len);\n}\nfunction allocUnsafe(len) {\n if (globalThis?.Buffer?.allocUnsafe != null) {\n return globalThis.Buffer.allocUnsafe(len);\n }\n return new Uint8Array(len);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/decode.js": +/*!*****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/decode.js ***! + \*****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* eslint max-depth: [\"error\", 6] */\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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(options) {\n const decoder = async function* (source) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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 for await (const buf of source) {\n buffer.append(buf);\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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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 (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n };\n return decoder;\n}\n/**\n * @param {*} reader\n * @param {import('./types').DecoderOptions} [options]\n * @returns\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({\n ...(options ?? {}),\n onLength\n })(varByteSource);\n};\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/decode.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/encode.js": +/*!*****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/encode.js ***! + \*****************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 _alloc_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./alloc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/alloc.js\");\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,_alloc_js__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n const encoder = async function* (source) {\n for await (const chunk of source) {\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 };\n return encoder;\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/encode.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/index.js": +/*!****************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/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\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_1__.decode),\n/* harmony export */ \"encode\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_0__.encode)\n/* harmony export */ });\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/encode.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/decode.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/it-length-prefixed/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js": +/*!********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/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 */ \"DUMP_SESSION_KEYS\": () => (/* binding */ DUMP_SESSION_KEYS),\n/* harmony export */ \"NOISE_MSG_MAX_LENGTH_BYTES\": () => (/* binding */ NOISE_MSG_MAX_LENGTH_BYTES),\n/* harmony export */ \"NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG\": () => (/* binding */ NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG)\n/* harmony export */ });\nconst NOISE_MSG_MAX_LENGTH_BYTES = 65535;\nconst NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG = NOISE_MSG_MAX_LENGTH_BYTES - 16;\nconst DUMP_SESSION_KEYS = Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js": +/*!***************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js ***! + \***************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"stablelib\": () => (/* binding */ stablelib)\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 _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @stablelib/x25519 */ \"./node_modules/@stablelib/x25519/lib/x25519.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_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.js\");\n\n\n\n\nconst stablelib = {\n hashSHA256(data) {\n return (0,_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.hash)(data);\n },\n getHKDF(ck, ikm) {\n const hkdf = new _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_0__.HKDF(_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.SHA256, ikm, ck);\n const okmU8Array = hkdf.expand(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 keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair();\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey\n };\n },\n generateX25519KeyPairFromSeed(seed) {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.generateKeyPairFromSeed(seed);\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey\n };\n },\n generateX25519SharedKey(privateKey, publicKey) {\n return _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.sharedKey(privateKey, publicKey);\n },\n chaCha20Poly1305Encrypt(plaintext, nonce, ad, k) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__.ChaCha20Poly1305(k);\n return ctx.seal(nonce, plaintext, ad);\n },\n chaCha20Poly1305Decrypt(ciphertext, nonce, ad, k, dst) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__.ChaCha20Poly1305(k);\n return ctx.open(nonce, ciphertext, ad, dst);\n }\n};\n//# sourceMappingURL=stablelib.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js": +/*!***************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js ***! + \***************************************************************************/ +/***/ ((__unused_webpack___webpack_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 _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.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\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 const data = handshake.encrypt(chunk.subarray(i, end), handshake.session);\n metrics?.encryptedPackets.increment();\n yield (0,_encoder_js__WEBPACK_IMPORTED_MODULE_2__.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_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 - _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.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 - _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js": +/*!******************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack___webpack_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 constructor(isInitiator, payload, prologue, crypto, staticKeypair, connection, remotePeer, handshake) {\n this.remoteExtensions = { webtransportCerthashes: [] };\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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js ***! + \****************************************************************************************/ +/***/ ((__unused_webpack___webpack_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_equals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.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 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_0__.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_2__.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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js": +/*!************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/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 */ \"noise\": () => (/* binding */ noise),\n/* harmony export */ \"stablelib\": () => (/* reexport safe */ _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_2__.stablelib)\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__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js\");\n/* harmony import */ var _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto/stablelib.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js\");\n\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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/logger.js ***! + \*****************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js": +/*!******************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/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 */ \"registerMetrics\": () => (/* binding */ registerMetrics)\n/* harmony export */ });\nfunction registerMetrics(metrics) {\n return {\n xxHandshakeSuccesses: metrics.registerCounter('libp2p_noise_xxhandshake_successes_total', {\n help: 'Total count of noise xxHandshakes successes_'\n }),\n xxHandshakeErrors: metrics.registerCounter('libp2p_noise_xxhandshake_error_total', {\n help: 'Total count of noise xxHandshakes errors'\n }),\n encryptedPackets: metrics.registerCounter('libp2p_noise_encrypted_packets_total', {\n help: 'Total count of noise encrypted packets successfully'\n }),\n decryptedPackets: metrics.registerCounter('libp2p_noise_decrypted_packets_total', {\n help: 'Total count of noise decrypted packets'\n }),\n decryptErrors: metrics.registerCounter('libp2p_noise_decrypt_errors_total', {\n help: 'Total count of noise decrypt errors'\n })\n };\n}\n//# sourceMappingURL=metrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js": +/*!****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/noise.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_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_pb_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pb-stream */ \"./node_modules/it-pb-stream/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_pipe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/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_stablelib_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./crypto/stablelib.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.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 _utils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@chainsafe/libp2p-noise/dist/src/utils.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\n\n\n\n\n\n\n\n\n\n\nclass Noise {\n constructor(init = {}) {\n this.protocol = '/noise';\n const { staticNoiseKey, extensions, crypto, prologueBytes, metrics } = init;\n this.crypto = crypto ?? _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_5__.stablelib;\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 ?? 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} 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_0__.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} 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_0__.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_9__.getPayload)(params.localPeer, this.staticKeys.publicKey, this.extensions);\n // run XX handshake\n return await 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_2__.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 (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)({ 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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js": +/*!****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_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 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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js": +/*!************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/dist/src/utils.js": +/*!****************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/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 */ \"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 await privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return await (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?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/alloc.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/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 */ });\nfunction alloc(len) {\n return new Uint8Array(len);\n}\nfunction allocUnsafe(len) {\n if (globalThis?.Buffer?.allocUnsafe != null) {\n return globalThis.Buffer.allocUnsafe(len);\n }\n return new Uint8Array(len);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/alloc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/decode.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/decode.js ***! + \*************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* eslint max-depth: [\"error\", 6] */\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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(options) {\n const decoder = async function* (source) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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 for await (const buf of source) {\n buffer.append(buf);\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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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 (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n };\n return decoder;\n}\n/**\n * @param {*} reader\n * @param {import('./types').DecoderOptions} [options]\n * @returns\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({\n ...(options ?? {}),\n onLength\n })(varByteSource);\n};\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/decode.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/encode.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/encode.js ***! + \*************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 _alloc_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./alloc.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/alloc.js\");\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,_alloc_js__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n const encoder = async function* (source) {\n for await (const chunk of source) {\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 };\n return encoder;\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/encode.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/index.js": +/*!************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/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\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_1__.decode),\n/* harmony export */ \"encode\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_0__.encode)\n/* harmony export */ });\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/encode.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/decode.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@chainsafe/libp2p-noise/node_modules/it-length-prefixed/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/@chainsafe/netmask/dist/src/cidr.js": /*!**********************************************************!*\ !*** ./node_modules/@chainsafe/netmask/dist/src/cidr.js ***! @@ -2520,7 +2993,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 */ \"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_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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// @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_2__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.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_2__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.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_2__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.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_2__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.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?"); +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?"); /***/ }), @@ -2531,7 +3004,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 _ciphers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ciphers.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js\");\n/* harmony import */ var _cipher_mode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cipher-mode.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js\");\n\n\nasync function create(key, iv) {\n const mode = (0,_cipher_mode_js__WEBPACK_IMPORTED_MODULE_1__.cipherMode)(key);\n const cipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_0__.createCipheriv(mode, key, iv);\n const decipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_0__.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 */ \"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?"); /***/ }), @@ -2542,7 +3015,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 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// 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 // 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', 'deriveBits']);\n const cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt']);\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 // 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', 'deriveBits']);\n const cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['decrypt']);\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/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?"); /***/ }), @@ -2553,7 +3026,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 await 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.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?"); /***/ }), @@ -2575,7 +3048,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 */ \"aes\": () => (/* reexport module object */ _aes_index_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ \"hmac\": () => (/* reexport module object */ _hmac_index_js__WEBPACK_IMPORTED_MODULE_0__),\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_4__[\"default\"]),\n/* harmony export */ \"randomBytes\": () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"])\n/* harmony export */ });\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hmac/index.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n/* harmony import */ var _aes_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./aes/index.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/index.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 _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 _pbkdf2_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbkdf2.js */ \"./node_modules/@libp2p/crypto/dist/src/pbkdf2.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?"); +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?"); /***/ }), @@ -2586,7 +3059,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 _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.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 uint8arrays_concat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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_1__[\"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_1__[\"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_1__[\"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_1__[\"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_1__[\"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_4__.concat)([\n Uint8Array.from([4]),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.base64urlToBuffer)(jwk.x, byteLen),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.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_5__.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_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?"); /***/ }), @@ -2597,7 +3070,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 await _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.sign(msg, privateKeyRaw);\n}\nasync function hashAndVerify(publicKey, sig, msg) {\n return await _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_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?"); /***/ }), @@ -2608,7 +3081,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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/identity.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 _keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.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\n\n\n\n\n\n\n\nclass Ed25519PublicKey {\n constructor(key) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n async verify(data, sig) {\n return await _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_6__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.KeyType.Ed25519,\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 { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Ed25519PrivateKey {\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 await _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_6__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.KeyType.Ed25519,\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 { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.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_4__.identity.digest(this.public.bytes);\n return multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_3__.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 await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_7__.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_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?"); /***/ }), @@ -2630,7 +3103,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/@libp2p/crypto/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/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?"); /***/ }), @@ -2641,7 +3114,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/@libp2p/crypto/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 await 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/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?"); /***/ }), @@ -2652,7 +3125,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_7__[\"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_6__.keyStretcher),\n/* harmony export */ \"keysPBM\": () => (/* reexport module object */ _keys_js__WEBPACK_IMPORTED_MODULE_0__),\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 _keys_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_1__ = __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_2__ = __webpack_require__(/*! node-forge/lib/pbe.js */ \"./node_modules/node-forge/lib/pbe.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _key_stretcher_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./key-stretcher.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js\");\n/* harmony import */ var _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ephemeral-keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js\");\n/* harmony import */ var _importer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./importer.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/importer.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n/* harmony import */ var _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ed25519-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-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_9__,\n ed25519: _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__,\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_4__.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 await 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_4__.CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE');\n }\n return await _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__.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_0__.PublicKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.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_0__.PrivateKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.RSA:\n return await supportedKeys.rsa.unmarshalRsaPrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.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_8__.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_4__.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_5__.fromString)(der.getBytes(), 'ascii');\n return await 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?"); +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?"); /***/ }), @@ -2685,7 +3158,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 */ \"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/@libp2p/crypto/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/@libp2p/crypto/dist/src/keys/keys.js?"); +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/@libp2p/crypto/dist/src/keys/keys.js?"); /***/ }), @@ -2696,7 +3169,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_1__[\"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_4__)\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 _random_bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\n\n\n\n\n\n\nasync function generateKey(bits) {\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_0__[\"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_0__[\"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_0__[\"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_0__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['verify']);\n return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_6__.CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS');\n }\n return await Promise.all([\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.exportKey('jwk', pair.privateKey),\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey)\n ]);\n}\nasync function derivePublicFromPrivate(jwKey) {\n return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_3__.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 */ \"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?"); /***/ }), @@ -2707,7 +3180,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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.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 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 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 node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.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 _exporter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n\n\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\nclass RsaPublicKey {\n constructor(key) {\n this._key = key;\n }\n async verify(data, sig) {\n return await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.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_6__.encrypt(this._key, bytes);\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_0__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass RsaPrivateKey {\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey;\n }\n genSecret() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.getRandomValues(16);\n }\n async sign(message) {\n return await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.hashAndSign(this._key, message);\n }\n get public() {\n if (this._publicKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_6__.decrypt(this._key, bytes);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.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 async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.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 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_5__.util.ByteBuffer(this.marshal());\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__.asn1.fromDer(buffer);\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__.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_5__.pki.encryptRsaPrivateKey(privateKey, password, options);\n }\n else if (format === 'libp2p-key') {\n return await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_8__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_6__.utils.pkcs1ToJwk(bytes);\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nfunction unmarshalRsaPublicKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_6__.utils.pkixToJwk(bytes);\n return new RsaPublicKey(jwk);\n}\nasync function fromJwk(jwk) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nasync function generateKeyPair(bits) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.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 */ \"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?"); /***/ }), @@ -2718,7 +3191,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 */ \"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 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 _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\n// @ts-expect-error types are missing\n\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_5__.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_3__.bigIntegerToUintBase64url)(privateKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.q),\n dp: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.dP),\n dq: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.dQ),\n qi: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.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_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_3__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.q),\n dP: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.dp),\n dQ: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.dq),\n qInv: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.qi)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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_5__.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_3__.bigIntegerToUintBase64url)(publicKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.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_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_3__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.e)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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/@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 */ \"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?"); /***/ }), @@ -2729,7 +3202,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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.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 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 _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./secp256k1.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n\n\n\n\n\n\n\nclass Secp256k1PublicKey {\n constructor(key) {\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePublicKey(key);\n this._key = key;\n }\n async verify(data, sig) {\n return await _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.compressPublicKey(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_6__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.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_0__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Secp256k1PrivateKey {\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey ?? _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.computePublicKey(key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePrivateKey(this._key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePublicKey(this._publicKey);\n }\n async sign(message) {\n return await _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.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_6__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.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_0__.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 await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_5__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_4__.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?"); +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?"); /***/ }), @@ -2740,7 +3213,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 */ \"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/@libp2p/crypto/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?"); +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?"); /***/ }), @@ -2751,7 +3224,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 */ pbkdf2)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_pbkdf2_js__WEBPACK_IMPORTED_MODULE_0__ = __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_1__ = __webpack_require__(/*! node-forge/lib/util.js */ \"./node_modules/node-forge/lib/util.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// @ts-expect-error types are missing\n\n// @ts-expect-error types are missing\n\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_2__.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_0__(password, salt, iterations, keySize, hasher);\n return node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_1__.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 */ \"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?"); /***/ }), @@ -2762,7 +3235,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 _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/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\n\nfunction randomBytes(length) {\n if (isNaN(length) || length <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('random bytes length must be a Number bigger than 0', 'ERR_INVALID_LENGTH');\n }\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.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_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?"); /***/ }), @@ -2773,7 +3246,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 */ \"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_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./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/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.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_5__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.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_4__.toString)(buf, 'base16'), 16);\n}\nfunction base64urlToBuffer(str, len) {\n let buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.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_5__.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 */ \"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?"); /***/ }), @@ -2788,212 +3261,14 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/base.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/base58.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/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/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/base64.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/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/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/interface.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/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/@libp2p/crypto/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/bytes.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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)\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/@libp2p/crypto/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/digest.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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/@libp2p/crypto/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/hasher.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/identity.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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/@libp2p/crypto/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/src/varint.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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/@libp2p/crypto/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/@libp2p/crypto/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/vendor/base-x.js": +/***/ "./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js": /*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/vendor/base-x.js ***! + !*** ./node_modules/@libp2p/interface-connection-encrypter/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 */ \"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/@libp2p/crypto/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/multiformats/vendor/varint.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/multiformats/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 */ });\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/@libp2p/crypto/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/index.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js?"); +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 constructor(message = 'Unexpected Peer') {\n super(message);\n this.code = UnexpectedPeerError.code;\n }\n static get code() {\n return 'ERR_UNEXPECTED_PEER';\n }\n}\nclass InvalidCryptoExchangeError extends Error {\n constructor(message = 'Invalid crypto exchange') {\n super(message);\n this.code = InvalidCryptoExchangeError.code;\n }\n static get code() {\n return 'ERR_INVALID_CRYPTO_EXCHANGE';\n }\n}\nclass InvalidCryptoTransmissionError extends Error {\n constructor(message = 'Invalid crypto transmission') {\n super(message);\n this.code = InvalidCryptoTransmissionError.code;\n }\n static get code() {\n return 'ERR_INVALID_CRYPTO_TRANSMISSION';\n }\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js?"); /***/ }), @@ -3004,7 +3279,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 */ \"isPeerDiscovery\": () => (/* binding */ isPeerDiscovery),\n/* harmony export */ \"symbol\": () => (/* binding */ symbol)\n/* harmony export */ });\nconst symbol = Symbol.for('@libp2p/peer-discovery');\nfunction isPeerDiscovery(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-discovery/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"isPeerDiscovery\": () => (/* binding */ isPeerDiscovery),\n/* harmony export */ \"peerDiscovery\": () => (/* binding */ peerDiscovery),\n/* harmony export */ \"symbol\": () => (/* binding */ symbol)\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');\nconst symbol = Symbol.for('@libp2p/peer-discovery');\nfunction isPeerDiscovery(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-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?"); /***/ }), @@ -3019,6 +3305,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@libp2p/interface-pubsub/dist/src/index.js": +/*!*****************************************************************!*\ + !*** ./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/@libp2p/interface-pubsub/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/interface-registrar/dist/src/index.js": /*!********************************************************************!*\ !*** ./node_modules/@libp2p/interface-registrar/dist/src/index.js ***! @@ -3030,6 +3327,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./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?"); + +/***/ }), + /***/ "./node_modules/@libp2p/interfaces/dist/src/errors.js": /*!************************************************************!*\ !*** ./node_modules/@libp2p/interfaces/dist/src/errors.js ***! @@ -3037,7 +3345,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 */ \"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 constructor(message = 'The operation was aborted') {\n super(message);\n this.code = AbortError.code;\n this.type = AbortError.type;\n }\n static get code() {\n return 'ABORT_ERR';\n }\n static get type() {\n return 'aborted';\n }\n}\nclass CodeError extends Error {\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 */ \"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?"); /***/ }), @@ -3048,7 +3356,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 */ \"CustomEvent\": () => (/* binding */ CustomEvent),\n/* harmony export */ \"EventEmitter\": () => (/* binding */ EventEmitter)\n/* harmony export */ });\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 _EventEmitter_listeners;\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 constructor() {\n super(...arguments);\n _EventEmitter_listeners.set(this, new Map());\n }\n listenerCount(type) {\n const listeners = __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").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 = __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").get(type);\n if (list == null) {\n list = [];\n __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").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 = __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").get(type);\n if (list == null) {\n return;\n }\n list = list.filter(({ callback }) => callback !== listener);\n __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").set(type, list);\n }\n dispatchEvent(event) {\n const result = super.dispatchEvent(event);\n let list = __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").get(event.type);\n if (list == null) {\n return result;\n }\n list = list.filter(({ once }) => !once);\n __classPrivateFieldGet(this, _EventEmitter_listeners, \"f\").set(event.type, list);\n return result;\n }\n safeDispatchEvent(type, detail) {\n return this.dispatchEvent(new CustomEvent(type, detail));\n }\n}\n_EventEmitter_listeners = new WeakMap();\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 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 */ \"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?"); /***/ }), @@ -3070,84 +3378,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 */ \"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/@libp2p/logger/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/@libp2p/logger/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/@libp2p/logger/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};\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 */ \"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};\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?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base.js ***! - \*********************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/dist/src/alloc-unsafe-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 */ \"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/@libp2p/logger/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/logger/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/logger/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/@libp2p/logger/node_modules/multiformats/src/bases/base.js?"); +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?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base32.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base32.js ***! - \***********************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/decode.js": +/*!*******************************************************!*\ + !*** ./node_modules/@libp2p/mplex/dist/src/decode.js ***! + \*******************************************************/ /***/ ((__unused_webpack___webpack_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/@libp2p/logger/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/@libp2p/logger/node_modules/multiformats/src/bases/base32.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Decoder\": () => (/* binding */ Decoder),\n/* harmony export */ \"MAX_MSG_QUEUE_SIZE\": () => (/* binding */ MAX_MSG_QUEUE_SIZE),\n/* harmony export */ \"MAX_MSG_SIZE\": () => (/* binding */ MAX_MSG_SIZE)\n/* harmony export */ });\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n\n\nconst MAX_MSG_SIZE = 1 << 20; // 1MB\nconst MAX_MSG_QUEUE_SIZE = 4 << 20; // 4MB\nclass Decoder {\n constructor(maxMessageSize = MAX_MSG_SIZE, maxUnprocessedMessageQueueSize = MAX_MSG_QUEUE_SIZE) {\n this._buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList();\n this._headerInfo = null;\n this._maxMessageSize = maxMessageSize;\n this._maxUnprocessedMessageQueueSize = maxUnprocessedMessageQueueSize;\n }\n write(chunk) {\n if (chunk == null || chunk.length === 0) {\n return [];\n }\n this._buffer.append(chunk);\n if (this._buffer.byteLength > this._maxUnprocessedMessageQueueSize) {\n throw Object.assign(new Error('unprocessed message queue size too large!'), { code: 'ERR_MSG_QUEUE_TOO_BIG' });\n }\n const msgs = [];\n while (this._buffer.length !== 0) {\n if (this._headerInfo == null) {\n try {\n this._headerInfo = this._decodeHeader(this._buffer);\n }\n catch (err) {\n if (err.code === 'ERR_MSG_TOO_BIG') {\n throw err;\n }\n break; // We haven't received enough data yet\n }\n }\n const { id, type, length, offset } = this._headerInfo;\n const bufferedDataLength = this._buffer.length - offset;\n if (bufferedDataLength < length) {\n break; // not enough data yet\n }\n const msg = {\n id,\n type\n };\n if (type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.NEW_STREAM || type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.MESSAGE_INITIATOR || type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.MESSAGE_RECEIVER) {\n msg.data = this._buffer.sublist(offset, offset + length);\n }\n msgs.push(msg);\n this._buffer.consume(offset + length);\n this._headerInfo = null;\n }\n return msgs;\n }\n /**\n * Attempts to decode the message header from the buffer\n */\n _decodeHeader(data) {\n const { value: h, offset } = readVarInt(data);\n const { value: length, offset: end } = readVarInt(data, offset);\n const type = h & 7;\n // @ts-expect-error h is a number not a CODE\n if (_message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypeNames[type] == null) {\n throw new Error(`Invalid type received: ${type}`);\n }\n // test message type varint + data length\n if (length > this._maxMessageSize) {\n throw Object.assign(new Error('message size too large!'), { code: 'ERR_MSG_TOO_BIG' });\n }\n // @ts-expect-error h is a number not a CODE\n return { id: h >> 3, type, offset: offset + end, length };\n }\n}\nconst MSB = 0x80;\nconst REST = 0x7F;\nfunction readVarInt(buf, offset = 0) {\n let res = 0;\n let shift = 0;\n let counter = offset;\n let b;\n const l = buf.length;\n do {\n if (counter >= l || shift > 49) {\n offset = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf.get(counter++);\n res += shift < 28\n ? (b & REST) << shift\n : (b & REST) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB);\n offset = counter - offset;\n return {\n value: res,\n offset\n };\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/decode.js?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base58.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base58.js ***! - \***********************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/encode.js": +/*!*******************************************************!*\ + !*** ./node_modules/@libp2p/mplex/dist/src/encode.js ***! + \*******************************************************/ /***/ ((__unused_webpack___webpack_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/@libp2p/logger/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/@libp2p/logger/node_modules/multiformats/src/bases/base58.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 varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! varint */ \"./node_modules/varint/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 _alloc_unsafe_js__WEBPACK_IMPORTED_MODULE_2__ = __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_3__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var it_batched_bytes__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-batched-bytes */ \"./node_modules/it-batched-bytes/dist/src/index.js\");\n\n\n\n\n\nconst POOL_SIZE = 10 * 1024;\nclass Encoder {\n constructor() {\n this._pool = (0,_alloc_unsafe_js__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 varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.id << 3 | msg.type, pool, offset);\n offset += varint__WEBPACK_IMPORTED_MODULE_0__.encode.bytes ?? 0;\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 varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.data.length, pool, offset);\n }\n else {\n varint__WEBPACK_IMPORTED_MODULE_0__.encode(0, pool, offset);\n }\n offset += varint__WEBPACK_IMPORTED_MODULE_0__.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_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, 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_4__[\"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?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base64.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/base64.js ***! - \***********************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/index.js": +/*!******************************************************!*\ + !*** ./node_modules/@libp2p/mplex/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 */ \"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/@libp2p/logger/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/@libp2p/logger/node_modules/multiformats/src/bases/base64.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\nclass Mplex {\n constructor(init = {}) {\n this.protocol = '/mplex/6.7.0';\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?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/interface.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bases/interface.js ***! - \**************************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/message-types.js": +/*!**************************************************************!*\ + !*** ./node_modules/@libp2p/mplex/dist/src/message-types.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/@libp2p/logger/node_modules/multiformats/src/bases/interface.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"InitiatorMessageTypes\": () => (/* binding */ InitiatorMessageTypes),\n/* harmony export */ \"MessageTypeNames\": () => (/* binding */ MessageTypeNames),\n/* harmony export */ \"MessageTypes\": () => (/* binding */ MessageTypes),\n/* harmony export */ \"ReceiverMessageTypes\": () => (/* binding */ ReceiverMessageTypes)\n/* harmony export */ });\nvar MessageTypes;\n(function (MessageTypes) {\n MessageTypes[MessageTypes[\"NEW_STREAM\"] = 0] = \"NEW_STREAM\";\n MessageTypes[MessageTypes[\"MESSAGE_RECEIVER\"] = 1] = \"MESSAGE_RECEIVER\";\n MessageTypes[MessageTypes[\"MESSAGE_INITIATOR\"] = 2] = \"MESSAGE_INITIATOR\";\n MessageTypes[MessageTypes[\"CLOSE_RECEIVER\"] = 3] = \"CLOSE_RECEIVER\";\n MessageTypes[MessageTypes[\"CLOSE_INITIATOR\"] = 4] = \"CLOSE_INITIATOR\";\n MessageTypes[MessageTypes[\"RESET_RECEIVER\"] = 5] = \"RESET_RECEIVER\";\n MessageTypes[MessageTypes[\"RESET_INITIATOR\"] = 6] = \"RESET_INITIATOR\";\n})(MessageTypes || (MessageTypes = {}));\nconst MessageTypeNames = Object.freeze({\n 0: 'NEW_STREAM',\n 1: 'MESSAGE_RECEIVER',\n 2: 'MESSAGE_INITIATOR',\n 3: 'CLOSE_RECEIVER',\n 4: 'CLOSE_INITIATOR',\n 5: 'RESET_RECEIVER',\n 6: 'RESET_INITIATOR'\n});\nconst InitiatorMessageTypes = Object.freeze({\n NEW_STREAM: MessageTypes.NEW_STREAM,\n MESSAGE: MessageTypes.MESSAGE_INITIATOR,\n CLOSE: MessageTypes.CLOSE_INITIATOR,\n RESET: MessageTypes.RESET_INITIATOR\n});\nconst ReceiverMessageTypes = Object.freeze({\n MESSAGE: MessageTypes.MESSAGE_RECEIVER,\n CLOSE: MessageTypes.CLOSE_RECEIVER,\n RESET: MessageTypes.RESET_RECEIVER\n});\n//# sourceMappingURL=message-types.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/message-types.js?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/src/bytes.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/src/bytes.js ***! - \****************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/mplex.js": +/*!******************************************************!*\ + !*** ./node_modules/@libp2p/mplex/dist/src/mplex.js ***! + \******************************************************/ /***/ ((__unused_webpack___webpack_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/@libp2p/logger/node_modules/multiformats/src/bytes.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 it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/mplex/dist/src/encode.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/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@libp2p/mplex/dist/src/stream.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_7__.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_4__.MessageTypeNames[msg.type]} (${msg.type})`\n };\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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 constructor(init) {\n this.protocol = '/mplex/6.7.0';\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_9__.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_8__.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_5__.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_10__.anySignal)([this.closeController.signal, this._init.signal]);\n try {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_1__.abortableSource)(source, signal);\n const decoder = new _decode_js__WEBPACK_IMPORTED_MODULE_3__.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_0__.pushableV)({\n objectMode: true,\n onEnd\n });\n return Object.assign((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__.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_4__.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_4__.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_4__.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_4__.MessageTypes.MESSAGE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.MESSAGE_INITIATOR ? _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.RESET_RECEIVER : _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.RESET_INITIATOR\n });\n // Inform the stream consumer they are not fast enough\n const error = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_8__.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_4__.MessageTypes.CLOSE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.RESET_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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?"); /***/ }), -/***/ "./node_modules/@libp2p/logger/node_modules/multiformats/vendor/base-x.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/logger/node_modules/multiformats/vendor/base-x.js ***! - \********************************************************************************/ +/***/ "./node_modules/@libp2p/mplex/dist/src/stream.js": +/*!*******************************************************!*\ + !*** ./node_modules/@libp2p/mplex/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 */ \"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/@libp2p/logger/node_modules/multiformats/vendor/base-x.js?"); +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 abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 any_signal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/dist/src/index.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@libp2p/mplex/dist/src/message-types.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_8__.logger)('libp2p:mplex: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 createStream(options) {\n const { id, name, send, onEnd, type = 'initiator', maxMsgSize = _decode_js__WEBPACK_IMPORTED_MODULE_3__.MAX_MSG_SIZE } = options;\n const abortController = new AbortController();\n const resetController = new AbortController();\n const closeController = new AbortController();\n const Types = type === 'initiator' ? _message_types_js__WEBPACK_IMPORTED_MODULE_5__.InitiatorMessageTypes : _message_types_js__WEBPACK_IMPORTED_MODULE_5__.ReceiverMessageTypes;\n const externalId = type === 'initiator' ? (`i${id}`) : `r${id}`;\n const streamName = `${name == null ? id : name}`;\n let sourceEnded = false;\n let sinkEnded = false;\n let sinkSunk = false;\n let endErr;\n const timeline = {\n open: Date.now()\n };\n const onSourceEnd = (err) => {\n if (sourceEnded) {\n return;\n }\n sourceEnded = true;\n log.trace('%s stream %s source end - err: %o', type, streamName, err);\n if (err != null && endErr == null) {\n endErr = err;\n }\n if (sinkEnded) {\n stream.stat.timeline.close = Date.now();\n if (onEnd != null) {\n onEnd(endErr);\n }\n }\n };\n const onSinkEnd = (err) => {\n if (sinkEnded) {\n return;\n }\n sinkEnded = true;\n log.trace('%s stream %s sink end - err: %o', type, streamName, err);\n if (err != null && endErr == null) {\n endErr = err;\n }\n if (sourceEnded) {\n timeline.close = Date.now();\n if (onEnd != null) {\n onEnd(endErr);\n }\n }\n };\n const streamSource = (0,it_pushable__WEBPACK_IMPORTED_MODULE_1__.pushable)({\n onEnd: onSourceEnd\n });\n const stream = {\n // Close for both Reading and Writing\n close: () => {\n log.trace('%s stream %s close', type, streamName);\n stream.closeRead();\n stream.closeWrite();\n },\n // Close for reading\n closeRead: () => {\n log.trace('%s stream %s closeRead', type, streamName);\n if (sourceEnded) {\n return;\n }\n streamSource.end();\n },\n // Close for writing\n closeWrite: () => {\n log.trace('%s stream %s closeWrite', type, streamName);\n if (sinkEnded) {\n return;\n }\n closeController.abort();\n try {\n send({ id, type: Types.CLOSE });\n }\n catch (err) {\n log.trace('%s stream %s error sending close', type, name, err);\n }\n onSinkEnd();\n },\n // Close for reading and writing (local error)\n abort: (err) => {\n log.trace('%s stream %s abort', type, streamName, err);\n // End the source with the passed error\n streamSource.end(err);\n abortController.abort();\n onSinkEnd(err);\n },\n // Close immediately for reading and writing (remote error)\n reset: () => {\n const err = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('stream reset', ERR_STREAM_RESET);\n resetController.abort();\n streamSource.end(err);\n onSinkEnd(err);\n },\n sink: async (source) => {\n if (sinkSunk) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('sink already called on stream', ERR_DOUBLE_SINK);\n }\n sinkSunk = true;\n if (sinkEnded) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('stream closed for writing', ERR_SINK_ENDED);\n }\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)([\n abortController.signal,\n resetController.signal,\n closeController.signal\n ]);\n try {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(source, signal);\n if (type === 'initiator') { // If initiator, open a new stream\n send({ id, type: _message_types_js__WEBPACK_IMPORTED_MODULE_5__.InitiatorMessageTypes.NEW_STREAM, data: new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_6__.fromString)(streamName)) });\n }\n for await (let data of source) {\n while (data.length > 0) {\n if (data.length <= maxMsgSize) {\n send({ id, type: Types.MESSAGE, data: data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(data) : data });\n break;\n }\n data = data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(data) : data;\n send({ id, type: Types.MESSAGE, data: data.sublist(0, maxMsgSize) });\n data.consume(maxMsgSize);\n }\n }\n }\n catch (err) {\n if (err.type === 'aborted' && err.message === 'The operation was aborted') {\n if (closeController.signal.aborted) {\n return;\n }\n if (resetController.signal.aborted) {\n err.message = 'stream reset';\n err.code = ERR_STREAM_RESET;\n }\n if (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', type, name);\n }\n else {\n log.trace('%s stream %s error', type, name, err);\n try {\n send({ id, type: Types.RESET });\n }\n catch (err) {\n log.trace('%s stream %s error sending reset', type, name, err);\n }\n }\n streamSource.end(err);\n onSinkEnd(err);\n return;\n }\n finally {\n signal.clear();\n }\n try {\n send({ id, type: Types.CLOSE });\n }\n catch (err) {\n log.trace('%s stream %s error sending close', type, name, err);\n }\n onSinkEnd();\n },\n source: streamSource,\n sourcePush: (data) => {\n streamSource.push(data);\n },\n sourceReadableLength() {\n return streamSource.readableLength;\n },\n stat: {\n direction: type === 'initiator' ? 'outbound' : 'inbound',\n timeline\n },\n metadata: {},\n id: externalId\n };\n return stream;\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/mplex/dist/src/stream.js?"); /***/ }), @@ -3169,7 +3477,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 _multistream_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.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 _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.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 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_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_2__.handshake)(stream);\n while (true) {\n const protocol = await _multistream_js__WEBPACK_IMPORTED_MODULE_1__.readString(reader, options);\n log('read \"%s\"', protocol);\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID) {\n log('respond with \"%s\" for \"%s\"', _constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID, protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(_constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID), options);\n continue;\n }\n if (protocols.includes(protocol)) {\n _multistream_js__WEBPACK_IMPORTED_MODULE_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol), options);\n log('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_1__.write(writer, new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList(...protocols.map(p => _multistream_js__WEBPACK_IMPORTED_MODULE_1__.encode((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(p)))), options);\n // multistream.writeAll(writer, protocols.map(p => uint8ArrayFromString(p)))\n log('respond with \"%s\" for %s', protocols, protocol);\n continue;\n }\n _multistream_js__WEBPACK_IMPORTED_MODULE_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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?"); +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 _multistream_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.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 _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.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 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_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_2__.handshake)(stream);\n while (true) {\n const protocol = await _multistream_js__WEBPACK_IMPORTED_MODULE_1__.readString(reader, options);\n log.trace('read \"%s\"', protocol);\n if (protocol === _constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID) {\n log.trace('respond with \"%s\" for \"%s\"', _constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID, protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(_constants_js__WEBPACK_IMPORTED_MODULE_3__.PROTOCOL_ID), options);\n continue;\n }\n if (protocols.includes(protocol)) {\n _multistream_js__WEBPACK_IMPORTED_MODULE_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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_1__.write(writer, new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList(...protocols.map(p => _multistream_js__WEBPACK_IMPORTED_MODULE_1__.encode((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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_1__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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?"); /***/ }), @@ -3191,7 +3499,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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/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_pipe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.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 it_first__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-first */ \"./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_9__.logger)('libp2p:mss');\nconst NewLine = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)('\\n');\nfunction encode(buffer) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(buffer, NewLine);\n return it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.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_0__.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 () => await 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_6__.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_2__.pipe)(input, it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.decode({ onLength, maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.MAX_PROTOCOL_LENGTH }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n if (buf == null || buf.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('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 err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('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_7__.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 */ \"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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/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_pipe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pipe */ \"./node_modules/@libp2p/multistream-select/node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 it_first__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-first */ \"./node_modules/@libp2p/multistream-select/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/multistream-select/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/multistream-select/dist/src/constants.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_9__.logger)('libp2p:mss');\nconst NewLine = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)('\\n');\nfunction encode(buffer) {\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(buffer, NewLine);\n return it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.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_0__.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 () => await 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_6__.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_2__.pipe)(input, (source) => it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.decode(source, { onLength, maxDataLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.MAX_PROTOCOL_LENGTH }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n if (buf == null || buf.length === 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_3__.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_3__.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_7__.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?"); /***/ }), @@ -3202,7 +3510,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 */ \"lazySelect\": () => (/* binding */ lazySelect),\n/* harmony export */ \"select\": () => (/* binding */ select)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n/* harmony import */ var it_handshake__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/index.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 _index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/multistream-select/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 it_pushable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_reader__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! it-reader */ \"./node_modules/it-reader/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.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('select: write [\"%s\", \"%s\"]', _index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID, protocol);\n const p1 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_2__.writeAll(writer, [p1, p2], options);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(reader, options);\n log('select: read \"%s\"', response);\n // Read the protocol response if we got the protocolId in return\n if (response === _index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(reader, options);\n log('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('select: write \"%s\"', protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_2__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol), options);\n const response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(reader, options);\n log('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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('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_7__.pushable)();\n let negotiated = false;\n return {\n stream: {\n sink: async (source) => await stream.sink((async function* () {\n let first = true;\n for await (const chunk of (0,it_merge__WEBPACK_IMPORTED_MODULE_8__[\"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_4__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol);\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList(_multistream_js__WEBPACK_IMPORTED_MODULE_2__.encode(p1), _multistream_js__WEBPACK_IMPORTED_MODULE_2__.encode(p2));\n if (chunk.length > 0)\n list.append(chunk);\n yield* list;\n }\n else {\n yield chunk;\n }\n }\n })()),\n source: (async function* () {\n if (!negotiated)\n negotiateTrigger.push(new Uint8Array());\n const byteReader = (0,it_reader__WEBPACK_IMPORTED_MODULE_9__.reader)(stream.source);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(byteReader);\n if (response === _index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(byteReader);\n }\n if (response !== protocol) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('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 */ \"lazySelect\": () => (/* binding */ lazySelect),\n/* harmony export */ \"select\": () => (/* binding */ select)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multistream_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multistream.js */ \"./node_modules/@libp2p/multistream-select/dist/src/multistream.js\");\n/* harmony import */ var it_handshake__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/index.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 _index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/multistream-select/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 it_pushable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-merge */ \"./node_modules/@libp2p/multistream-select/node_modules/it-merge/dist/src/index.js\");\n/* harmony import */ var it_reader__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! it-reader */ \"./node_modules/it-reader/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.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_5__.PROTOCOL_ID, protocol);\n const p1 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol);\n _multistream_js__WEBPACK_IMPORTED_MODULE_2__.writeAll(writer, [p1, p2], options);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.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_5__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.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_2__.write(writer, (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol), options);\n const response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.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_1__.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_7__.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_8__[\"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_4__.fromString)(_index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID);\n const p2 = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.fromString)(protocol);\n const list = new uint8arraylist__WEBPACK_IMPORTED_MODULE_6__.Uint8ArrayList(_multistream_js__WEBPACK_IMPORTED_MODULE_2__.encode(p1), _multistream_js__WEBPACK_IMPORTED_MODULE_2__.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_9__.reader)(stream.source);\n let response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(byteReader);\n if (response === _index_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_ID) {\n response = await _multistream_js__WEBPACK_IMPORTED_MODULE_2__.readString(byteReader);\n }\n if (response !== protocol) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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?"); + +/***/ }), + +/***/ "./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 ***! + \*********************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); + +/***/ }), + +/***/ "./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 ***! + \***************************************************************************************************/ +/***/ ((__unused_webpack___webpack_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?"); /***/ }), @@ -3213,7 +3543,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 */ \"default\": () => (/* binding */ first)\n/* harmony export */ });\n/**\n * Returns the first result from an (async) iterable, unless empty, in which\n * case returns `undefined`\n */\nasync function first(source) {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\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 */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\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?"); + +/***/ }), + +/***/ "./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 ***! + \*****************************************************************************************/ +/***/ ((__unused_webpack___webpack_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\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 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?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/map.js": +/*!***************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/dist/src/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 */ \"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 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?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/set.js": +/*!***************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/dist/src/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 */ \"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 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?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/util.js": +/*!****************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/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 */ \"mapIterable\": () => (/* binding */ mapIterable)\n/* harmony export */ });\n/**\n * Calls the passed map function on every entry of the passed iterable iterator\n */\nfunction mapIterable(iter, map) {\n const iterator = {\n [Symbol.iterator]: () => {\n return iterator;\n },\n next: () => {\n const next = iter.next();\n const val = next.value;\n if (next.done === true || val == null) {\n const result = {\n done: true,\n value: undefined\n };\n return result;\n }\n return {\n done: false,\n value: map(val)\n };\n }\n };\n return iterator;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-collections/dist/src/util.js?"); /***/ }), @@ -3224,7 +3631,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 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_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/peer-id/dist/src/index.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 await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 await createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return await createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.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 await createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(pubKey);\n return await 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?"); +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 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_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.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 await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 await createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return await createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.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 await createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(pubKey);\n return await 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?"); /***/ }), @@ -3235,403 +3642,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 */ \"PeerIdProto\": () => (/* binding */ PeerIdProto)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-id-factory/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 PeerIdProto;\n(function (PeerIdProto) {\n let _codec;\n PeerIdProto.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.id != null) {\n w.uint32(10);\n w.bytes(obj.id);\n }\n if (obj.pubKey != null) {\n w.uint32(18);\n w.bytes(obj.pubKey);\n }\n if (obj.privKey != null) {\n w.uint32(26);\n w.bytes(obj.privKey);\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.id = reader.bytes();\n break;\n case 2:\n obj.pubKey = reader.bytes();\n break;\n case 3:\n obj.privKey = 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 PeerIdProto.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerIdProto.codec());\n };\n PeerIdProto.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerIdProto.codec());\n };\n})(PeerIdProto || (PeerIdProto = {}));\n//# sourceMappingURL=proto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/dist/src/proto.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerIdProto\": () => (/* binding */ PeerIdProto)\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 PeerIdProto;\n(function (PeerIdProto) {\n let _codec;\n PeerIdProto.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.id != null) {\n w.uint32(10);\n w.bytes(obj.id);\n }\n if (obj.pubKey != null) {\n w.uint32(18);\n w.bytes(obj.pubKey);\n }\n if (obj.privKey != null) {\n w.uint32(26);\n w.bytes(obj.privKey);\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.id = reader.bytes();\n break;\n case 2:\n obj.pubKey = reader.bytes();\n break;\n case 3:\n obj.privKey = 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 PeerIdProto.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerIdProto.codec());\n };\n PeerIdProto.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerIdProto.codec());\n };\n})(PeerIdProto || (PeerIdProto = {}));\n//# sourceMappingURL=proto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/dist/src/proto.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.js ***! - \*******************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/dist/src/index.js": +/*!********************************************************!*\ + !*** ./node_modules/@libp2p/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/peer-id-factory/node_modules/@libp2p/interface-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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/src/basics.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_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.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-factory/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/peer-id/dist/src/index.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": +/*!************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! + \************************************************************************/ /***/ ((__unused_webpack___webpack_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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/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 */ \"Envelope\": () => (/* binding */ Envelope)\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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js ***! - \******************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/envelope/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"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/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.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_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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.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?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base10.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base10.js ***! - \********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/errors.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/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 */ \"base10\": () => (/* binding */ base10)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base10.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_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/errors.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base16.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base16.js ***! - \********************************************************************************************/ +/***/ "./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 */ \"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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base16.js?"); +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-id-factory/node_modules/multiformats/src/bases/base2.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base2.js ***! - \*******************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"base2\": () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base2.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base256emoji.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base256emoji.js ***! - \**************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"base256emoji\": () => (/* binding */ base256emoji)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base256emoji.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 _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/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 _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 _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js ***! - \********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! + \******************************************************************************/ /***/ ((__unused_webpack___webpack_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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base36.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base64.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base8.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/identity.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/interface.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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)\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/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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 */ });\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/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/raw.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/hasher.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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_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/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/interface.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/link/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/link/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/@libp2p/peer-id-factory/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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// 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/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/varint.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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 */ });\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/@libp2p/peer-id-factory/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.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 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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); /***/ }), @@ -3642,7 +3741,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 */ \"PeerStoreAddressBook\": () => (/* binding */ PeerStoreAddressBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.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/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:address-book');\nconst EVENT_NAME = 'change:multiaddrs';\nasync function allowAll() {\n return true;\n}\nclass PeerStoreAddressBook {\n constructor(dispatchEvent, store, addressFilter) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n this.addressFilter = addressFilter ?? allowAll;\n }\n /**\n * ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.\n * This will return a boolean that indicates if the record was successfully processed and added\n * into the AddressBook.\n */\n async consumePeerRecord(envelope) {\n log.trace('consumePeerRecord await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('consumePeerRecord got write lock');\n let peerId;\n let peer;\n let updatedPeer;\n try {\n let peerRecord;\n try {\n peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(envelope.payload);\n }\n catch (err) {\n log.error('invalid peer record received');\n return false;\n }\n peerId = peerRecord.peerId;\n const multiaddrs = peerRecord.multiaddrs;\n // Verify peerId\n if (!peerId.equals(envelope.peerId)) {\n log('signing key does not match PeerId in the PeerRecord');\n return false;\n }\n // ensure the record has multiaddrs\n if (multiaddrs == null || multiaddrs.length === 0) {\n return false;\n }\n if (await this.store.has(peerId)) {\n peer = await this.store.load(peerId);\n if (peer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(peer.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 return false;\n }\n }\n }\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter, true);\n // Replace unsigned addresses by the new ones from the record\n // TODO: Once we have ttls for the addresses, we should merge these in\n updatedPeer = await this.store.patchOrCreate(peerId, {\n addresses,\n peerRecordEnvelope: envelope.marshal().subarray()\n });\n log('stored provided peer record for %p', peerRecord.peerId);\n }\n finally {\n log.trace('consumePeerRecord release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(({ multiaddr }) => multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n return true;\n }\n async getRawEnvelope(peerId) {\n log.trace('getRawEnvelope await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getRawEnvelope got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.peerRecordEnvelope;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getRawEnvelope release read lock');\n release();\n }\n }\n /**\n * Get an Envelope containing a PeerRecord for the given peer.\n * Returns undefined if no record exists.\n */\n async getPeerRecord(peerId) {\n const raw = await this.getRawEnvelope(peerId);\n if (raw == null) {\n return undefined;\n }\n return await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(raw);\n }\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.addresses;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let hasPeer = false;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length && addresses.length === peer.addresses.length) {\n // not changing anything, no need to update\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, { addresses });\n log('set multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set multiaddrs for %p', peerId);\n log('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (!hasPeer) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async add(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let hasPeer;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, { addresses });\n log('added multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (hasPeer === true) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n addresses: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: [],\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n }\n }\n}\nasync function filterMultiaddrs(peerId, multiaddrs, addressFilter, isCertified = false) {\n const output = [];\n await Promise.all(multiaddrs.map(async (multiaddr) => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(multiaddr)) {\n log.error('multiaddr must be an instance of Multiaddr');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddr must be an instance of Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const include = await addressFilter(peerId, multiaddr);\n if (!include) {\n return;\n }\n output.push({\n multiaddr,\n isCertified\n });\n }));\n return output;\n}\n//# sourceMappingURL=address-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/address-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreAddressBook\": () => (/* binding */ PeerStoreAddressBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.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/* 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 _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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:address-book');\nconst EVENT_NAME = 'change:multiaddrs';\nasync function allowAll() {\n return true;\n}\nclass PeerStoreAddressBook {\n constructor(dispatchEvent, store, addressFilter) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n this.addressFilter = addressFilter ?? allowAll;\n }\n /**\n * ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.\n * This will return a boolean that indicates if the record was successfully processed and added\n * into the AddressBook.\n */\n async consumePeerRecord(envelope) {\n log.trace('consumePeerRecord await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('consumePeerRecord got write lock');\n let peerId;\n let peer;\n let updatedPeer;\n try {\n let peerRecord;\n try {\n peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(envelope.payload);\n }\n catch (err) {\n log.error('invalid peer record received');\n return false;\n }\n peerId = peerRecord.peerId;\n const multiaddrs = peerRecord.multiaddrs;\n // Verify peerId\n if (!peerId.equals(envelope.peerId)) {\n log('signing key does not match PeerId in the PeerRecord');\n return false;\n }\n // ensure the record has multiaddrs\n if (multiaddrs == null || multiaddrs.length === 0) {\n return false;\n }\n if (await this.store.has(peerId)) {\n peer = await this.store.load(peerId);\n if (peer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(peer.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 return false;\n }\n }\n }\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter, true);\n // Replace unsigned addresses by the new ones from the record\n // TODO: Once we have ttls for the addresses, we should merge these in\n updatedPeer = await this.store.patchOrCreate(peerId, {\n addresses,\n peerRecordEnvelope: envelope.marshal().subarray()\n });\n log('stored provided peer record for %p', peerRecord.peerId);\n }\n finally {\n log.trace('consumePeerRecord release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(({ multiaddr }) => multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n return true;\n }\n async getRawEnvelope(peerId) {\n log.trace('getRawEnvelope await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getRawEnvelope got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.peerRecordEnvelope;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getRawEnvelope release read lock');\n release();\n }\n }\n /**\n * Get an Envelope containing a PeerRecord for the given peer.\n * Returns undefined if no record exists.\n */\n async getPeerRecord(peerId) {\n const raw = await this.getRawEnvelope(peerId);\n if (raw == null) {\n return undefined;\n }\n return await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(raw);\n }\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.addresses;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let hasPeer = false;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length && addresses.length === peer.addresses.length) {\n // not changing anything, no need to update\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, { addresses });\n log('set multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set multiaddrs for %p', peerId);\n log('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (!hasPeer) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async add(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let hasPeer;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, { addresses });\n log('added multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (hasPeer === true) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n addresses: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: [],\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n }\n }\n}\nasync function filterMultiaddrs(peerId, multiaddrs, addressFilter, isCertified = false) {\n const output = [];\n await Promise.all(multiaddrs.map(async (multiaddr) => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(multiaddr)) {\n log.error('multiaddr must be an instance of Multiaddr');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddr must be an instance of Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const include = await addressFilter(peerId, multiaddr);\n if (!include) {\n return;\n }\n output.push({\n multiaddr,\n isCertified\n });\n }));\n return output;\n}\n//# sourceMappingURL=address-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/address-book.js?"); /***/ }), @@ -3675,7 +3774,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 */ \"PeerStoreKeyBook\": () => (/* binding */ PeerStoreKeyBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:key-book');\nconst EVENT_NAME = 'change:pubkey';\nclass PeerStoreKeyBook {\n /**\n * The KeyBook is responsible for keeping the known public keys of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Set the Peer public key\n */\n async set(peerId, publicKey) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(publicKey instanceof Uint8Array)) {\n log.error('publicKey must be an instance of Uint8Array to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('publicKey must be an instance of PublicKey', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let updatedKey = false;\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n if ((peer.pubKey != null) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(peer.pubKey, publicKey)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: publicKey\n });\n updatedKey = true;\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n if (updatedKey) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n }\n /**\n * Get Public key of the given PeerId, if stored\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('get await write lock');\n const release = await this.store.lock.readLock();\n log.trace('get got write lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.pubKey;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log('get release write lock');\n release();\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: undefined\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey: undefined,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n}\n//# sourceMappingURL=key-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/key-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreKeyBook\": () => (/* binding */ PeerStoreKeyBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:key-book');\nconst EVENT_NAME = 'change:pubkey';\nclass PeerStoreKeyBook {\n /**\n * The KeyBook is responsible for keeping the known public keys of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Set the Peer public key\n */\n async set(peerId, publicKey) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(publicKey instanceof Uint8Array)) {\n log.error('publicKey must be an instance of Uint8Array to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('publicKey must be an instance of PublicKey', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let updatedKey = false;\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n if ((peer.pubKey != null) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(peer.pubKey, publicKey)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: publicKey\n });\n updatedKey = true;\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n if (updatedKey) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n }\n /**\n * Get Public key of the given PeerId, if stored\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('get await write lock');\n const release = await this.store.lock.readLock();\n log.trace('get got write lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.pubKey;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log('get release write lock');\n release();\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: undefined\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey: undefined,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n}\n//# sourceMappingURL=key-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/key-book.js?"); /***/ }), @@ -3686,7 +3785,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 */ \"PeerStoreMetadataBook\": () => (/* binding */ PeerStoreMetadataBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:metadata-book');\nconst EVENT_NAME = 'change:metadata';\nclass PeerStoreMetadataBook {\n /**\n * The MetadataBook is responsible for keeping metadata\n * about known peers\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Get the known data of a provided peer\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(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 const peer = await this.store.load(peerId);\n return peer.metadata;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return new Map();\n }\n /**\n * Get specific metadata value, if it exists\n */\n async getValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('getValue await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getValue got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.metadata.get(key);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getValue release write lock');\n release();\n }\n }\n async set(peerId, metadata) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(metadata instanceof Map)) {\n log.error('valid metadata must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid metadata must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.mergeOrCreate(peerId, {\n metadata\n });\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n /**\n * Set metadata key and value of a provided peer\n */\n async setValue(peerId, key, value) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (typeof key !== 'string' || !(value instanceof Uint8Array)) {\n log.error('valid key and value must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid key and value must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('setValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('setValue got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const existingValue = peer.metadata.get(key);\n if (existingValue != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(value, existingValue)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n metadata: new Map([[key, value]])\n });\n }\n finally {\n log.trace('setValue release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: updatedPeer.metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n if (peer != null) {\n await this.store.patch(peerId, {\n metadata: new Map()\n });\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: new Map(),\n oldMetadata: peer.metadata\n }\n }));\n }\n }\n async deleteValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('deleteValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('deleteValue got write lock');\n let metadata;\n let peer;\n try {\n peer = await this.store.load(peerId);\n metadata = peer.metadata;\n metadata.delete(key);\n await this.store.patch(peerId, {\n metadata\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('deleteValue release write lock');\n release();\n }\n if (metadata != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n }\n}\n//# sourceMappingURL=metadata-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/metadata-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreMetadataBook\": () => (/* binding */ PeerStoreMetadataBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:metadata-book');\nconst EVENT_NAME = 'change:metadata';\nclass PeerStoreMetadataBook {\n /**\n * The MetadataBook is responsible for keeping metadata\n * about known peers\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Get the known data of a provided peer\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(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 const peer = await this.store.load(peerId);\n return peer.metadata;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return new Map();\n }\n /**\n * Get specific metadata value, if it exists\n */\n async getValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('getValue await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getValue got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.metadata.get(key);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getValue release write lock');\n release();\n }\n }\n async set(peerId, metadata) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(metadata instanceof Map)) {\n log.error('valid metadata must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid metadata must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.mergeOrCreate(peerId, {\n metadata\n });\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n /**\n * Set metadata key and value of a provided peer\n */\n async setValue(peerId, key, value) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (typeof key !== 'string' || !(value instanceof Uint8Array)) {\n log.error('valid key and value must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid key and value must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('setValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('setValue got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const existingValue = peer.metadata.get(key);\n if (existingValue != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(value, existingValue)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n metadata: new Map([[key, value]])\n });\n }\n finally {\n log.trace('setValue release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: updatedPeer.metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n if (peer != null) {\n await this.store.patch(peerId, {\n metadata: new Map()\n });\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: new Map(),\n oldMetadata: peer.metadata\n }\n }));\n }\n }\n async deleteValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('deleteValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('deleteValue got write lock');\n let metadata;\n let peer;\n try {\n peer = await this.store.load(peerId);\n metadata = peer.metadata;\n metadata.delete(key);\n await this.store.patch(peerId, {\n metadata\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('deleteValue release write lock');\n release();\n }\n if (metadata != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n }\n}\n//# sourceMappingURL=metadata-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/metadata-book.js?"); /***/ }), @@ -3697,7 +3796,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 */ \"Address\": () => (/* binding */ Address),\n/* harmony export */ \"Metadata\": () => (/* binding */ Metadata),\n/* harmony export */ \"Peer\": () => (/* binding */ Peer)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 _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.metadata != null) {\n for (const value of obj.metadata) {\n w.uint32(26);\n Metadata.codec().encode(value, w);\n }\n }\n if (obj.pubKey != null) {\n w.uint32(34);\n w.bytes(obj.pubKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: []\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 3:\n obj.metadata.push(Metadata.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pubKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = 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.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 Metadata;\n(function (Metadata) {\n let _codec;\n Metadata.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 Metadata.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Metadata.codec());\n };\n Metadata.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Metadata.codec());\n };\n})(Metadata || (Metadata = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./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 */ \"Address\": () => (/* binding */ Address),\n/* harmony export */ \"Metadata\": () => (/* binding */ Metadata),\n/* harmony export */ \"Peer\": () => (/* binding */ Peer)\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 _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.metadata != null) {\n for (const value of obj.metadata) {\n w.uint32(26);\n Metadata.codec().encode(value, w);\n }\n }\n if (obj.pubKey != null) {\n w.uint32(34);\n w.bytes(obj.pubKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: []\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 3:\n obj.metadata.push(Metadata.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pubKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = 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.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 Metadata;\n(function (Metadata) {\n let _codec;\n Metadata.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 Metadata.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Metadata.codec());\n };\n Metadata.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Metadata.codec());\n };\n})(Metadata || (Metadata = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/pb/peer.js?"); /***/ }), @@ -3708,7 +3807,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 */ \"Tag\": () => (/* binding */ Tag),\n/* harmony export */ \"Tags\": () => (/* binding */ Tags)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 Tags;\n(function (Tags) {\n let _codec;\n Tags.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.tags != null) {\n for (const value of obj.tags) {\n w.uint32(10);\n Tag.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n tags: []\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.tags.push(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 Tags.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tags.codec());\n };\n Tags.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tags.codec());\n };\n})(Tags || (Tags = {}));\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.name != null && obj.name !== '')) {\n w.uint32(10);\n w.string(obj.name);\n }\n if (obj.value != null) {\n w.uint32(16);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(24);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n name: ''\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.name = reader.string();\n break;\n case 2:\n obj.value = reader.uint32();\n break;\n case 3:\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=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/pb/tags.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Tag\": () => (/* binding */ Tag),\n/* harmony export */ \"Tags\": () => (/* binding */ Tags)\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 Tags;\n(function (Tags) {\n let _codec;\n Tags.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.tags != null) {\n for (const value of obj.tags) {\n w.uint32(10);\n Tag.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n tags: []\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.tags.push(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 Tags.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tags.codec());\n };\n Tags.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tags.codec());\n };\n})(Tags || (Tags = {}));\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.name != null && obj.name !== '')) {\n w.uint32(10);\n w.string(obj.name);\n }\n if (obj.value != null) {\n w.uint32(16);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(24);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n name: ''\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.name = reader.string();\n break;\n case 2:\n obj.value = reader.uint32();\n break;\n case 3:\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=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/pb/tags.js?"); /***/ }), @@ -3719,7 +3818,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 */ \"PeerStoreProtoBook\": () => (/* binding */ PeerStoreProtoBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/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\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:proto-book');\nconst EVENT_NAME = 'change:protocols';\nclass PeerStoreProtoBook {\n /**\n * The ProtoBook is responsible for keeping the known supported\n * protocols of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n async get(peerId) {\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.protocols;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n log('stored provided protocols for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async add(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...peer.protocols,\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n protocols\n });\n log('added provided protocols for %p', peerId);\n }\n finally {\n log.trace('add release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async remove(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('remove await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('remove got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const protocolSet = new Set(peer.protocols);\n for (const protocol of protocols) {\n protocolSet.delete(protocol);\n }\n if (peer.protocols.length === protocolSet.size) {\n return;\n }\n protocols = Array.from(protocolSet);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n }\n finally {\n log.trace('remove release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n protocols: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: [],\n oldProtocols: peer.protocols\n }\n }));\n }\n }\n}\n//# sourceMappingURL=proto-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/proto-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreProtoBook\": () => (/* binding */ PeerStoreProtoBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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_interfaces_events__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:proto-book');\nconst EVENT_NAME = 'change:protocols';\nclass PeerStoreProtoBook {\n /**\n * The ProtoBook is responsible for keeping the known supported\n * protocols of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n async get(peerId) {\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.protocols;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n log('stored provided protocols for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async add(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...peer.protocols,\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n protocols\n });\n log('added provided protocols for %p', peerId);\n }\n finally {\n log.trace('add release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async remove(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('remove await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('remove got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const protocolSet = new Set(peer.protocols);\n for (const protocol of protocols) {\n protocolSet.delete(protocol);\n }\n if (peer.protocols.length === protocolSet.size) {\n return;\n }\n protocols = Array.from(protocolSet);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n }\n finally {\n log.trace('remove release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n protocols: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: [],\n oldProtocols: peer.protocols\n }\n }));\n }\n }\n}\n//# sourceMappingURL=proto-book.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/proto-book.js?"); /***/ }), @@ -3730,172 +3829,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 */ \"PersistentStore\": () => (/* binding */ PersistentStore)\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-store/node_modules/@libp2p/peer-id/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 _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:store');\nconst NAMESPACE_COMMON = '/peers/';\nclass PersistentStore {\n constructor(components) {\n this.components = components;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n _peerIdToDatastoreKey(peerId) {\n if (peerId.type == null) {\n log.error('peerId must be an instance of peer-id to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('peerId must be an instance of peer-id', _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_4__.Key(`${NAMESPACE_COMMON}${b32key}`);\n }\n async has(peerId) {\n return await this.components.datastore.has(this._peerIdToDatastoreKey(peerId));\n }\n async delete(peerId) {\n await this.components.datastore.delete(this._peerIdToDatastoreKey(peerId));\n }\n async load(peerId) {\n const buf = await this.components.datastore.get(this._peerIdToDatastoreKey(peerId));\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.decode(buf);\n const metadata = new Map();\n for (const meta of peer.metadata) {\n metadata.set(meta.key, meta.value);\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_6__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata,\n pubKey: peer.pubKey ?? undefined,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined\n };\n }\n async save(peer) {\n if (peer.pubKey != null && peer.id.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__.equals)(peer.pubKey, peer.id.publicKey)) {\n log.error('peer publicKey bytes do not match peer id publicKey bytes');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n // dedupe addresses\n const addressSet = new Set();\n const addresses = peer.addresses\n .filter(address => {\n if (addressSet.has(address.multiaddr.toString())) {\n return false;\n }\n addressSet.add(address.multiaddr.toString());\n return true;\n })\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ multiaddr, isCertified }) => ({\n multiaddr: multiaddr.bytes,\n isCertified\n }));\n const metadata = [];\n [...peer.metadata.keys()].sort().forEach(key => {\n const value = peer.metadata.get(key);\n if (value != null) {\n metadata.push({ key, value });\n }\n });\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.encode({\n addresses,\n protocols: peer.protocols.sort(),\n pubKey: peer.pubKey,\n metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope\n });\n await this.components.datastore.put(this._peerIdToDatastoreKey(peer.id), buf.subarray());\n return await this.load(peer.id);\n }\n async patch(peerId, data) {\n const peer = await this.load(peerId);\n return await this._patch(peerId, data, peer);\n }\n async patchOrCreate(peerId, data) {\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._patch(peerId, data, peer);\n }\n async _patch(peerId, data, peer) {\n return await this.save({\n ...peer,\n ...data,\n id: peerId\n });\n }\n async merge(peerId, data) {\n const peer = await this.load(peerId);\n return await this._merge(peerId, data, peer);\n }\n async mergeOrCreate(peerId, data) {\n /** @type {Peer} */\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._merge(peerId, data, peer);\n }\n async _merge(peerId, data, peer) {\n // if the peer has certified addresses, use those in\n // favour of the supplied versions\n const addresses = new Map();\n peer.addresses.forEach((addr) => {\n addresses.set(addr.multiaddr.toString(), addr.isCertified);\n });\n (data.addresses ?? []).forEach(addr => {\n const addrString = addr.multiaddr.toString();\n const isAlreadyCertified = Boolean(addresses.get(addrString));\n const isCertified = isAlreadyCertified || addr.isCertified;\n addresses.set(addrString, isCertified);\n });\n return await this.save({\n id: peerId,\n addresses: Array.from(addresses.entries()).map(([addrStr, isCertified]) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addrStr),\n isCertified\n };\n }),\n protocols: Array.from(new Set([\n ...(peer.protocols ?? []),\n ...(data.protocols ?? [])\n ])),\n metadata: new Map([\n ...(peer.metadata?.entries() ?? []),\n ...(data.metadata?.entries() ?? [])\n ]),\n pubKey: data.pubKey ?? (peer != null ? peer.pubKey : undefined),\n peerRecordEnvelope: data.peerRecordEnvelope ?? (peer != null ? peer.peerRecordEnvelope : undefined)\n });\n }\n async *all() {\n for await (const key of this.components.datastore.queryKeys({\n prefix: NAMESPACE_COMMON\n })) {\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_5__.base32.decode(base32Str);\n yield this.load((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(buf));\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/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/peer-store/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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-store/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-store/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-store/node_modules/@libp2p/peer-record/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js": -/*!*********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***********************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.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_1__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.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_11__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js": -/*!***************************************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-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 */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js": -/*!*********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!******************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!*******************************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \*******************************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc-direct'],\n [281, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); +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_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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/@libp2p/peer-store/node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:store');\nconst NAMESPACE_COMMON = '/peers/';\nclass PersistentStore {\n constructor(components) {\n this.components = components;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n _peerIdToDatastoreKey(peerId) {\n if (peerId.type == null) {\n log.error('peerId must be an instance of peer-id to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('peerId must be an instance of peer-id', _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_4__.Key(`${NAMESPACE_COMMON}${b32key}`);\n }\n async has(peerId) {\n return await this.components.datastore.has(this._peerIdToDatastoreKey(peerId));\n }\n async delete(peerId) {\n await this.components.datastore.delete(this._peerIdToDatastoreKey(peerId));\n }\n async load(peerId) {\n const buf = await this.components.datastore.get(this._peerIdToDatastoreKey(peerId));\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.decode(buf);\n const metadata = new Map();\n for (const meta of peer.metadata) {\n metadata.set(meta.key, meta.value);\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_6__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata,\n pubKey: peer.pubKey ?? undefined,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined\n };\n }\n async save(peer) {\n if (peer.pubKey != null && peer.id.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__.equals)(peer.pubKey, peer.id.publicKey)) {\n log.error('peer publicKey bytes do not match peer id publicKey bytes');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n // dedupe addresses\n const addressSet = new Set();\n const addresses = peer.addresses\n .filter(address => {\n if (addressSet.has(address.multiaddr.toString())) {\n return false;\n }\n addressSet.add(address.multiaddr.toString());\n return true;\n })\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ multiaddr, isCertified }) => ({\n multiaddr: multiaddr.bytes,\n isCertified\n }));\n const metadata = [];\n [...peer.metadata.keys()].sort().forEach(key => {\n const value = peer.metadata.get(key);\n if (value != null) {\n metadata.push({ key, value });\n }\n });\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.encode({\n addresses,\n protocols: peer.protocols.sort(),\n pubKey: peer.pubKey,\n metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope\n });\n await this.components.datastore.put(this._peerIdToDatastoreKey(peer.id), buf.subarray());\n return await this.load(peer.id);\n }\n async patch(peerId, data) {\n const peer = await this.load(peerId);\n return await this._patch(peerId, data, peer);\n }\n async patchOrCreate(peerId, data) {\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._patch(peerId, data, peer);\n }\n async _patch(peerId, data, peer) {\n return await this.save({\n ...peer,\n ...data,\n id: peerId\n });\n }\n async merge(peerId, data) {\n const peer = await this.load(peerId);\n return await this._merge(peerId, data, peer);\n }\n async mergeOrCreate(peerId, data) {\n /** @type {Peer} */\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._merge(peerId, data, peer);\n }\n async _merge(peerId, data, peer) {\n // if the peer has certified addresses, use those in\n // favour of the supplied versions\n const addresses = new Map();\n peer.addresses.forEach((addr) => {\n addresses.set(addr.multiaddr.toString(), addr.isCertified);\n });\n (data.addresses ?? []).forEach(addr => {\n const addrString = addr.multiaddr.toString();\n const isAlreadyCertified = Boolean(addresses.get(addrString));\n const isCertified = isAlreadyCertified || addr.isCertified;\n addresses.set(addrString, isCertified);\n });\n return await this.save({\n id: peerId,\n addresses: Array.from(addresses.entries()).map(([addrStr, isCertified]) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addrStr),\n isCertified\n };\n }),\n protocols: Array.from(new Set([\n ...(peer.protocols ?? []),\n ...(data.protocols ?? [])\n ])),\n metadata: new Map([\n ...(peer.metadata?.entries() ?? []),\n ...(data.metadata?.entries() ?? [])\n ]),\n pubKey: data.pubKey ?? (peer != null ? peer.pubKey : undefined),\n peerRecordEnvelope: data.peerRecordEnvelope ?? (peer != null ? peer.peerRecordEnvelope : undefined)\n });\n }\n async *all() {\n for await (const key of this.components.datastore.queryKeys({\n prefix: NAMESPACE_COMMON\n })) {\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_5__.base32.decode(base32Str);\n yield this.load((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(buf));\n }\n }\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/dist/src/store.js?"); /***/ }), @@ -3917,7 +3851,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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/@libp2p/peer-store/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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); /***/ }), @@ -3928,7 +3862,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 */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js?"); /***/ }), @@ -3954,377 +3888,47 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base10.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base16.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base2.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base256emoji.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base36.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base64.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base8.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/identity.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/interface.js": +/***/ "./node_modules/@libp2p/peer-store/node_modules/interface-datastore/dist/src/key.js": /*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/interface.js ***! + !*** ./node_modules/@libp2p/peer-store/node_modules/interface-datastore/dist/src/key.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/@libp2p/peer-store/node_modules/multiformats/src/bases/interface.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Key\": () => (/* binding */ Key)\n/* harmony export */ });\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\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/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\nconst pathSepS = '/';\nconst pathSepB = new TextEncoder().encode(pathSepS);\nconst pathSep = pathSepB[0];\n/**\n * A Key represents the unique identifier of an object.\n * Our Key scheme is inspired by file systems and Google App Engine key model.\n * Keys are meant to be unique across a system. Keys are hierarchical,\n * incorporating more and more specific namespaces. Thus keys can be deemed\n * 'children' or 'ancestors' of other keys:\n * - `new Key('/Comedy')`\n * - `new Key('/Comedy/MontyPython')`\n * Also, every namespace can be parametrized to embed relevant object\n * information. For example, the Key `name` (most specific namespace) could\n * include the object type:\n * - `new Key('/Comedy/MontyPython/Actor:JohnCleese')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')`\n *\n */\nclass Key {\n /**\n * @param {string | Uint8Array} s\n * @param {boolean} [clean]\n */\n constructor(s, clean) {\n if (typeof s === 'string') {\n this._buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(s);\n }\n else if (s instanceof Uint8Array) {\n this._buf = s;\n }\n else {\n throw new Error('Invalid key, should be String of Uint8Array');\n }\n if (clean == null) {\n clean = true;\n }\n if (clean) {\n this.clean();\n }\n if (this._buf.byteLength === 0 || this._buf[0] !== pathSep) {\n throw new Error('Invalid key');\n }\n }\n /**\n * Convert to the string representation\n *\n * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.\n * @returns {string}\n */\n toString(encoding = 'utf8') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(this._buf, encoding);\n }\n /**\n * Return the Uint8Array representation of the key\n *\n * @returns {Uint8Array}\n */\n uint8Array() {\n return this._buf;\n }\n /**\n * Return string representation of the key\n *\n * @returns {string}\n */\n get [Symbol.toStringTag]() {\n return `Key(${this.toString()})`;\n }\n /**\n * Constructs a key out of a namespace array.\n *\n * @param {Array} list - The array of namespaces\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.withNamespaces(['one', 'two'])\n * // => Key('/one/two')\n * ```\n */\n static withNamespaces(list) {\n return new Key(list.join(pathSepS));\n }\n /**\n * Returns a randomly (uuid) generated key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.random()\n * // => Key('/f98719ea086343f7b71f32ea9d9d521d')\n * ```\n */\n static random() {\n return new Key((0,nanoid__WEBPACK_IMPORTED_MODULE_2__.nanoid)().replace(/-/g, ''));\n }\n /**\n * @param {*} other\n */\n static asKey(other) {\n if (other instanceof Uint8Array || typeof other === 'string') {\n // we can create a key from this\n return new Key(other);\n }\n if (typeof other.uint8Array === 'function') {\n // this is an older version or may have crossed the esm/cjs boundary\n return new Key(other.uint8Array());\n }\n return null;\n }\n /**\n * Cleanup the current key\n *\n * @returns {void}\n */\n clean() {\n if (this._buf == null || this._buf.byteLength === 0) {\n this._buf = pathSepB;\n }\n if (this._buf[0] !== pathSep) {\n const bytes = new Uint8Array(this._buf.byteLength + 1);\n bytes.fill(pathSep, 0, 1);\n bytes.set(this._buf, 1);\n this._buf = bytes;\n }\n // normalize does not remove trailing slashes\n while (this._buf.byteLength > 1 && this._buf[this._buf.byteLength - 1] === pathSep) {\n this._buf = this._buf.subarray(0, -1);\n }\n }\n /**\n * Check if the given key is sorted lower than ourself.\n *\n * @param {Key} key - The other Key to check against\n * @returns {boolean}\n */\n less(key) {\n const list1 = this.list();\n const list2 = key.list();\n for (let i = 0; i < list1.length; i++) {\n if (list2.length < i + 1) {\n return false;\n }\n const c1 = list1[i];\n const c2 = list2[i];\n if (c1 < c2) {\n return true;\n }\n else if (c1 > c2) {\n return false;\n }\n }\n return list1.length < list2.length;\n }\n /**\n * Returns the key with all parts in reversed order.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').reverse()\n * // => Key('/Actor:JohnCleese/MontyPython/Comedy')\n * ```\n */\n reverse() {\n return Key.withNamespaces(this.list().slice().reverse());\n }\n /**\n * Returns the `namespaces` making up this Key.\n *\n * @returns {Array}\n */\n namespaces() {\n return this.list();\n }\n /** Returns the \"base\" namespace of this key.\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').baseNamespace()\n * // => 'Actor:JohnCleese'\n * ```\n */\n baseNamespace() {\n const ns = this.namespaces();\n return ns[ns.length - 1];\n }\n /**\n * Returns the `list` representation of this key.\n *\n * @returns {Array}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()\n * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']\n * ```\n */\n list() {\n return this.toString().split(pathSepS).slice(1);\n }\n /**\n * Returns the \"type\" of this key (value of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').type()\n * // => 'Actor'\n * ```\n */\n type() {\n return namespaceType(this.baseNamespace());\n }\n /**\n * Returns the \"name\" of this key (field of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').name()\n * // => 'JohnCleese'\n * ```\n */\n name() {\n return namespaceValue(this.baseNamespace());\n }\n /**\n * Returns an \"instance\" of this type key (appends value to namespace).\n *\n * @param {string} s - The string to append.\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor').instance('JohnClesse')\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n instance(s) {\n return new Key(this.toString() + ':' + s);\n }\n /**\n * Returns the \"path\" of this key (parent + type).\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').path()\n * // => Key('/Comedy/MontyPython/Actor')\n * ```\n */\n path() {\n let p = this.parent().toString();\n if (!p.endsWith(pathSepS)) {\n p += pathSepS;\n }\n p += this.type();\n return new Key(p);\n }\n /**\n * Returns the `parent` Key of this Key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key(\"/Comedy/MontyPython/Actor:JohnCleese\").parent()\n * // => Key(\"/Comedy/MontyPython\")\n * ```\n */\n parent() {\n const list = this.list();\n if (list.length === 1) {\n return new Key(pathSepS);\n }\n return new Key(list.slice(0, -1).join(pathSepS));\n }\n /**\n * Returns the `child` Key of this Key.\n *\n * @param {Key} key - The child Key to add\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').child(new Key('Actor:JohnCleese'))\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n child(key) {\n if (this.toString() === pathSepS) {\n return key;\n }\n else if (key.toString() === pathSepS) {\n return this;\n }\n return new Key(this.toString() + key.toString(), false);\n }\n /**\n * Returns whether this key is a prefix of `other`\n *\n * @param {Key} other - The other key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy').isAncestorOf('/Comedy/MontyPython')\n * // => true\n * ```\n */\n isAncestorOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return other.toString().startsWith(this.toString());\n }\n /**\n * Returns whether this key is a contains another as prefix.\n *\n * @param {Key} other - The other Key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').isDecendantOf('/Comedy')\n * // => true\n * ```\n */\n isDecendantOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return this.toString().startsWith(other.toString());\n }\n /**\n * Checks if this key has only one namespace.\n *\n * @returns {boolean}\n *\n */\n isTopLevel() {\n return this.list().length === 1;\n }\n /**\n * Concats one or more Keys into one new Key.\n *\n * @param {Array} keys - The array of keys to concatenate\n * @returns {Key}\n */\n concat(...keys) {\n return Key.withNamespaces([...this.namespaces(), ...flatten(keys.map(key => key.namespaces()))]);\n }\n}\n/**\n * The first component of a namespace. `foo` in `foo:bar`\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceType(ns) {\n const parts = ns.split(':');\n if (parts.length < 2) {\n return '';\n }\n return parts.slice(0, -1).join(':');\n}\n/**\n * The last component of a namespace, `baz` in `foo:bar:baz`.\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceValue(ns) {\n const parts = ns.split(':');\n return parts[parts.length - 1];\n}\n/**\n * Flatten array of arrays (only one level)\n *\n * @template T\n * @param {Array} arr\n * @returns {T[]}\n */\nfunction flatten(arr) {\n return ([]).concat(...arr);\n}\n//# sourceMappingURL=key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/interface-datastore/dist/src/key.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.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 */ \"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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/basics.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 /**\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/peer-store/node_modules/multiformats/src/bytes.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bytes.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 */ \"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/@libp2p/peer-store/node_modules/multiformats/src/bytes.js?"); +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 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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/multiformats/src/hashes/sha2-browser.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/pubsub/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/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_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_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_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_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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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/peer-store/node_modules/multiformats/src/cid.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js ***! - \******************************************************************************/ +/***/ "./node_modules/@libp2p/topology/dist/src/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/@libp2p/topology/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\": () => (/* 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/@libp2p/peer-store/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/codecs/json.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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 */ });\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/@libp2p/peer-store/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/codecs/raw.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/hasher.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/identity.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/index.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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_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/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/interface.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/link/interface.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/src/link/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/@libp2p/peer-store/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/src/varint.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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/@libp2p/peer-store/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/@libp2p/peer-store/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/vendor/base-x.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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// 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/@libp2p/peer-store/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/multiformats/vendor/varint.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/multiformats/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 */ });\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/@libp2p/peer-store/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js ***! - \*****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js?"); +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 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 get [_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol]() {\n return true;\n }\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?"); /***/ }), @@ -4379,7 +3983,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 */ \"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 const { address } = ma.nodeAddress();\n return Boolean((0,private_ip__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(address));\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__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?"); /***/ }), @@ -4390,7 +3994,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 */ \"streamToMaConnection\": () => (/* binding */ streamToMaConnection)\n/* harmony export */ });\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:stream:converter');\n/**\n * Convert a duplex iterable into a MultiaddrConnection.\n * https://github.com/libp2p/interface-transport#multiaddrconnection\n */\nfunction streamToMaConnection(props, options = {}) {\n const { stream, remoteAddr } = props;\n const { sink, source } = stream;\n const mapSource = (async function* () {\n for await (const list of source) {\n yield* list;\n }\n }());\n const maConn = {\n async sink(source) {\n if (options.signal != null) {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(source, options.signal);\n }\n try {\n await sink(source);\n await close();\n }\n catch (err) {\n // If aborted we can safely ignore\n if (err.type !== 'aborted') {\n // If the source errored the socket will already have been destroyed by\n // toIterable.duplex(). If the socket errored it will already be\n // destroyed. There's nothing to do here except log the error & return.\n log(err);\n }\n }\n },\n source: (options.signal != null) ? (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(mapSource, options.signal) : mapSource,\n remoteAddr,\n /** @type {Timeline} */\n timeline: { open: Date.now(), close: undefined },\n async close() {\n await sink(async function* () {\n yield new Uint8Array(0);\n }());\n await close();\n }\n };\n async function close() {\n if (maConn.timeline.close == null) {\n maConn.timeline.close = Date.now();\n }\n return await Promise.resolve();\n }\n return maConn;\n}\n//# sourceMappingURL=stream-to-ma-conn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"streamToMaConnection\": () => (/* binding */ streamToMaConnection)\n/* harmony export */ });\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/@libp2p/utils/node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:stream:converter');\n/**\n * Convert a duplex iterable into a MultiaddrConnection.\n * https://github.com/libp2p/interface-transport#multiaddrconnection\n */\nfunction streamToMaConnection(props, options = {}) {\n const { stream, remoteAddr } = props;\n const { sink, source } = stream;\n const mapSource = (async function* () {\n for await (const list of source) {\n if (list instanceof Uint8Array) {\n yield list;\n }\n else {\n yield* list;\n }\n }\n }());\n const maConn = {\n async sink(source) {\n if (options.signal != null) {\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(source, options.signal);\n }\n try {\n await sink(source);\n await close();\n }\n catch (err) {\n // If aborted we can safely ignore\n if (err.type !== 'aborted') {\n // If the source errored the socket will already have been destroyed by\n // toIterable.duplex(). If the socket errored it will already be\n // destroyed. There's nothing to do here except log the error & return.\n log(err);\n }\n }\n },\n source: (options.signal != null) ? (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(mapSource, options.signal) : mapSource,\n remoteAddr,\n timeline: { open: Date.now(), close: undefined },\n async close() {\n await sink(async function* () {\n yield new Uint8Array(0);\n }());\n await close();\n }\n };\n async function close() {\n if (maConn.timeline.close == null) {\n maConn.timeline.close = Date.now();\n }\n await Promise.resolve();\n }\n return maConn;\n}\n//# sourceMappingURL=stream-to-ma-conn.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/node_modules/abortable-iterator/dist/src/abort-error.js": +/*!********************************************************************************************!*\ + !*** ./node_modules/@libp2p/utils/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/utils/node_modules/abortable-iterator/dist/src/abort-error.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/utils/node_modules/abortable-iterator/dist/src/index.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/utils/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/utils/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/utils/node_modules/abortable-iterator/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/websockets/dist/src/constants.js": +/*!***************************************************************!*\ + !*** ./node_modules/@libp2p/websockets/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 */ \"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?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/websockets/dist/src/filters.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/websockets/dist/src/filters.js ***! + \*************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"all\": () => (/* binding */ all),\n/* harmony export */ \"dnsWsOrWss\": () => (/* binding */ dnsWsOrWss),\n/* harmony export */ \"dnsWss\": () => (/* binding */ dnsWss),\n/* harmony export */ \"wss\": () => (/* binding */ wss)\n/* harmony export */ });\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 _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/websockets/dist/src/constants.js\");\n\n\nfunction all(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSockets.matches(testMa) ||\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa);\n });\n}\nfunction wss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa);\n });\n}\nfunction dnsWss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa) &&\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WSS));\n });\n}\nfunction dnsWsOrWss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n // WS\n if (_multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSockets.matches(testMa)) {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WS));\n }\n // WSS\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa) &&\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WSS));\n });\n}\n//# sourceMappingURL=filters.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/filters.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/websockets/dist/src/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/@libp2p/websockets/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 */ \"webSockets\": () => (/* binding */ webSockets)\n/* harmony export */ });\n/* harmony import */ var it_ws_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-ws/client */ \"./node_modules/it-ws/dist/src/client.js\");\n/* harmony import */ var _multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr-to-uri */ \"./node_modules/@multiformats/multiaddr-to-uri/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 p_defer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/@libp2p/websockets/dist/src/listener.browser.js\");\n/* harmony import */ var _socket_to_conn_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./socket-to-conn.js */ \"./node_modules/@libp2p/websockets/dist/src/socket-to-conn.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 _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_4__.logger)('libp2p:websockets');\nclass WebSockets {\n constructor(init) {\n this.init = init;\n }\n get [Symbol.toStringTag]() {\n return '@libp2p/websockets';\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_9__.symbol]() {\n return true;\n }\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_7__.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_2__.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_3__[\"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_0__.connect)((0,_multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_1__.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_2__.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_6__.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_8__.wss(multiaddrs);\n }\n return _filters_js__WEBPACK_IMPORTED_MODULE_8__.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?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/websockets/dist/src/listener.browser.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@libp2p/websockets/dist/src/listener.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 */ \"createListener\": () => (/* binding */ createListener)\n/* harmony export */ });\nfunction createListener() {\n throw new Error('WebSocket Servers can not be created in the browser!');\n}\n//# sourceMappingURL=listener.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@libp2p/websockets/dist/src/listener.browser.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js": +/*!********************************************************************!*\ + !*** ./node_modules/@libp2p/websockets/dist/src/socket-to-conn.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_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 abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@libp2p/websockets/dist/src/constants.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 _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: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_0__.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_0__.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_1__.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?"); /***/ }), @@ -4401,359 +4082,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 */ \"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 */ \"IPFS\": () => (/* binding */ IPFS),\n/* harmony export */ \"P2P\": () => (/* binding */ P2P),\n/* harmony export */ \"QUIC\": () => (/* binding */ QUIC),\n/* harmony export */ \"Reliable\": () => (/* binding */ Reliable),\n/* harmony export */ \"Stardust\": () => (/* binding */ Stardust),\n/* harmony export */ \"TCP\": () => (/* binding */ TCP),\n/* harmony export */ \"UDP\": () => (/* binding */ UDP),\n/* harmony export */ \"UTP\": () => (/* binding */ UTP),\n/* harmony export */ \"WebRTCDirect\": () => (/* binding */ WebRTCDirect),\n/* harmony export */ \"WebRTCStar\": () => (/* binding */ WebRTCStar),\n/* harmony export */ \"WebSocketStar\": () => (/* binding */ WebSocketStar),\n/* harmony export */ \"WebSockets\": () => (/* binding */ WebSockets),\n/* harmony export */ \"WebSocketsSecure\": () => (/* binding */ WebSocketsSecure)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n/*\n * Valid combinations\n */\nconst DNS4 = base('dns4');\nconst DNS6 = base('dns6');\nconst DNSADDR = base('dnsaddr');\nconst DNS = or(base('dns'), DNSADDR, DNS4, DNS6);\nconst IP = or(base('ip4'), base('ip6'));\nconst TCP = or(and(IP, base('tcp')), and(DNS, base('tcp')));\nconst UDP = and(IP, base('udp'));\nconst UTP = and(UDP, base('utp'));\nconst QUIC = and(UDP, base('quic'));\nconst WebSockets = or(and(TCP, base('ws')), and(DNS, base('ws')));\nconst WebSocketsSecure = or(and(TCP, base('wss')), and(DNS, base('wss')));\nconst HTTP = or(and(TCP, base('http')), and(IP, base('http')), and(DNS, base('http')));\nconst HTTPS = or(and(TCP, base('https')), and(IP, base('https')), and(DNS, base('https')));\nconst WebRTCStar = or(and(WebSockets, base('p2p-webrtc-star'), base('p2p')), and(WebSocketsSecure, base('p2p-webrtc-star'), base('p2p')), and(WebSockets, base('p2p-webrtc-star')), and(WebSocketsSecure, base('p2p-webrtc-star')));\nconst WebSocketStar = or(and(WebSockets, base('p2p-websocket-star'), base('p2p')), and(WebSocketsSecure, base('p2p-websocket-star'), base('p2p')), and(WebSockets, base('p2p-websocket-star')), and(WebSocketsSecure, base('p2p-websocket-star')));\nconst WebRTCDirect = or(and(HTTP, base('p2p-webrtc-direct'), base('p2p')), and(HTTPS, base('p2p-webrtc-direct'), base('p2p')), and(HTTP, base('p2p-webrtc-direct')), and(HTTPS, base('p2p-webrtc-direct')));\nconst Reliable = or(WebSockets, WebSocketsSecure, HTTP, HTTPS, WebRTCStar, WebRTCDirect, TCP, UTP, QUIC, DNS);\n// Unlike ws-star, stardust can run over any transport thus removing the requirement for websockets (but don't even think about running a stardust server over webrtc-star ;) )\nconst Stardust = or(and(Reliable, base('p2p-stardust'), base('p2p')), and(Reliable, base('p2p-stardust')));\nconst _P2P = or(and(Reliable, base('p2p')), WebRTCStar, WebRTCDirect, base('p2p'));\nconst _Circuit = or(and(_P2P, base('p2p-circuit'), _P2P), and(_P2P, base('p2p-circuit')), and(base('p2p-circuit'), _P2P), and(Reliable, base('p2p-circuit')), and(base('p2p-circuit'), Reliable), base('p2p-circuit'));\nconst CircuitRecursive = () => or(and(_Circuit, CircuitRecursive), _Circuit);\nconst Circuit = CircuitRecursive();\nconst P2P = or(and(Circuit, _P2P, Circuit), and(_P2P, Circuit), and(Circuit, _P2P), Circuit, _P2P);\nconst IPFS = P2P;\n/*\n * Validation funcs\n */\nfunction makeMatchesFunction(partialMatch) {\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const out = partialMatch(ma.protoNames());\n if (out === null) {\n return false;\n }\n if (out === true || out === false) {\n return out;\n }\n return out.length === 0;\n }\n return matches;\n}\nfunction and(...args) {\n function partialMatch(a) {\n if (a.length < args.length) {\n return null;\n }\n let out = a;\n args.some((arg) => {\n out = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (Array.isArray(out)) {\n a = out;\n }\n if (out === null) {\n return true;\n }\n return false;\n });\n return out;\n }\n return {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch: partialMatch\n };\n}\nfunction or(...args) {\n function partialMatch(a) {\n let out = null;\n args.some((arg) => {\n const res = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (res != null) {\n out = res;\n return true;\n }\n return false;\n });\n return out;\n }\n const result = {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch: partialMatch\n };\n return result;\n}\nfunction base(n) {\n const name = n;\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const pnames = ma.protoNames();\n if (pnames.length === 1 && pnames[0] === name) {\n return true;\n }\n return false;\n }\n function partialMatch(protos) {\n if (protos.length === 0) {\n return null;\n }\n if (protos[0] === name) {\n return protos.slice(1);\n }\n return null;\n }\n return {\n toString: function () { return name; },\n matches: matches,\n partialMatch: partialMatch\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\n // TODO: 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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = sizeForAddr(p, buf.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n i += n;\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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n case 41: // ipv6\n return bytes2ip(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 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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n return ip2bytes(str);\n case 41: // ipv6\n return ip2bytes(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 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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/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 */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\nconst P2P_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('p2p').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ipfs').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, addr.address, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\n }\n toJSON() {\n return this.toString();\n }\n toOptions() {\n const codes = this.protoCodes();\n const parts = this.toString().split('/').slice(1);\n let transport;\n let port;\n if (parts.length > 2) {\n // default to https when protocol & port are omitted from DNS addrs\n if (DNS_CODES.includes(codes[0]) && P2P_CODES.includes(codes[1])) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('tcp').name;\n port = 443;\n }\n else {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(parts[2]).name;\n port = parseInt(parts[3]);\n }\n }\n else if (DNS_CODES.includes(codes[0])) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('tcp').name;\n port = 443;\n }\n else {\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: (codes[0] === 41 || codes[0] === 55) ? 6 : 4,\n host: parts[1],\n transport,\n port\n };\n return opts;\n }\n protos() {\n return this.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \***********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base10.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base16.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base2.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base256emoji.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base32.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base36.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base58.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base64.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/base8.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/identity.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/interface.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bases/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/mafmt/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/basics.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/bytes.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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)\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/mafmt/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/cid.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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 */ });\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/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/** @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 {\n code: this.code,\n version: this.version,\n hash: this.multihash.bytes\n }\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 returs 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 // 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/mafmt/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/codecs/json.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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 */ });\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/mafmt/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/codecs/raw.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/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/mafmt/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/hashes/digest.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@multiformats/mafmt/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 alogrithm 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/mafmt/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/hashes/hasher.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/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/mafmt/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/hashes/identity.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/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/mafmt/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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_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/mafmt/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/mafmt/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/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/mafmt/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/mafmt/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/mafmt/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/interface.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/link/interface.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/src/link/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/mafmt/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/src/varint.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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/mafmt/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/mafmt/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/vendor/base-x.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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// 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/mafmt/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/mafmt/node_modules/multiformats/vendor/varint.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/mafmt/node_modules/multiformats/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 */ });\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/mafmt/node_modules/multiformats/vendor/varint.js?"); +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 */ \"IPFS\": () => (/* binding */ IPFS),\n/* harmony export */ \"P2P\": () => (/* binding */ P2P),\n/* harmony export */ \"P2PWebRTCDirect\": () => (/* binding */ P2PWebRTCDirect),\n/* harmony export */ \"P2PWebRTCStar\": () => (/* binding */ P2PWebRTCStar),\n/* harmony export */ \"QUIC\": () => (/* binding */ QUIC),\n/* harmony export */ \"QUICV1\": () => (/* binding */ QUICV1),\n/* harmony export */ \"Reliable\": () => (/* binding */ Reliable),\n/* harmony export */ \"Stardust\": () => (/* binding */ Stardust),\n/* harmony export */ \"TCP\": () => (/* binding */ TCP),\n/* harmony export */ \"UDP\": () => (/* binding */ UDP),\n/* harmony export */ \"UTP\": () => (/* binding */ UTP),\n/* harmony export */ \"WebRTC\": () => (/* binding */ WebRTC),\n/* harmony export */ \"WebRTCDirect\": () => (/* binding */ WebRTCDirect),\n/* harmony export */ \"WebSocketStar\": () => (/* binding */ WebSocketStar),\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 _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n/*\n * Valid combinations\n */\nconst DNS4 = base('dns4');\nconst DNS6 = base('dns6');\nconst DNSADDR = base('dnsaddr');\nconst DNS = or(base('dns'), DNSADDR, DNS4, DNS6);\nconst IP = or(base('ip4'), base('ip6'));\nconst TCP = or(and(IP, base('tcp')), and(DNS, base('tcp')));\nconst UDP = and(IP, base('udp'));\nconst UTP = and(UDP, base('utp'));\nconst QUIC = and(UDP, base('quic'));\nconst QUICV1 = and(UDP, base('quic-v1'));\nconst WebSockets = or(and(TCP, base('ws')), and(DNS, base('ws')));\nconst WebSocketsSecure = or(and(TCP, base('wss')), and(DNS, base('wss')), and(TCP, base('tls'), base('ws')), and(DNS, base('tls'), base('ws')));\nconst HTTP = or(and(TCP, base('http')), and(IP, base('http')), and(DNS, base('http')));\nconst HTTPS = or(and(TCP, base('https')), and(IP, base('https')), and(DNS, base('https')));\nconst _WebRTCDirect = and(UDP, base('webrtc-direct'), base('certhash'));\nconst WebRTCDirect = or(and(_WebRTCDirect, base('p2p')), _WebRTCDirect);\nconst _WebTransport = and(QUICV1, base('webtransport'), base('certhash'), base('certhash'));\nconst WebTransport = or(and(_WebTransport, base('p2p')), _WebTransport);\n/**\n * @deprecated\n */\nconst P2PWebRTCStar = or(and(WebSockets, base('p2p-webrtc-star'), base('p2p')), and(WebSocketsSecure, base('p2p-webrtc-star'), base('p2p')), and(WebSockets, base('p2p-webrtc-star')), and(WebSocketsSecure, base('p2p-webrtc-star')));\nconst WebSocketStar = or(and(WebSockets, base('p2p-websocket-star'), base('p2p')), and(WebSocketsSecure, base('p2p-websocket-star'), base('p2p')), and(WebSockets, base('p2p-websocket-star')), and(WebSocketsSecure, base('p2p-websocket-star')));\n/**\n * @deprecated\n */\nconst P2PWebRTCDirect = or(and(HTTP, base('p2p-webrtc-direct'), base('p2p')), and(HTTPS, base('p2p-webrtc-direct'), base('p2p')), and(HTTP, base('p2p-webrtc-direct')), and(HTTPS, base('p2p-webrtc-direct')));\nconst Reliable = or(WebSockets, WebSocketsSecure, HTTP, HTTPS, P2PWebRTCStar, P2PWebRTCDirect, TCP, UTP, QUIC, DNS, WebRTCDirect, WebTransport);\n// Unlike ws-star, stardust can run over any transport thus removing the requirement for websockets (but don't even think about running a stardust server over webrtc-star ;) )\nconst Stardust = or(and(Reliable, base('p2p-stardust'), base('p2p')), and(Reliable, base('p2p-stardust')));\nconst _P2P = or(and(Reliable, base('p2p')), P2PWebRTCStar, P2PWebRTCDirect, WebRTCDirect, WebTransport, base('p2p'));\nconst _Circuit = or(and(_P2P, base('p2p-circuit'), _P2P), and(_P2P, base('p2p-circuit')), and(base('p2p-circuit'), _P2P), and(Reliable, base('p2p-circuit')), and(base('p2p-circuit'), Reliable), base('p2p-circuit'));\nconst CircuitRecursive = () => or(and(_Circuit, CircuitRecursive), _Circuit);\nconst Circuit = CircuitRecursive();\nconst P2P = or(and(Circuit, _P2P, Circuit), and(_P2P, Circuit), and(Circuit, _P2P), Circuit, _P2P);\nconst IPFS = P2P;\nconst WebRTC = or(and(Circuit, base('webrtc'), base('p2p')), and(Circuit, base('webrtc')), and(Reliable, base('webrtc'), base('p2p')), and(Reliable, base('webrtc')), base('webrtc'));\n/*\n * Validation funcs\n */\nfunction makeMatchesFunction(partialMatch) {\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const out = partialMatch(ma.protoNames());\n if (out === null) {\n return false;\n }\n if (out === true || out === false) {\n return out;\n }\n return out.length === 0;\n }\n return matches;\n}\nfunction and(...args) {\n function partialMatch(a) {\n if (a.length < args.length) {\n return null;\n }\n let out = a;\n args.some((arg) => {\n out = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (Array.isArray(out)) {\n a = out;\n }\n if (out === null) {\n return true;\n }\n return false;\n });\n return out;\n }\n return {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n}\nfunction or(...args) {\n function partialMatch(a) {\n let out = null;\n args.some((arg) => {\n const res = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (res != null) {\n out = res;\n return true;\n }\n return false;\n });\n return out;\n }\n const result = {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n return result;\n}\nfunction base(n) {\n const name = n;\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const pnames = ma.protoNames();\n if (pnames.length === 1 && pnames[0] === name) {\n return true;\n }\n return false;\n }\n function partialMatch(protos) {\n if (protos.length === 0) {\n return null;\n }\n if (protos[0] === name) {\n return protos.slice(1);\n }\n return null;\n }\n return {\n toString: function () { return name; },\n matches,\n partialMatch\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/mafmt/dist/src/index.js?"); /***/ }), @@ -4764,359 +4093,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-to-uri/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\nconst reduceValue = (_, v) => v;\nconst tcpUri = (str, port, parts, opts) => {\n // return tcp when explicitly requested\n if ((opts != null) && opts.assumeHttp === false)\n return `tcp://${str}:${port}`;\n // check if tcp is the last protocol in multiaddr\n let protocol = 'tcp';\n let explicitPort = `:${port}`;\n const last = parts[parts.length - 1];\n if (last.protocol === 'tcp') {\n // assume http and produce clean urls\n protocol = port === '443' ? 'https' : 'http';\n explicitPort = port === '443' || port === '80' ? '' : explicitPort;\n }\n return `${protocol}://${str}${explicitPort}`;\n};\nconst Reducers = {\n ip4: reduceValue,\n ip6: (str, content, i, parts) => (parts.length === 1 && parts[0].protocol === 'ip6'\n ? content\n : `[${content}]`),\n tcp: (str, content, i, parts, opts) => (parts.some(p => ['http', 'https', 'ws', 'wss'].includes(p.protocol))\n ? `${str}:${content}`\n : tcpUri(str, content, parts, opts)),\n udp: (str, content) => `udp://${str}:${content}`,\n dnsaddr: reduceValue,\n dns4: reduceValue,\n dns6: reduceValue,\n ipfs: (str, content) => `${str}/ipfs/${content}`,\n p2p: (str, content) => `${str}/p2p/${content}`,\n http: str => `http://${str}`,\n https: str => `https://${str}`,\n ws: str => `ws://${str}`,\n wss: str => `wss://${str}`,\n 'p2p-websocket-star': str => `${str}/p2p-websocket-star`,\n 'p2p-webrtc-star': str => `${str}/p2p-webrtc-star`,\n 'p2p-webrtc-direct': str => `${str}/p2p-webrtc-direct`\n};\nfunction multiaddrToUri(input, opts) {\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(input);\n const parts = ma.toString().split('/').slice(1);\n return ma\n .tuples()\n .map(tuple => ({\n protocol: parts.shift() ?? '',\n content: (tuple[1] != null) ? parts.shift() ?? '' : ''\n }))\n .reduce((str, part, i, parts) => {\n const reduce = Reducers[part.protocol];\n if (reduce == null) {\n throw new Error(`Unsupported protocol ${part.protocol}`);\n }\n return reduce(str, part.content, i, parts, opts);\n }, '');\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/codec.js": -/*!************************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\n // TODO: 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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = sizeForAddr(p, buf.slice(i + n));\n if (size === 0) {\n tuples.push([code]);\n i += n;\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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n case 41: // ipv6\n return bytes2ip(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 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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(proto);\n switch (protocol.code) {\n case 4: // ipv4\n return ip2bytes(str);\n case 41: // ipv6\n return ip2bytes(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 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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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-to-uri/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/index.js": -/*!************************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/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 */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\nconst P2P_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('p2p').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ipfs').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, addr.address, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\n }\n toJSON() {\n return this.toString();\n }\n toOptions() {\n const codes = this.protoCodes();\n const parts = this.toString().split('/').slice(1);\n let transport;\n let port;\n if (parts.length > 2) {\n // default to https when protocol & port are omitted from DNS addrs\n if (DNS_CODES.includes(codes[0]) && P2P_CODES.includes(codes[1])) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('tcp').name;\n port = 443;\n }\n else {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(parts[2]).name;\n port = parseInt(parts[3]);\n }\n }\n else if (DNS_CODES.includes(codes[0])) {\n transport = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('tcp').name;\n port = 443;\n }\n else {\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: (codes[0] === 41 || codes[0] === 55) ? 6 : 4,\n host: parts[1],\n transport,\n port\n };\n return opts;\n }\n protos() {\n return this.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!**********************************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \**********************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base10.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base16.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base2.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base256emoji.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base32.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base36.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base58.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base64.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/base8.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/identity.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/interface.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bases/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/multiaddr-to-uri/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/basics.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/bytes.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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)\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/multiaddr-to-uri/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/cid.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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 */ });\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/** @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 {\n code: this.code,\n version: this.version,\n hash: this.multihash.bytes\n }\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 returs 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 // 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/multiaddr-to-uri/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/codecs/json.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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 */ });\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/multiaddr-to-uri/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/codecs/raw.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/hashes/digest.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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 alogrithm 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/multiaddr-to-uri/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/hashes/hasher.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/hashes/identity.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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_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/multiaddr-to-uri/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/multiaddr-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/interface.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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/multiaddr-to-uri/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/link/interface.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/link/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/multiaddr-to-uri/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/src/varint.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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-to-uri/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/multiaddr-to-uri/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/vendor/base-x.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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// 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/multiaddr-to-uri/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/vendor/varint.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr-to-uri/node_modules/multiformats/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 */ });\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/multiaddr-to-uri/node_modules/multiformats/vendor/varint.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\nconst reduceValue = (_, v) => v;\nconst tcpUri = (str, port, parts, opts) => {\n // return tcp when explicitly requested\n if ((opts != null) && opts.assumeHttp === false)\n return `tcp://${str}:${port}`;\n // check if tcp is the last protocol in multiaddr\n let protocol = 'tcp';\n let explicitPort = `:${port}`;\n const last = parts[parts.length - 1];\n if (last.protocol === 'tcp') {\n // assume http and produce clean urls\n protocol = port === '443' ? 'https' : 'http';\n explicitPort = port === '443' || port === '80' ? '' : explicitPort;\n }\n return `${protocol}://${str}${explicitPort}`;\n};\nconst Reducers = {\n ip4: reduceValue,\n ip6: (str, content, i, parts) => (parts.length === 1 && parts[0].protocol === 'ip6'\n ? content\n : `[${content}]`),\n tcp: (str, content, i, parts, opts) => (parts.some(p => ['http', 'https', 'ws', 'wss'].includes(p.protocol))\n ? `${str}:${content}`\n : tcpUri(str, content, parts, opts)),\n udp: (str, content) => `udp://${str}:${content}`,\n dnsaddr: reduceValue,\n dns4: reduceValue,\n dns6: reduceValue,\n ipfs: (str, content) => `${str}/ipfs/${content}`,\n p2p: (str, content) => `${str}/p2p/${content}`,\n http: str => `http://${str}`,\n https: str => `https://${str}`,\n ws: str => `ws://${str}`,\n wss: str => `wss://${str}`,\n 'p2p-websocket-star': str => `${str}/p2p-websocket-star`,\n 'p2p-webrtc-star': str => `${str}/p2p-webrtc-star`,\n 'p2p-webrtc-direct': str => `${str}/p2p-webrtc-direct`\n};\nfunction multiaddrToUri(input, opts) {\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(input);\n const parts = ma.toString().split('/').slice(1);\n return ma\n .tuples()\n .map(tuple => ({\n protocol: parts.shift() ?? '',\n content: (tuple[1] != null) ? parts.shift() ?? '' : ''\n }))\n .reduce((str, part, i, parts) => {\n const reduce = Reducers[part.protocol];\n if (reduce == null) {\n throw new Error(`Unsupported protocol ${part.protocol}`);\n }\n return reduce(str, part.content, i, parts, opts);\n }, '');\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr-to-uri/dist/src/index.js?"); /***/ }), @@ -5127,7 +4104,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 */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\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 */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\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_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\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_1__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/codec.js?"); /***/ }), @@ -5138,7 +4115,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 _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.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_1__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.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_11__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/src/bases/base32.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 uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.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 varint__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_8__.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_7__.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_7__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_9__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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(varint__WEBPACK_IMPORTED_MODULE_9__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_9__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.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_6__.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_8__.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?"); /***/ }), @@ -5149,7 +4126,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 */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n multiaddr;\n netmask;\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); /***/ }), @@ -5160,7 +4137,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 */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\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_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\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 if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (this.#string == null) {\n this.#string = _codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToString(this.bytes);\n }\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_7__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.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_7__.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_7__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_5__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_5__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_6__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (this.#tuples == null) {\n this.#tuples = _codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToTuples(this.bytes);\n }\n return this.#tuples;\n }\n stringTuples() {\n if (this.#stringTuples == null) {\n this.#stringTuples = _codec_js__WEBPACK_IMPORTED_MODULE_6__.tuplesToStringTuples(this.tuples());\n }\n return this.#stringTuples;\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_6__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_4__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n // on initialization, this.#path is undefined\n // after the first call, it is either a string or null\n if (this.#path === undefined) {\n try {\n this.#path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (this.#path == null) {\n this.#path = null;\n }\n }\n catch {\n this.#path = null;\n }\n }\n return this.#path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`no available resolver for ${resolvableProto.name}`, 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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(${_codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@multiformats/multiaddr/dist/src/index.js?"); /***/ }), @@ -5186,303 +4163,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base10.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base16.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base2.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base256emoji.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base32.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base36.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base58.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base64.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/base8.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/identity.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/interface.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bases/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/multiaddr/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/basics.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/bytes.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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)\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/multiaddr/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/cid.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/codecs/json.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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 */ });\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/multiaddr/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/codecs/raw.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/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/multiaddr/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/hashes/digest.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/hashes/hasher.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/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/multiaddr/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/hashes/identity.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/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/multiaddr/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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_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/multiaddr/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/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/multiaddr/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@multiformats/multiaddr/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/multiaddr/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/interface.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/multiaddr/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/link/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/link/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/multiaddr/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/src/varint.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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/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/multiaddr/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/vendor/base-x.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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// 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/multiaddr/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@multiformats/multiaddr/node_modules/multiformats/vendor/varint.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@multiformats/multiaddr/node_modules/multiformats/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 */ });\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/multiaddr/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - /***/ "./node_modules/@noble/ed25519/lib/esm/index.js": /*!******************************************************!*\ !*** ./node_modules/@noble/ed25519/lib/esm/index.js ***! @@ -5490,7 +4170,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__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 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.ZERO;\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 if (wbits === 0) {\n let pr = precomputes[offset];\n if (window % 2)\n pr = pr.negate();\n f = f.add(pr);\n }\n else {\n let cached = precomputes[offset + Math.abs(wbits) - 1];\n if (wbits < 0)\n cached = cached.negate();\n p = p.add(cached);\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 return this.multiplyUnsafe(CURVE.l).equals(ExtendedPoint.ZERO);\n }\n toAffine(invZ = invert(this.z)) {\n const { x, y, z } = this;\n const ax = mod(x * invZ);\n const ay = mod(y * invZ);\n const zz = mod(z * invZ);\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 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("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?"); /***/ }), @@ -5567,7 +4247,7 @@ 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 */ \"ConnectionManager\": () => (/* reexport safe */ _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.ConnectionManager),\n/* harmony export */ \"DefaultPubSubTopic\": () => (/* reexport safe */ _lib_constants_js__WEBPACK_IMPORTED_MODULE_0__.DefaultPubSubTopic),\n/* harmony export */ \"DefaultUserAgent\": () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__.DefaultUserAgent),\n/* harmony export */ \"KeepAliveManager\": () => (/* reexport safe */ _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__.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_7__.PageDirection),\n/* harmony export */ \"StoreCodec\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.StoreCodec),\n/* harmony export */ \"WakuNode\": () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__.WakuNode),\n/* harmony export */ \"createCursor\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_8__.waitForRemotePeer),\n/* harmony export */ \"waku\": () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ \"wakuFilter\": () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ \"wakuGossipSub\": () => (/* reexport safe */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuGossipSub),\n/* harmony export */ \"wakuLightPush\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuLightPush),\n/* harmony export */ \"wakuRelay\": () => (/* reexport safe */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuRelay),\n/* harmony export */ \"wakuStore\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_relay\": () => (/* reexport module object */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ \"waku_store\": () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__)\n/* harmony export */ });\n/* harmony import */ var _lib_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/waku.js */ \"./node_modules/@waku/core/dist/lib/waku.js\");\n/* harmony import */ var _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/message/version_0.js */ \"./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/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/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/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/relay/index.js */ \"./node_modules/@waku/core/dist/lib/relay/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./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_9__.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_10__.KeepAliveManager),\n/* harmony export */ \"LightPushCodec\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__.LightPushCodec),\n/* harmony export */ \"PageDirection\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ \"StoreCodec\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_7__.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_8__.waitForRemotePeer),\n/* harmony export */ \"waku\": () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ \"wakuFilterV1\": () => (/* reexport safe */ _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ \"wakuFilterV2\": () => (/* reexport safe */ _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuFilterV2),\n/* harmony export */ \"wakuLightPush\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuLightPush),\n/* harmony export */ \"wakuStore\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.wakuStore),\n/* harmony export */ \"waku_filter_v1\": () => (/* reexport module object */ _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ \"waku_filter_v2\": () => (/* reexport module object */ _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ \"waku_light_push\": () => (/* reexport module object */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ \"waku_store\": () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__)\n/* harmony export */ });\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/waku.js */ \"./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/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/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/core/dist/lib/message/index.js\");\n/* harmony import */ var _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/filter/v1/index.js */ \"./node_modules/@waku/core/dist/lib/filter/v1/index.js\");\n/* harmony import */ var _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/filter/v2/index.js */ \"./node_modules/@waku/core/dist/lib/filter/v2/index.js\");\n/* harmony import */ var _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/light_push/index.js */ \"./node_modules/@waku/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/index.js?"); /***/ }), @@ -5578,7 +4258,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 constructor(multicodec, peerStore, getConnections) {\n this.multicodec = multicodec;\n this.peerStore = peerStore;\n this.getConnections = getConnections;\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.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/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_libp2p__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/core/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 peerStore;\n getConnections;\n constructor(multicodec, peerStore, getConnections) {\n this.multicodec = multicodec;\n this.peerStore = peerStore;\n this.getConnections = getConnections;\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.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/core/dist/lib/base_protocol.js?"); /***/ }), @@ -5589,7 +4269,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 */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nclass ConnectionManager {\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 constructor(libp2pComponents, keepAliveOptions, relay, options) {\n this.dialAttemptsForPeer = new Map();\n this.onEventHandlers = {\n \"peer:discovery\": async (evt) => {\n const { id: peerId } = evt.detail;\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => log(`Error dialing peer ${peerId.toString()} : ${err}`));\n },\n \"peer:connect\": (evt) => {\n {\n this.keepAliveManager.start(evt.detail.remotePeer, this.libp2pComponents.ping.bind(this));\n }\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail.remotePeer);\n };\n },\n };\n this.libp2pComponents = libp2pComponents;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__.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 }\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.libp2pComponents.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2pComponents.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2pComponents.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n let dialAttempt = 0;\n while (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()}`);\n await this.libp2pComponents.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.libp2pComponents\n .getConnections(peerId)\n .forEach((conn) => (conn.tags = Array.from(new Set([...conn.tags, ...tags]))));\n this.dialAttemptsForPeer.delete(peerId.toString());\n return;\n }\n catch (error) {\n log(`\n Error dialing peer ${peerId.toString()}`);\n dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);\n if (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n log(`Reattempting dial (${dialAttempt})`);\n }\n }\n }\n try {\n log(`Deleting undialable peer ${peerId.toString()} from peer store`);\n return await this.libp2pComponents.peerStore.delete(peerId);\n }\n catch (error) {\n throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;\n }\n }\n startPeerDiscoveryListener() {\n this.libp2pComponents.peerStore.addEventListener(\"peer\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2pComponents.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.libp2pComponents.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\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.libp2pComponents.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2pComponents\n .getConnections()\n .filter((conn) => {\n 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 /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n const tags = (await this.libp2pComponents.peerStore.getTags(peerId)).map((tag) => tag.name);\n return tags;\n }\n}\nConnectionManager.instances = new Map();\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/connection_manager.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 */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nclass ConnectionManager {\n static instances = new Map();\n keepAliveManager;\n options;\n libp2pComponents;\n dialAttemptsForPeer = new Map();\n dialErrorsForPeer = new Map();\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 constructor(libp2pComponents, keepAliveOptions, relay, options) {\n this.libp2pComponents = libp2pComponents;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__.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 }\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.libp2pComponents.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2pComponents.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2pComponents.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n let dialAttempt = 0;\n while (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()}`);\n await this.libp2pComponents.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.libp2pComponents\n .getConnections(peerId)\n .forEach((conn) => (conn.tags = Array.from(new Set([...conn.tags, ...tags]))));\n this.dialAttemptsForPeer.delete(peerId.toString());\n return;\n }\n catch (e) {\n const error = e;\n this.dialErrorsForPeer.set(peerId.toString(), error);\n log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);\n dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);\n if (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n log(`Reattempting dial (${dialAttempt})`);\n }\n }\n }\n try {\n log(`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${JSON.stringify(this.dialErrorsForPeer.get(peerId.toString()).errors[0])}\n }`);\n this.dialErrorsForPeer.delete(peerId.toString());\n return await this.libp2pComponents.peerStore.delete(peerId);\n }\n catch (error) {\n throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;\n }\n }\n startPeerDiscoveryListener() {\n this.libp2pComponents.peerStore.addEventListener(\"peer\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2pComponents.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.libp2pComponents.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n }\n onEventHandlers = {\n \"peer:discovery\": async (evt) => {\n const { id: peerId } = evt.detail;\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => log(`Error dialing peer ${peerId.toString()} : ${err}`));\n },\n \"peer:connect\": (evt) => {\n {\n this.keepAliveManager.start(evt.detail.remotePeer, this.libp2pComponents.ping.bind(this));\n }\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail.remotePeer);\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.libp2pComponents.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2pComponents\n .getConnections()\n .filter((conn) => {\n 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 /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n const tags = (await this.libp2pComponents.peerStore.getTags(peerId)).map((tag) => tag.name);\n return tags;\n }\n}\n\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/connection_manager.js?"); /***/ }), @@ -5604,36 +4284,47 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/filter/filter_rpc.js": -/*!***************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/filter/filter_rpc.js ***! - \***************************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v1/filter_rpc.js": +/*!******************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v1/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 */ \"FilterRpc\": () => (/* binding */ FilterRpc)\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 uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterRPC represents a message conforming to the Waku Filter protocol\n */\nclass FilterRpc {\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(topic, contentFilters, requestId, subscribe = true) {\n return new FilterRpc({\n requestId: requestId || (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n subscribe,\n topic,\n contentFilters,\n },\n push: undefined,\n });\n }\n /**\n *\n * @param bytes Uint8Array of bytes from a FilterRPC message\n * @returns FilterRpc\n */\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.decode(bytes);\n return new FilterRpc(res);\n }\n /**\n * Encode the current FilterRPC request to bytes\n * @returns Uint8Array\n */\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.encode(this.proto);\n }\n get push() {\n return this.proto.push;\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/core/dist/lib/filter/filter_rpc.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"FilterRpc\": () => (/* binding */ FilterRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/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 * FilterRPC represents a message conforming to the Waku Filter protocol\n */\nclass FilterRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(topic, contentFilters, requestId, subscribe = true) {\n return new FilterRpc({\n requestId: requestId || (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n subscribe,\n topic,\n contentFilters,\n },\n push: undefined,\n });\n }\n /**\n *\n * @param bytes Uint8Array of bytes from a FilterRPC message\n * @returns FilterRpc\n */\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.decode(bytes);\n return new FilterRpc(res);\n }\n /**\n * Encode the current FilterRPC request to bytes\n * @returns Uint8Array\n */\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.encode(this.proto);\n }\n get push() {\n return this.proto.push;\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/core/dist/lib/filter/v1/filter_rpc.js?"); /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/filter/index.js": -/*!**********************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/filter/index.js ***! - \**********************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v1/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v1/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 */ \"FilterCodec\": () => (/* binding */ FilterCodec),\n/* harmony export */ \"wakuFilter\": () => (/* binding */ wakuFilter)\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 it_all__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.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 _base_protocol_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../group_by.js */ \"./node_modules/@waku/core/dist/lib/group_by.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/core/dist/lib/filter/filter_rpc.js\");\n\n\n\n\n\n\n\n\n\nconst FilterCodec = \"/vac/waku/filter/2.0.0-beta1\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:filter\");\n/**\n * Implements client side of the [Waku v2 Filter protocol](https://rfc.vac.dev/spec/12/).\n *\n * Note this currently only works in NodeJS when the Waku node is listening on a port, see:\n * - https://github.com/status-im/go-waku/issues/245\n * - https://github.com/status-im/nwaku/issues/948\n */\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_4__.BaseProtocol {\n constructor(libp2p, options) {\n super(FilterCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options ?? {};\n this.subscriptions = new Map();\n this.libp2p\n .handle(this.multicodec, this.onRequest.bind(this))\n .catch((e) => log(\"Failed to register filter protocol\", e));\n }\n /**\n * @param decoders Decoder or array of Decoders to use to decode messages, it also specifies the content topics.\n * @param callback A function that will be called on each message returned by the filter.\n * @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.\n * @returns Unsubscribe function that can be used to end the subscription.\n */\n async subscribe(decoders, callback, opts) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPubSubTopic } = this.options;\n const contentTopics = Array.from((0,_group_by_js__WEBPACK_IMPORTED_MODULE_6__.groupByContentTopic)(decodersArray).keys());\n const contentFilters = contentTopics.map((contentTopic) => ({\n contentTopic,\n }));\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(pubSubTopic, contentFilters, undefined, true);\n const requestId = request.requestId;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode(), stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode(), async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(source));\n log(\"response\", res);\n }\n catch (e) {\n log(\"Error subscribing to peer \", peer.id.toString(), \"for content topics\", contentTopics, \": \", e);\n throw e;\n }\n const subscription = {\n callback,\n decoders: decodersArray,\n pubSubTopic,\n };\n this.subscriptions.set(requestId, subscription);\n return async () => {\n await this.unsubscribe(pubSubTopic, contentFilters, requestId, peer);\n this.subscriptions.delete(requestId);\n };\n }\n getActiveSubscriptions() {\n const map = new Map();\n const subscriptions = this.subscriptions;\n for (const item of subscriptions.values()) {\n const values = map.get(item.pubSubTopic) || [];\n const nextValues = item.decoders.map((decoder) => decoder.contentTopic);\n map.set(item.pubSubTopic, [...values, ...nextValues]);\n }\n return map;\n }\n onRequest(streamData) {\n log(\"Receiving message push\");\n try {\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)(streamData.stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode(), async (source) => {\n for await (const bytes of source) {\n const res = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.decode(bytes.slice());\n if (res.requestId && res.push?.messages?.length) {\n await this.pushMessages(res.requestId, res.push.messages);\n }\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 async pushMessages(requestId, messages) {\n const subscription = this.subscriptions.get(requestId);\n if (!subscription) {\n log(`No subscription locally registered for request ID ${requestId}`);\n return;\n }\n const { decoders, callback, pubSubTopic } = subscription;\n if (!decoders || !decoders.length) {\n log(`No decoder registered for request ID ${requestId}`);\n return;\n }\n for (const protoMessage of messages) {\n const contentTopic = protoMessage.contentTopic;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__.toProtoMessage)(protoMessage));\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n }\n }\n async unsubscribe(topic, contentFilters, requestId, peer) {\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(topic, contentFilters, requestId, false);\n const stream = await this.newStream(peer);\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([unsubscribeRequest.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode(), stream.sink);\n }\n catch (e) {\n log(\"Error unsubscribing\", e);\n throw e;\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./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 */ \"FilterCodec\": () => (/* binding */ FilterCodec),\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/core/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/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/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/core/dist/lib/filter/v1/filter_rpc.js\");\n\n\n\n\n\n\n\n\n\n\nconst FilterCodec = \"/vac/waku/filter/2.0.0-beta1\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter\");\n/**\n * Implements client side of the [Waku v2 Filter protocol](https://rfc.vac.dev/spec/12/).\n *\n * Note this currently only works in NodeJS when the Waku node is listening on a port, see:\n * - https://github.com/status-im/go-waku/issues/245\n * - https://github.com/status-im/nwaku/issues/948\n */\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n libp2p;\n options;\n subscriptions;\n constructor(libp2p, options) {\n super(FilterCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options ?? {};\n this.subscriptions = new Map();\n this.libp2p\n .handle(this.multicodec, this.onRequest.bind(this))\n .catch((e) => log(\"Failed to register filter protocol\", e));\n }\n /**\n * @param decoders Decoder or array of Decoders to use to decode messages, it also specifies the content topics.\n * @param callback A function that will be called on each message returned by the filter.\n * @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.\n * @returns Unsubscribe function that can be used to end the subscription.\n */\n async subscribe(decoders, callback, opts) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_6__.DefaultPubSubTopic } = this.options;\n const contentTopics = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(decodersArray).keys());\n const contentFilters = contentTopics.map((contentTopic) => ({\n contentTopic,\n }));\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(pubSubTopic, contentFilters, undefined, true);\n const requestId = request.requestId;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\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 log(\"response\", res);\n }\n catch (e) {\n log(\"Error subscribing to peer \", peer.id.toString(), \"for content topics\", contentTopics, \": \", e);\n throw e;\n }\n const subscription = {\n callback,\n decoders: decodersArray,\n pubSubTopic,\n };\n this.subscriptions.set(requestId, subscription);\n return async () => {\n await this.unsubscribe(pubSubTopic, contentFilters, requestId, peer);\n this.subscriptions.delete(requestId);\n };\n }\n toSubscriptionIterator(decoders, opts) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)(this, decoders, opts);\n }\n getActiveSubscriptions() {\n const map = new Map();\n const subscriptions = this.subscriptions;\n for (const item of subscriptions.values()) {\n const values = map.get(item.pubSubTopic) || [];\n const nextValues = item.decoders.map((decoder) => decoder.contentTopic);\n map.set(item.pubSubTopic, [...values, ...nextValues]);\n }\n return map;\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 res = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.decode(bytes.slice());\n if (res.requestId && res.push?.messages?.length) {\n await this.pushMessages(res.requestId, res.push.messages);\n }\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 async pushMessages(requestId, messages) {\n const subscription = this.subscriptions.get(requestId);\n if (!subscription) {\n log(`No subscription locally registered for request ID ${requestId}`);\n return;\n }\n const { decoders, callback, pubSubTopic } = subscription;\n if (!decoders || !decoders.length) {\n log(`No decoder registered for request ID ${requestId}`);\n return;\n }\n for (const protoMessage of messages) {\n const contentTopic = protoMessage.contentTopic;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__.toProtoMessage)(protoMessage));\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n }\n }\n async unsubscribe(topic, contentFilters, requestId, peer) {\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(topic, contentFilters, requestId, false);\n const stream = await this.newStream(peer);\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 (e) {\n log(\"Error unsubscribing\", e);\n throw e;\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/filter/v1/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/group_by.js": -/*!******************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/group_by.js ***! - \******************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v2/filter_rpc.js": +/*!******************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v2/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 */ \"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/dist/lib/group_by.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/core/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/core/dist/lib/filter/v2/filter_rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/dist/lib/filter/v2/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v2/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 */ \"wakuFilterV2\": () => (/* binding */ wakuFilterV2)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/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/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../constants.js */ \"./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/core/dist/lib/filter/v2/filter_rpc.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter:v2\");\nconst FilterV2Codecs = {\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 FilterV2 extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n libp2p;\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(FilterV2Codecs.SUBSCRIBE, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.libp2p\n .handle(FilterV2Codecs.PUSH, this.onRequest.bind(this))\n .catch((e) => {\n log(\"Failed to register \", FilterV2Codecs.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 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 wakuFilterV2(init = {}) {\n return (libp2p) => new FilterV2(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 let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, message);\n // const decoded = await dec.fromProtoObj(pubSubTopic, message);\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/filter/v2/index.js?"); /***/ }), @@ -5644,7 +4335,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 */ });\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/core/dist/index.js\");\n/* harmony import */ var _relay_constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./relay/constants.js */ \"./node_modules/@waku/core/dist/lib/relay/constants.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:keep-alive\");\nclass KeepAliveManager {\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(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: _relay_constants_js__WEBPACK_IMPORTED_MODULE_2__.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/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 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/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(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/core/dist/lib/keep_alive_manager.js?"); /***/ }), @@ -5655,7 +4346,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_0__.PushResponse),\n/* harmony export */ \"wakuLightPush\": () => (/* binding */ wakuLightPush)\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/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/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/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./push_rpc.js */ \"./node_modules/@waku/core/dist/lib/light_push/push_rpc.js\");\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"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_6__.BaseProtocol {\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options || {};\n }\n async send(encoder, message, opts) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_7__.DefaultPubSubTopic } = this.options;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n const recipients = [];\n try {\n const protoMessage = await encoder.toProtoObj(message);\n if (!protoMessage) {\n log(\"Failed to encode to protoMessage, aborting push\");\n return { recipients };\n }\n const query = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.createRequest(protoMessage, pubSubTopic);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([query.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 try {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const response = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.decode(bytes).response;\n if (!response) {\n log(\"No response in PushRPC\");\n return { recipients };\n }\n if (response.isSuccess) {\n recipients.push(peer.id);\n }\n }\n catch (err) {\n log(\"Failed to decode push reply\", err);\n }\n }\n catch (err) {\n log(\"Failed to send waku light push request\", err);\n }\n return { recipients };\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/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 */ \"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/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/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/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants.js */ \"./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/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 libp2p;\n options;\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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/core/dist/lib/light_push/index.js?"); /***/ }), @@ -5666,7 +4357,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/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nclass PushRpc {\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/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/core/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/core/dist/lib/light_push/push_rpc.js?"); /***/ }), @@ -5677,18 +4368,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 */ \"topic_only_message\": () => (/* reexport module object */ _topic_only_message_js__WEBPACK_IMPORTED_MODULE_1__),\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/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./topic_only_message.js */ \"./node_modules/@waku/core/dist/lib/message/topic_only_message.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/message/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/message/topic_only_message.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/message/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 */ \"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/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 constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n this.payload = new Uint8Array();\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n}\nclass TopicOnlyDecoder {\n constructor() {\n this.contentTopic = \"\";\n }\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/core/dist/lib/message/topic_only_message.js?"); +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/core/dist/lib/message/version_0.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/message/index.js?"); /***/ }), @@ -5699,40 +4379,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 */ \"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 }\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 }\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?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/constants.js": -/*!*************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/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 */ \"RelayCodecs\": () => (/* binding */ RelayCodecs),\n/* harmony export */ \"RelayFanoutTTL\": () => (/* binding */ RelayFanoutTTL),\n/* harmony export */ \"RelayGossipFactor\": () => (/* binding */ RelayGossipFactor),\n/* harmony export */ \"RelayHeartbeatInitialDelay\": () => (/* binding */ RelayHeartbeatInitialDelay),\n/* harmony export */ \"RelayHeartbeatInterval\": () => (/* binding */ RelayHeartbeatInterval),\n/* harmony export */ \"RelayMaxIHaveLength\": () => (/* binding */ RelayMaxIHaveLength),\n/* harmony export */ \"RelayOpportunisticGraftPeers\": () => (/* binding */ RelayOpportunisticGraftPeers),\n/* harmony export */ \"RelayOpportunisticGraftTicks\": () => (/* binding */ RelayOpportunisticGraftTicks),\n/* harmony export */ \"RelayPingContentTopic\": () => (/* binding */ RelayPingContentTopic),\n/* harmony export */ \"RelayPruneBackoff\": () => (/* binding */ RelayPruneBackoff),\n/* harmony export */ \"RelayPrunePeers\": () => (/* binding */ RelayPrunePeers),\n/* harmony export */ \"minute\": () => (/* binding */ minute),\n/* harmony export */ \"second\": () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n/**\n * RelayCodec is the libp2p identifier for the waku relay protocol\n */\nconst RelayCodecs = [\"/vac/waku/relay/2.0.0\"];\nconst RelayPingContentTopic = \"/relay-ping/1/ping/null\";\n/**\n * RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or\n * RelayDlazy, whichever is greater.\n */\nconst RelayGossipFactor = 0.25;\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst RelayHeartbeatInitialDelay = 100;\n/**\n * RelayHeartbeatInterval controls the time between heartbeats.\n */\nconst RelayHeartbeatInterval = second;\n/**\n * RelayPrunePeers 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 RelayPrunePeers other peers that we\n * know of.\n */\nconst RelayPrunePeers = 16;\n/**\n * RelayPruneBackoff 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 RelayPruneBackoff 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 RelayPruneBackoff\n * before attempting to re-graft.\n */\nconst RelayPruneBackoff = minute;\n/**\n * RelayFanoutTTL controls how long we keep track of the fanout state. If it's been\n * RelayFanoutTTL 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 RelayFanoutTTL = minute;\n/**\n * RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every RelayOpportunisticGraftTicks 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 RelayOpportunisticGraftTicks = 60;\n/**\n * RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst RelayOpportunisticGraftPeers = 2;\n/**\n * RelayMaxIHaveLength 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 RelayMaxIHaveLength = 5000;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/dist/lib/relay/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/index.js": -/*!*********************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/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 */ \"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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../group_by.js */ \"./node_modules/@waku/core/dist/lib/group_by.js\");\n/* harmony import */ var _message_topic_only_message_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../message/topic_only_message.js */ \"./node_modules/@waku/core/dist/lib/message/topic_only_message.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/core/dist/lib/relay/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/core/dist/lib/relay/message_validator.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"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 constructor(libp2p, options) {\n if (!this.isRelayPubSub(libp2p.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.pubsub;\n this.pubSubTopic = options?.pubSubTopic ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.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 _message_topic_only_message_js__WEBPACK_IMPORTED_MODULE_5__.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 const msg = await encoder.toWire(message);\n if (!msg) {\n log(\"Failed to encode message, aborting publish\");\n return { recipients: [] };\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 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(async ({ decoder, callback }) => {\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 callback(msg);\n }\n else {\n log(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\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\", async (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}\nRelay.multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_6__.RelayCodecs[0];\nfunction wakuRelay(init = {}) {\n return (libp2p) => new Relay(libp2p, init);\n}\nfunction wakuGossipSub(init = {}) {\n return (components) => {\n init = {\n ...init,\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,_group_by_js__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/core/dist/lib/relay/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/message_validator.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/message_validator.js ***! - \*********************************************************************/ -/***/ ((__unused_webpack___webpack_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/core/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/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/core/dist/lib/relay/message_validator.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/core/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/core/dist/lib/message/version_0.js?"); /***/ }), @@ -5743,7 +4390,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/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/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 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/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/core/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/core/dist/lib/store/history_rpc.js?"); /***/ }), @@ -5754,7 +4401,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 */ \"DefaultPageSize\": () => (/* binding */ DefaultPageSize),\n/* harmony export */ \"PageDirection\": () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__.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_0__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.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 _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 debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./history_rpc.js */ \"./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_1__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_4__(\"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_9__.BaseProtocol {\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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_2__.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_12__.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_10__.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_12__.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_12__.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_7__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.encode(), stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.decode(), async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_8__.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_11__.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_10__.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_3__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_0__.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,\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/core/dist/lib/store/index.js?"); +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_12__.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_0__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/core/node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./history_rpc.js */ \"./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_1__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_4__(\"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_9__.BaseProtocol {\n libp2p;\n options;\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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_2__.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_12__.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_10__.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_12__.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_12__.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_7__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_8__.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_11__.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_10__.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_3__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_0__.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,\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/core/dist/lib/store/index.js?"); /***/ }), @@ -5787,854 +4434,194 @@ 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 */ \"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 _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _connection_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n\n\n\nconst DefaultPingKeepAliveValueSecs = 0;\nconst DefaultRelayKeepAliveValueSecs = 5 * 60;\nconst DefaultUserAgent = \"js-waku\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:waku\");\nclass WakuNode {\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_2__.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 if (typeof protocols === \"undefined\") {\n this.relay && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay);\n this.store && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store);\n this.filter && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter);\n this.lightPush && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush);\n }\n const codecs = [];\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.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_0__.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_0__.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_0__.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 ${peer.toString()} with protocols ${_protocols}`);\n return this.libp2p.dialProtocol(peer, 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}\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./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 */ \"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/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/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/core/dist/lib/waku.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js ***! - \************************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"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 */ \"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 */ \"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 * 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//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.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_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/core/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/core/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/core/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/core/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/core/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/core/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/core/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/core/node_modules/@waku/proto/dist/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js ***! - \********************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"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/it-pipe/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.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_topology__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/topology */ \"./node_modules/@waku/core/node_modules/@libp2p/topology/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./node_modules/@waku/core/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\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_5__.EventEmitter {\n constructor(components, options = {}) {\n super();\n this.multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_21__.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_8__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPruneBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.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_8__.FloodsubID);\n }\n // From pubsub\n this.log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.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_12__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__.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_19__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.msgIdFnStrictSign;\n break;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.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_12__.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_9__.messageIdToString;\n this.mcache = options.messageCache || new _message_cache_js__WEBPACK_IMPORTED_MODULE_6__.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_8__.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_11__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_10__.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_2__.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_18__.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_21__.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.addressBook.add(p.id, p.addrs);\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_4__.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_8__.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_8__.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_8__.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 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_22__.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_8__.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_22__.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_24__.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_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 ? 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_2__.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_23__.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 await this.handleReceivedRpc(peerId, rpc);\n }\n else {\n this.handleReceivedRpc(peerId, rpc).catch((err) => this.log(err));\n }\n }\n catch (e) {\n this.log(e);\n }\n }\n });\n }\n catch (err) {\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 this.log('rpc from %p', from);\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_5__.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) => this.log(err));\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_14__.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_14__.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_14__.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_5__.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_5__.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_14__.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_15__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.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_8__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_8__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.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 this.sendRpc(id, { messages: ihave, control: { iwant, prune } });\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_8__.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_8__.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_8__.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_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_8__.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_8__.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 || !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_8__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_9__.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 this.gossipTracer.addPromise(id, iwantList);\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_8__.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_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)) {\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) {\n return [];\n }\n return await Promise.all(prune.map((topic) => this.makePrune(id, topic, doPX)));\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_13__.ChurnReason.Unsub, 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 interval - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, interval) {\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() + interval;\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_8__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n if (expire < 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_9__.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 p = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(pi.peerID).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 const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.openAndCertify(pi.signedPeerRecord, 'libp2p-peer-record');\n const eid = envelope.peerId;\n if (!envelope.peerId.equals(p)) {\n this.log(\"bogus peer record obtained through px: peer ID %p doesn't match expected peer %p\", eid, p);\n return;\n }\n if (!(await this.components.peerStore.addressBook.consumePeerRecord(envelope))) {\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_2__.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 // 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 // TODO:rust-libp2p checks `self.backoffs.is_backoff_with_slack()`\n if (!this.direct.has(id) && this.score.score(id) >= 0) {\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);\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) {\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_15__.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_5__.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_5__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 if (acceptance === _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n const cacheEntry = this.mcache.validate(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource.toString(), msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource.toString(), originatingPeers);\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\n // Not valid\n else {\n const cacheEntry = this.mcache.remove(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.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.toString(), msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\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 const prune = [await this.makePrune(id, topic, this.opts.doPX)];\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_7__.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 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))));\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))));\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_9__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_8__.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_9__.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_8__.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_9__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id).protocol === _constants_js__WEBPACK_IMPORTED_MODULE_8__.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 is measured in milliseconds\n // The protobuf has it as a uint64\n const backoff = this.opts.pruneBackoff / 1000;\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_2__.peerIdFromString)(peerId);\n return {\n peerID: id.toBytes(),\n signedPeerRecord: await this.components.peerStore.addressBook.getRawEnvelope(id)\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_9__.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_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_20__.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_9__.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_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)) {\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_20__.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_20__.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) || 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_9__.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_5__.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_9__.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 for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\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_17__.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_8__.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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.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/core/node_modules/@waku/proto/dist/lib/filter.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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 /// Peer unsubscribed.\n ChurnReason[\"Unsub\"] = \"unsubscribed\";\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 */\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: ['topic', 'reason']\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: ['topic', 'reason']\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 for each topic',\n labelNames: ['topic', 'acceptance']\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 // 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 /** 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 msgPublishPeers: 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: ['topic', '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 /** 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: ['topic', 'status']\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: ['topic', 'error']\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 labelNames: ['topic', 'p']\n }),\n /** Separate score weights */\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 /* 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({ topic, reason }, 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({ topic, reason }, count);\n },\n onReportValidationMcacheHit(hit) {\n this.asyncValidationMcacheHit.inc({ hit: hit ? 'hit' : 'miss' });\n },\n onReportValidation(topicStr, acceptance) {\n const topic = this.toTopic(topicStr);\n this.asyncValidationResult.inc({ topic: topic, acceptance });\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.msgPublishPeers.inc({ topic }, tosendCount);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'direct' }, tosendGroupCount.direct);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'floodsub' }, tosendGroupCount.floodsub);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'mesh' }, tosendGroupCount.mesh);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'fanout' }, tosendGroupCount.fanout);\n },\n onMsgRecvPreValidation(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedPreValidation.inc({ topic }, 1);\n },\n onMsgRecvResult(topicStr, status) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedStatus.inc({ topic, 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({ topic, error }, 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 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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js": -/*!***************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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 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 firstSeen: 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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js": -/*!******************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/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/core/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/core/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 /**\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.firstSeen, _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.firstSeen, _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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/abortable-iterator/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 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 }), (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode)(), 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, (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)(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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js": -/*!************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/core/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/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***********************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***********************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/core/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!******************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!*******************************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \*******************************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc'],\n [281, 0, 'webrtc-w3c'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter_v2.js": /*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js ***! + !*** ./node_modules/@waku/core/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/core/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/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 */ \"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/core/node_modules/@waku/proto/dist/lib/filter_v2.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \************************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/light_push.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@waku/core/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.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/core/node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/index.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/message.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/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 */ \"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/core/node_modules/@waku/proto/dist/lib/message.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/peer_exchange.js": /*!************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js ***! + !*** ./node_modules/@waku/core/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 */ \"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/@waku/core/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/@waku/core/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/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.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/core/node_modules/@waku/proto/dist/lib/peer_exchange.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\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 _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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@waku/core/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/errors.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/@libp2p/pubsub/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/utils.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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 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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/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_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_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_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_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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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/@waku/core/node_modules/@libp2p/pubsub/dist/src/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/topology/dist/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/topology/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 */ \"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 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 get [_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol]() {\n return true;\n }\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/@waku/core/node_modules/@libp2p/topology/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/it-all/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/it-all/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\": () => (/* binding */ all)\n/* harmony export */ });\n/**\n * Collects all values from an (async) iterable and returns them as an array\n */\nasync function all(source) {\n const arr = [];\n for await (const entry of source) {\n arr.push(entry);\n }\n return arr;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/it-all/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base10.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base16.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base2.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base256emoji.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base32.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base36.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base64.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base8.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/identity.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/bases/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/@waku/core/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/basics.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bytes.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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)\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/@waku/core/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/cid.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/codecs/json.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 */ });\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/@waku/core/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/codecs/raw.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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/@waku/core/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/hasher.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/identity.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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_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/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/interface.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/store.js": /*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/interface.js ***! + !*** ./node_modules/@waku/core/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// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/multiformats/src/interface.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/core/node_modules/@waku/proto/dist/lib/store.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/link/interface.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/link/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/@waku/core/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/varint.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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/@waku/core/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/vendor/base-x.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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// 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/@waku/core/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/vendor/varint.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 */ });\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/@waku/core/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/topic_only_message.js": /*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js ***! + !*** ./node_modules/@waku/core/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/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/core/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.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/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/core/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js?"); +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/protons-runtime/dist/src/index.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/index.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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/index.js?"); +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/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\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/core/node_modules/@waku/utils/dist/common/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js?"); +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 */ \"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/core/node_modules/@waku/utils/dist/common/is_size_valid.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/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, 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/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 */ \"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/core/node_modules/@waku/utils/dist/common/index.js\");\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/libp2p/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/libp2p/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 */ \"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/core/node_modules/@waku/utils/dist/libp2p/index.js?"); /***/ }), @@ -6645,744 +4632,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 */ \"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/@waku/create/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/@waku/create/node_modules/@libp2p/mplex/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/websockets */ \"./node_modules/@waku/create/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/@waku/create/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/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 libp2p__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! libp2p */ \"./node_modules/libp2p/dist/src/index.js\");\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 * **Note: This is NOT compatible with nwaku v0.11**\n *\n * @see https://github.com/status-im/nwaku/issues/1085\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_core__WEBPACK_IMPORTED_MODULE_4__.wakuGossipSub)(options), libp2pOptions, options?.userAgent);\n const relay = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.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_core__WEBPACK_IMPORTED_MODULE_4__.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_core__WEBPACK_IMPORTED_MODULE_4__.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 libp2pOpts = Object.assign({\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 identify: {\n host: {\n agentVersion: userAgent ?? _waku_core__WEBPACK_IMPORTED_MODULE_4__.DefaultUserAgent,\n },\n },\n }, wakuGossipSub ? { pubsub: wakuGossipSub } : {}, options ?? {});\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_6__.createLibp2p)(libp2pOpts);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/constants.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/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 */ \"DUMP_SESSION_KEYS\": () => (/* binding */ DUMP_SESSION_KEYS),\n/* harmony export */ \"NOISE_MSG_MAX_LENGTH_BYTES\": () => (/* binding */ NOISE_MSG_MAX_LENGTH_BYTES),\n/* harmony export */ \"NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG\": () => (/* binding */ NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG)\n/* harmony export */ });\nconst NOISE_MSG_MAX_LENGTH_BYTES = 65535;\nconst NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG = NOISE_MSG_MAX_LENGTH_BYTES - 16;\nconst DUMP_SESSION_KEYS = Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=crypto.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"stablelib\": () => (/* binding */ stablelib)\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 _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @stablelib/x25519 */ \"./node_modules/@stablelib/x25519/lib/x25519.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_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.js\");\n\n\n\n\nconst stablelib = {\n hashSHA256(data) {\n return (0,_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.hash)(data);\n },\n getHKDF(ck, ikm) {\n const hkdf = new _stablelib_hkdf__WEBPACK_IMPORTED_MODULE_0__.HKDF(_stablelib_sha256__WEBPACK_IMPORTED_MODULE_2__.SHA256, ikm, ck);\n const okmU8Array = hkdf.expand(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 keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.generateKeyPair();\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey\n };\n },\n generateX25519KeyPairFromSeed(seed) {\n const keypair = _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.generateKeyPairFromSeed(seed);\n return {\n publicKey: keypair.publicKey,\n privateKey: keypair.secretKey\n };\n },\n generateX25519SharedKey(privateKey, publicKey) {\n return _stablelib_x25519__WEBPACK_IMPORTED_MODULE_1__.sharedKey(privateKey, publicKey);\n },\n chaCha20Poly1305Encrypt(plaintext, nonce, ad, k) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__.ChaCha20Poly1305(k);\n return ctx.seal(nonce, plaintext, ad);\n },\n chaCha20Poly1305Decrypt(ciphertext, nonce, ad, k, dst) {\n const ctx = new _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_3__.ChaCha20Poly1305(k);\n return ctx.open(nonce, ciphertext, ad, dst);\n }\n};\n//# sourceMappingURL=stablelib.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js ***! - \*****************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @stablelib/chacha20poly1305 */ \"./node_modules/@stablelib/chacha20poly1305/lib/chacha20poly1305.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js\");\n\n\n\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 const data = handshake.encrypt(chunk.subarray(i, end), handshake.session);\n metrics?.encryptedPackets.increment();\n yield (0,_encoder_js__WEBPACK_IMPORTED_MODULE_2__.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_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 - _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.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 - _stablelib_chacha20poly1305__WEBPACK_IMPORTED_MODULE_0__.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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/streaming.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/encoder.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js ***! - \*************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n\n\n\n\n\nclass XXHandshake {\n constructor(isInitiator, payload, prologue, crypto, staticKeypair, connection, remotePeer, handshake) {\n this.remoteExtensions = { webtransportCerthashes: [] };\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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('Stage 0 - Initiator finished sending first message.');\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logLocalEphemeralKeys)(this.session.hs.e);\n }\n else {\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)(\"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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('All good with the signature!');\n }\n else {\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('Stage 2 - Initiator sent message with signed payload.');\n }\n else {\n (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)('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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js": -/*!******************************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js ***! - \******************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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_equals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../logger.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js\");\n\n\n\n\n\nclass AbstractHandshake {\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_0__.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 (0,_logger_js__WEBPACK_IMPORTED_MODULE_3__.logger)(err.message);\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_2__.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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/abstract-handshake.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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/@waku/create/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/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshakes/xx.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/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 */ \"noise\": () => (/* binding */ noise),\n/* harmony export */ \"stablelib\": () => (/* reexport safe */ _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_2__.stablelib)\n/* harmony export */ });\n/* harmony import */ var _noise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./noise.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/noise.js\");\n/* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./crypto.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto.js\");\n/* harmony import */ var _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crypto/stablelib.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js\");\n\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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/logger.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/logger.js ***! - \*******************************************************************************************/ -/***/ ((__unused_webpack___webpack_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/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/logger.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/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 */ \"registerMetrics\": () => (/* binding */ registerMetrics)\n/* harmony export */ });\nfunction registerMetrics(metrics) {\n return {\n xxHandshakeSuccesses: metrics.registerCounter('libp2p_noise_xxhandshake_successes_total', {\n help: 'Total count of noise xxHandshakes successes_'\n }),\n xxHandshakeErrors: metrics.registerCounter('libp2p_noise_xxhandshake_error_total', {\n help: 'Total count of noise xxHandshakes errors'\n }),\n encryptedPackets: metrics.registerCounter('libp2p_noise_encrypted_packets_total', {\n help: 'Total count of noise encrypted packets successfully'\n }),\n decryptedPackets: metrics.registerCounter('libp2p_noise_decrypted_packets_total', {\n help: 'Total count of noise decrypted packets'\n }),\n decryptErrors: metrics.registerCounter('libp2p_noise_decrypt_errors_total', {\n help: 'Total count of noise decrypt errors'\n })\n };\n}\n//# sourceMappingURL=metrics.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/noise.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/noise.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_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_pb_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pb-stream */ \"./node_modules/@waku/create/node_modules/it-pb-stream/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_pipe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/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 _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/constants.js\");\n/* harmony import */ var _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./crypto/stablelib.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/stablelib.js\");\n/* harmony import */ var _crypto_streaming_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./crypto/streaming.js */ \"./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/handshake-xx.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/utils.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/metrics.js\");\n\n\n\n\n\n\n\n\n\n\n\nclass Noise {\n constructor(init = {}) {\n this.protocol = '/noise';\n const { staticNoiseKey, extensions, crypto, prologueBytes, metrics } = init;\n this.crypto = crypto ?? _crypto_stablelib_js__WEBPACK_IMPORTED_MODULE_5__.stablelib;\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 ?? 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} 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_0__.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} 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_0__.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_9__.getPayload)(params.localPeer, this.staticKeys.publicKey, this.extensions);\n // run XX handshake\n return await 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_2__.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 (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)({ 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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/noise.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/nonce.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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/@waku/create/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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/utils.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/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 */ \"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/@waku/create/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/@waku/create/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 await privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return await (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/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/interface-connection-encrypter/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 */ \"InvalidCryptoTransmissionError\": () => (/* binding */ InvalidCryptoTransmissionError),\n/* harmony export */ \"UnexpectedPeerError\": () => (/* binding */ UnexpectedPeerError)\n/* harmony export */ });\nclass UnexpectedPeerError extends Error {\n constructor(message = 'Unexpected Peer') {\n super(message);\n this.code = UnexpectedPeerError.code;\n }\n static get code() {\n return 'ERR_UNEXPECTED_PEER';\n }\n}\nclass InvalidCryptoExchangeError extends Error {\n constructor(message = 'Invalid crypto exchange') {\n super(message);\n this.code = InvalidCryptoExchangeError.code;\n }\n static get code() {\n return 'ERR_INVALID_CRYPTO_EXCHANGE';\n }\n}\nclass InvalidCryptoTransmissionError extends Error {\n constructor(message = 'Invalid crypto transmission') {\n super(message);\n this.code = InvalidCryptoTransmissionError.code;\n }\n static get code() {\n return 'ERR_INVALID_CRYPTO_TRANSMISSION';\n }\n}\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/interface-connection-encrypter/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/interface-transport/dist/src/index.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/@libp2p/interface-transport/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/alloc-unsafe-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 */ \"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/@waku/create/node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/decode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/decode.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Decoder\": () => (/* binding */ Decoder),\n/* harmony export */ \"MAX_MSG_QUEUE_SIZE\": () => (/* binding */ MAX_MSG_QUEUE_SIZE),\n/* harmony export */ \"MAX_MSG_SIZE\": () => (/* binding */ MAX_MSG_SIZE)\n/* harmony export */ });\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n\n\nconst MAX_MSG_SIZE = 1 << 20; // 1MB\nconst MAX_MSG_QUEUE_SIZE = 4 << 20; // 4MB\nclass Decoder {\n constructor(maxMessageSize = MAX_MSG_SIZE, maxUnprocessedMessageQueueSize = MAX_MSG_QUEUE_SIZE) {\n this._buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_1__.Uint8ArrayList();\n this._headerInfo = null;\n this._maxMessageSize = maxMessageSize;\n this._maxUnprocessedMessageQueueSize = maxUnprocessedMessageQueueSize;\n }\n write(chunk) {\n if (chunk == null || chunk.length === 0) {\n return [];\n }\n this._buffer.append(chunk);\n if (this._buffer.byteLength > this._maxUnprocessedMessageQueueSize) {\n throw Object.assign(new Error('unprocessed message queue size too large!'), { code: 'ERR_MSG_QUEUE_TOO_BIG' });\n }\n const msgs = [];\n while (this._buffer.length !== 0) {\n if (this._headerInfo == null) {\n try {\n this._headerInfo = this._decodeHeader(this._buffer);\n }\n catch (err) {\n if (err.code === 'ERR_MSG_TOO_BIG') {\n throw err;\n }\n break; // We haven't received enough data yet\n }\n }\n const { id, type, length, offset } = this._headerInfo;\n const bufferedDataLength = this._buffer.length - offset;\n if (bufferedDataLength < length) {\n break; // not enough data yet\n }\n const msg = {\n id,\n type\n };\n if (type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.NEW_STREAM || type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.MESSAGE_INITIATOR || type === _message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypes.MESSAGE_RECEIVER) {\n msg.data = this._buffer.sublist(offset, offset + length);\n }\n msgs.push(msg);\n this._buffer.consume(offset + length);\n this._headerInfo = null;\n }\n return msgs;\n }\n /**\n * Attempts to decode the message header from the buffer\n */\n _decodeHeader(data) {\n const { value: h, offset } = readVarInt(data);\n const { value: length, offset: end } = readVarInt(data, offset);\n const type = h & 7;\n // @ts-expect-error h is a number not a CODE\n if (_message_types_js__WEBPACK_IMPORTED_MODULE_0__.MessageTypeNames[type] == null) {\n throw new Error(`Invalid type received: ${type}`);\n }\n // test message type varint + data length\n if (length > this._maxMessageSize) {\n throw Object.assign(new Error('message size too large!'), { code: 'ERR_MSG_TOO_BIG' });\n }\n // @ts-expect-error h is a number not a CODE\n return { id: h >> 3, type, offset: offset + end, length };\n }\n}\nconst MSB = 0x80;\nconst REST = 0x7F;\nfunction readVarInt(buf, offset = 0) {\n let res = 0;\n let shift = 0;\n let counter = offset;\n let b;\n const l = buf.length;\n do {\n if (counter >= l || shift > 49) {\n offset = 0;\n throw new RangeError('Could not decode varint');\n }\n b = buf.get(counter++);\n res += shift < 28\n ? (b & REST) << shift\n : (b & REST) * Math.pow(2, shift);\n shift += 7;\n } while (b >= MSB);\n offset = counter - offset;\n return {\n value: res,\n offset\n };\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/encode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/encode.js ***! - \*********************************************************************************/ -/***/ ((__unused_webpack___webpack_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 varint__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! varint */ \"./node_modules/varint/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 _alloc_unsafe_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./alloc-unsafe.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/alloc-unsafe-browser.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var it_batched_bytes__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-batched-bytes */ \"./node_modules/it-batched-bytes/dist/src/index.js\");\n\n\n\n\n\nconst POOL_SIZE = 10 * 1024;\nclass Encoder {\n constructor() {\n this._pool = (0,_alloc_unsafe_js__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 varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.id << 3 | msg.type, pool, offset);\n offset += varint__WEBPACK_IMPORTED_MODULE_0__.encode.bytes ?? 0;\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 varint__WEBPACK_IMPORTED_MODULE_0__.encode(msg.data.length, pool, offset);\n }\n else {\n varint__WEBPACK_IMPORTED_MODULE_0__.encode(0, pool, offset);\n }\n offset += varint__WEBPACK_IMPORTED_MODULE_0__.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_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, 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_4__[\"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/@waku/create/node_modules/@libp2p/mplex/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/index.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/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 */ \"mplex\": () => (/* binding */ mplex)\n/* harmony export */ });\n/* harmony import */ var _mplex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mplex.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/mplex.js\");\n\nclass Mplex {\n constructor(init = {}) {\n this.protocol = '/mplex/6.7.0';\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/@waku/create/node_modules/@libp2p/mplex/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-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 */ \"InitiatorMessageTypes\": () => (/* binding */ InitiatorMessageTypes),\n/* harmony export */ \"MessageTypeNames\": () => (/* binding */ MessageTypeNames),\n/* harmony export */ \"MessageTypes\": () => (/* binding */ MessageTypes),\n/* harmony export */ \"ReceiverMessageTypes\": () => (/* binding */ ReceiverMessageTypes)\n/* harmony export */ });\nvar MessageTypes;\n(function (MessageTypes) {\n MessageTypes[MessageTypes[\"NEW_STREAM\"] = 0] = \"NEW_STREAM\";\n MessageTypes[MessageTypes[\"MESSAGE_RECEIVER\"] = 1] = \"MESSAGE_RECEIVER\";\n MessageTypes[MessageTypes[\"MESSAGE_INITIATOR\"] = 2] = \"MESSAGE_INITIATOR\";\n MessageTypes[MessageTypes[\"CLOSE_RECEIVER\"] = 3] = \"CLOSE_RECEIVER\";\n MessageTypes[MessageTypes[\"CLOSE_INITIATOR\"] = 4] = \"CLOSE_INITIATOR\";\n MessageTypes[MessageTypes[\"RESET_RECEIVER\"] = 5] = \"RESET_RECEIVER\";\n MessageTypes[MessageTypes[\"RESET_INITIATOR\"] = 6] = \"RESET_INITIATOR\";\n})(MessageTypes || (MessageTypes = {}));\nconst MessageTypeNames = Object.freeze({\n 0: 'NEW_STREAM',\n 1: 'MESSAGE_RECEIVER',\n 2: 'MESSAGE_INITIATOR',\n 3: 'CLOSE_RECEIVER',\n 4: 'CLOSE_INITIATOR',\n 5: 'RESET_RECEIVER',\n 6: 'RESET_INITIATOR'\n});\nconst InitiatorMessageTypes = Object.freeze({\n NEW_STREAM: MessageTypes.NEW_STREAM,\n MESSAGE: MessageTypes.MESSAGE_INITIATOR,\n CLOSE: MessageTypes.CLOSE_INITIATOR,\n RESET: MessageTypes.RESET_INITIATOR\n});\nconst ReceiverMessageTypes = Object.freeze({\n MESSAGE: MessageTypes.MESSAGE_RECEIVER,\n CLOSE: MessageTypes.CLOSE_RECEIVER,\n RESET: MessageTypes.RESET_RECEIVER\n});\n//# sourceMappingURL=message-types.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/mplex.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/mplex.js ***! - \********************************************************************************/ -/***/ ((__unused_webpack___webpack_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 it_pushable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/encode.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/stream.js\");\n/* harmony import */ var uint8arrays__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays */ \"./node_modules/uint8arrays/dist/src/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/index.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_7__.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_4__.MessageTypeNames[msg.type]} (${msg.type})`\n };\n if (msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.MESSAGE_INITIATOR || msg.type === _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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 constructor(init) {\n this.protocol = '/mplex/6.7.0';\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_9__.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_8__.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_5__.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 // see: https://github.com/jacobheun/any-signal/pull/18\n const abortSignals = [this.closeController.signal];\n if (this._init.signal != null) {\n abortSignals.push(this._init.signal);\n }\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_1__.abortableSource)(source, any_signal__WEBPACK_IMPORTED_MODULE_10__(abortSignals));\n try {\n const decoder = new _decode_js__WEBPACK_IMPORTED_MODULE_3__.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 };\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_0__.pushableV)({\n objectMode: true,\n onEnd\n });\n return Object.assign((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__.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_4__.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_4__.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_4__.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_4__.MessageTypes.MESSAGE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.MESSAGE_INITIATOR ? _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.RESET_RECEIVER : _message_types_js__WEBPACK_IMPORTED_MODULE_4__.MessageTypes.RESET_INITIATOR\n });\n // Inform the stream consumer they are not fast enough\n const error = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_8__.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_4__.MessageTypes.CLOSE_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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_4__.MessageTypes.RESET_INITIATOR:\n case _message_types_js__WEBPACK_IMPORTED_MODULE_4__.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/@waku/create/node_modules/@libp2p/mplex/dist/src/mplex.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/stream.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/mplex/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 */ \"createStream\": () => (/* binding */ createStream)\n/* harmony export */ });\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/decode.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/index.js\");\n/* harmony import */ var _message_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./message-types.js */ \"./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/message-types.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_8__.logger)('libp2p:mplex: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 createStream(options) {\n const { id, name, send, onEnd, type = 'initiator', maxMsgSize = _decode_js__WEBPACK_IMPORTED_MODULE_3__.MAX_MSG_SIZE } = options;\n const abortController = new AbortController();\n const resetController = new AbortController();\n const closeController = new AbortController();\n const Types = type === 'initiator' ? _message_types_js__WEBPACK_IMPORTED_MODULE_5__.InitiatorMessageTypes : _message_types_js__WEBPACK_IMPORTED_MODULE_5__.ReceiverMessageTypes;\n const externalId = type === 'initiator' ? (`i${id}`) : `r${id}`;\n const streamName = `${name == null ? id : name}`;\n let sourceEnded = false;\n let sinkEnded = false;\n let sinkSunk = false;\n let endErr;\n const timeline = {\n open: Date.now()\n };\n const onSourceEnd = (err) => {\n if (sourceEnded) {\n return;\n }\n sourceEnded = true;\n log.trace('%s stream %s source end - err: %o', type, streamName, err);\n if (err != null && endErr == null) {\n endErr = err;\n }\n if (sinkEnded) {\n stream.stat.timeline.close = Date.now();\n if (onEnd != null) {\n onEnd(endErr);\n }\n }\n };\n const onSinkEnd = (err) => {\n if (sinkEnded) {\n return;\n }\n sinkEnded = true;\n log.trace('%s stream %s sink end - err: %o', type, streamName, err);\n if (err != null && endErr == null) {\n endErr = err;\n }\n if (sourceEnded) {\n timeline.close = Date.now();\n if (onEnd != null) {\n onEnd(endErr);\n }\n }\n };\n const streamSource = (0,it_pushable__WEBPACK_IMPORTED_MODULE_1__.pushable)({\n onEnd: onSourceEnd\n });\n const stream = {\n // Close for both Reading and Writing\n close: () => {\n log.trace('%s stream %s close', type, streamName);\n stream.closeRead();\n stream.closeWrite();\n },\n // Close for reading\n closeRead: () => {\n log.trace('%s stream %s closeRead', type, streamName);\n if (sourceEnded) {\n return;\n }\n streamSource.end();\n },\n // Close for writing\n closeWrite: () => {\n log.trace('%s stream %s closeWrite', type, streamName);\n if (sinkEnded) {\n return;\n }\n closeController.abort();\n try {\n send({ id, type: Types.CLOSE });\n }\n catch (err) {\n log.trace('%s stream %s error sending close', type, name, err);\n }\n onSinkEnd();\n },\n // Close for reading and writing (local error)\n abort: (err) => {\n log.trace('%s stream %s abort', type, streamName, err);\n // End the source with the passed error\n streamSource.end(err);\n abortController.abort();\n onSinkEnd(err);\n },\n // Close immediately for reading and writing (remote error)\n reset: () => {\n const err = new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('stream reset', ERR_STREAM_RESET);\n resetController.abort();\n streamSource.end(err);\n onSinkEnd(err);\n },\n sink: async (source) => {\n if (sinkSunk) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('sink already called on stream', ERR_DOUBLE_SINK);\n }\n sinkSunk = true;\n if (sinkEnded) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('stream closed for writing', ERR_SINK_ENDED);\n }\n source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_0__.abortableSource)(source, (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)([\n abortController.signal,\n resetController.signal,\n closeController.signal\n ]));\n try {\n if (type === 'initiator') { // If initiator, open a new stream\n send({ id, type: _message_types_js__WEBPACK_IMPORTED_MODULE_5__.InitiatorMessageTypes.NEW_STREAM, data: new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_6__.fromString)(streamName)) });\n }\n for await (let data of source) {\n while (data.length > 0) {\n if (data.length <= maxMsgSize) {\n send({ id, type: Types.MESSAGE, data: data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(data) : data });\n break;\n }\n data = data instanceof Uint8Array ? new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(data) : data;\n send({ id, type: Types.MESSAGE, data: data.sublist(0, maxMsgSize) });\n data.consume(maxMsgSize);\n }\n }\n }\n catch (err) {\n if (err.type === 'aborted' && err.message === 'The operation was aborted') {\n if (closeController.signal.aborted) {\n return;\n }\n if (resetController.signal.aborted) {\n err.message = 'stream reset';\n err.code = ERR_STREAM_RESET;\n }\n if (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', type, name);\n }\n else {\n log.trace('%s stream %s error', type, name, err);\n try {\n send({ id, type: Types.RESET });\n }\n catch (err) {\n log.trace('%s stream %s error sending reset', type, name, err);\n }\n }\n streamSource.end(err);\n onSinkEnd(err);\n return;\n }\n try {\n send({ id, type: Types.CLOSE });\n }\n catch (err) {\n log.trace('%s stream %s error sending close', type, name, err);\n }\n onSinkEnd();\n },\n source: streamSource,\n sourcePush: (data) => {\n streamSource.push(data);\n },\n sourceReadableLength() {\n return streamSource.readableLength;\n },\n stat: {\n direction: type === 'initiator' ? 'outbound' : 'inbound',\n timeline\n },\n metadata: {},\n id: externalId\n };\n return stream;\n}\n//# sourceMappingURL=stream.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/mplex/dist/src/stream.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/create/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/create/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/create/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/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 */ \"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/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/filters.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/filters.js ***! - \***************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"all\": () => (/* binding */ all),\n/* harmony export */ \"dnsWsOrWss\": () => (/* binding */ dnsWsOrWss),\n/* harmony export */ \"dnsWss\": () => (/* binding */ dnsWss),\n/* harmony export */ \"wss\": () => (/* binding */ wss)\n/* harmony export */ });\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/@waku/create/node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.js\");\n\n\nfunction all(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSockets.matches(testMa) ||\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa);\n });\n}\nfunction wss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa);\n });\n}\nfunction dnsWss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa) &&\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WSS));\n });\n}\nfunction dnsWsOrWss(multiaddrs) {\n return multiaddrs.filter((ma) => {\n if (ma.protoCodes().includes(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_CIRCUIT)) {\n return false;\n }\n const testMa = ma.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_P2P);\n // WS\n if (_multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSockets.matches(testMa)) {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WS));\n }\n // WSS\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.WebSocketsSecure.matches(testMa) &&\n _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_0__.DNS.matches(testMa.decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_TCP).decapsulateCode(_constants_js__WEBPACK_IMPORTED_MODULE_1__.CODE_WSS));\n });\n}\n//# sourceMappingURL=filters.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/filters.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/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 */ \"webSockets\": () => (/* binding */ webSockets)\n/* harmony export */ });\n/* harmony import */ var it_ws_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-ws/client */ \"./node_modules/it-ws/dist/src/client.js\");\n/* harmony import */ var _multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr-to-uri */ \"./node_modules/@multiformats/multiaddr-to-uri/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 p_defer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-defer */ \"./node_modules/p-defer/index.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/listener.browser.js\");\n/* harmony import */ var _socket_to_conn_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./socket-to-conn.js */ \"./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/socket-to-conn.js\");\n/* harmony import */ var _filters_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filters.js */ \"./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/filters.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@waku/create/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_4__.logger)('libp2p:websockets');\nclass WebSockets {\n constructor(init) {\n this.init = init;\n }\n get [Symbol.toStringTag]() {\n return '@libp2p/websockets';\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_9__.symbol]() {\n return true;\n }\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_7__.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_2__.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_3__[\"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_0__.connect)((0,_multiformats_multiaddr_to_uri__WEBPACK_IMPORTED_MODULE_1__.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_2__.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_6__.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_8__.wss(multiaddrs);\n }\n return _filters_js__WEBPACK_IMPORTED_MODULE_8__.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/@waku/create/node_modules/@libp2p/websockets/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/listener.browser.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/listener.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 */ \"createListener\": () => (/* binding */ createListener)\n/* harmony export */ });\nfunction createListener() {\n throw new Error('WebSocket Servers can not be created in the browser!');\n}\n//# sourceMappingURL=listener.browser.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/listener.browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/socket-to-conn.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/socket-to-conn.js ***! - \**********************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.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 _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: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_0__.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_0__.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_1__.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/@waku/create/node_modules/@libp2p/websockets/dist/src/socket-to-conn.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/@multiformats/mafmt/dist/src/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@multiformats/mafmt/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 */ \"IPFS\": () => (/* binding */ IPFS),\n/* harmony export */ \"P2P\": () => (/* binding */ P2P),\n/* harmony export */ \"P2PWebRTCDirect\": () => (/* binding */ P2PWebRTCDirect),\n/* harmony export */ \"P2PWebRTCStar\": () => (/* binding */ P2PWebRTCStar),\n/* harmony export */ \"QUIC\": () => (/* binding */ QUIC),\n/* harmony export */ \"Reliable\": () => (/* binding */ Reliable),\n/* harmony export */ \"Stardust\": () => (/* binding */ Stardust),\n/* harmony export */ \"TCP\": () => (/* binding */ TCP),\n/* harmony export */ \"UDP\": () => (/* binding */ UDP),\n/* harmony export */ \"UTP\": () => (/* binding */ UTP),\n/* harmony export */ \"WebRTC\": () => (/* binding */ WebRTC),\n/* harmony export */ \"WebRTCDirect\": () => (/* binding */ WebRTCDirect),\n/* harmony export */ \"WebSocketStar\": () => (/* binding */ WebSocketStar),\n/* harmony export */ \"WebSockets\": () => (/* binding */ WebSockets),\n/* harmony export */ \"WebSocketsSecure\": () => (/* binding */ WebSocketsSecure)\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 * Valid combinations\n */\nconst DNS4 = base('dns4');\nconst DNS6 = base('dns6');\nconst DNSADDR = base('dnsaddr');\nconst DNS = or(base('dns'), DNSADDR, DNS4, DNS6);\nconst IP = or(base('ip4'), base('ip6'));\nconst TCP = or(and(IP, base('tcp')), and(DNS, base('tcp')));\nconst UDP = and(IP, base('udp'));\nconst UTP = and(UDP, base('utp'));\nconst QUIC = and(UDP, base('quic'));\nconst WebSockets = or(and(TCP, base('ws')), and(DNS, base('ws')));\nconst WebSocketsSecure = or(and(TCP, base('wss')), and(DNS, base('wss')), and(TCP, base('tls'), base('ws')), and(DNS, base('tls'), base('ws')));\nconst HTTP = or(and(TCP, base('http')), and(IP, base('http')), and(DNS, base('http')));\nconst HTTPS = or(and(TCP, base('https')), and(IP, base('https')), and(DNS, base('https')));\nconst _WebRTCDirect = and(UDP, base('webrtc-direct'), base('certhash'));\nconst WebRTCDirect = or(and(_WebRTCDirect, base('p2p')), _WebRTCDirect);\n/**\n * @deprecated\n */\nconst P2PWebRTCStar = or(and(WebSockets, base('p2p-webrtc-star'), base('p2p')), and(WebSocketsSecure, base('p2p-webrtc-star'), base('p2p')), and(WebSockets, base('p2p-webrtc-star')), and(WebSocketsSecure, base('p2p-webrtc-star')));\nconst WebSocketStar = or(and(WebSockets, base('p2p-websocket-star'), base('p2p')), and(WebSocketsSecure, base('p2p-websocket-star'), base('p2p')), and(WebSockets, base('p2p-websocket-star')), and(WebSocketsSecure, base('p2p-websocket-star')));\n/**\n * @deprecated\n */\nconst P2PWebRTCDirect = or(and(HTTP, base('p2p-webrtc-direct'), base('p2p')), and(HTTPS, base('p2p-webrtc-direct'), base('p2p')), and(HTTP, base('p2p-webrtc-direct')), and(HTTPS, base('p2p-webrtc-direct')));\nconst Reliable = or(WebSockets, WebSocketsSecure, HTTP, HTTPS, P2PWebRTCStar, P2PWebRTCDirect, TCP, UTP, QUIC, DNS, WebRTCDirect);\n// Unlike ws-star, stardust can run over any transport thus removing the requirement for websockets (but don't even think about running a stardust server over webrtc-star ;) )\nconst Stardust = or(and(Reliable, base('p2p-stardust'), base('p2p')), and(Reliable, base('p2p-stardust')));\nconst _P2P = or(and(Reliable, base('p2p')), P2PWebRTCStar, P2PWebRTCDirect, WebRTCDirect, base('p2p'));\nconst _Circuit = or(and(_P2P, base('p2p-circuit'), _P2P), and(_P2P, base('p2p-circuit')), and(base('p2p-circuit'), _P2P), and(Reliable, base('p2p-circuit')), and(base('p2p-circuit'), Reliable), base('p2p-circuit'));\nconst CircuitRecursive = () => or(and(_Circuit, CircuitRecursive), _Circuit);\nconst Circuit = CircuitRecursive();\nconst P2P = or(and(Circuit, _P2P, Circuit), and(_P2P, Circuit), and(Circuit, _P2P), Circuit, _P2P);\nconst IPFS = P2P;\nconst WebRTC = or(and(Circuit, base('webrtc')), and(Reliable, base('webrtc')), base('webrtc'));\n/*\n * Validation funcs\n */\nfunction makeMatchesFunction(partialMatch) {\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const out = partialMatch(ma.protoNames());\n if (out === null) {\n return false;\n }\n if (out === true || out === false) {\n return out;\n }\n return out.length === 0;\n }\n return matches;\n}\nfunction and(...args) {\n function partialMatch(a) {\n if (a.length < args.length) {\n return null;\n }\n let out = a;\n args.some((arg) => {\n out = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (Array.isArray(out)) {\n a = out;\n }\n if (out === null) {\n return true;\n }\n return false;\n });\n return out;\n }\n return {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n}\nfunction or(...args) {\n function partialMatch(a) {\n let out = null;\n args.some((arg) => {\n const res = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (res != null) {\n out = res;\n return true;\n }\n return false;\n });\n return out;\n }\n const result = {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n return result;\n}\nfunction base(n) {\n const name = n;\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const pnames = ma.protoNames();\n if (pnames.length === 1 && pnames[0] === name) {\n return true;\n }\n return false;\n }\n function partialMatch(protos) {\n if (protos.length === 0) {\n return null;\n }\n if (protos[0] === name) {\n return protos.slice(1);\n }\n return null;\n }\n return {\n toString: function () { return name; },\n matches,\n partialMatch\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/@multiformats/mafmt/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/it-pb-stream/dist/src/index.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/it-pb-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_handshake__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/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/**\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\nfunction pbStream(duplex, opts = {}) {\n const shake = (0,it_handshake__WEBPACK_IMPORTED_MODULE_0__.handshake)(duplex);\n const lpReader = it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.decode.fromReader(shake.reader, opts);\n const W = {\n read: async (bytes) => {\n // just read\n const { value } = await shake.reader.next(bytes);\n if (value == null) {\n throw new Error('Value is null');\n }\n return value;\n },\n readLP: async () => {\n // read, decode\n // @ts-expect-error .next is part of the generator interface\n const { value } = await lpReader.next();\n if (value == null) {\n throw new Error('Value is null');\n }\n return value;\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 shake.writer.push(data);\n }\n else {\n shake.writer.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 () => await W.readPB(proto),\n write: (d) => { W.writePB(d, proto); },\n unwrap: () => W\n };\n },\n unwrap: () => {\n // returns vanilla duplex again, terminates all reads/writes from this object\n shake.rest();\n duplex.source = shake.stream.source;\n duplex.sink = shake.stream.sink;\n return duplex;\n }\n };\n return W;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/it-pb-stream/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base10.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base16.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base2.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base256emoji.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base32.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base36.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base58.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base64.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base8.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/identity.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/interface.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/src/bases/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/@waku/create/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/basics.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bytes.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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)\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/@waku/create/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/cid.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/codecs/json.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 */ });\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/@waku/create/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/codecs/raw.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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/@waku/create/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/digest.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/hasher.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/identity.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/index.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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_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/@waku/create/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/interface.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/link/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/src/link/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/@waku/create/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/varint.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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/@waku/create/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/vendor/base-x.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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// 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/@waku/create/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/vendor/varint.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 */ });\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/@waku/create/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js?"); +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/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/libp2p/dist/src/index.js\");\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 * If `useFilterV1` is set to true, the node will use Filter V1 protocol.\n * If `useFilterV1` is set to false or undefined, the node will use Filter V2 protocol. (default behavior)\n *\n * **Note: This is NOT compatible with nwaku v0.11**\n *\n * @see https://github.com/status-im/nwaku/issues/1085\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 let filter;\n if (options?.useFilterV1) {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV1)(options);\n }\n else {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV2)();\n }\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 * Implements generics to allow for conditional type checking for Filter V1 and V2 protocols.\n * If `useFilterV1` is set to true, the node will use Filter V1 protocol.\n * If `useFilterV1` is set to false or undefined, the node will use Filter V2 protocol. (default behavior)\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 let filter;\n if (!options?.useFilterV1) {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV2)();\n }\n else {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV1)(options);\n }\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 libp2pOpts = Object.assign({\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 identify: {\n host: {\n agentVersion: userAgent ?? _waku_core__WEBPACK_IMPORTED_MODULE_4__.DefaultUserAgent,\n },\n },\n }, wakuGossipSub ? { pubsub: wakuGossipSub } : {}, options ?? {});\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_7__.createLibp2p)(libp2pOpts);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/create/dist/index.js?"); /***/ }), @@ -7393,7 +4643,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 */ \"DnsNodeDiscovery\": () => (/* binding */ DnsNodeDiscovery)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/dns-discovery/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 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._errorTolerance = 10;\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/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?"); /***/ }), @@ -7404,7 +4654,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 */ \"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 /**\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_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/dns-discovery/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?"); /***/ }), @@ -7415,7 +4665,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 */ \"ENRTree\": () => (/* binding */ ENRTree)\n/* harmony export */ });\n/* harmony import */ var _waku_enr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/enr */ \"./node_modules/@waku/dns-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/uint8arrays/dist/src/from-string.js\");\n\n\n\n\n\nclass ENRTree {\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}\nENRTree.RECORD_PREFIX = _waku_enr__WEBPACK_IMPORTED_MODULE_0__.ENR.RECORD_PREFIX;\nENRTree.TREE_PREFIX = \"enrtree:\";\nENRTree.BRANCH_PREFIX = \"enrtree-branch:\";\nENRTree.ROOT_PREFIX = \"enrtree-root:\";\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/enr/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/dns-discovery/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?"); /***/ }), @@ -7437,469 +4687,172 @@ 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 */ \"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 = 120000;\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 constructor(components, options) {\n super();\n this._started = false;\n this._components = components;\n this._options = options;\n const { enrUrl } = options;\n log(\"Use following EIP-1459 ENR Tree URL: \", enrUrl);\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 const { enrUrl, wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, [enrUrl], wantedNodeCapabilityCount);\n }\n for await (const peer of this.nextPeer()) {\n if (!this._started)\n return;\n const peerInfo = peer.peerInfo;\n if (!peerInfo)\n continue;\n if ((await this._components.peerStore.getTags(peerInfo.id)).find(({ name }) => name === DEFAULT_BOOTSTRAP_TAG_NAME))\n continue;\n await this._components.peerStore.tagPeer(peerInfo.id, DEFAULT_BOOTSTRAP_TAG_NAME, {\n value: this._options.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL,\n });\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent(\"peer\", { detail: peerInfo }));\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__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrl, wantedNodeCapabilityCount) {\n return (components) => new PeerDiscoveryDns(components, { enrUrl, wantedNodeCapabilityCount });\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/dist/index.js?"); +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 = 120000;\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 { enrUrl } = options;\n log(\"Use following EIP-1459 ENR Tree URL: \", enrUrl);\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 const { enrUrl, wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, [enrUrl], wantedNodeCapabilityCount);\n }\n for await (const peer of this.nextPeer()) {\n if (!this._started)\n return;\n const peerInfo = peer.peerInfo;\n if (!peerInfo)\n continue;\n if ((await this._components.peerStore.getTags(peerInfo.id)).find(({ name }) => name === DEFAULT_BOOTSTRAP_TAG_NAME))\n continue;\n await this._components.peerStore.tagPeer(peerInfo.id, DEFAULT_BOOTSTRAP_TAG_NAME, {\n value: this._options.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL,\n });\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent(\"peer\", { detail: peerInfo }));\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__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrl, wantedNodeCapabilityCount) {\n return (components) => new PeerDiscoveryDns(components, { enrUrl, 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/dns-discovery/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/@libp2p/interface-peer-id/dist/src/index.js ***! - \***************************************************************************************************/ +/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/utils/dist/bytes/index.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@waku/dns-discovery/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 */ \"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/@waku/dns-discovery/node_modules/@libp2p/interface-peer-id/dist/src/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/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/dns-discovery/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/@libp2p/peer-id/dist/src/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/dns-discovery/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/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 */ \"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/dns-discovery/node_modules/@waku/enr/dist/constants.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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 */ \"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/dns-discovery/node_modules/@waku/enr/dist/constants.js?"); +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/enr/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/dns-discovery/node_modules/@waku/enr/dist/creator.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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 */ \"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/dns-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/dns-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/dns-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/dns-discovery/node_modules/@waku/enr/dist/creator.js?"); +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/enr/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/dns-discovery/node_modules/@waku/enr/dist/crypto.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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 */ \"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/dns-discovery/node_modules/@waku/enr/dist/crypto.js?"); +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/enr/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/dns-discovery/node_modules/@waku/enr/dist/decoder.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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 */ \"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/dns-discovery/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/dns-discovery/node_modules/@waku/enr/dist/decoder.js?"); +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/dns-discovery/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/enr/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/enr/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/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/enr/dist/waku2_codec.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/enr/node_modules/@waku/utils/dist/bytes/index.js": /*!*****************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/enr.js ***! + !*** ./node_modules/@waku/enr/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 */ \"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/dns-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/dns-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/dns-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/dns-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/dns-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/dns-discovery/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 constructor() {\n super(...arguments);\n this.getLocationMultiaddr = _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__.locationMultiaddrFromEnrFields.bind({}, this);\n }\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 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}\nENR.RECORD_PREFIX = \"enr:\";\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/enr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/get_multiaddr.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-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/dns-discovery/node_modules/@waku/enr/dist/get_multiaddr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/index.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-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/dns-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/dns-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/dns-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/dns-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/dns-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/dns-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/dns-discovery/node_modules/@waku/enr/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-discovery/node_modules/@waku/enr/dist/multiaddr_from_fields.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-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/dns-discovery/node_modules/@waku/enr/dist/multiaddrs_codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/peer_id.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/@waku/dns-discovery/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/dns-discovery/node_modules/@waku/enr/dist/peer_id.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/raw_enr.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-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_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/dns-discovery/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/dns-discovery/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/dns-discovery/node_modules/@waku/enr/dist/waku2_codec.js\");\n\n\n\n\n\nclass RawEnr extends Map {\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/dns-discovery/node_modules/@waku/enr/dist/raw_enr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/v4.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-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/dns-discovery/node_modules/@waku/enr/dist/v4.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/enr/dist/waku2_codec.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-discovery/node_modules/@waku/enr/dist/waku2_codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base10.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base16.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base2.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base256emoji.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base36.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base58.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base64.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base8.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/identity.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/interface.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/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/@waku/dns-discovery/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/basics.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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)\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/@waku/dns-discovery/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/cid.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 */ });\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/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/raw.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/hasher.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/identity.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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_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/@waku/dns-discovery/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/interface.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/link/interface.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/src/link/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/@waku/dns-discovery/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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// 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/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/varint.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 */ });\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/@waku/dns-discovery/node_modules/multiformats/vendor/varint.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/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/enr/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), @@ -7943,7 +4896,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 */ \"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 */ \"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/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./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/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./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/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./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/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/interfaces/dist/receiver.js\");\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/interfaces/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\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/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./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/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./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/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./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/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/interfaces/dist/misc.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/interfaces/dist/index.js?"); /***/ }), @@ -7969,6 +4922,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=messag /***/ }), +/***/ "./node_modules/@waku/interfaces/dist/misc.js": +/*!****************************************************!*\ + !*** ./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/interfaces/dist/misc.js?"); + +/***/ }), + /***/ "./node_modules/@waku/interfaces/dist/peer_exchange.js": /*!*************************************************************!*\ !*** ./node_modules/@waku/interfaces/dist/peer_exchange.js ***! @@ -7987,7 +4951,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 */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/interfaces/dist/protocols.js?"); +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/interfaces/dist/protocols.js?"); /***/ }), @@ -8053,7 +5017,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 */ \"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 */\n constructor(contentTopic, hsResult, ephemeral = true) {\n this.contentTopic = contentTopic;\n this.hsResult = hsResult;\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 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 return {\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 }\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/noise/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?"); /***/ }), @@ -8141,7 +5105,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 */\n constructor(sender, responder, myStaticKey, pairingParameters, myEphemeralKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.generateX25519KeyPair)()) {\n this.sender = sender;\n this.responder = responder;\n this.myStaticKey = myStaticKey;\n this.myEphemeralKey = myEphemeralKey;\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(contentTopic, messageNametag) {\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 hsMessage = await this.responder.nextMessage(contentTopic);\n const step = this.handshake.stepHandshake({\n readPayloadV2: hsMessage.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 await this.responder.subscribe(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.contentTopic, this.handshake.hs.toMessageNametag());\n await this.responder.stop(this.contentTopic);\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);\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 await this.responder.subscribe(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.contentTopic, this.qrMessageNameTag);\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.contentTopic, this.handshake.hs.toMessageNametag());\n await this.responder.stop(this.contentTopic);\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);\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 * @returns an array with [NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]\n */\n static getSecureCodec(contentTopic, hsResult) {\n const secureEncoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferEncoder(contentTopic, hsResult);\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 * @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?"); /***/ }), @@ -8200,6 +5164,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@waku/noise/node_modules/@waku/core/dist/lib/message/version_0.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/noise/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/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/noise/node_modules/@waku/core/dist/lib/message/version_0.js?"); + +/***/ }), + /***/ "./node_modules/@waku/proto/dist/index.js": /*!************************************************!*\ !*** ./node_modules/@waku/proto/dist/index.js ***! @@ -8218,7 +5193,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 */ \"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/@waku/proto/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?"); /***/ }), @@ -8229,7 +5204,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/@waku/proto/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?"); /***/ }), @@ -8240,7 +5215,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 */ \"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/@waku/proto/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?"); /***/ }), @@ -8251,7 +5226,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/@waku/proto/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?"); /***/ }), @@ -8262,7 +5237,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/@waku/proto/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?"); /***/ }), @@ -8273,84 +5248,216 @@ 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/@waku/proto/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?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js": +/***/ "./node_modules/@waku/relay/dist/constants.js": +/*!****************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"RelayCodecs\": () => (/* binding */ RelayCodecs),\n/* harmony export */ \"RelayFanoutTTL\": () => (/* binding */ RelayFanoutTTL),\n/* harmony export */ \"RelayGossipFactor\": () => (/* binding */ RelayGossipFactor),\n/* harmony export */ \"RelayHeartbeatInitialDelay\": () => (/* binding */ RelayHeartbeatInitialDelay),\n/* harmony export */ \"RelayHeartbeatInterval\": () => (/* binding */ RelayHeartbeatInterval),\n/* harmony export */ \"RelayMaxIHaveLength\": () => (/* binding */ RelayMaxIHaveLength),\n/* harmony export */ \"RelayOpportunisticGraftPeers\": () => (/* binding */ RelayOpportunisticGraftPeers),\n/* harmony export */ \"RelayOpportunisticGraftTicks\": () => (/* binding */ RelayOpportunisticGraftTicks),\n/* harmony export */ \"RelayPruneBackoff\": () => (/* binding */ RelayPruneBackoff),\n/* harmony export */ \"RelayPrunePeers\": () => (/* binding */ RelayPrunePeers),\n/* harmony export */ \"minute\": () => (/* binding */ minute),\n/* harmony export */ \"second\": () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n/**\n * RelayCodec is the libp2p identifier for the waku relay protocol\n */\nconst RelayCodecs = [\"/vac/waku/relay/2.0.0\"];\n/**\n * RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or\n * RelayDlazy, whichever is greater.\n */\nconst RelayGossipFactor = 0.25;\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst RelayHeartbeatInitialDelay = 100;\n/**\n * RelayHeartbeatInterval controls the time between heartbeats.\n */\nconst RelayHeartbeatInterval = second;\n/**\n * RelayPrunePeers 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 RelayPrunePeers other peers that we\n * know of.\n */\nconst RelayPrunePeers = 16;\n/**\n * RelayPruneBackoff 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 RelayPruneBackoff 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 RelayPruneBackoff\n * before attempting to re-graft.\n */\nconst RelayPruneBackoff = minute;\n/**\n * RelayFanoutTTL controls how long we keep track of the fanout state. If it's been\n * RelayFanoutTTL 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 RelayFanoutTTL = minute;\n/**\n * RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every RelayOpportunisticGraftTicks 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 RelayOpportunisticGraftTicks = 60;\n/**\n * RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst RelayOpportunisticGraftPeers = 2;\n/**\n * RelayMaxIHaveLength 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 RelayMaxIHaveLength = 5000;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/index.js": +/*!************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"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/@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/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\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_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/dist/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/relay/dist/message_validator.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_9__ = __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_6__(\"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_7__.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.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.pubsub;\n this.pubSubTopic = options?.pubSubTopic ?? _waku_core__WEBPACK_IMPORTED_MODULE_3__.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_9__.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_5__.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_4__.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_4__.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_5__.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(async ({ decoder, callback }) => {\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 callback(msg);\n }\n else {\n log(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\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\", async (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_8__.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_2__.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_7__.RelayCodecs;\n return pubsub;\n };\n}\nfunction toObservers(decoders, callback) {\n const contentTopicToDecoders = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_5__.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?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/message_validator.js": +/*!************************************************************!*\ + !*** ./node_modules/@waku/relay/dist/message_validator.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_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/@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?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/topic_only_message.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/relay/dist/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 */ \"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/@waku/proto/dist/index.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ _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/proto/node_modules/protons-runtime/dist/src/codec.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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js?"); +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/proto/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.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 */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.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/relay/node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/message.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/proto/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/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/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/group_by.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js?"); +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/relay/node_modules/@waku/utils/dist/common/group_by.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/index.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js?"); +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/relay/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/relay/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/relay/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/relay/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/relay/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/relay/node_modules/@waku/utils/dist/common/index.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js ***! - \*********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_defined.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js?"); +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/relay/node_modules/@waku/utils/dist/common/is_defined.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js ***! - \*********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_size_valid.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js?"); +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/relay/node_modules/@waku/utils/dist/common/is_size_valid.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/random_subset.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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/relay/node_modules/@waku/utils/dist/common/random_subset.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/to_async_iterator.js": +/*!********************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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, 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/relay/node_modules/@waku/utils/dist/common/to_async_iterator.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"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/relay/node_modules/@waku/utils/dist/common/index.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js?"); /***/ }), @@ -8365,61 +5472,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/utils/dist/common/index.js": -/*!*******************************************************!*\ - !*** ./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 */ \"getPseudoRandomSubset\": () => (/* reexport safe */ _random_subset_js__WEBPACK_IMPORTED_MODULE_1__.getPseudoRandomSubset),\n/* harmony export */ \"isDefined\": () => (/* reexport safe */ _is_defined_js__WEBPACK_IMPORTED_MODULE_0__.isDefined)\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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/@waku/utils/dist/common/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/common/is_defined.js": -/*!************************************************************!*\ - !*** ./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/utils/dist/common/is_defined.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/common/random_subset.js": -/*!***************************************************************!*\ - !*** ./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/utils/dist/common/random_subset.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/index.js": -/*!************************************************!*\ - !*** ./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 */ \"getPseudoRandomSubset\": () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getPseudoRandomSubset),\n/* harmony export */ \"isDefined\": () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isDefined)\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?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/libp2p/index.js": -/*!*******************************************************!*\ - !*** ./node_modules/@waku/utils/dist/libp2p/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 */ \"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?"); - -/***/ }), - /***/ "./node_modules/abortable-iterator/dist/src/abort-error.js": /*!*****************************************************************!*\ !*** ./node_modules/abortable-iterator/dist/src/abort-error.js ***! @@ -8442,6 +5494,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/any-signal/dist/src/index.js": +/*!***************************************************!*\ + !*** ./node_modules/any-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 */ \"anySignal\": () => (/* binding */ anySignal)\n/* harmony export */ });\n/**\n * Takes an array of AbortSignals and returns a single signal.\n * If any signals are aborted, the returned signal will be aborted.\n */\nfunction anySignal(signals) {\n const controller = new globalThis.AbortController();\n function onAbort() {\n controller.abort();\n for (const signal of signals) {\n if (signal?.removeEventListener != null) {\n signal.removeEventListener('abort', onAbort);\n }\n }\n }\n for (const signal of signals) {\n if (signal?.aborted === true) {\n onAbort();\n break;\n }\n if (signal?.addEventListener != null) {\n signal.addEventListener('abort', onAbort);\n }\n }\n function clear() {\n for (const signal of signals) {\n if (signal?.removeEventListener != null) {\n signal.removeEventListener('abort', onAbort);\n }\n }\n }\n const signal = controller.signal;\n signal.clear = clear;\n return signal;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/any-signal/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/byte-access/dist/src/index.js": /*!****************************************************!*\ !*** ./node_modules/byte-access/dist/src/index.js ***! @@ -8453,6 +5516,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/datastore-core/node_modules/interface-datastore/dist/src/key.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/datastore-core/node_modules/interface-datastore/dist/src/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 */ \"Key\": () => (/* binding */ Key)\n/* harmony export */ });\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\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/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\nconst pathSepS = '/';\nconst pathSepB = new TextEncoder().encode(pathSepS);\nconst pathSep = pathSepB[0];\n/**\n * A Key represents the unique identifier of an object.\n * Our Key scheme is inspired by file systems and Google App Engine key model.\n * Keys are meant to be unique across a system. Keys are hierarchical,\n * incorporating more and more specific namespaces. Thus keys can be deemed\n * 'children' or 'ancestors' of other keys:\n * - `new Key('/Comedy')`\n * - `new Key('/Comedy/MontyPython')`\n * Also, every namespace can be parametrized to embed relevant object\n * information. For example, the Key `name` (most specific namespace) could\n * include the object type:\n * - `new Key('/Comedy/MontyPython/Actor:JohnCleese')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')`\n *\n */\nclass Key {\n /**\n * @param {string | Uint8Array} s\n * @param {boolean} [clean]\n */\n constructor(s, clean) {\n if (typeof s === 'string') {\n this._buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(s);\n }\n else if (s instanceof Uint8Array) {\n this._buf = s;\n }\n else {\n throw new Error('Invalid key, should be String of Uint8Array');\n }\n if (clean == null) {\n clean = true;\n }\n if (clean) {\n this.clean();\n }\n if (this._buf.byteLength === 0 || this._buf[0] !== pathSep) {\n throw new Error('Invalid key');\n }\n }\n /**\n * Convert to the string representation\n *\n * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.\n * @returns {string}\n */\n toString(encoding = 'utf8') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(this._buf, encoding);\n }\n /**\n * Return the Uint8Array representation of the key\n *\n * @returns {Uint8Array}\n */\n uint8Array() {\n return this._buf;\n }\n /**\n * Return string representation of the key\n *\n * @returns {string}\n */\n get [Symbol.toStringTag]() {\n return `Key(${this.toString()})`;\n }\n /**\n * Constructs a key out of a namespace array.\n *\n * @param {Array} list - The array of namespaces\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.withNamespaces(['one', 'two'])\n * // => Key('/one/two')\n * ```\n */\n static withNamespaces(list) {\n return new Key(list.join(pathSepS));\n }\n /**\n * Returns a randomly (uuid) generated key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.random()\n * // => Key('/f98719ea086343f7b71f32ea9d9d521d')\n * ```\n */\n static random() {\n return new Key((0,nanoid__WEBPACK_IMPORTED_MODULE_2__.nanoid)().replace(/-/g, ''));\n }\n /**\n * @param {*} other\n */\n static asKey(other) {\n if (other instanceof Uint8Array || typeof other === 'string') {\n // we can create a key from this\n return new Key(other);\n }\n if (typeof other.uint8Array === 'function') {\n // this is an older version or may have crossed the esm/cjs boundary\n return new Key(other.uint8Array());\n }\n return null;\n }\n /**\n * Cleanup the current key\n *\n * @returns {void}\n */\n clean() {\n if (this._buf == null || this._buf.byteLength === 0) {\n this._buf = pathSepB;\n }\n if (this._buf[0] !== pathSep) {\n const bytes = new Uint8Array(this._buf.byteLength + 1);\n bytes.fill(pathSep, 0, 1);\n bytes.set(this._buf, 1);\n this._buf = bytes;\n }\n // normalize does not remove trailing slashes\n while (this._buf.byteLength > 1 && this._buf[this._buf.byteLength - 1] === pathSep) {\n this._buf = this._buf.subarray(0, -1);\n }\n }\n /**\n * Check if the given key is sorted lower than ourself.\n *\n * @param {Key} key - The other Key to check against\n * @returns {boolean}\n */\n less(key) {\n const list1 = this.list();\n const list2 = key.list();\n for (let i = 0; i < list1.length; i++) {\n if (list2.length < i + 1) {\n return false;\n }\n const c1 = list1[i];\n const c2 = list2[i];\n if (c1 < c2) {\n return true;\n }\n else if (c1 > c2) {\n return false;\n }\n }\n return list1.length < list2.length;\n }\n /**\n * Returns the key with all parts in reversed order.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').reverse()\n * // => Key('/Actor:JohnCleese/MontyPython/Comedy')\n * ```\n */\n reverse() {\n return Key.withNamespaces(this.list().slice().reverse());\n }\n /**\n * Returns the `namespaces` making up this Key.\n *\n * @returns {Array}\n */\n namespaces() {\n return this.list();\n }\n /** Returns the \"base\" namespace of this key.\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').baseNamespace()\n * // => 'Actor:JohnCleese'\n * ```\n */\n baseNamespace() {\n const ns = this.namespaces();\n return ns[ns.length - 1];\n }\n /**\n * Returns the `list` representation of this key.\n *\n * @returns {Array}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()\n * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']\n * ```\n */\n list() {\n return this.toString().split(pathSepS).slice(1);\n }\n /**\n * Returns the \"type\" of this key (value of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').type()\n * // => 'Actor'\n * ```\n */\n type() {\n return namespaceType(this.baseNamespace());\n }\n /**\n * Returns the \"name\" of this key (field of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').name()\n * // => 'JohnCleese'\n * ```\n */\n name() {\n return namespaceValue(this.baseNamespace());\n }\n /**\n * Returns an \"instance\" of this type key (appends value to namespace).\n *\n * @param {string} s - The string to append.\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor').instance('JohnClesse')\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n instance(s) {\n return new Key(this.toString() + ':' + s);\n }\n /**\n * Returns the \"path\" of this key (parent + type).\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').path()\n * // => Key('/Comedy/MontyPython/Actor')\n * ```\n */\n path() {\n let p = this.parent().toString();\n if (!p.endsWith(pathSepS)) {\n p += pathSepS;\n }\n p += this.type();\n return new Key(p);\n }\n /**\n * Returns the `parent` Key of this Key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key(\"/Comedy/MontyPython/Actor:JohnCleese\").parent()\n * // => Key(\"/Comedy/MontyPython\")\n * ```\n */\n parent() {\n const list = this.list();\n if (list.length === 1) {\n return new Key(pathSepS);\n }\n return new Key(list.slice(0, -1).join(pathSepS));\n }\n /**\n * Returns the `child` Key of this Key.\n *\n * @param {Key} key - The child Key to add\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').child(new Key('Actor:JohnCleese'))\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n child(key) {\n if (this.toString() === pathSepS) {\n return key;\n }\n else if (key.toString() === pathSepS) {\n return this;\n }\n return new Key(this.toString() + key.toString(), false);\n }\n /**\n * Returns whether this key is a prefix of `other`\n *\n * @param {Key} other - The other key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy').isAncestorOf('/Comedy/MontyPython')\n * // => true\n * ```\n */\n isAncestorOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return other.toString().startsWith(this.toString());\n }\n /**\n * Returns whether this key is a contains another as prefix.\n *\n * @param {Key} other - The other Key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').isDecendantOf('/Comedy')\n * // => true\n * ```\n */\n isDecendantOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return this.toString().startsWith(other.toString());\n }\n /**\n * Checks if this key has only one namespace.\n *\n * @returns {boolean}\n *\n */\n isTopLevel() {\n return this.list().length === 1;\n }\n /**\n * Concats one or more Keys into one new Key.\n *\n * @param {Array} keys - The array of keys to concatenate\n * @returns {Key}\n */\n concat(...keys) {\n return Key.withNamespaces([...this.namespaces(), ...flatten(keys.map(key => key.namespaces()))]);\n }\n}\n/**\n * The first component of a namespace. `foo` in `foo:bar`\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceType(ns) {\n const parts = ns.split(':');\n if (parts.length < 2) {\n return '';\n }\n return parts.slice(0, -1).join(':');\n}\n/**\n * The last component of a namespace, `baz` in `foo:bar:baz`.\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceValue(ns) {\n const parts = ns.split(':');\n return parts[parts.length - 1];\n}\n/**\n * Flatten array of arrays (only one level)\n *\n * @template T\n * @param {Array} arr\n * @returns {T[]}\n */\nfunction flatten(arr) {\n return ([]).concat(...arr);\n}\n//# sourceMappingURL=key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/node_modules/interface-datastore/dist/src/key.js?"); + +/***/ }), + /***/ "./node_modules/datastore-core/node_modules/it-all/dist/src/index.js": /*!***************************************************************************!*\ !*** ./node_modules/datastore-core/node_modules/it-all/dist/src/index.js ***! @@ -8493,7 +5567,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 */ \"MemoryDatastore\": () => (/* binding */ MemoryDatastore)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/datastore-core/src/base.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/datastore-core/src/errors.js\");\n\n\n\n\n/**\n * @typedef {import('interface-datastore').Pair} Pair\n * @typedef {import('interface-datastore').Datastore} Datastore\n * @typedef {import('interface-store').Options} Options\n */\n\n/**\n * @class MemoryDatastore\n * @implements {Datastore}\n */\nclass MemoryDatastore extends _base_js__WEBPACK_IMPORTED_MODULE_0__.BaseDatastore {\n constructor () {\n super()\n\n /** @type {Record} */\n this.data = {}\n }\n\n open () {\n return Promise.resolve()\n }\n\n close () {\n return Promise.resolve()\n }\n\n /**\n * @param {Key} key\n * @param {Uint8Array} val\n */\n async put (key, val) { // eslint-disable-line require-await\n this.data[key.toString()] = val\n }\n\n /**\n * @param {Key} key\n */\n async get (key) {\n const exists = await this.has(key)\n if (!exists) throw _errors_js__WEBPACK_IMPORTED_MODULE_2__.notFoundError()\n return this.data[key.toString()]\n }\n\n /**\n * @param {Key} key\n */\n async has (key) { // eslint-disable-line require-await\n return this.data[key.toString()] !== undefined\n }\n\n /**\n * @param {Key} key\n */\n async delete (key) { // eslint-disable-line require-await\n delete this.data[key.toString()]\n }\n\n async * _all () {\n yield * Object.entries(this.data)\n .map(([key, value]) => ({ key: new interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__.Key(key), value }))\n }\n\n async * _allKeys () {\n yield * Object.entries(this.data)\n .map(([key]) => new interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__.Key(key))\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/src/memory.js?"); +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 _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/datastore-core/src/base.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/datastore-core/node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/datastore-core/src/errors.js\");\n\n\n\n\n/**\n * @typedef {import('interface-datastore').Pair} Pair\n * @typedef {import('interface-datastore').Datastore} Datastore\n * @typedef {import('interface-store').Options} Options\n */\n\n/**\n * @class MemoryDatastore\n * @implements {Datastore}\n */\nclass MemoryDatastore extends _base_js__WEBPACK_IMPORTED_MODULE_0__.BaseDatastore {\n constructor () {\n super()\n\n /** @type {Record} */\n this.data = {}\n }\n\n open () {\n return Promise.resolve()\n }\n\n close () {\n return Promise.resolve()\n }\n\n /**\n * @param {Key} key\n * @param {Uint8Array} val\n */\n async put (key, val) { // eslint-disable-line require-await\n this.data[key.toString()] = val\n }\n\n /**\n * @param {Key} key\n */\n async get (key) {\n const exists = await this.has(key)\n if (!exists) throw _errors_js__WEBPACK_IMPORTED_MODULE_2__.notFoundError()\n return this.data[key.toString()]\n }\n\n /**\n * @param {Key} key\n */\n async has (key) { // eslint-disable-line require-await\n return this.data[key.toString()] !== undefined\n }\n\n /**\n * @param {Key} key\n */\n async delete (key) { // eslint-disable-line require-await\n delete this.data[key.toString()]\n }\n\n async * _all () {\n yield * Object.entries(this.data)\n .map(([key, value]) => ({ key: new interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__.Key(key), value }))\n }\n\n async * _allKeys () {\n yield * Object.entries(this.data)\n .map(([key]) => new interface_datastore_key__WEBPACK_IMPORTED_MODULE_1__.Key(key))\n }\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/datastore-core/src/memory.js?"); /***/ }), @@ -8596,17 +5670,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/interface-datastore/dist/src/key.js": -/*!**********************************************************!*\ - !*** ./node_modules/interface-datastore/dist/src/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 */ \"Key\": () => (/* binding */ Key)\n/* harmony export */ });\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\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/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\nconst pathSepS = '/';\nconst pathSepB = new TextEncoder().encode(pathSepS);\nconst pathSep = pathSepB[0];\n/**\n * A Key represents the unique identifier of an object.\n * Our Key scheme is inspired by file systems and Google App Engine key model.\n * Keys are meant to be unique across a system. Keys are hierarchical,\n * incorporating more and more specific namespaces. Thus keys can be deemed\n * 'children' or 'ancestors' of other keys:\n * - `new Key('/Comedy')`\n * - `new Key('/Comedy/MontyPython')`\n * Also, every namespace can be parametrized to embed relevant object\n * information. For example, the Key `name` (most specific namespace) could\n * include the object type:\n * - `new Key('/Comedy/MontyPython/Actor:JohnCleese')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')`\n *\n */\nclass Key {\n /**\n * @param {string | Uint8Array} s\n * @param {boolean} [clean]\n */\n constructor(s, clean) {\n if (typeof s === 'string') {\n this._buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(s);\n }\n else if (s instanceof Uint8Array) {\n this._buf = s;\n }\n else {\n throw new Error('Invalid key, should be String of Uint8Array');\n }\n if (clean == null) {\n clean = true;\n }\n if (clean) {\n this.clean();\n }\n if (this._buf.byteLength === 0 || this._buf[0] !== pathSep) {\n throw new Error('Invalid key');\n }\n }\n /**\n * Convert to the string representation\n *\n * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.\n * @returns {string}\n */\n toString(encoding = 'utf8') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(this._buf, encoding);\n }\n /**\n * Return the Uint8Array representation of the key\n *\n * @returns {Uint8Array}\n */\n uint8Array() {\n return this._buf;\n }\n /**\n * Return string representation of the key\n *\n * @returns {string}\n */\n get [Symbol.toStringTag]() {\n return `Key(${this.toString()})`;\n }\n /**\n * Constructs a key out of a namespace array.\n *\n * @param {Array} list - The array of namespaces\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.withNamespaces(['one', 'two'])\n * // => Key('/one/two')\n * ```\n */\n static withNamespaces(list) {\n return new Key(list.join(pathSepS));\n }\n /**\n * Returns a randomly (uuid) generated key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.random()\n * // => Key('/f98719ea086343f7b71f32ea9d9d521d')\n * ```\n */\n static random() {\n return new Key((0,nanoid__WEBPACK_IMPORTED_MODULE_2__.nanoid)().replace(/-/g, ''));\n }\n /**\n * @param {*} other\n */\n static asKey(other) {\n if (other instanceof Uint8Array || typeof other === 'string') {\n // we can create a key from this\n return new Key(other);\n }\n if (typeof other.uint8Array === 'function') {\n // this is an older version or may have crossed the esm/cjs boundary\n return new Key(other.uint8Array());\n }\n return null;\n }\n /**\n * Cleanup the current key\n *\n * @returns {void}\n */\n clean() {\n if (this._buf == null || this._buf.byteLength === 0) {\n this._buf = pathSepB;\n }\n if (this._buf[0] !== pathSep) {\n const bytes = new Uint8Array(this._buf.byteLength + 1);\n bytes.fill(pathSep, 0, 1);\n bytes.set(this._buf, 1);\n this._buf = bytes;\n }\n // normalize does not remove trailing slashes\n while (this._buf.byteLength > 1 && this._buf[this._buf.byteLength - 1] === pathSep) {\n this._buf = this._buf.subarray(0, -1);\n }\n }\n /**\n * Check if the given key is sorted lower than ourself.\n *\n * @param {Key} key - The other Key to check against\n * @returns {boolean}\n */\n less(key) {\n const list1 = this.list();\n const list2 = key.list();\n for (let i = 0; i < list1.length; i++) {\n if (list2.length < i + 1) {\n return false;\n }\n const c1 = list1[i];\n const c2 = list2[i];\n if (c1 < c2) {\n return true;\n }\n else if (c1 > c2) {\n return false;\n }\n }\n return list1.length < list2.length;\n }\n /**\n * Returns the key with all parts in reversed order.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').reverse()\n * // => Key('/Actor:JohnCleese/MontyPython/Comedy')\n * ```\n */\n reverse() {\n return Key.withNamespaces(this.list().slice().reverse());\n }\n /**\n * Returns the `namespaces` making up this Key.\n *\n * @returns {Array}\n */\n namespaces() {\n return this.list();\n }\n /** Returns the \"base\" namespace of this key.\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').baseNamespace()\n * // => 'Actor:JohnCleese'\n * ```\n */\n baseNamespace() {\n const ns = this.namespaces();\n return ns[ns.length - 1];\n }\n /**\n * Returns the `list` representation of this key.\n *\n * @returns {Array}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()\n * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']\n * ```\n */\n list() {\n return this.toString().split(pathSepS).slice(1);\n }\n /**\n * Returns the \"type\" of this key (value of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').type()\n * // => 'Actor'\n * ```\n */\n type() {\n return namespaceType(this.baseNamespace());\n }\n /**\n * Returns the \"name\" of this key (field of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').name()\n * // => 'JohnCleese'\n * ```\n */\n name() {\n return namespaceValue(this.baseNamespace());\n }\n /**\n * Returns an \"instance\" of this type key (appends value to namespace).\n *\n * @param {string} s - The string to append.\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor').instance('JohnClesse')\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n instance(s) {\n return new Key(this.toString() + ':' + s);\n }\n /**\n * Returns the \"path\" of this key (parent + type).\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').path()\n * // => Key('/Comedy/MontyPython/Actor')\n * ```\n */\n path() {\n let p = this.parent().toString();\n if (!p.endsWith(pathSepS)) {\n p += pathSepS;\n }\n p += this.type();\n return new Key(p);\n }\n /**\n * Returns the `parent` Key of this Key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key(\"/Comedy/MontyPython/Actor:JohnCleese\").parent()\n * // => Key(\"/Comedy/MontyPython\")\n * ```\n */\n parent() {\n const list = this.list();\n if (list.length === 1) {\n return new Key(pathSepS);\n }\n return new Key(list.slice(0, -1).join(pathSepS));\n }\n /**\n * Returns the `child` Key of this Key.\n *\n * @param {Key} key - The child Key to add\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').child(new Key('Actor:JohnCleese'))\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n child(key) {\n if (this.toString() === pathSepS) {\n return key;\n }\n else if (key.toString() === pathSepS) {\n return this;\n }\n return new Key(this.toString() + key.toString(), false);\n }\n /**\n * Returns whether this key is a prefix of `other`\n *\n * @param {Key} other - The other key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy').isAncestorOf('/Comedy/MontyPython')\n * // => true\n * ```\n */\n isAncestorOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return other.toString().startsWith(this.toString());\n }\n /**\n * Returns whether this key is a contains another as prefix.\n *\n * @param {Key} other - The other Key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').isDecendantOf('/Comedy')\n * // => true\n * ```\n */\n isDecendantOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return this.toString().startsWith(other.toString());\n }\n /**\n * Checks if this key has only one namespace.\n *\n * @returns {boolean}\n *\n */\n isTopLevel() {\n return this.list().length === 1;\n }\n /**\n * Concats one or more Keys into one new Key.\n *\n * @param {Array} keys - The array of keys to concatenate\n * @returns {Key}\n */\n concat(...keys) {\n return Key.withNamespaces([...this.namespaces(), ...flatten(keys.map(key => key.namespaces()))]);\n }\n}\n/**\n * The first component of a namespace. `foo` in `foo:bar`\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceType(ns) {\n const parts = ns.split(':');\n if (parts.length < 2) {\n return '';\n }\n return parts.slice(0, -1).join(':');\n}\n/**\n * The last component of a namespace, `baz` in `foo:bar:baz`.\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceValue(ns) {\n const parts = ns.split(':');\n return parts[parts.length - 1];\n}\n/**\n * Flatten array of arrays (only one level)\n *\n * @template T\n * @param {Array} arr\n * @returns {T[]}\n */\nfunction flatten(arr) {\n return ([]).concat(...arr);\n}\n//# sourceMappingURL=key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/interface-datastore/dist/src/key.js?"); - -/***/ }), - /***/ "./node_modules/ip-regex/index.js": /*!****************************************!*\ !*** ./node_modules/ip-regex/index.js ***! @@ -8629,6 +5692,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/it-all/dist/src/index.js": +/*!***********************************************!*\ + !*** ./node_modules/it-all/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 */ });\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction all(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n const arr = [];\n for await (const entry of source) {\n arr.push(entry);\n }\n return arr;\n })();\n }\n const arr = [];\n for (const entry of source) {\n arr.push(entry);\n }\n return arr;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (all);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-all/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/it-batched-bytes/dist/src/index.js": /*!*********************************************************!*\ !*** ./node_modules/it-batched-bytes/dist/src/index.js ***! @@ -8662,6 +5736,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./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\": () => (/* binding */ first)\n/* harmony export */ });\n/**\n * Returns the first result from an (async) iterable, unless empty, in which\n * case returns `undefined`\n */\nasync function first(source) {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-first/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/it-handshake/dist/src/index.js": /*!*****************************************************!*\ !*** ./node_modules/it-handshake/dist/src/index.js ***! @@ -8669,18 +5754,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 */ });\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\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 return await Promise.reject(sinkErr);\n }\n sourcePromise.resolve(source);\n return 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?"); - -/***/ }), - -/***/ "./node_modules/it-length-prefixed/dist/src/alloc.js": -/*!***********************************************************!*\ - !*** ./node_modules/it-length-prefixed/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 */ });\nfunction alloc(len) {\n return new Uint8Array(len);\n}\nfunction allocUnsafe(len) {\n if (globalThis?.Buffer?.allocUnsafe != null) {\n return globalThis.Buffer.allocUnsafe(len);\n }\n return new Uint8Array(len);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/alloc.js?"); +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?"); /***/ }), @@ -8691,7 +5765,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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* eslint max-depth: [\"error\", 6] */\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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(options) {\n const decoder = async function* (source) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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 for await (const buf of source) {\n buffer.append(buf);\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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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 (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n };\n return decoder;\n}\n/**\n * @param {*} reader\n * @param {import('./types').DecoderOptions} [options]\n * @returns\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({\n ...(options ?? {}),\n onLength\n })(varByteSource);\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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(source, options) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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_2__(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_2__(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?"); /***/ }), @@ -8702,7 +5776,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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 _alloc_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./alloc.js */ \"./node_modules/it-length-prefixed/dist/src/alloc.js\");\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,_alloc_js__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n const encoder = async function* (source) {\n for await (const chunk of source) {\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 };\n return encoder;\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./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_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.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_0__.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?"); /***/ }), @@ -8717,6 +5791,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/it-length-prefixed/dist/src/utils.js": +/*!***********************************************************!*\ + !*** ./node_modules/it-length-prefixed/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 */ \"isAsyncIterable\": () => (/* binding */ isAsyncIterable)\n/* harmony export */ });\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/it-length-prefixed/dist/src/utils.js?"); + +/***/ }), + /***/ "./node_modules/it-map/dist/src/index.js": /*!***********************************************!*\ !*** ./node_modules/it-map/dist/src/index.js ***! @@ -8761,6 +5846,17 @@ 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 ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_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__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/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 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 err_code__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/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 };\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_1__.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_1__.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_4__(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_1__.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_4__(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_4__(new Error('message length too long'), 'ERR_MSG_DATA_TOO_LONG');\n }\n return await 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_0__.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 () => await 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?"); + +/***/ }), + /***/ "./node_modules/it-pipe/dist/src/index.js": /*!************************************************!*\ !*** ./node_modules/it-pipe/dist/src/index.js ***! @@ -8922,7 +6018,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 */ \"DefaultAddressManager\": () => (/* binding */ DefaultAddressManager)\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 _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\nconst defaultAddressFilter = (addrs) => addrs;\nclass DefaultAddressManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\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 super();\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 Set();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n * Signal that we have confidence an observed multiaddr is publicly dialable -\n * this will make it appear in the output of getAddresses()\n */\n confirmObservedAddr(addr) {\n }\n /**\n * Signal that we do not have confidence an observed multiaddr is publicly dialable -\n * this will remove it from the output of getObservedAddrs()\n */\n removeObservedAddr(addr) {\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(addr);\n const remotePeer = ma.getPeerId();\n // strip our peer id if it has been passed\n if (remotePeer != null) {\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(remotePeer);\n // use same encoding for comparison\n if (remotePeerId.equals(this.components.peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(`/p2p/${this.components.peerId.toString()}`));\n }\n }\n const addrString = ma.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.add(addrString);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('change:addresses'));\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 addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()));\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_1__.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?"); +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_interfaces_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/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\n\n\nconst defaultAddressFilter = (addrs) => addrs;\nclass DefaultAddressManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\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 super();\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 Set();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n * Signal that we have confidence an observed multiaddr is publicly dialable -\n * this will make it appear in the output of getAddresses()\n */\n confirmObservedAddr(addr) {\n }\n /**\n * Signal that we do not have confidence an observed multiaddr is publicly dialable -\n * this will remove it from the output of getObservedAddrs()\n */\n removeObservedAddr(addr) {\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(addr);\n const remotePeer = ma.getPeerId();\n // strip our peer id if it has been passed\n if (remotePeer != null) {\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(remotePeer);\n // use same encoding for comparison\n if (remotePeerId.equals(this.components.peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(`/p2p/${this.components.peerId.toString()}`));\n }\n }\n const addrString = ma.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.add(addrString);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('change:addresses'));\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 addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()));\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_1__.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?"); /***/ }), @@ -8944,7 +6040,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 */ \"canHop\": () => (/* binding */ canHop),\n/* harmony export */ \"handleCanHop\": () => (/* binding */ handleCanHop),\n/* harmony export */ \"handleHop\": () => (/* binding */ handleHop),\n/* harmony export */ \"hop\": () => (/* binding */ hop)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/utils.js\");\n/* harmony import */ var _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _stop_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:hop');\nasync function handleHop(hopRequest) {\n const { connection, request, streamHandler, circuit, connectionManager } = hopRequest;\n // Ensure hop is enabled\n if (!circuit.hopEnabled()) {\n log('HOP request received but we are not acting as a relay');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n }\n // Validate the HOP request has the required input\n try {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.validateAddrs)(request, streamHandler);\n }\n catch (err) {\n log.error('invalid hop request via peer %p %o', connection.remotePeer, err);\n return;\n }\n if (request.dstPeer == null) {\n log('HOP request received but we do not receive a dstPeer');\n return;\n }\n // Get the connection to the destination (stop) peer\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__.peerIdFromBytes)(request.dstPeer.id);\n const destinationConnections = connectionManager.getConnections(destinationPeer);\n if (destinationConnections.length === 0 && !circuit.hopActive()) {\n log('HOP request received but we are not connected to the destination peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // TODO: Handle being an active relay\n if (destinationConnections.length === 0) {\n log('did not have connection to remote peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // Handle the incoming HOP request by performing a STOP request\n const stopRequest = {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP,\n dstPeer: request.dstPeer,\n srcPeer: request.srcPeer\n };\n let destinationStream;\n try {\n log('performing STOP request');\n const result = await (0,_stop_js__WEBPACK_IMPORTED_MODULE_7__.stop)({\n connection: destinationConnections[0],\n request: stopRequest\n });\n if (result == null) {\n throw new Error('Could not stop');\n }\n destinationStream = result;\n }\n catch (err) {\n log.error(err);\n return;\n }\n log('hop request from %p is valid', connection.remotePeer);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS\n });\n const sourceStream = streamHandler.rest();\n log('creating related connections');\n // Short circuit the two streams to create the relayed connection\n return await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(sourceStream, destinationStream, sourceStream);\n}\n/**\n * Performs a HOP request to a relay peer, to request a connection to another\n * peer. A new, virtual, connection will be created between the two via the relay.\n */\nasync function hop(options) {\n const { connection, request, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write(request);\n const response = await streamHandler.read();\n if (response == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('HOP request had no response'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n }\n if (response.code === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n log('hop request was successful');\n return streamHandler.rest();\n }\n log('hop request failed with code %d, closing stream', response.code);\n streamHandler.close();\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`HOP request failed with code \"${response.code ?? 'unknown'}\"`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n}\n/**\n * Performs a CAN_HOP request to a relay peer, in order to understand its capabilities\n */\nasync function canHop(options) {\n const { connection, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP\n });\n const response = await streamHandler.read();\n await streamHandler.close();\n if (response == null || response.code !== _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n return false;\n }\n return true;\n}\n/**\n * Creates an unencoded CAN_HOP response based on the Circuits configuration\n */\nfunction handleCanHop(options) {\n const { connection, streamHandler, circuit } = options;\n const canHop = circuit.hopEnabled();\n log('can hop (%s) request from %p', canHop, connection.remotePeer);\n streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: canHop ? _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS : _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n}\n//# sourceMappingURL=hop.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/circuit/hop.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"canHop\": () => (/* binding */ canHop),\n/* harmony export */ \"handleCanHop\": () => (/* binding */ handleCanHop),\n/* harmony export */ \"handleHop\": () => (/* binding */ handleHop),\n/* harmony export */ \"hop\": () => (/* binding */ hop)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/utils.js\");\n/* harmony import */ var _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _stop_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:hop');\nasync function handleHop(hopRequest) {\n const { connection, request, streamHandler, circuit, connectionManager } = hopRequest;\n // Ensure hop is enabled\n if (!circuit.hopEnabled()) {\n log('HOP request received but we are not acting as a relay');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n }\n // Validate the HOP request has the required input\n try {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.validateAddrs)(request, streamHandler);\n }\n catch (err) {\n log.error('invalid hop request via peer %p %o', connection.remotePeer, err);\n return;\n }\n if (request.dstPeer == null) {\n log('HOP request received but we do not receive a dstPeer');\n return;\n }\n // Get the connection to the destination (stop) peer\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__.peerIdFromBytes)(request.dstPeer.id);\n const destinationConnections = connectionManager.getConnections(destinationPeer);\n if (destinationConnections.length === 0 && !circuit.hopActive()) {\n log('HOP request received but we are not connected to the destination peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // TODO: Handle being an active relay\n if (destinationConnections.length === 0) {\n log('did not have connection to remote peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // Handle the incoming HOP request by performing a STOP request\n const stopRequest = {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP,\n dstPeer: request.dstPeer,\n srcPeer: request.srcPeer\n };\n let destinationStream;\n try {\n log('performing STOP request');\n const result = await (0,_stop_js__WEBPACK_IMPORTED_MODULE_7__.stop)({\n connection: destinationConnections[0],\n request: stopRequest\n });\n if (result == null) {\n throw new Error('Could not stop');\n }\n destinationStream = result;\n }\n catch (err) {\n log.error(err);\n return;\n }\n log('hop request from %p is valid', connection.remotePeer);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS\n });\n const sourceStream = streamHandler.rest();\n log('creating related connections');\n // Short circuit the two streams to create the relayed connection\n return await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(sourceStream, destinationStream, sourceStream);\n}\n/**\n * Performs a HOP request to a relay peer, to request a connection to another\n * peer. A new, virtual, connection will be created between the two via the relay.\n */\nasync function hop(options) {\n const { connection, request, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write(request);\n const response = await streamHandler.read();\n if (response == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('HOP request had no response'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n }\n if (response.code === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n log('hop request was successful');\n return streamHandler.rest();\n }\n log('hop request failed with code %d, closing stream', response.code);\n streamHandler.close();\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`HOP request failed with code \"${response.code ?? 'unknown'}\"`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n}\n/**\n * Performs a CAN_HOP request to a relay peer, in order to understand its capabilities\n */\nasync function canHop(options) {\n const { connection, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP\n });\n const response = await streamHandler.read();\n await streamHandler.close();\n if (response == null || response.code !== _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n return false;\n }\n return true;\n}\n/**\n * Creates an unencoded CAN_HOP response based on the Circuits configuration\n */\nfunction handleCanHop(options) {\n const { connection, streamHandler, circuit } = options;\n const canHop = circuit.hopEnabled();\n log('can hop (%s) request from %p', canHop, connection.remotePeer);\n streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: canHop ? _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS : _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n}\n//# sourceMappingURL=hop.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/circuit/hop.js?"); /***/ }), @@ -8966,7 +6062,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 */ \"StreamHandler\": () => (/* binding */ StreamHandler)\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_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_handshake__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-handshake */ \"./node_modules/it-handshake/dist/src/index.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/index.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:stream-handler');\nclass StreamHandler {\n constructor(options) {\n const { stream, maxLength = 4096 } = options;\n this.stream = stream;\n this.shake = (0,it_handshake__WEBPACK_IMPORTED_MODULE_2__.handshake)(this.stream);\n this.decoder = it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.decode.fromReader(this.shake.reader, { maxDataLength: maxLength });\n }\n /**\n * Read and decode message\n */\n async read() {\n // @ts-expect-error FIXME is a source, needs to be a generator\n const msg = await this.decoder.next();\n if (msg.value != null) {\n const value = _pb_index_js__WEBPACK_IMPORTED_MODULE_3__.CircuitRelay.decode(msg.value);\n log('read message type', value.type);\n return value;\n }\n log('read received no value, closing stream');\n // End the stream, we didn't get data\n this.close();\n }\n /**\n * Encode and write array of buffers\n */\n write(msg) {\n log('write message type %s', msg.type);\n this.shake.write(it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.encode.single(_pb_index_js__WEBPACK_IMPORTED_MODULE_3__.CircuitRelay.encode(msg)));\n }\n /**\n * Return the handshake rest stream and invalidate handler\n */\n rest() {\n this.shake.rest();\n return this.shake.stream;\n }\n /**\n * @param {CircuitRelay} msg - An unencoded CircuitRelay protobuf message\n */\n end(msg) {\n this.write(msg);\n this.close();\n }\n /**\n * Close the stream\n */\n close() {\n log('closing the stream');\n void this.rest().sink([]).catch(err => {\n log.error(err);\n });\n }\n}\n//# sourceMappingURL=stream-handler.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"StreamHandler\": () => (/* binding */ StreamHandler)\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_length_prefixed__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/libp2p/node_modules/it-length-prefixed/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 _pb_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/index.js\");\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:stream-handler');\nclass StreamHandler {\n constructor(options) {\n const { stream, maxLength = 4096 } = options;\n this.stream = stream;\n this.shake = (0,it_handshake__WEBPACK_IMPORTED_MODULE_2__.handshake)(this.stream);\n this.decoder = it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.decode.fromReader(this.shake.reader, { maxDataLength: maxLength });\n }\n /**\n * Read and decode message\n */\n async read() {\n // @ts-expect-error FIXME is a source, needs to be a generator\n const msg = await this.decoder.next();\n if (msg.value != null) {\n const value = _pb_index_js__WEBPACK_IMPORTED_MODULE_3__.CircuitRelay.decode(msg.value);\n log('read message type', value.type);\n return value;\n }\n log('read received no value, closing stream');\n // End the stream, we didn't get data\n this.close();\n }\n /**\n * Encode and write array of buffers\n */\n write(msg) {\n log('write message type %s', msg.type);\n this.shake.write(it_length_prefixed__WEBPACK_IMPORTED_MODULE_1__.encode.single(_pb_index_js__WEBPACK_IMPORTED_MODULE_3__.CircuitRelay.encode(msg)));\n }\n /**\n * Return the handshake rest stream and invalidate handler\n */\n rest() {\n this.shake.rest();\n return this.shake.stream;\n }\n /**\n * @param {CircuitRelay} msg - An unencoded CircuitRelay protobuf message\n */\n end(msg) {\n this.write(msg);\n this.close();\n }\n /**\n * Close the stream\n */\n close() {\n log('closing the stream');\n void this.rest().sink([]).catch(err => {\n log.error(err);\n });\n }\n}\n//# sourceMappingURL=stream-handler.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js?"); /***/ }), @@ -9010,7 +6106,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 */ \"createListener\": () => (/* binding */ createListener)\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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nfunction createListener(options) {\n const listeningAddrs = new Map();\n /**\n * Add swarm handler and listen for incoming connections\n */\n async function listen(addr) {\n const addrString = addr.toString().split('/p2p-circuit').find(a => a !== '');\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(addrString);\n const relayPeerStr = ma.getPeerId();\n if (relayPeerStr == null) {\n throw new Error('Could not determine relay peer from multiaddr');\n }\n const relayPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(relayPeerStr);\n await options.peerStore.addressBook.add(relayPeerId, [ma]);\n const relayConn = await options.connectionManager.openConnection(relayPeerId);\n const relayedAddr = relayConn.remoteAddr.encapsulate('/p2p-circuit');\n listeningAddrs.set(relayConn.remotePeer.toString(), relayedAddr);\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('listening'));\n }\n /**\n * Get fixed up multiaddrs\n *\n * NOTE: This method will grab the peers multiaddrs and expand them such that:\n *\n * a) If it's an existing /p2p-circuit address for a specific relay i.e.\n * `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit` this method will expand the\n * address to `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer` where\n * `QmPeer` is this peers id\n * b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit\n * addr, such when dialing over a relay with this address, it will create the circuit using\n * the encapsulated transport address. This is useful when for example, a peer should only\n * be dialed over TCP rather than any other transport\n *\n * @returns {Multiaddr[]}\n */\n function getAddrs() {\n const addrs = [];\n for (const addr of listeningAddrs.values()) {\n addrs.push(addr);\n }\n return addrs;\n }\n const listener = Object.assign(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter(), {\n close: async () => await Promise.resolve(),\n listen,\n getAddrs\n });\n // Remove listeningAddrs when a peer disconnects\n options.connectionManager.addEventListener('peer:disconnect', (evt) => {\n const { detail: connection } = evt;\n const deleted = listeningAddrs.delete(connection.remotePeer.toString());\n if (deleted) {\n // Announce listen addresses change\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('close'));\n }\n });\n return listener;\n}\n//# sourceMappingURL=listener.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/listener.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"createListener\": () => (/* binding */ createListener)\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 _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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nfunction createListener(options) {\n const listeningAddrs = new Map();\n /**\n * Add swarm handler and listen for incoming connections\n */\n async function listen(addr) {\n const addrString = addr.toString().split('/p2p-circuit').find(a => a !== '');\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(addrString);\n const relayPeerStr = ma.getPeerId();\n if (relayPeerStr == null) {\n throw new Error('Could not determine relay peer from multiaddr');\n }\n const relayPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(relayPeerStr);\n await options.peerStore.addressBook.add(relayPeerId, [ma]);\n const relayConn = await options.connectionManager.openConnection(relayPeerId);\n const relayedAddr = relayConn.remoteAddr.encapsulate('/p2p-circuit');\n listeningAddrs.set(relayConn.remotePeer.toString(), relayedAddr);\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('listening'));\n }\n /**\n * Get fixed up multiaddrs\n *\n * NOTE: This method will grab the peers multiaddrs and expand them such that:\n *\n * a) If it's an existing /p2p-circuit address for a specific relay i.e.\n * `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit` this method will expand the\n * address to `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer` where\n * `QmPeer` is this peers id\n * b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit\n * addr, such when dialing over a relay with this address, it will create the circuit using\n * the encapsulated transport address. This is useful when for example, a peer should only\n * be dialed over TCP rather than any other transport\n *\n * @returns {Multiaddr[]}\n */\n function getAddrs() {\n const addrs = [];\n for (const addr of listeningAddrs.values()) {\n addrs.push(addr);\n }\n return addrs;\n }\n const listener = Object.assign(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter(), {\n close: async () => await Promise.resolve(),\n listen,\n getAddrs\n });\n // Remove listeningAddrs when a peer disconnects\n options.connectionManager.addEventListener('peer:disconnect', (evt) => {\n const { detail: connection } = evt;\n const deleted = listeningAddrs.delete(connection.remotePeer.toString());\n if (deleted) {\n // Announce listen addresses change\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('close'));\n }\n });\n return listener;\n}\n//# sourceMappingURL=listener.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/listener.js?"); /***/ }), @@ -9043,7 +6139,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 */ \"Circuit\": () => (/* binding */ Circuit)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/utils/stream-to-ma-conn */ \"./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/libp2p/dist/src/circuit/listener.js\");\n/* harmony import */ var _circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./circuit/hop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/hop.js\");\n/* harmony import */ var _circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./circuit/stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\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_0__.logger)('libp2p:circuit');\nclass Circuit {\n constructor(components, init) {\n this._init = init;\n this.components = components;\n this._started = false;\n }\n isStarted() {\n return this._started;\n }\n async start() {\n if (this._started) {\n return;\n }\n this._started = true;\n await this.components.registrar.handle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC, (data) => {\n void this._onProtocol(data).catch(err => {\n log.error(err);\n });\n }, { ...this._init })\n .catch(err => {\n log.error(err);\n });\n }\n async stop() {\n await this.components.registrar.unhandle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC);\n }\n hopEnabled() {\n return true;\n }\n hopActive() {\n return true;\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return 'libp2p/circuit-relay-v1';\n }\n async _onProtocol(data) {\n const { connection, stream } = data;\n const controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__.TimeoutController(this._init.hop.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_16__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n try {\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_14__.abortableDuplex)(stream, controller.signal);\n const streamHandler = new _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__.StreamHandler({\n stream: {\n ...stream,\n ...source\n }\n });\n const request = await streamHandler.read();\n if (request == null) {\n log('request was invalid, could not read from stream');\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n let virtualConnection;\n switch (request.type) {\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP: {\n log('received CAN_HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleCanHop)({ circuit: this, connection, streamHandler });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP: {\n log('received HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleHop)({\n connection,\n request,\n streamHandler,\n circuit: this,\n connectionManager: this.components.connectionManager\n });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP: {\n log('received STOP request from %p', connection.remotePeer);\n virtualConnection = await (0,_circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__.handleStop)({\n connection,\n request,\n streamHandler\n });\n break;\n }\n default: {\n log('Request of type %s not supported', request.type);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n }\n if (virtualConnection != null) {\n const remoteAddr = connection.remoteAddr\n .encapsulate('/p2p-circuit')\n .encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.dstPeer?.addrs[0]));\n const localAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.srcPeer?.addrs[0]);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr,\n localAddr\n });\n const type = request.type === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP ? 'relay' : 'inbound';\n log('new %s connection %s', type, maConn.remoteAddr);\n const conn = await this.components.upgrader.upgradeInbound(maConn);\n log('%s connection %s upgraded', type, maConn.remoteAddr);\n if (this.handler != null) {\n this.handler(conn);\n }\n }\n }\n finally {\n controller.clear();\n }\n }\n /**\n * Dial a peer over a relay\n */\n async dial(ma, options = {}) {\n // Check the multiaddr to see if it contains a relay and a destination peer\n const addrs = ma.toString().split('/p2p-circuit');\n const relayAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[0]);\n const destinationAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[addrs.length - 1]);\n const relayId = relayAddr.getPeerId();\n const destinationId = destinationAddr.getPeerId();\n if (relayId == null || destinationId == null) {\n const errMsg = 'Circuit relay dial failed as addresses did not have peer id';\n log.error(errMsg);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(errMsg), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_RELAYED_DIAL);\n }\n const relayPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(relayId);\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(destinationId);\n let disconnectOnFailure = false;\n const relayConnections = this.components.connectionManager.getConnections(relayPeer);\n let relayConnection = relayConnections[0];\n if (relayConnection == null) {\n await this.components.peerStore.addressBook.add(relayPeer, [relayAddr]);\n relayConnection = await this.components.connectionManager.openConnection(relayPeer, options);\n disconnectOnFailure = true;\n }\n try {\n const virtualConnection = await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.hop)({\n ...options,\n connection: relayConnection,\n request: {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP,\n srcPeer: {\n id: this.components.peerId.toBytes(),\n addrs: this.components.addressManager.getAddresses().map(addr => addr.bytes)\n },\n dstPeer: {\n id: destinationPeer.toBytes(),\n addrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(destinationAddr).bytes]\n }\n }\n });\n const localAddr = relayAddr.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr: ma,\n localAddr\n });\n log('new outbound connection %s', maConn.remoteAddr);\n return await this.components.upgrader.upgradeOutbound(maConn);\n }\n catch (err) {\n log.error('Circuit relay dial failed', err);\n disconnectOnFailure && await relayConnection.close();\n throw err;\n }\n }\n /**\n * Create a listener\n */\n createListener(options) {\n // Called on successful HOP and STOP requests\n this.handler = options.handler;\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_8__.createListener)({\n connectionManager: this.components.connectionManager,\n peerStore: this.components.peerStore\n });\n }\n /**\n * Filter check for all Multiaddrs that this transport can dial on\n *\n * @param {Multiaddr[]} multiaddrs\n * @returns {Multiaddr[]}\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n return multiaddrs.filter((ma) => {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__.Circuit.matches(ma);\n });\n }\n}\n//# sourceMappingURL=transport.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/transport.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Circuit\": () => (/* binding */ Circuit)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/utils/stream-to-ma-conn */ \"./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/libp2p/dist/src/circuit/listener.js\");\n/* harmony import */ var _circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./circuit/hop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/hop.js\");\n/* harmony import */ var _circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./circuit/stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\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_0__.logger)('libp2p:circuit');\nclass Circuit {\n constructor(components, init) {\n this._init = init;\n this.components = components;\n this._started = false;\n }\n isStarted() {\n return this._started;\n }\n async start() {\n if (this._started) {\n return;\n }\n this._started = true;\n await this.components.registrar.handle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC, (data) => {\n void this._onProtocol(data).catch(err => {\n log.error(err);\n });\n }, { ...this._init })\n .catch(err => {\n log.error(err);\n });\n }\n async stop() {\n await this.components.registrar.unhandle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC);\n }\n hopEnabled() {\n return true;\n }\n hopActive() {\n return true;\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return 'libp2p/circuit-relay-v1';\n }\n async _onProtocol(data) {\n const { connection, stream } = data;\n const controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__.TimeoutController(this._init.hop.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_16__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n try {\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_14__.abortableDuplex)(stream, controller.signal);\n const streamHandler = new _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__.StreamHandler({\n stream: {\n ...stream,\n ...source\n }\n });\n const request = await streamHandler.read();\n if (request == null) {\n log('request was invalid, could not read from stream');\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n let virtualConnection;\n switch (request.type) {\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP: {\n log('received CAN_HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleCanHop)({ circuit: this, connection, streamHandler });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP: {\n log('received HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleHop)({\n connection,\n request,\n streamHandler,\n circuit: this,\n connectionManager: this.components.connectionManager\n });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP: {\n log('received STOP request from %p', connection.remotePeer);\n virtualConnection = await (0,_circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__.handleStop)({\n connection,\n request,\n streamHandler\n });\n break;\n }\n default: {\n log('Request of type %s not supported', request.type);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n }\n if (virtualConnection != null) {\n const remoteAddr = connection.remoteAddr\n .encapsulate('/p2p-circuit')\n .encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.dstPeer?.addrs[0]));\n const localAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.srcPeer?.addrs[0]);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr,\n localAddr\n });\n const type = request.type === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP ? 'relay' : 'inbound';\n log('new %s connection %s', type, maConn.remoteAddr);\n const conn = await this.components.upgrader.upgradeInbound(maConn);\n log('%s connection %s upgraded', type, maConn.remoteAddr);\n if (this.handler != null) {\n this.handler(conn);\n }\n }\n }\n finally {\n controller.clear();\n }\n }\n /**\n * Dial a peer over a relay\n */\n async dial(ma, options = {}) {\n // Check the multiaddr to see if it contains a relay and a destination peer\n const addrs = ma.toString().split('/p2p-circuit');\n const relayAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[0]);\n const destinationAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[addrs.length - 1]);\n const relayId = relayAddr.getPeerId();\n const destinationId = destinationAddr.getPeerId();\n if (relayId == null || destinationId == null) {\n const errMsg = 'Circuit relay dial failed as addresses did not have peer id';\n log.error(errMsg);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(errMsg), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_RELAYED_DIAL);\n }\n const relayPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(relayId);\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(destinationId);\n let disconnectOnFailure = false;\n const relayConnections = this.components.connectionManager.getConnections(relayPeer);\n let relayConnection = relayConnections[0];\n if (relayConnection == null) {\n await this.components.peerStore.addressBook.add(relayPeer, [relayAddr]);\n relayConnection = await this.components.connectionManager.openConnection(relayPeer, options);\n disconnectOnFailure = true;\n }\n try {\n const virtualConnection = await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.hop)({\n ...options,\n connection: relayConnection,\n request: {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP,\n srcPeer: {\n id: this.components.peerId.toBytes(),\n addrs: this.components.addressManager.getAddresses().map(addr => addr.bytes)\n },\n dstPeer: {\n id: destinationPeer.toBytes(),\n addrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(destinationAddr).bytes]\n }\n }\n });\n const localAddr = relayAddr.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr: ma,\n localAddr\n });\n log('new outbound connection %s', maConn.remoteAddr);\n return await this.components.upgrader.upgradeOutbound(maConn);\n }\n catch (err) {\n log.error('Circuit relay dial failed', err);\n disconnectOnFailure && await relayConnection.close();\n throw err;\n }\n }\n /**\n * Create a listener\n */\n createListener(options) {\n // Called on successful HOP and STOP requests\n this.handler = options.handler;\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_8__.createListener)({\n connectionManager: this.components.connectionManager,\n peerStore: this.components.peerStore\n });\n }\n /**\n * Filter check for all Multiaddrs that this transport can dial on\n *\n * @param {Multiaddr[]} multiaddrs\n * @returns {Multiaddr[]}\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n return multiaddrs.filter((ma) => {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__.Circuit.matches(ma);\n });\n }\n}\n//# sourceMappingURL=transport.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/transport.js?"); /***/ }), @@ -9054,7 +6150,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 */ \"namespaceToCid\": () => (/* binding */ namespaceToCid)\n/* harmony export */ });\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/sha2-browser.js\");\n\n\n/**\n * Convert a namespace string into a cid\n */\nasync function namespaceToCid(namespace) {\n const bytes = new TextEncoder().encode(namespace);\n const hash = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(bytes);\n return multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.CID.createV0(hash);\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/utils.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"namespaceToCid\": () => (/* binding */ namespaceToCid)\n/* harmony export */ });\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.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\n\n/**\n * Convert a namespace string into a cid\n */\nasync function namespaceToCid(namespace) {\n const bytes = new TextEncoder().encode(namespace);\n const hash = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_1__.sha256.digest(bytes);\n return multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.CID.createV0(hash);\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/circuit/utils.js?"); /***/ }), @@ -9076,7 +6172,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 */ \"validateConfig\": () => (/* binding */ validateConfig)\n/* harmony export */ });\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/constants.js\");\n/* harmony import */ var _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./identify/consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circuit/constants.js */ \"./node_modules/libp2p/dist/src/circuit/constants.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_interface_transport__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst DefaultConfig = {\n addresses: {\n listen: [],\n announce: [],\n noAnnounce: [],\n announceFilter: (multiaddrs) => multiaddrs\n },\n connectionManager: {\n maxConnections: 300,\n minConnections: 50,\n autoDial: true,\n autoDialInterval: 10000,\n maxParallelDials: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_PARALLEL_DIALS,\n maxDialsPerPeer: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_PER_PEER_DIALS,\n dialTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_2__.DIAL_TIMEOUT,\n inboundUpgradeTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_2__.INBOUND_UPGRADE_TIMEOUT,\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__.dnsaddrResolver\n },\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_5__.publicAddressesFirst\n },\n connectionGater: {},\n transportManager: {\n faultTolerance: _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_6__.FaultTolerance.FATAL_ALL\n },\n peerRouting: {\n refreshManager: {\n enabled: true,\n interval: 6e5,\n bootDelay: 10e3\n }\n },\n nat: {\n enabled: true,\n ttl: 7200,\n keepAlive: true\n },\n relay: {\n enabled: true,\n advertise: {\n bootDelay: _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__.ADVERTISE_BOOT_DELAY,\n enabled: false,\n ttl: _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__.ADVERTISE_TTL\n },\n hop: {\n enabled: false,\n active: false,\n timeout: 30000\n },\n autoRelay: {\n enabled: false,\n maxListeners: 2\n }\n },\n identify: {\n protocolPrefix: 'ipfs',\n host: {\n agentVersion: _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__.AGENT_VERSION\n },\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 },\n ping: {\n protocolPrefix: 'ipfs',\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n timeout: 10000\n },\n fetch: {\n protocolPrefix: 'libp2p',\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n timeout: 10000\n }\n};\nfunction validateConfig(opts) {\n const resultingOptions = (0,merge_options__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(DefaultConfig, opts);\n if (resultingOptions.transports == null || resultingOptions.transports.length < 1) {\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.ERR_TRANSPORTS_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_TRANSPORTS_REQUIRED);\n }\n if (resultingOptions.connectionEncryption == null || resultingOptions.connectionEncryption.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.CONN_ENCRYPTION_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.CONN_ENCRYPTION_REQUIRED);\n }\n if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.ERR_PROTECTOR_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_PROTECTOR_REQUIRED);\n }\n // Append user agent version to default AGENT_VERSION depending on the environment\n if (resultingOptions.identify.host.agentVersion === _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__.AGENT_VERSION) {\n if (wherearewe__WEBPACK_IMPORTED_MODULE_9__.isNode || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isElectronMain) {\n resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.process.version}`;\n }\n else if (wherearewe__WEBPACK_IMPORTED_MODULE_9__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isWebWorker || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isElectronRenderer || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isReactNative) {\n resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;\n }\n }\n return resultingOptions;\n}\n//# sourceMappingURL=config.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/config.js?"); +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 merge_options__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr/resolvers */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/resolvers/index.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/constants.js\");\n/* harmony import */ var _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./identify/consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circuit/constants.js */ \"./node_modules/libp2p/dist/src/circuit/constants.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_interface_transport__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var wherearewe__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! wherearewe */ \"./node_modules/wherearewe/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst DefaultConfig = {\n addresses: {\n listen: [],\n announce: [],\n noAnnounce: [],\n announceFilter: (multiaddrs) => multiaddrs\n },\n connectionManager: {\n maxConnections: 300,\n minConnections: 50,\n autoDial: true,\n autoDialInterval: 10000,\n maxParallelDials: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_PARALLEL_DIALS,\n maxDialsPerPeer: _constants_js__WEBPACK_IMPORTED_MODULE_2__.MAX_PER_PEER_DIALS,\n dialTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_2__.DIAL_TIMEOUT,\n inboundUpgradeTimeout: _constants_js__WEBPACK_IMPORTED_MODULE_2__.INBOUND_UPGRADE_TIMEOUT,\n resolvers: {\n dnsaddr: _multiformats_multiaddr_resolvers__WEBPACK_IMPORTED_MODULE_1__.dnsaddrResolver\n },\n addressSorter: _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_5__.publicAddressesFirst\n },\n connectionGater: {},\n transportManager: {\n faultTolerance: _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_6__.FaultTolerance.FATAL_ALL\n },\n peerRouting: {\n refreshManager: {\n enabled: true,\n interval: 6e5,\n bootDelay: 10e3\n }\n },\n nat: {\n enabled: true,\n ttl: 7200,\n keepAlive: true\n },\n relay: {\n enabled: true,\n advertise: {\n bootDelay: _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__.ADVERTISE_BOOT_DELAY,\n enabled: false,\n ttl: _circuit_constants_js__WEBPACK_IMPORTED_MODULE_4__.ADVERTISE_TTL\n },\n hop: {\n enabled: false,\n active: false,\n timeout: 30000\n },\n autoRelay: {\n enabled: false,\n maxListeners: 2\n }\n },\n identify: {\n protocolPrefix: 'ipfs',\n host: {\n agentVersion: _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__.AGENT_VERSION\n },\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 },\n ping: {\n protocolPrefix: 'ipfs',\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n timeout: 10000\n },\n fetch: {\n protocolPrefix: 'libp2p',\n maxInboundStreams: 1,\n maxOutboundStreams: 1,\n timeout: 10000\n }\n};\nfunction validateConfig(opts) {\n const resultingOptions = (0,merge_options__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(DefaultConfig, opts);\n if (resultingOptions.transports == null || resultingOptions.transports.length < 1) {\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.ERR_TRANSPORTS_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_TRANSPORTS_REQUIRED);\n }\n if (resultingOptions.connectionEncryption == null || resultingOptions.connectionEncryption.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.CONN_ENCRYPTION_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.CONN_ENCRYPTION_REQUIRED);\n }\n if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef\n throw err_code__WEBPACK_IMPORTED_MODULE_8__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_7__.messages.ERR_PROTECTOR_REQUIRED), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_PROTECTOR_REQUIRED);\n }\n // Append user agent version to default AGENT_VERSION depending on the environment\n if (resultingOptions.identify.host.agentVersion === _identify_consts_js__WEBPACK_IMPORTED_MODULE_3__.AGENT_VERSION) {\n if (wherearewe__WEBPACK_IMPORTED_MODULE_9__.isNode || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isElectronMain) {\n resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.process.version}`;\n }\n else if (wherearewe__WEBPACK_IMPORTED_MODULE_9__.isBrowser || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isWebWorker || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isElectronRenderer || wherearewe__WEBPACK_IMPORTED_MODULE_9__.isReactNative) {\n resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;\n }\n }\n return resultingOptions;\n}\n//# sourceMappingURL=config.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/config.js?"); /***/ }), @@ -9098,7 +6194,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 */ \"DialRequest\": () => (/* binding */ DialRequest)\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 any_signal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/index.js\");\n/* harmony import */ var p_fifo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-fifo */ \"./node_modules/p-fifo/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_5__.logger)('libp2p:dialer:dial-request');\nclass DialRequest {\n /**\n * Manages running the `dialAction` on multiple provided `addrs` in parallel\n * up to a maximum determined by the number of tokens returned\n * from `dialer.getTokens`. Once a DialRequest is created, it can be\n * started using `DialRequest.run(options)`. Once a single dial has succeeded,\n * all other dials in the request will be cancelled.\n */\n constructor(options) {\n const { addrs, dialAction, dialer } = options;\n this.addrs = addrs;\n this.dialer = dialer;\n this.dialAction = dialAction;\n }\n async run(options = {}) {\n const tokens = this.dialer.getTokens(this.addrs.length);\n // If no tokens are available, throw\n if (tokens.length < 1) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('No dial tokens available'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NO_DIAL_TOKENS);\n }\n const tokenHolder = new p_fifo__WEBPACK_IMPORTED_MODULE_2__();\n for (const token of tokens) {\n void tokenHolder.push(token).catch(err => {\n log.error(err);\n });\n }\n const dialAbortControllers = this.addrs.map(() => {\n const controller = new AbortController();\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_3__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n return controller;\n });\n if (options.signal != null) {\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_3__.setMaxListeners)?.(Infinity, options.signal);\n }\n catch { }\n }\n let completedDials = 0;\n let done = false;\n try {\n return await Promise.any(this.addrs.map(async (addr, i) => {\n const token = await tokenHolder.shift(); // get token\n // End attempt once another attempt succeeded\n if (done) {\n this.dialer.releaseToken(tokens.splice(tokens.indexOf(token), 1)[0]);\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction already succeeded'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_ALREADY_SUCCEEDED);\n }\n const controller = dialAbortControllers[i];\n if (controller == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction did not come with an AbortController'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_PARAMETERS);\n }\n let conn;\n try {\n const signal = controller.signal;\n conn = await this.dialAction(addr, { ...options, signal: (options.signal != null) ? (0,any_signal__WEBPACK_IMPORTED_MODULE_1__.anySignal)([signal, options.signal]) : signal });\n // Remove the successful AbortController so it is not aborted\n dialAbortControllers[i] = undefined;\n }\n finally {\n completedDials++;\n // If we have more or equal dials remaining than tokens, recycle the token, otherwise release it\n if (this.addrs.length - completedDials >= tokens.length) {\n void tokenHolder.push(token).catch(err => {\n log.error(err);\n });\n }\n else {\n this.dialer.releaseToken(tokens.splice(tokens.indexOf(token), 1)[0]);\n }\n }\n if (conn == null) {\n // Notify Promise.any that attempt was not successful\n // to prevent from returning undefined despite there\n // were successful dial attempts\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction led to empty object'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_TRANSPORT_DIAL_FAILED);\n }\n else {\n // This dial succeeded, don't attempt anything else\n done = true;\n }\n return conn;\n }));\n }\n finally {\n // success/failure happened, abort everything else\n dialAbortControllers.forEach(c => {\n if (c !== undefined) {\n c.abort();\n }\n });\n tokens.forEach(token => this.dialer.releaseToken(token)); // release tokens back to the dialer\n }\n }\n}\n//# sourceMappingURL=dial-request.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"DialRequest\": () => (/* binding */ DialRequest)\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 any_signal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! any-signal */ \"./node_modules/libp2p/node_modules/any-signal/index.js\");\n/* harmony import */ var p_fifo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! p-fifo */ \"./node_modules/p-fifo/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_5__.logger)('libp2p:dialer:dial-request');\nclass DialRequest {\n /**\n * Manages running the `dialAction` on multiple provided `addrs` in parallel\n * up to a maximum determined by the number of tokens returned\n * from `dialer.getTokens`. Once a DialRequest is created, it can be\n * started using `DialRequest.run(options)`. Once a single dial has succeeded,\n * all other dials in the request will be cancelled.\n */\n constructor(options) {\n const { addrs, dialAction, dialer } = options;\n this.addrs = addrs;\n this.dialer = dialer;\n this.dialAction = dialAction;\n }\n async run(options = {}) {\n const tokens = this.dialer.getTokens(this.addrs.length);\n // If no tokens are available, throw\n if (tokens.length < 1) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('No dial tokens available'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_NO_DIAL_TOKENS);\n }\n const tokenHolder = new p_fifo__WEBPACK_IMPORTED_MODULE_2__();\n for (const token of tokens) {\n void tokenHolder.push(token).catch(err => {\n log.error(err);\n });\n }\n const dialAbortControllers = this.addrs.map(() => {\n const controller = new AbortController();\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_3__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n return controller;\n });\n if (options.signal != null) {\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_3__.setMaxListeners)?.(Infinity, options.signal);\n }\n catch { }\n }\n let completedDials = 0;\n let done = false;\n try {\n return await Promise.any(this.addrs.map(async (addr, i) => {\n const token = await tokenHolder.shift(); // get token\n // End attempt once another attempt succeeded\n if (done) {\n this.dialer.releaseToken(tokens.splice(tokens.indexOf(token), 1)[0]);\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction already succeeded'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_ALREADY_SUCCEEDED);\n }\n const controller = dialAbortControllers[i];\n if (controller == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction did not come with an AbortController'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_INVALID_PARAMETERS);\n }\n let conn;\n try {\n const signal = controller.signal;\n conn = await this.dialAction(addr, { ...options, signal: (options.signal != null) ? (0,any_signal__WEBPACK_IMPORTED_MODULE_1__.anySignal)([signal, options.signal]) : signal });\n // Remove the successful AbortController so it is not aborted\n dialAbortControllers[i] = undefined;\n }\n finally {\n completedDials++;\n // If we have more or equal dials remaining than tokens, recycle the token, otherwise release it\n if (this.addrs.length - completedDials >= tokens.length) {\n void tokenHolder.push(token).catch(err => {\n log.error(err);\n });\n }\n else {\n this.dialer.releaseToken(tokens.splice(tokens.indexOf(token), 1)[0]);\n }\n }\n if (conn == null) {\n // Notify Promise.any that attempt was not successful\n // to prevent from returning undefined despite there\n // were successful dial attempts\n throw err_code__WEBPACK_IMPORTED_MODULE_0__(new Error('dialAction led to empty object'), _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_TRANSPORT_DIAL_FAILED);\n }\n else {\n // This dial succeeded, don't attempt anything else\n done = true;\n }\n return conn;\n }));\n }\n finally {\n // success/failure happened, abort everything else\n dialAbortControllers.forEach(c => {\n if (c !== undefined) {\n c.abort();\n }\n });\n tokens.forEach(token => this.dialer.releaseToken(token)); // release tokens back to the dialer\n }\n }\n}\n//# sourceMappingURL=dial-request.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js?"); /***/ }), @@ -9109,7 +6205,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 */ \"DefaultDialer\": () => (/* binding */ DefaultDialer)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! any-signal */ \"./node_modules/any-signal/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _dial_request_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dial-request.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/tracked-map */ \"./node_modules/@libp2p/tracked-map/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../constants.js */ \"./node_modules/libp2p/dist/src/constants.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:dialer');\nclass DefaultDialer {\n constructor(components, init = {}) {\n this.started = false;\n this.addressSorter = init.addressSorter ?? _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_7__.publicAddressesFirst;\n this.maxAddrsToDial = init.maxAddrsToDial ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_ADDRS_TO_DIAL;\n this.timeout = init.dialTimeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.DIAL_TIMEOUT;\n this.maxDialsPerPeer = init.maxDialsPerPeer ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PER_PEER_DIALS;\n this.tokens = [...new Array(init.maxParallelDials ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PARALLEL_DIALS)].map((_, index) => index);\n this.components = components;\n this.pendingDials = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__.trackedMap)({\n name: 'libp2p_dialler_pending_dials',\n metrics: components.metrics\n });\n this.pendingDialTargets = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__.trackedMap)({\n name: 'libp2p_dialler_pending_dial_targets',\n metrics: components.metrics\n });\n for (const [key, value] of Object.entries(init.resolvers ?? {})) {\n _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.resolvers.set(key, value);\n }\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n }\n /**\n * Clears any pending dials\n */\n async stop() {\n this.started = false;\n for (const dial of this.pendingDials.values()) {\n try {\n dial.controller.abort();\n }\n catch (err) {\n log.error(err);\n }\n }\n this.pendingDials.clear();\n for (const pendingTarget of this.pendingDialTargets.values()) {\n pendingTarget.abort();\n }\n this.pendingDialTargets.clear();\n }\n /**\n * Connects to a given `peer` by dialing all of its known addresses.\n * The dial to the first address that is successfully able to upgrade a connection\n * will be used.\n */\n async dial(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_12__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId != null) {\n if (this.components.peerId.equals(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Tried to dial self'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_DIALED_SELF);\n }\n if (multiaddr != null) {\n log('storing multiaddrs %p', peerId, multiaddr);\n await this.components.peerStore.addressBook.add(peerId, [multiaddr]);\n }\n if (await this.components.connectionGater.denyDialPeer(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The dial request is blocked by gater.allowDialPeer'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_PEER_DIAL_INTERCEPTED);\n }\n }\n log('creating dial target for %p', peerId);\n // resolving multiaddrs can involve dns lookups so allow them to be aborted\n const controller = new AbortController();\n const controllerId = randomId();\n this.pendingDialTargets.set(controllerId, controller);\n let signal = controller.signal;\n // merge with the passed signal, if any\n if (options.signal != null) {\n signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)([signal, options.signal]);\n }\n let dialTarget;\n try {\n dialTarget = await this._createDialTarget({ peerId, multiaddr }, {\n ...options,\n signal\n });\n }\n finally {\n // done resolving the multiaddrs so remove the abort controller\n this.pendingDialTargets.delete(controllerId);\n }\n if (dialTarget.addrs.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The dial request has no valid addresses'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_NO_VALID_ADDRESSES);\n }\n // try to join an in-flight dial for this peer if one is available\n const pendingDial = this.pendingDials.get(dialTarget.id) ?? this._createPendingDial(dialTarget, options);\n try {\n const connection = await pendingDial.promise;\n log('dial succeeded to %s', dialTarget.id);\n return connection;\n }\n catch (err) {\n log('dial failed to %s', dialTarget.id, err);\n // Error is a timeout\n if (pendingDial.controller.signal.aborted) {\n err.code = _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TIMEOUT;\n }\n log.error(err);\n throw err;\n }\n finally {\n pendingDial.destroy();\n }\n }\n /**\n * Creates a DialTarget. The DialTarget is used to create and track\n * the DialRequest to a given peer.\n *\n * If a multiaddr is received it should be the only address attempted.\n *\n * Multiaddrs not supported by the available transports will be filtered out.\n */\n async _createDialTarget(peerIdOrMultiaddr, options) {\n let addrs = [];\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(peerIdOrMultiaddr.multiaddr)) {\n addrs.push(peerIdOrMultiaddr.multiaddr);\n }\n // only load addresses if a peer id was passed, otherwise only dial the passed multiaddr\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(peerIdOrMultiaddr.multiaddr) && (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__.isPeerId)(peerIdOrMultiaddr.peerId)) {\n addrs.push(...await this._loadAddresses(peerIdOrMultiaddr.peerId));\n }\n addrs = (await Promise.all(addrs.map(async (ma) => await this._resolve(ma, options))))\n .flat()\n // Multiaddrs not supported by the available transports will be filtered out.\n .filter(ma => Boolean(this.components.transportManager.transportForMultiaddr(ma)));\n // deduplicate addresses\n addrs = [...new Set(addrs.map(ma => ma.toString()))].map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(ma));\n if (addrs.length > this.maxAddrsToDial) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('dial with more addresses than allowed'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TOO_MANY_ADDRESSES);\n }\n const peerId = (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__.isPeerId)(peerIdOrMultiaddr.peerId) ? peerIdOrMultiaddr.peerId : undefined;\n if (peerId != null) {\n const peerIdMultiaddr = `/p2p/${peerId.toString()}`;\n addrs = addrs.map(addr => {\n const addressPeerId = addr.getPeerId();\n if (addressPeerId == null || !peerId.equals(addressPeerId)) {\n return addr.encapsulate(peerIdMultiaddr);\n }\n return addr;\n });\n }\n return {\n id: peerId == null ? randomId() : peerId.toString(),\n addrs\n };\n }\n /**\n * Loads a list of addresses from the peer store for the passed peer id\n */\n async _loadAddresses(peer) {\n const addresses = await this.components.peerStore.addressBook.get(peer);\n return (await Promise.all(addresses.map(async (address) => {\n const deny = await this.components.connectionGater.denyDialMultiaddr(peer, address.multiaddr);\n if (deny) {\n return false;\n }\n return address;\n })))\n .filter(isTruthy)\n // Sort addresses so, for example, we try certified public address first\n .sort(this.addressSorter)\n .map(address => address.multiaddr);\n }\n /**\n * Creates a PendingDial that wraps the underlying DialRequest\n */\n _createPendingDial(dialTarget, options = {}) {\n /**\n * @param {Multiaddr} addr\n * @param {{ signal: { aborted: any; }; }} options\n */\n const dialAction = async (addr, options = {}) => {\n if (options.signal?.aborted === true) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('already aborted'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_ALREADY_ABORTED);\n }\n return await this.components.transportManager.dial(addr, options).catch(err => {\n log.error('dial to %s failed', addr, err);\n throw err;\n });\n };\n const dialRequest = new _dial_request_js__WEBPACK_IMPORTED_MODULE_6__.DialRequest({\n addrs: dialTarget.addrs,\n dialAction,\n dialer: this\n });\n // Combine the timeout signal and options.signal, if provided\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_3__.TimeoutController(this.timeout);\n const signals = [timeoutController.signal];\n (options.signal != null) && signals.push(options.signal);\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)(signals);\n // this signal will potentially be used while dialing lots of\n // peers so prevent MaxListenersExceededWarning appearing in the console\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_5__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n const pendingDial = {\n dialRequest,\n controller: timeoutController,\n promise: dialRequest.run({ ...options, signal }),\n destroy: () => {\n timeoutController.clear();\n this.pendingDials.delete(dialTarget.id);\n }\n };\n this.pendingDials.set(dialTarget.id, pendingDial);\n return pendingDial;\n }\n getTokens(num) {\n const total = Math.min(num, this.maxDialsPerPeer, this.tokens.length);\n const tokens = this.tokens.splice(0, total);\n log('%d tokens request, returning %d, %d remaining', num, total, this.tokens.length);\n return tokens;\n }\n releaseToken(token) {\n // Guard against duplicate releases\n if (this.tokens.includes(token)) {\n return;\n }\n log('token %d released', token);\n this.tokens.push(token);\n }\n /**\n * Resolve multiaddr recursively\n */\n async _resolve(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 this._resolveRecord(ma, options);\n const recursiveMultiaddrs = await Promise.all(resolvedMultiaddrs.map(async (nm) => {\n return await this._resolve(nm, options);\n }));\n const addrs = recursiveMultiaddrs.flat();\n return addrs.reduce((array, newM) => {\n if (array.find(m => m.equals(newM)) == null) {\n array.push(newM);\n }\n return array;\n }, ([]));\n }\n /**\n * Resolve a given multiaddr. If this fails, an empty array will be returned\n */\n async _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 }\n}\n/**\n * Type safe version of `list.filter(Boolean)`\n */\nfunction isTruthy(e) {\n return Boolean(e);\n}\n/**\n * Returns a random string\n */\nfunction randomId() {\n return `${(parseInt(String(Math.random() * 1e9), 10)).toString()}${Date.now()}`;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/dialer/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"DefaultDialer\": () => (/* binding */ DefaultDialer)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var any_signal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! any-signal */ \"./node_modules/libp2p/node_modules/any-signal/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _dial_request_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dial-request.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js\");\n/* harmony import */ var _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/utils/address-sort */ \"./node_modules/@libp2p/utils/dist/src/address-sort.js\");\n/* harmony import */ var _libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/tracked-map */ \"./node_modules/@libp2p/tracked-map/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../constants.js */ \"./node_modules/libp2p/dist/src/constants.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:dialer');\nclass DefaultDialer {\n constructor(components, init = {}) {\n this.started = false;\n this.addressSorter = init.addressSorter ?? _libp2p_utils_address_sort__WEBPACK_IMPORTED_MODULE_7__.publicAddressesFirst;\n this.maxAddrsToDial = init.maxAddrsToDial ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_ADDRS_TO_DIAL;\n this.timeout = init.dialTimeout ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.DIAL_TIMEOUT;\n this.maxDialsPerPeer = init.maxDialsPerPeer ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PER_PEER_DIALS;\n this.tokens = [...new Array(init.maxParallelDials ?? _constants_js__WEBPACK_IMPORTED_MODULE_10__.MAX_PARALLEL_DIALS)].map((_, index) => index);\n this.components = components;\n this.pendingDials = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__.trackedMap)({\n name: 'libp2p_dialler_pending_dials',\n metrics: components.metrics\n });\n this.pendingDialTargets = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_8__.trackedMap)({\n name: 'libp2p_dialler_pending_dial_targets',\n metrics: components.metrics\n });\n for (const [key, value] of Object.entries(init.resolvers ?? {})) {\n _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.resolvers.set(key, value);\n }\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n }\n /**\n * Clears any pending dials\n */\n async stop() {\n this.started = false;\n for (const dial of this.pendingDials.values()) {\n try {\n dial.controller.abort();\n }\n catch (err) {\n log.error(err);\n }\n }\n this.pendingDials.clear();\n for (const pendingTarget of this.pendingDialTargets.values()) {\n pendingTarget.abort();\n }\n this.pendingDialTargets.clear();\n }\n /**\n * Connects to a given `peer` by dialing all of its known addresses.\n * The dial to the first address that is successfully able to upgrade a connection\n * will be used.\n */\n async dial(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_12__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId != null) {\n if (this.components.peerId.equals(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Tried to dial self'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_DIALED_SELF);\n }\n if (multiaddr != null) {\n log('storing multiaddrs %p', peerId, multiaddr);\n await this.components.peerStore.addressBook.add(peerId, [multiaddr]);\n }\n if (await this.components.connectionGater.denyDialPeer(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The dial request is blocked by gater.allowDialPeer'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_PEER_DIAL_INTERCEPTED);\n }\n }\n log('creating dial target for %p', peerId);\n // resolving multiaddrs can involve dns lookups so allow them to be aborted\n const controller = new AbortController();\n const controllerId = randomId();\n this.pendingDialTargets.set(controllerId, controller);\n let signal = controller.signal;\n // merge with the passed signal, if any\n if (options.signal != null) {\n signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)([signal, options.signal]);\n }\n let dialTarget;\n try {\n dialTarget = await this._createDialTarget({ peerId, multiaddr }, {\n ...options,\n signal\n });\n }\n finally {\n // done resolving the multiaddrs so remove the abort controller\n this.pendingDialTargets.delete(controllerId);\n }\n if (dialTarget.addrs.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The dial request has no valid addresses'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_NO_VALID_ADDRESSES);\n }\n // try to join an in-flight dial for this peer if one is available\n const pendingDial = this.pendingDials.get(dialTarget.id) ?? this._createPendingDial(dialTarget, options);\n try {\n const connection = await pendingDial.promise;\n log('dial succeeded to %s', dialTarget.id);\n return connection;\n }\n catch (err) {\n log('dial failed to %s', dialTarget.id, err);\n // Error is a timeout\n if (pendingDial.controller.signal.aborted) {\n err.code = _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TIMEOUT;\n }\n log.error(err);\n throw err;\n }\n finally {\n pendingDial.destroy();\n }\n }\n /**\n * Creates a DialTarget. The DialTarget is used to create and track\n * the DialRequest to a given peer.\n *\n * If a multiaddr is received it should be the only address attempted.\n *\n * Multiaddrs not supported by the available transports will be filtered out.\n */\n async _createDialTarget(peerIdOrMultiaddr, options) {\n let addrs = [];\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(peerIdOrMultiaddr.multiaddr)) {\n addrs.push(peerIdOrMultiaddr.multiaddr);\n }\n // only load addresses if a peer id was passed, otherwise only dial the passed multiaddr\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(peerIdOrMultiaddr.multiaddr) && (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__.isPeerId)(peerIdOrMultiaddr.peerId)) {\n addrs.push(...await this._loadAddresses(peerIdOrMultiaddr.peerId));\n }\n addrs = (await Promise.all(addrs.map(async (ma) => await this._resolve(ma, options))))\n .flat()\n // Multiaddrs not supported by the available transports will be filtered out.\n .filter(ma => Boolean(this.components.transportManager.transportForMultiaddr(ma)));\n // deduplicate addresses\n addrs = [...new Set(addrs.map(ma => ma.toString()))].map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(ma));\n if (addrs.length > this.maxAddrsToDial) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('dial with more addresses than allowed'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_TOO_MANY_ADDRESSES);\n }\n const peerId = (0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_11__.isPeerId)(peerIdOrMultiaddr.peerId) ? peerIdOrMultiaddr.peerId : undefined;\n if (peerId != null) {\n const peerIdMultiaddr = `/p2p/${peerId.toString()}`;\n addrs = addrs.map(addr => {\n const addressPeerId = addr.getPeerId();\n if (addressPeerId == null || !peerId.equals(addressPeerId)) {\n return addr.encapsulate(peerIdMultiaddr);\n }\n return addr;\n });\n }\n return {\n id: peerId == null ? randomId() : peerId.toString(),\n addrs\n };\n }\n /**\n * Loads a list of addresses from the peer store for the passed peer id\n */\n async _loadAddresses(peer) {\n const addresses = await this.components.peerStore.addressBook.get(peer);\n return (await Promise.all(addresses.map(async (address) => {\n const deny = await this.components.connectionGater.denyDialMultiaddr(peer, address.multiaddr);\n if (deny) {\n return false;\n }\n return address;\n })))\n .filter(isTruthy)\n // Sort addresses so, for example, we try certified public address first\n .sort(this.addressSorter)\n .map(address => address.multiaddr);\n }\n /**\n * Creates a PendingDial that wraps the underlying DialRequest\n */\n _createPendingDial(dialTarget, options = {}) {\n /**\n * @param {Multiaddr} addr\n * @param {{ signal: { aborted: any; }; }} options\n */\n const dialAction = async (addr, options = {}) => {\n if (options.signal?.aborted === true) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('already aborted'), _errors_js__WEBPACK_IMPORTED_MODULE_9__.codes.ERR_ALREADY_ABORTED);\n }\n return await this.components.transportManager.dial(addr, options).catch(err => {\n log.error('dial to %s failed', addr, err);\n throw err;\n });\n };\n const dialRequest = new _dial_request_js__WEBPACK_IMPORTED_MODULE_6__.DialRequest({\n addrs: dialTarget.addrs,\n dialAction,\n dialer: this\n });\n // Combine the timeout signal and options.signal, if provided\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_3__.TimeoutController(this.timeout);\n const signals = [timeoutController.signal];\n (options.signal != null) && signals.push(options.signal);\n const signal = (0,any_signal__WEBPACK_IMPORTED_MODULE_4__.anySignal)(signals);\n // this signal will potentially be used while dialing lots of\n // peers so prevent MaxListenersExceededWarning appearing in the console\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_5__.setMaxListeners)?.(Infinity, signal);\n }\n catch { }\n const pendingDial = {\n dialRequest,\n controller: timeoutController,\n promise: dialRequest.run({ ...options, signal }),\n destroy: () => {\n timeoutController.clear();\n this.pendingDials.delete(dialTarget.id);\n }\n };\n this.pendingDials.set(dialTarget.id, pendingDial);\n return pendingDial;\n }\n getTokens(num) {\n const total = Math.min(num, this.maxDialsPerPeer, this.tokens.length);\n const tokens = this.tokens.splice(0, total);\n log('%d tokens request, returning %d, %d remaining', num, total, this.tokens.length);\n return tokens;\n }\n releaseToken(token) {\n // Guard against duplicate releases\n if (this.tokens.includes(token)) {\n return;\n }\n log('token %d released', token);\n this.tokens.push(token);\n }\n /**\n * Resolve multiaddr recursively\n */\n async _resolve(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 this._resolveRecord(ma, options);\n const recursiveMultiaddrs = await Promise.all(resolvedMultiaddrs.map(async (nm) => {\n return await this._resolve(nm, options);\n }));\n const addrs = recursiveMultiaddrs.flat();\n return addrs.reduce((array, newM) => {\n if (array.find(m => m.equals(newM)) == null) {\n array.push(newM);\n }\n return array;\n }, ([]));\n }\n /**\n * Resolve a given multiaddr. If this fails, an empty array will be returned\n */\n async _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 }\n}\n/**\n * Type safe version of `list.filter(Boolean)`\n */\nfunction isTruthy(e) {\n return Boolean(e);\n}\n/**\n * Returns a random string\n */\nfunction randomId() {\n return `${(parseInt(String(Math.random() * 1e9), 10)).toString()}${Date.now()}`;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/dialer/index.js?"); /***/ }), @@ -9120,7 +6216,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 */ \"DefaultConnectionManager\": () => (/* binding */ DefaultConnectionManager)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./latency-monitor.js */ \"./node_modules/libp2p/dist/src/connection-manager/latency-monitor.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-connection/status */ \"./node_modules/libp2p/node_modules/@libp2p/interface-connection/dist/src/status.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-peer-store/tags */ \"./node_modules/@libp2p/interface-peer-store/dist/src/tags.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager');\nconst defaultOptions = {\n maxConnections: Infinity,\n minConnections: 0,\n maxEventLoopDelay: Infinity,\n pollInterval: 2000,\n autoDialInterval: 10000,\n inboundConnectionThreshold: 5,\n maxIncomingPendingConnections: 10\n};\nconst STARTUP_RECONNECT_TIMEOUT = 60000;\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.EventEmitter {\n constructor(components, init) {\n super();\n this.opts = merge_options__WEBPACK_IMPORTED_MODULE_2__[\"default\"].call({ ignoreUndefined: true }, defaultOptions, init);\n if (this.opts.maxConnections < this.opts.minConnections) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Connection Manager maxConnections must be greater than minConnections'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n log('options: %o', this.opts);\n this.components = components;\n /**\n * Map of connections per peer\n */\n this.connections = new Map();\n this.started = false;\n if (init.maxEventLoopDelay != null && init.maxEventLoopDelay > 0 && init.maxEventLoopDelay !== Infinity) {\n this.latencyMonitor = new _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__.LatencyMonitor({\n latencyCheckIntervalMs: init.pollInterval,\n dataEmitIntervalMs: init.pollInterval\n });\n }\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this);\n }\n catch { }\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.startupReconnectTimeout = init.startupReconnectTimeout ?? STARTUP_RECONNECT_TIMEOUT;\n this.dialTimeout = init.dialTimeout ?? 30000;\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.inboundConnectionRateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__.RateLimiterMemory({\n points: this.opts.inboundConnectionThreshold,\n duration: 1\n });\n this.incomingPendingConnections = 0;\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.components.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.components.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.components.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 // latency monitor\n this.latencyMonitor?.start();\n this._onLatencyMeasure = this._onLatencyMeasure.bind(this);\n this.latencyMonitor?.addEventListener('data', this._onLatencyMeasure);\n this.started = true;\n log('started');\n }\n async afterStart() {\n this.components.upgrader.addEventListener('connection', this.onConnect);\n this.components.upgrader.addEventListener('connectionEnd', this.onDisconnect);\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = [];\n for (const peer of await this.components.peerStore.all()) {\n const tags = await this.components.peerStore.getTags(peer.id);\n const hasKeepAlive = tags.filter(tag => tag.name === _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__.KEEP_ALIVE).length > 0;\n if (hasKeepAlive) {\n keepAlivePeers.push(peer.id);\n }\n }\n this.connectOnStartupController?.clear();\n this.connectOnStartupController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.startupReconnectTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this.connectOnStartupController.signal);\n }\n catch { }\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer, {\n signal: this.connectOnStartupController?.signal\n })\n .catch(err => {\n log.error(err);\n });\n }));\n })\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n this.connectOnStartupController?.clear();\n });\n }\n async beforeStop() {\n // if we are still dialing KEEP_ALIVE peers, abort those dials\n this.connectOnStartupController?.abort();\n this.components.upgrader.removeEventListener('connection', this.onConnect);\n this.components.upgrader.removeEventListener('connectionEnd', this.onDisconnect);\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.latencyMonitor?.removeEventListener('data', this._onLatencyMeasure);\n this.latencyMonitor?.stop();\n this.started = false;\n await this._close();\n log('stopped');\n }\n /**\n * Cleans up the connections\n */\n async _close() {\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 }\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 peerIdStr = peerId.toString();\n const storedConns = this.connections.get(peerIdStr);\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n this.connections.set(peerIdStr, [connection]);\n }\n if (peerId.publicKey != null) {\n await this.components.peerStore.keyBook.set(peerId, peerId.publicKey);\n }\n const numConnections = this.getConnections().length;\n const toPrune = numConnections - this.opts.maxConnections;\n await this._checkMaxLimit('maxConnections', numConnections, toPrune);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:connect', { detail: connection }));\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.toString();\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:disconnect', { detail: connection }));\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId.toString()) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_14__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId == null && multiaddr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new TypeError('Can only open connections to PeerIds or Multiaddrs'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n if (peerId != null) {\n log('dial to', 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 let timeoutController;\n if (options?.signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.dialTimeout);\n options.signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\n try {\n const connection = await this.components.dialer.dial(peerIdOrMultiaddr, options);\n let peerConnections = this.connections.get(connection.remotePeer.toString());\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer.toString(), 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 finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n }\n }\n async closeConnections(peerId) {\n const connections = this.connections.get(peerId.toString()) ?? [];\n await Promise.all(connections.map(async (connection) => {\n return await connection.close();\n }));\n }\n /**\n * Get all open connections with a peer\n */\n getAll(peerId) {\n if (!(0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__.isPeerId)(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('peerId must be an instance of peer-id'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n const id = peerId.toString();\n const connections = this.connections.get(id);\n // Return all open connections\n if (connections != null) {\n return connections.filter(connection => connection.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__.OPEN);\n }\n return [];\n }\n /**\n * If the event loop is slow, maybe close a connection\n */\n _onLatencyMeasure(evt) {\n const { detail: summary } = evt;\n this._checkMaxLimit('maxEventLoopDelay', summary.avgMs, 1)\n .catch(err => {\n log.error(err);\n });\n }\n /**\n * If the `value` of `name` has exceeded its limit, maybe close a connection\n */\n async _checkMaxLimit(name, value, toPrune = 1) {\n const limit = this.opts[name];\n if (limit == null) {\n log.trace('limit %s was not set so it cannot be applied', name);\n return;\n }\n log.trace('checking limit of %s. current value: %d of %d', name, value, limit);\n if (value > limit) {\n log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune);\n await this._pruneConnections(toPrune);\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 _pruneConnections(toPrune) {\n const connections = this.getConnections();\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__.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 const tags = await this.components.peerStore.getTags(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, tags.reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\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 toClose.push(connection);\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 // TODO: should not need to invoke this manually\n this.onDisconnect(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('connectionEnd', {\n detail: connection\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 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.opts.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.opts.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}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/index.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./latency-monitor.js */ \"./node_modules/libp2p/dist/src/connection-manager/latency-monitor.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-connection/status */ \"./node_modules/libp2p/node_modules/@libp2p/interface-connection/dist/src/status.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-peer-store/tags */ \"./node_modules/@libp2p/interface-peer-store/dist/src/tags.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager');\nconst defaultOptions = {\n maxConnections: Infinity,\n minConnections: 0,\n maxEventLoopDelay: Infinity,\n pollInterval: 2000,\n autoDialInterval: 10000,\n inboundConnectionThreshold: 5,\n maxIncomingPendingConnections: 10\n};\nconst STARTUP_RECONNECT_TIMEOUT = 60000;\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.EventEmitter {\n constructor(components, init) {\n super();\n this.opts = merge_options__WEBPACK_IMPORTED_MODULE_2__[\"default\"].call({ ignoreUndefined: true }, defaultOptions, init);\n if (this.opts.maxConnections < this.opts.minConnections) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Connection Manager maxConnections must be greater than minConnections'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n log('options: %o', this.opts);\n this.components = components;\n /**\n * Map of connections per peer\n */\n this.connections = new Map();\n this.started = false;\n if (init.maxEventLoopDelay != null && init.maxEventLoopDelay > 0 && init.maxEventLoopDelay !== Infinity) {\n this.latencyMonitor = new _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__.LatencyMonitor({\n latencyCheckIntervalMs: init.pollInterval,\n dataEmitIntervalMs: init.pollInterval\n });\n }\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this);\n }\n catch { }\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.startupReconnectTimeout = init.startupReconnectTimeout ?? STARTUP_RECONNECT_TIMEOUT;\n this.dialTimeout = init.dialTimeout ?? 30000;\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.inboundConnectionRateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__.RateLimiterMemory({\n points: this.opts.inboundConnectionThreshold,\n duration: 1\n });\n this.incomingPendingConnections = 0;\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.components.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.components.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.components.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 // latency monitor\n this.latencyMonitor?.start();\n this._onLatencyMeasure = this._onLatencyMeasure.bind(this);\n this.latencyMonitor?.addEventListener('data', this._onLatencyMeasure);\n this.started = true;\n log('started');\n }\n async afterStart() {\n this.components.upgrader.addEventListener('connection', this.onConnect);\n this.components.upgrader.addEventListener('connectionEnd', this.onDisconnect);\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = [];\n for (const peer of await this.components.peerStore.all()) {\n const tags = await this.components.peerStore.getTags(peer.id);\n const hasKeepAlive = tags.filter(tag => tag.name === _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__.KEEP_ALIVE).length > 0;\n if (hasKeepAlive) {\n keepAlivePeers.push(peer.id);\n }\n }\n this.connectOnStartupController?.clear();\n this.connectOnStartupController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.startupReconnectTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this.connectOnStartupController.signal);\n }\n catch { }\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer, {\n signal: this.connectOnStartupController?.signal\n })\n .catch(err => {\n log.error(err);\n });\n }));\n })\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n this.connectOnStartupController?.clear();\n });\n }\n async beforeStop() {\n // if we are still dialing KEEP_ALIVE peers, abort those dials\n this.connectOnStartupController?.abort();\n this.components.upgrader.removeEventListener('connection', this.onConnect);\n this.components.upgrader.removeEventListener('connectionEnd', this.onDisconnect);\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.latencyMonitor?.removeEventListener('data', this._onLatencyMeasure);\n this.latencyMonitor?.stop();\n this.started = false;\n await this._close();\n log('stopped');\n }\n /**\n * Cleans up the connections\n */\n async _close() {\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 }\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 peerIdStr = peerId.toString();\n const storedConns = this.connections.get(peerIdStr);\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n this.connections.set(peerIdStr, [connection]);\n }\n if (peerId.publicKey != null) {\n await this.components.peerStore.keyBook.set(peerId, peerId.publicKey);\n }\n const numConnections = this.getConnections().length;\n const toPrune = numConnections - this.opts.maxConnections;\n await this._checkMaxLimit('maxConnections', numConnections, toPrune);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:connect', { detail: connection }));\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.toString();\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:disconnect', { detail: connection }));\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId.toString()) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_14__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId == null && multiaddr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new TypeError('Can only open connections to PeerIds or Multiaddrs'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n if (peerId != null) {\n log('dial to', 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 let timeoutController;\n if (options?.signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.dialTimeout);\n options.signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\n try {\n const connection = await this.components.dialer.dial(peerIdOrMultiaddr, options);\n let peerConnections = this.connections.get(connection.remotePeer.toString());\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer.toString(), 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 finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n }\n }\n async closeConnections(peerId) {\n const connections = this.connections.get(peerId.toString()) ?? [];\n await Promise.all(connections.map(async (connection) => {\n return await connection.close();\n }));\n }\n /**\n * Get all open connections with a peer\n */\n getAll(peerId) {\n if (!(0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__.isPeerId)(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('peerId must be an instance of peer-id'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n const id = peerId.toString();\n const connections = this.connections.get(id);\n // Return all open connections\n if (connections != null) {\n return connections.filter(connection => connection.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__.OPEN);\n }\n return [];\n }\n /**\n * If the event loop is slow, maybe close a connection\n */\n _onLatencyMeasure(evt) {\n const { detail: summary } = evt;\n this._checkMaxLimit('maxEventLoopDelay', summary.avgMs, 1)\n .catch(err => {\n log.error(err);\n });\n }\n /**\n * If the `value` of `name` has exceeded its limit, maybe close a connection\n */\n async _checkMaxLimit(name, value, toPrune = 1) {\n const limit = this.opts[name];\n if (limit == null) {\n log.trace('limit %s was not set so it cannot be applied', name);\n return;\n }\n log.trace('checking limit of %s. current value: %d of %d', name, value, limit);\n if (value > limit) {\n log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune);\n await this._pruneConnections(toPrune);\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 _pruneConnections(toPrune) {\n const connections = this.getConnections();\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__.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 const tags = await this.components.peerStore.getTags(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, tags.reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\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 toClose.push(connection);\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 // TODO: should not need to invoke this manually\n this.onDisconnect(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('connectionEnd', {\n detail: connection\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 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.opts.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.opts.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}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/connection-manager/index.js?"); /***/ }), @@ -9252,7 +6348,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 */ \"FetchService\": () => (/* binding */ FetchService)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.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 _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/proto.js */ \"./node_modules/libp2p/dist/src/fetch/pb/proto.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/fetch/constants.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:fetch');\n/**\n * A simple libp2p protocol for requesting a value corresponding to a key from a peer.\n * Developers can register one or more lookup function for retrieving the value corresponding to\n * a given key. Each lookup function must act on a distinct part of the overall key space, defined\n * by a fixed prefix that all keys that should be routed to that lookup function will start with.\n */\nclass FetchService {\n constructor(components, init) {\n this.started = false;\n this.components = components;\n this.protocol = `/${init.protocolPrefix ?? 'libp2p'}/${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_VERSION}`;\n this.lookupFunctions = new Map(); // Maps key prefix to value lookup function\n this.handleMessage = this.handleMessage.bind(this);\n this.init = init;\n }\n async start() {\n await this.components.registrar.handle(this.protocol, (data) => {\n void this.handleMessage(data)\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n data.stream.close();\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.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 * Sends a request to fetch the value associated with the given key from the given peer\n */\n async fetch(peer, key, options = {}) {\n log('dialing %s to %p', this.protocol, peer);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n log('using default timeout of %d ms', this.init.timeout);\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_6__.abortableDuplex)(stream, signal);\n log('fetch %s', key);\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)([_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchRequest.encode({ identifier: key })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode(), source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode(), async function (source) {\n const buf = await (0,it_first__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(source);\n if (buf == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data received'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n const response = _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.decode(buf);\n switch (response.status) {\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.OK): {\n log('received status for %s ok', key);\n return response.data;\n }\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.NOT_FOUND): {\n log('received status for %s not found', key);\n return null;\n }\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.ERROR): {\n log('received status for %s error', key);\n const errmsg = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_12__.toString)(response.data);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Error in fetch protocol response: ' + errmsg), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n default: {\n log('received status for %s unknown', key);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Unknown response status'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n }\n });\n return result ?? null;\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Invoked when a fetch request is received. Reads the request message off the given stream and\n * responds based on looking up the key in the request via the lookup callback that corresponds\n * to the key's prefix.\n */\n async handleMessage(data) {\n const { stream } = data;\n const self = this;\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)(stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode(), async function* (source) {\n const buf = await (0,it_first__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(source);\n if (buf == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data received'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n // for await (const buf of source) {\n const request = _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchRequest.decode(buf);\n let response;\n const lookup = self._getLookupFunction(request.identifier);\n if (lookup != null) {\n log('look up data with identifier %s', request.identifier);\n const data = await lookup(request.identifier);\n if (data != null) {\n log('sending status for %s ok', request.identifier);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.OK, data };\n }\n else {\n log('sending status for %s not found', request.identifier);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.NOT_FOUND, data: new Uint8Array(0) };\n }\n }\n else {\n log('sending status for %s error', request.identifier);\n const errmsg = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_11__.fromString)(`No lookup function registered for key: ${request.identifier}`);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.ERROR, data: errmsg };\n }\n yield _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.encode(response);\n }, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode(), stream);\n }\n /**\n * Given a key, finds the appropriate function for looking up its corresponding value, based on\n * the key's prefix.\n */\n _getLookupFunction(key) {\n for (const prefix of this.lookupFunctions.keys()) {\n if (key.startsWith(prefix)) {\n return this.lookupFunctions.get(prefix);\n }\n }\n }\n /**\n * Registers a new lookup callback that can map keys to values, for a given set of keys that\n * share the same prefix\n *\n * @example\n *\n * ```js\n * // ...\n * libp2p.fetchService.registerLookupFunction('/prefix', (key) => { ... })\n * ```\n */\n registerLookupFunction(prefix, lookup) {\n if (this.lookupFunctions.has(prefix)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(\"Fetch protocol handler for key prefix '\" + prefix + \"' already registered\"), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n this.lookupFunctions.set(prefix, lookup);\n }\n /**\n * Registers a new lookup callback that can map keys to values, for a given set of keys that\n * share the same prefix.\n *\n * @example\n *\n * ```js\n * // ...\n * libp2p.fetchService.unregisterLookupFunction('/prefix')\n * ```\n */\n unregisterLookupFunction(prefix, lookup) {\n if (lookup != null) {\n const existingLookup = this.lookupFunctions.get(prefix);\n if (existingLookup !== lookup) {\n return;\n }\n }\n this.lookupFunctions.delete(prefix);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/fetch/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"FetchService\": () => (/* binding */ FetchService)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/proto.js */ \"./node_modules/libp2p/dist/src/fetch/pb/proto.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/fetch/constants.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-first */ \"./node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:fetch');\n/**\n * A simple libp2p protocol for requesting a value corresponding to a key from a peer.\n * Developers can register one or more lookup function for retrieving the value corresponding to\n * a given key. Each lookup function must act on a distinct part of the overall key space, defined\n * by a fixed prefix that all keys that should be routed to that lookup function will start with.\n */\nclass FetchService {\n constructor(components, init) {\n this.started = false;\n this.components = components;\n this.protocol = `/${init.protocolPrefix ?? 'libp2p'}/${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_5__.PROTOCOL_VERSION}`;\n this.lookupFunctions = new Map(); // Maps key prefix to value lookup function\n this.handleMessage = this.handleMessage.bind(this);\n this.init = init;\n }\n async start() {\n await this.components.registrar.handle(this.protocol, (data) => {\n void this.handleMessage(data)\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n data.stream.close();\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.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 * Sends a request to fetch the value associated with the given key from the given peer\n */\n async fetch(peer, key, options = {}) {\n log('dialing %s to %p', this.protocol, peer);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n log('using default timeout of %d ms', this.init.timeout);\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_6__.abortableDuplex)(stream, signal);\n log('fetch %s', key);\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)([_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchRequest.encode({ identifier: key })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode(), source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode(), async function (source) {\n const buf = await (0,it_first__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(source);\n if (buf == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data received'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n const response = _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.decode(buf);\n switch (response.status) {\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.OK): {\n log('received status for %s ok', key);\n return response.data;\n }\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.NOT_FOUND): {\n log('received status for %s not found', key);\n return null;\n }\n case (_pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.ERROR): {\n log('received status for %s error', key);\n const errmsg = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_12__.toString)(response.data);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Error in fetch protocol response: ' + errmsg), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n default: {\n log('received status for %s unknown', key);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Unknown response status'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n }\n });\n return result ?? null;\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Invoked when a fetch request is received. Reads the request message off the given stream and\n * responds based on looking up the key in the request via the lookup callback that corresponds\n * to the key's prefix.\n */\n async handleMessage(data) {\n const { stream } = data;\n const self = this;\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_7__.pipe)(stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode(), async function* (source) {\n const buf = await (0,it_first__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(source);\n if (buf == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data received'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_MESSAGE);\n }\n // for await (const buf of source) {\n const request = _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchRequest.decode(buf);\n let response;\n const lookup = self._getLookupFunction(request.identifier);\n if (lookup != null) {\n log('look up data with identifier %s', request.identifier);\n const data = await lookup(request.identifier);\n if (data != null) {\n log('sending status for %s ok', request.identifier);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.OK, data };\n }\n else {\n log('sending status for %s not found', request.identifier);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.NOT_FOUND, data: new Uint8Array(0) };\n }\n }\n else {\n log('sending status for %s error', request.identifier);\n const errmsg = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_11__.fromString)(`No lookup function registered for key: ${request.identifier}`);\n response = { status: _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.StatusCode.ERROR, data: errmsg };\n }\n yield _pb_proto_js__WEBPACK_IMPORTED_MODULE_4__.FetchResponse.encode(response);\n }, it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode(), stream);\n }\n /**\n * Given a key, finds the appropriate function for looking up its corresponding value, based on\n * the key's prefix.\n */\n _getLookupFunction(key) {\n for (const prefix of this.lookupFunctions.keys()) {\n if (key.startsWith(prefix)) {\n return this.lookupFunctions.get(prefix);\n }\n }\n }\n /**\n * Registers a new lookup callback that can map keys to values, for a given set of keys that\n * share the same prefix\n *\n * @example\n *\n * ```js\n * // ...\n * libp2p.fetchService.registerLookupFunction('/prefix', (key) => { ... })\n * ```\n */\n registerLookupFunction(prefix, lookup) {\n if (this.lookupFunctions.has(prefix)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(\"Fetch protocol handler for key prefix '\" + prefix + \"' already registered\"), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n this.lookupFunctions.set(prefix, lookup);\n }\n /**\n * Registers a new lookup callback that can map keys to values, for a given set of keys that\n * share the same prefix.\n *\n * @example\n *\n * ```js\n * // ...\n * libp2p.fetchService.unregisterLookupFunction('/prefix')\n * ```\n */\n unregisterLookupFunction(prefix, lookup) {\n if (lookup != null) {\n const existingLookup = this.lookupFunctions.get(prefix);\n if (existingLookup !== lookup) {\n return;\n }\n }\n this.lookupFunctions.delete(prefix);\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/fetch/index.js?"); /***/ }), @@ -9274,7 +6370,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 */ \"getPeerAddress\": () => (/* binding */ getPeerAddress)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n\n\n\n\n\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__.isPeerId)(peer)) {\n return {\n peerId: peer\n };\n }\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.isMultiaddr)(peer)) {\n const peerId = peer.getPeerId();\n return {\n multiaddr: peer,\n peerId: peerId == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(peerId)\n };\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error(`${peer} is not a PeerId or a Multiaddr`), // eslint-disable-line @typescript-eslint/restrict-template-expressions\n _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/get-peer.js?"); +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_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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n\n\n\n\n\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__.isPeerId)(peer)) {\n return {\n peerId: peer\n };\n }\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.isMultiaddr)(peer)) {\n const peerId = peer.getPeerId();\n return {\n multiaddr: peer,\n peerId: peerId == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(peerId)\n };\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error(`${peer} is not a PeerId or a Multiaddr`), // eslint-disable-line @typescript-eslint/restrict-template-expressions\n _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/get-peer.js?"); /***/ }), @@ -9296,7 +6392,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 */ \"IdentifyService\": () => (/* binding */ IdentifyService),\n/* harmony export */ \"Message\": () => (/* binding */ Message),\n/* harmony export */ \"multicodecs\": () => (/* binding */ multicodecs)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.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 it_first__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/libp2p/dist/src/identify/pb/message.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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;\nclass IdentifyService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.init = init;\n this.identifyProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.IDENTIFY_PROTOCOL_VERSION}`,\n ...init.host\n };\n // When a new connection happens, trigger identify\n this.components.connectionManager.addEventListener('peer:connect', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(log.error);\n });\n // When self multiaddrs change, trigger identify-push\n this.components.peerStore.addEventListener('change:multiaddrs', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n // When self protocols change, trigger identify-push\n this.components.peerStore.addEventListener('change:protocols', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.agentVersion));\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.protocolVersion));\n await this.components.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.maxOutboundStreams\n });\n await this.components.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxPushIncomingStreams,\n maxOutboundStreams: this.init.maxPushOutgoingStreams\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.identifyProtocolStr);\n await this.components.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async push(connections) {\n const signedPeerRecord = await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId);\n const listenAddrs = this.components.addressManager.getAddresses().map((ma) => ma.bytes);\n const protocols = await this.components.peerStore.protoBook.get(this.components.peerId);\n const pushes = connections.map(async (connection) => {\n let stream;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyPushProtocolStr], {\n signal: timeoutController.signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n await source.sink((0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([_pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.encode({\n listenAddrs,\n signedPeerRecord,\n protocols\n })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode()));\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 timeoutController.clear();\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async pushToPeerStore() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n for (const conn of this.components.connectionManager.getConnections()) {\n const peerId = conn.remotePeer;\n const peer = await this.components.peerStore.get(peerId);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n continue;\n }\n connections.push(conn);\n }\n await this.push(connections);\n }\n async _identify(connection, options = {}) {\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_13__.abortableDuplex)(stream, signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data could be retrieved'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_CONNECTION_ENDED);\n }\n try {\n return _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n catch (err) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_MESSAGE);\n }\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Requests the `Identify` message from peer associated with the given `connection`.\n * If the identified peer does not match the `PeerId` associated with the connection,\n * an error will be thrown.\n */\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;\n if (publicKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('public key was missing from identify message'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PUBLIC_KEY);\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (this.components.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer is our own peer id?'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);\n if (signedPeerRecord != null) {\n log('received signed peer record from %p', id);\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (!envelope.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n return;\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('no signed peer record received from %p', id);\n }\n log('falling back to legacy addresses from %p', id);\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n // TODO: Add and score our observed addr\n log('received observed address of %s', cleanObservedAddr?.toString());\n // this.components.addressManager.addObservedAddr(observedAddr)\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 timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const publicKey = this.components.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.components.peerStore.get(this.components.peerId);\n const multiaddrs = this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.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_8__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n signedPeerRecord = envelope.marshal().subarray();\n }\n const message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.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_13__.abortableDuplex)(stream, timeoutController.signal);\n const msgWithLenPrefix = (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([message], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode());\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 timeoutController.clear();\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n let message;\n try {\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data != null) {\n message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n }\n catch (err) {\n return log.error('received invalid message', err);\n }\n finally {\n stream.close();\n timeoutController.clear();\n }\n if (message == null) {\n return log.error('received invalid message');\n }\n const id = connection.remotePeer;\n if (this.components.peerId.equals(id)) {\n log('received push from ourselves?');\n return;\n }\n log('received push from %p', id);\n if (message.signedPeerRecord != null) {\n log('received signedPeerRecord in push');\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(message.signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n log('consumed signedPeerRecord sent in push');\n await this.components.peerStore.protoBook.set(id, message.protocols);\n return;\n }\n else {\n log('failed to consume signedPeerRecord sent in push');\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('did not receive signedPeerRecord in push');\n }\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, message.listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n // Update the protocols\n try {\n await this.components.peerStore.protoBook.set(id, message.protocols);\n }\n catch (err) {\n log.error('received invalid protocols', err);\n }\n log('handled push from %p', id);\n }\n /**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\n static getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr);\n }\n catch {\n }\n }\n }\n}\n/**\n * The protocols the IdentifyService supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH\n};\nconst Message = { Identify: _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify };\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/identify/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"IdentifyService\": () => (/* binding */ IdentifyService),\n/* harmony export */ \"Message\": () => (/* binding */ Message),\n/* harmony export */ \"multicodecs\": () => (/* binding */ multicodecs)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/index.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 it_first__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-first */ \"./node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/libp2p/dist/src/identify/pb/message.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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;\nclass IdentifyService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.init = init;\n this.identifyProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.IDENTIFY_PROTOCOL_VERSION}`,\n ...init.host\n };\n // When a new connection happens, trigger identify\n this.components.connectionManager.addEventListener('peer:connect', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(log.error);\n });\n // When self multiaddrs change, trigger identify-push\n this.components.peerStore.addEventListener('change:multiaddrs', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n // When self protocols change, trigger identify-push\n this.components.peerStore.addEventListener('change:protocols', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.agentVersion));\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.protocolVersion));\n await this.components.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.maxOutboundStreams\n });\n await this.components.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxPushIncomingStreams,\n maxOutboundStreams: this.init.maxPushOutgoingStreams\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.identifyProtocolStr);\n await this.components.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async push(connections) {\n const signedPeerRecord = await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId);\n const listenAddrs = this.components.addressManager.getAddresses().map((ma) => ma.bytes);\n const protocols = await this.components.peerStore.protoBook.get(this.components.peerId);\n const pushes = connections.map(async (connection) => {\n let stream;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyPushProtocolStr], {\n signal: timeoutController.signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n await source.sink((0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([_pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.encode({\n listenAddrs,\n signedPeerRecord,\n protocols\n })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode()));\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 timeoutController.clear();\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async pushToPeerStore() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n for (const conn of this.components.connectionManager.getConnections()) {\n const peerId = conn.remotePeer;\n const peer = await this.components.peerStore.get(peerId);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n continue;\n }\n connections.push(conn);\n }\n await this.push(connections);\n }\n async _identify(connection, options = {}) {\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_13__.abortableDuplex)(stream, signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data could be retrieved'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_CONNECTION_ENDED);\n }\n try {\n return _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n catch (err) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_MESSAGE);\n }\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Requests the `Identify` message from peer associated with the given `connection`.\n * If the identified peer does not match the `PeerId` associated with the connection,\n * an error will be thrown.\n */\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;\n if (publicKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('public key was missing from identify message'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PUBLIC_KEY);\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (this.components.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer is our own peer id?'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);\n if (signedPeerRecord != null) {\n log('received signed peer record from %p', id);\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (!envelope.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n return;\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('no signed peer record received from %p', id);\n }\n log('falling back to legacy addresses from %p', id);\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n // TODO: Add and score our observed addr\n log('received observed address of %s', cleanObservedAddr?.toString());\n // this.components.addressManager.addObservedAddr(observedAddr)\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 timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const publicKey = this.components.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.components.peerStore.get(this.components.peerId);\n const multiaddrs = this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.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_8__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n signedPeerRecord = envelope.marshal().subarray();\n }\n const message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.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_13__.abortableDuplex)(stream, timeoutController.signal);\n const msgWithLenPrefix = (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([message], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode());\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 timeoutController.clear();\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n let message;\n try {\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data != null) {\n message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n }\n catch (err) {\n return log.error('received invalid message', err);\n }\n finally {\n stream.close();\n timeoutController.clear();\n }\n if (message == null) {\n return log.error('received invalid message');\n }\n const id = connection.remotePeer;\n if (this.components.peerId.equals(id)) {\n log('received push from ourselves?');\n return;\n }\n log('received push from %p', id);\n if (message.signedPeerRecord != null) {\n log('received signedPeerRecord in push');\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(message.signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n log('consumed signedPeerRecord sent in push');\n await this.components.peerStore.protoBook.set(id, message.protocols);\n return;\n }\n else {\n log('failed to consume signedPeerRecord sent in push');\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('did not receive signedPeerRecord in push');\n }\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, message.listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n // Update the protocols\n try {\n await this.components.peerStore.protoBook.set(id, message.protocols);\n }\n catch (err) {\n log.error('received invalid protocols', err);\n }\n log('handled push from %p', id);\n }\n /**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\n static getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr);\n }\n catch {\n }\n }\n }\n}\n/**\n * The protocols the IdentifyService supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH\n};\nconst Message = { Identify: _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify };\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/identify/index.js?"); /***/ }), @@ -9340,7 +6436,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 */ \"KeyChain\": () => (/* binding */ KeyChain)\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 sanitize_filename__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sanitize-filename */ \"./node_modules/sanitize-filename/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _cms_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cms.js */ \"./node_modules/libp2p/dist/src/keychain/cms.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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 _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_crypto__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* eslint max-nested-callbacks: [\"error\", 5] */\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_1__(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_3__.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_3__.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 KeyChain {\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_2__[\"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_10__.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 this.started = false;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n const dsname = DsInfoName('self');\n if (!(await this.components.datastore.has(dsname))) {\n await this.importPeer('self', this.components.peerId);\n }\n this.started = true;\n }\n stop() {\n this.started = false;\n }\n /**\n * Gets an object that can encrypt/decrypt protected data\n * using the Cryptographic Message Syntax (CMS).\n *\n * CMS describes an encapsulation syntax for data protection. It\n * is used to digitally sign, digest, authenticate, or encrypt\n * arbitrary message content\n */\n get cms() {\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n return new _cms_js__WEBPACK_IMPORTED_MODULE_4__.CMS(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_7__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_10__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key name'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (typeof type !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key type'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Key name already exists'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid RSA key size'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_9__.generateKeyPair)(type, size);\n const kid = await keypair.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await keypair.export(dek);\n keyInfo = {\n name: 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_7__.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 return keys.find((k) => k.id === id);\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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res));\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old key name '${oldName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_OLD_KEY_NAME_INVALID);\n }\n if (!validateKeyName(newName) || newName === 'self') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new key name '${newName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${newName}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (password == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Password is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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_9__.importKey)(pem, password);\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (pem == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PEM encoded key is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n let privateKey;\n try {\n privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.importKey)(pem, password);\n }\n catch (err) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Cannot read the key, most likely the password is wrong'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (peer == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n if (peer.privateKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId.privKey is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await privateKey.export(dek);\n const keyInfo = {\n name: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old pass type '${typeof oldPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_OLD_PASS_TYPE);\n }\n if (typeof newPass !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new pass type '${typeof newPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_NEW_PASS_TYPE);\n }\n if (newPass.length < 20) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid pass length ${newPass.length}`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PASS_LENGTH);\n }\n log('recreating keychain');\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_10__.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_7__.toString)(res);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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/dist/src/keychain/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"KeyChain\": () => (/* binding */ KeyChain)\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 sanitize_filename__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sanitize-filename */ \"./node_modules/sanitize-filename/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/libp2p/node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _cms_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cms.js */ \"./node_modules/libp2p/dist/src/keychain/cms.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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 _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_crypto__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* eslint max-nested-callbacks: [\"error\", 5] */\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_1__(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_3__.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_3__.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 KeyChain {\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_2__[\"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_10__.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 this.started = false;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n const dsname = DsInfoName('self');\n if (!(await this.components.datastore.has(dsname))) {\n await this.importPeer('self', this.components.peerId);\n }\n this.started = true;\n }\n stop() {\n this.started = false;\n }\n /**\n * Gets an object that can encrypt/decrypt protected data\n * using the Cryptographic Message Syntax (CMS).\n *\n * CMS describes an encapsulation syntax for data protection. It\n * is used to digitally sign, digest, authenticate, or encrypt\n * arbitrary message content\n */\n get cms() {\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n return new _cms_js__WEBPACK_IMPORTED_MODULE_4__.CMS(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_7__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_10__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key name'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (typeof type !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key type'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Key name already exists'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid RSA key size'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_9__.generateKeyPair)(type, size);\n const kid = await keypair.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await keypair.export(dek);\n keyInfo = {\n name: 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_7__.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 return keys.find((k) => k.id === id);\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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res));\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old key name '${oldName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_OLD_KEY_NAME_INVALID);\n }\n if (!validateKeyName(newName) || newName === 'self') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new key name '${newName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${newName}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (password == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Password is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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_9__.importKey)(pem, password);\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (pem == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PEM encoded key is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n let privateKey;\n try {\n privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.importKey)(pem, password);\n }\n catch (err) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Cannot read the key, most likely the password is wrong'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (peer == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n if (peer.privateKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId.privKey is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await privateKey.export(dek);\n const keyInfo = {\n name: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old pass type '${typeof oldPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_OLD_PASS_TYPE);\n }\n if (typeof newPass !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new pass type '${typeof newPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_NEW_PASS_TYPE);\n }\n if (newPass.length < 20) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid pass length ${newPass.length}`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PASS_LENGTH);\n }\n log('recreating keychain');\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_10__.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_7__.toString)(res);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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/dist/src/keychain/index.js?"); /***/ }), @@ -9362,7 +6458,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 */ \"Libp2pNode\": () => (/* binding */ Libp2pNode),\n/* harmony export */ \"createLibp2pNode\": () => (/* binding */ createLibp2pNode)\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_interfaces_events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/startable */ \"./node_modules/@libp2p/interfaces/dist/src/startable.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/datastore-core/src/memory.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./content-routing/index.js */ \"./node_modules/libp2p/dist/src/content-routing/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./connection-manager/auto-dialler.js */ \"./node_modules/libp2p/dist/src/connection-manager/auto-dialler.js\");\n/* harmony import */ var _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/transport.js */ \"./node_modules/libp2p/dist/src/circuit/transport.js\");\n/* harmony import */ var _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./circuit/index.js */ \"./node_modules/libp2p/dist/src/circuit/index.js\");\n/* harmony import */ var _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./keychain/index.js */ \"./node_modules/libp2p/dist/src/keychain/index.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/libp2p/dist/src/upgrader.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _identify_index_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./identify/index.js */ \"./node_modules/libp2p/dist/src/identify/index.js\");\n/* harmony import */ var _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./fetch/index.js */ \"./node_modules/libp2p/dist/src/fetch/index.js\");\n/* harmony import */ var _ping_index_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ping/index.js */ \"./node_modules/libp2p/dist/src/ping/index.js\");\n/* harmony import */ var _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./nat-manager.js */ \"./node_modules/libp2p/dist/src/nat-manager.js\");\n/* harmony import */ var _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./peer-record-updater.js */ \"./node_modules/libp2p/dist/src/peer-record-updater.js\");\n/* harmony import */ var _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./dht/dht-peer-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-peer-routing.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./dht/dht-content-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-content-routing.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./components.js */ \"./node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./config.js */ \"./node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./dht/dummy-dht.js */ \"./node_modules/libp2p/dist/src/dht/dummy-dht.js\");\n/* harmony import */ var _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./pubsub/dummy-pubsub.js */ \"./node_modules/libp2p/dist/src/pubsub/dummy-pubsub.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./connection-manager/dialer/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p');\nclass Libp2pNode extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter {\n constructor(init) {\n super();\n this.started = false;\n this.peerId = init.peerId;\n const components = this.components = new _components_js__WEBPACK_IMPORTED_MODULE_25__.DefaultComponents({\n peerId: init.peerId,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__.MemoryDatastore(),\n connectionGater: {\n denyDialPeer: async () => await Promise.resolve(false),\n denyDialMultiaddr: async () => await Promise.resolve(false),\n denyInboundConnection: async () => await Promise.resolve(false),\n denyOutboundConnection: async () => await Promise.resolve(false),\n denyInboundEncryptedConnection: async () => await Promise.resolve(false),\n denyOutboundEncryptedConnection: async () => await Promise.resolve(false),\n denyInboundUpgradedConnection: async () => await Promise.resolve(false),\n denyOutboundUpgradedConnection: async () => await Promise.resolve(false),\n filterMultiaddrForPeer: async () => await Promise.resolve(true),\n ...init.connectionGater\n }\n });\n components.peerStore = new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n });\n this.services = [\n components\n ];\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.components.metrics = this.configureComponent(init.metrics(this.components));\n }\n this.peerStore = this.components.peerStore;\n this.peerStore.addEventListener('peer', evt => {\n const { detail: peerData } = evt;\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peerData }));\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.components.connectionProtector = init.connectionProtector(components);\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_15__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map(fn => this.configureComponent(fn(this.components))),\n muxers: (init.streamMuxers ?? []).map(fn => this.configureComponent(fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Create the dialer\n this.components.dialer = new _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__.DefaultDialer(this.components, init.connectionManager);\n // Create the Connection Manager\n this.connectionManager = this.components.connectionManager = new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__.DefaultConnectionManager(this.components, init.connectionManager);\n // forward connection manager events\n this.components.connectionManager.addEventListener('peer:disconnect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:disconnect', { detail: event.detail }));\n });\n this.components.connectionManager.addEventListener('peer:connect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:connect', { detail: event.detail }));\n });\n // Create the Registrar\n this.registrar = this.components.registrar = new _registrar_js__WEBPACK_IMPORTED_MODULE_16__.DefaultRegistrar(this.components);\n // Setup the transport manager\n this.components.transportManager = new _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__.DefaultTransportManager(this.components, init.transportManager);\n // Addresses {listen, announce, noAnnounce}\n this.components.addressManager = new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__.DefaultAddressManager(this.components, init.addresses);\n // update our peer record when addresses change\n this.configureComponent(new _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__.PeerRecordUpdater(this.components));\n this.configureComponent(new _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__.AutoDialler(this.components, {\n enabled: init.connectionManager.autoDial,\n minConnections: init.connectionManager.minConnections,\n autoDialInterval: init.connectionManager.autoDialInterval\n }));\n // Create keychain\n const keychainOpts = _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions();\n this.keychain = this.configureComponent(new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain(this.components, {\n ...keychainOpts,\n ...init.keychain\n }));\n // Create the Nat Manager\n this.services.push(new _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__.NatManager(this.components, init.nat));\n init.transports.forEach((fn) => {\n this.components.transportManager.add(this.configureComponent(fn(this.components)));\n });\n // Add the identify service\n this.identifyService = new _identify_index_js__WEBPACK_IMPORTED_MODULE_17__.IdentifyService(this.components, {\n ...init.identify\n });\n this.configureComponent(this.identifyService);\n // dht provided components (peerRouting, contentRouting, dht)\n if (init.dht != null) {\n this.dht = this.components.dht = init.dht(this.components);\n }\n else {\n this.dht = new _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__.DummyDHT();\n }\n // Create pubsub if provided\n if (init.pubsub != null) {\n this.pubsub = this.components.pubsub = init.pubsub(this.components);\n }\n else {\n this.pubsub = new _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__.DummyPubSub();\n }\n // Attach remaining APIs\n // peer and content routing will automatically get modules from _modules and _dht\n const peerRouters = (init.peerRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n peerRouters.push(this.configureComponent(new _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__.DHTPeerRouting(this.dht)));\n // use dht for peer discovery\n this.dht.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n this.peerRouting = this.components.peerRouting = this.configureComponent(new _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPeerRouting(this.components, {\n ...init.peerRouting,\n routers: peerRouters\n }));\n const contentRouters = (init.contentRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n contentRouters.push(this.configureComponent(new _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__.DHTContentRouting(this.dht)));\n }\n this.contentRouting = this.components.contentRouting = this.configureComponent(new _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n if (init.relay.enabled) {\n this.components.transportManager.add(this.configureComponent(new _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__.Circuit(this.components, init.relay)));\n this.configureComponent(new _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__.Relay(this.components, {\n addressSorter: init.connectionManager.addressSorter,\n ...init.relay\n }));\n }\n this.fetchService = this.configureComponent(new _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__.FetchService(this.components, {\n ...init.fetch\n }));\n this.pingService = this.configureComponent(new _ping_index_js__WEBPACK_IMPORTED_MODULE_19__.PingService(this.components, {\n ...init.ping\n }));\n // Discovery modules\n for (const fn of init.peerDiscovery ?? []) {\n const service = this.configureComponent(fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n }\n configureComponent(component) {\n if ((0,_libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__.isStartable)(component)) {\n this.services.push(component);\n }\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 try {\n await Promise.all(this.services.map(async (service) => {\n if (service.beforeStart != null) {\n await service.beforeStart();\n }\n }));\n // start any startables\n await Promise.all(this.services.map(service => service.start()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStart != null) {\n await service.afterStart();\n }\n }));\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 Promise.all(this.services.map(async (service) => {\n if (service.beforeStop != null) {\n await service.beforeStop();\n }\n }));\n await Promise.all(this.services.map(service => service.stop()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStop != null) {\n await service.afterStop();\n }\n }));\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 getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__.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 await this.components.connectionManager.openConnection(peer, options);\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return await 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_3__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.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.pubKey != null) {\n return peerInfo.pubKey;\n }\n if (this.dht == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('Public key was not in the peer store and the DHT is not enabled'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search the dht\n for await (const event of this.dht.get(peerKey, options)) {\n if (event.name === 'VALUE') {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__.unmarshalPublicKey)(event.value);\n await this.peerStore.keyBook.set(peer, event.value);\n return key.bytes;\n }\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error(`Node not responding with its public key: ${peer.toString()}`), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_RECORD);\n }\n async fetch(peer, key, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.fetchService.fetch(peer, key, options);\n }\n async ping(peer, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.pingService.ping(peer, options);\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 await this.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.registrar.unregister(id);\n }\n /**\n * Called whenever peer discovery services emit `peer` events.\n * Known peers may be emitted.\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_7__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n if (peer.multiaddrs.length > 0) {\n void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => log.error(err));\n }\n if (peer.protocols.length > 0) {\n void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => log.error(err));\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peer }));\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 // @ts-expect-error missing the peer id property\n const keyChain = new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain({\n datastore\n }, {\n ..._keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions(),\n ...(options.keychain ?? {})\n });\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_27__.createEd25519PeerId)();\n }\n return new Libp2pNode((0,_config_js__WEBPACK_IMPORTED_MODULE_26__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/libp2p.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/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 _libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/startable */ \"./node_modules/@libp2p/interfaces/dist/src/startable.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/datastore-core/src/memory.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./content-routing/index.js */ \"./node_modules/libp2p/dist/src/content-routing/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./connection-manager/auto-dialler.js */ \"./node_modules/libp2p/dist/src/connection-manager/auto-dialler.js\");\n/* harmony import */ var _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/transport.js */ \"./node_modules/libp2p/dist/src/circuit/transport.js\");\n/* harmony import */ var _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./circuit/index.js */ \"./node_modules/libp2p/dist/src/circuit/index.js\");\n/* harmony import */ var _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./keychain/index.js */ \"./node_modules/libp2p/dist/src/keychain/index.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/libp2p/dist/src/upgrader.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _identify_index_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./identify/index.js */ \"./node_modules/libp2p/dist/src/identify/index.js\");\n/* harmony import */ var _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./fetch/index.js */ \"./node_modules/libp2p/dist/src/fetch/index.js\");\n/* harmony import */ var _ping_index_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ping/index.js */ \"./node_modules/libp2p/dist/src/ping/index.js\");\n/* harmony import */ var _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./nat-manager.js */ \"./node_modules/libp2p/dist/src/nat-manager.js\");\n/* harmony import */ var _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./peer-record-updater.js */ \"./node_modules/libp2p/dist/src/peer-record-updater.js\");\n/* harmony import */ var _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./dht/dht-peer-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-peer-routing.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./dht/dht-content-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-content-routing.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./components.js */ \"./node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./config.js */ \"./node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./dht/dummy-dht.js */ \"./node_modules/libp2p/dist/src/dht/dummy-dht.js\");\n/* harmony import */ var _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./pubsub/dummy-pubsub.js */ \"./node_modules/libp2p/dist/src/pubsub/dummy-pubsub.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./connection-manager/dialer/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p');\nclass Libp2pNode extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter {\n constructor(init) {\n super();\n this.started = false;\n this.peerId = init.peerId;\n const components = this.components = new _components_js__WEBPACK_IMPORTED_MODULE_25__.DefaultComponents({\n peerId: init.peerId,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__.MemoryDatastore(),\n connectionGater: {\n denyDialPeer: async () => await Promise.resolve(false),\n denyDialMultiaddr: async () => await Promise.resolve(false),\n denyInboundConnection: async () => await Promise.resolve(false),\n denyOutboundConnection: async () => await Promise.resolve(false),\n denyInboundEncryptedConnection: async () => await Promise.resolve(false),\n denyOutboundEncryptedConnection: async () => await Promise.resolve(false),\n denyInboundUpgradedConnection: async () => await Promise.resolve(false),\n denyOutboundUpgradedConnection: async () => await Promise.resolve(false),\n filterMultiaddrForPeer: async () => await Promise.resolve(true),\n ...init.connectionGater\n }\n });\n components.peerStore = new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n });\n this.services = [\n components\n ];\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.components.metrics = this.configureComponent(init.metrics(this.components));\n }\n this.peerStore = this.components.peerStore;\n this.peerStore.addEventListener('peer', evt => {\n const { detail: peerData } = evt;\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peerData }));\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.components.connectionProtector = init.connectionProtector(components);\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_15__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map(fn => this.configureComponent(fn(this.components))),\n muxers: (init.streamMuxers ?? []).map(fn => this.configureComponent(fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Create the dialer\n this.components.dialer = new _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__.DefaultDialer(this.components, init.connectionManager);\n // Create the Connection Manager\n this.connectionManager = this.components.connectionManager = new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__.DefaultConnectionManager(this.components, init.connectionManager);\n // forward connection manager events\n this.components.connectionManager.addEventListener('peer:disconnect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:disconnect', { detail: event.detail }));\n });\n this.components.connectionManager.addEventListener('peer:connect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:connect', { detail: event.detail }));\n });\n // Create the Registrar\n this.registrar = this.components.registrar = new _registrar_js__WEBPACK_IMPORTED_MODULE_16__.DefaultRegistrar(this.components);\n // Setup the transport manager\n this.components.transportManager = new _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__.DefaultTransportManager(this.components, init.transportManager);\n // Addresses {listen, announce, noAnnounce}\n this.components.addressManager = new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__.DefaultAddressManager(this.components, init.addresses);\n // update our peer record when addresses change\n this.configureComponent(new _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__.PeerRecordUpdater(this.components));\n this.configureComponent(new _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__.AutoDialler(this.components, {\n enabled: init.connectionManager.autoDial,\n minConnections: init.connectionManager.minConnections,\n autoDialInterval: init.connectionManager.autoDialInterval\n }));\n // Create keychain\n const keychainOpts = _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions();\n this.keychain = this.configureComponent(new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain(this.components, {\n ...keychainOpts,\n ...init.keychain\n }));\n // Create the Nat Manager\n this.services.push(new _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__.NatManager(this.components, init.nat));\n init.transports.forEach((fn) => {\n this.components.transportManager.add(this.configureComponent(fn(this.components)));\n });\n // Add the identify service\n this.identifyService = new _identify_index_js__WEBPACK_IMPORTED_MODULE_17__.IdentifyService(this.components, {\n ...init.identify\n });\n this.configureComponent(this.identifyService);\n // dht provided components (peerRouting, contentRouting, dht)\n if (init.dht != null) {\n this.dht = this.components.dht = init.dht(this.components);\n }\n else {\n this.dht = new _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__.DummyDHT();\n }\n // Create pubsub if provided\n if (init.pubsub != null) {\n this.pubsub = this.components.pubsub = init.pubsub(this.components);\n }\n else {\n this.pubsub = new _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__.DummyPubSub();\n }\n // Attach remaining APIs\n // peer and content routing will automatically get modules from _modules and _dht\n const peerRouters = (init.peerRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n peerRouters.push(this.configureComponent(new _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__.DHTPeerRouting(this.dht)));\n // use dht for peer discovery\n this.dht.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n this.peerRouting = this.components.peerRouting = this.configureComponent(new _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPeerRouting(this.components, {\n ...init.peerRouting,\n routers: peerRouters\n }));\n const contentRouters = (init.contentRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n contentRouters.push(this.configureComponent(new _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__.DHTContentRouting(this.dht)));\n }\n this.contentRouting = this.components.contentRouting = this.configureComponent(new _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n if (init.relay.enabled) {\n this.components.transportManager.add(this.configureComponent(new _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__.Circuit(this.components, init.relay)));\n this.configureComponent(new _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__.Relay(this.components, {\n addressSorter: init.connectionManager.addressSorter,\n ...init.relay\n }));\n }\n this.fetchService = this.configureComponent(new _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__.FetchService(this.components, {\n ...init.fetch\n }));\n this.pingService = this.configureComponent(new _ping_index_js__WEBPACK_IMPORTED_MODULE_19__.PingService(this.components, {\n ...init.ping\n }));\n // Discovery modules\n for (const fn of init.peerDiscovery ?? []) {\n const service = this.configureComponent(fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n }\n configureComponent(component) {\n if ((0,_libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__.isStartable)(component)) {\n this.services.push(component);\n }\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 try {\n await Promise.all(this.services.map(async (service) => {\n if (service.beforeStart != null) {\n await service.beforeStart();\n }\n }));\n // start any startables\n await Promise.all(this.services.map(service => service.start()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStart != null) {\n await service.afterStart();\n }\n }));\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 Promise.all(this.services.map(async (service) => {\n if (service.beforeStop != null) {\n await service.beforeStop();\n }\n }));\n await Promise.all(this.services.map(service => service.stop()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStop != null) {\n await service.afterStop();\n }\n }));\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 getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__.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 await this.components.connectionManager.openConnection(peer, options);\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return await 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_3__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.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.pubKey != null) {\n return peerInfo.pubKey;\n }\n if (this.dht == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('Public key was not in the peer store and the DHT is not enabled'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search the dht\n for await (const event of this.dht.get(peerKey, options)) {\n if (event.name === 'VALUE') {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__.unmarshalPublicKey)(event.value);\n await this.peerStore.keyBook.set(peer, event.value);\n return key.bytes;\n }\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error(`Node not responding with its public key: ${peer.toString()}`), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_RECORD);\n }\n async fetch(peer, key, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.fetchService.fetch(peer, key, options);\n }\n async ping(peer, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.pingService.ping(peer, options);\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 await this.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.registrar.unregister(id);\n }\n /**\n * Called whenever peer discovery services emit `peer` events.\n * Known peers may be emitted.\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_7__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n if (peer.multiaddrs.length > 0) {\n void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => log.error(err));\n }\n if (peer.protocols.length > 0) {\n void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => log.error(err));\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peer }));\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 // @ts-expect-error missing the peer id property\n const keyChain = new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain({\n datastore\n }, {\n ..._keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions(),\n ...(options.keychain ?? {})\n });\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_27__.createEd25519PeerId)();\n }\n return new Libp2pNode((0,_config_js__WEBPACK_IMPORTED_MODULE_26__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/libp2p.js?"); /***/ }), @@ -9384,7 +6480,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 */ \"PeerRecordUpdater\": () => (/* binding */ PeerRecordUpdater)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:peer-record-updater');\nclass PeerRecordUpdater {\n constructor(components) {\n this.components = components;\n this.started = false;\n this.update = this.update.bind(this);\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n this.components.transportManager.addEventListener('listener:listening', this.update);\n this.components.transportManager.addEventListener('listener:close', this.update);\n this.components.addressManager.addEventListener('change:addresses', this.update);\n }\n async stop() {\n this.started = false;\n this.components.transportManager.removeEventListener('listener:listening', this.update);\n this.components.transportManager.removeEventListener('listener:close', this.update);\n this.components.addressManager.removeEventListener('change:addresses', this.update);\n }\n /**\n * Create (or update if existing) self peer record and store it in the AddressBook.\n */\n update() {\n Promise.resolve()\n .then(async () => {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs: this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.protocols)('p2p').code))\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n })\n .catch(err => {\n log.error('Could not update self peer record: %o', err);\n });\n }\n}\n//# sourceMappingURL=peer-record-updater.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/peer-record-updater.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerRecordUpdater\": () => (/* binding */ PeerRecordUpdater)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:peer-record-updater');\nclass PeerRecordUpdater {\n constructor(components) {\n this.components = components;\n this.started = false;\n this.update = this.update.bind(this);\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n this.components.transportManager.addEventListener('listener:listening', this.update);\n this.components.transportManager.addEventListener('listener:close', this.update);\n this.components.addressManager.addEventListener('change:addresses', this.update);\n }\n async stop() {\n this.started = false;\n this.components.transportManager.removeEventListener('listener:listening', this.update);\n this.components.transportManager.removeEventListener('listener:close', this.update);\n this.components.addressManager.removeEventListener('change:addresses', this.update);\n }\n /**\n * Create (or update if existing) self peer record and store it in the AddressBook.\n */\n update() {\n Promise.resolve()\n .then(async () => {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs: this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.protocols)('p2p').code))\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n })\n .catch(err => {\n log.error('Could not update self peer record: %o', err);\n });\n }\n}\n//# sourceMappingURL=peer-record-updater.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/peer-record-updater.js?"); /***/ }), @@ -9395,7 +6491,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 */ \"DefaultPeerRouting\": () => (/* binding */ DefaultPeerRouting)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./content-routing/utils.js */ \"./node_modules/libp2p/dist/src/content-routing/utils.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/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 it_first__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_drain__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-drain */ \"./node_modules/it-drain/dist/src/index.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! it-filter */ \"./node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! set-delayed-interval */ \"./node_modules/set-delayed-interval/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-routing');\nclass DefaultPeerRouting {\n constructor(components, init) {\n this.components = components;\n this.routers = init.routers ?? [];\n this.refreshManagerInit = init.refreshManager ?? {};\n this.started = false;\n this._findClosestPeersTask = this._findClosestPeersTask.bind(this);\n }\n isStarted() {\n return this.started;\n }\n /**\n * Start peer routing service.\n */\n async start() {\n if (this.started || this.routers.length === 0 || this.timeoutId != null || this.refreshManagerInit.enabled === false) {\n return;\n }\n this.timeoutId = (0,set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__.setDelayedInterval)(this._findClosestPeersTask, this.refreshManagerInit.interval, this.refreshManagerInit.bootDelay);\n this.started = true;\n }\n /**\n * Recurrent task to find closest peers and add their addresses to the Address Book.\n */\n async _findClosestPeersTask() {\n if (this.abortController != null) {\n // we are already running the query\n return;\n }\n try {\n this.abortController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_4__.TimeoutController(this.refreshManagerInit.timeout ?? 10e3);\n // this controller may be used while dialing lots of peers so prevent MaxListenersExceededWarning\n // appearing in the console\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_11__.setMaxListeners)?.(Infinity, this.abortController.signal);\n }\n catch { }\n // nb getClosestPeers adds the addresses to the address book\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(this.getClosestPeers(this.components.peerId.toBytes(), { signal: this.abortController.signal }));\n }\n catch (err) {\n log.error(err);\n }\n finally {\n this.abortController?.clear();\n this.abortController = undefined;\n }\n }\n /**\n * Stop peer routing service.\n */\n async stop() {\n (0,set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__.clearDelayedInterval)(this.timeoutId);\n // abort query if it is in-flight\n this.abortController?.abort();\n this.started = false;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No peer routers available'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n if (id.toString() === this.components.peerId.toString()) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Should not try to find self'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_FIND_SELF);\n }\n const output = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_5__[\"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_9__[\"default\"])(source, Boolean), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.storeAddresses)(source, this.components.peerStore), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(source));\n if (output != null) {\n return output;\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_2__.messages.NOT_FOUND), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No peer routers available'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n yield* (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(...this.routers.map(router => router.getClosestPeers(key, options))), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.storeAddresses)(source, this.components.peerStore), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.uniquePeers)(source), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.requirePeers)(source));\n }\n}\n//# sourceMappingURL=peer-routing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/peer-routing.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./content-routing/utils.js */ \"./node_modules/libp2p/dist/src/content-routing/utils.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var it_merge__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-merge */ \"./node_modules/it-merge/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 it_first__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-first */ \"./node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var it_drain__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! it-drain */ \"./node_modules/it-drain/dist/src/index.js\");\n/* harmony import */ var it_filter__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! it-filter */ \"./node_modules/it-filter/dist/src/index.js\");\n/* harmony import */ var set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! set-delayed-interval */ \"./node_modules/set-delayed-interval/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-routing');\nclass DefaultPeerRouting {\n constructor(components, init) {\n this.components = components;\n this.routers = init.routers ?? [];\n this.refreshManagerInit = init.refreshManager ?? {};\n this.started = false;\n this._findClosestPeersTask = this._findClosestPeersTask.bind(this);\n }\n isStarted() {\n return this.started;\n }\n /**\n * Start peer routing service.\n */\n async start() {\n if (this.started || this.routers.length === 0 || this.timeoutId != null || this.refreshManagerInit.enabled === false) {\n return;\n }\n this.timeoutId = (0,set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__.setDelayedInterval)(this._findClosestPeersTask, this.refreshManagerInit.interval, this.refreshManagerInit.bootDelay);\n this.started = true;\n }\n /**\n * Recurrent task to find closest peers and add their addresses to the Address Book.\n */\n async _findClosestPeersTask() {\n if (this.abortController != null) {\n // we are already running the query\n return;\n }\n try {\n this.abortController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_4__.TimeoutController(this.refreshManagerInit.timeout ?? 10e3);\n // this controller may be used while dialing lots of peers so prevent MaxListenersExceededWarning\n // appearing in the console\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_11__.setMaxListeners)?.(Infinity, this.abortController.signal);\n }\n catch { }\n // nb getClosestPeers adds the addresses to the address book\n await (0,it_drain__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(this.getClosestPeers(this.components.peerId.toBytes(), { signal: this.abortController.signal }));\n }\n catch (err) {\n log.error(err);\n }\n finally {\n this.abortController?.clear();\n this.abortController = undefined;\n }\n }\n /**\n * Stop peer routing service.\n */\n async stop() {\n (0,set_delayed_interval__WEBPACK_IMPORTED_MODULE_10__.clearDelayedInterval)(this.timeoutId);\n // abort query if it is in-flight\n this.abortController?.abort();\n this.started = false;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No peer routers available'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n if (id.toString() === this.components.peerId.toString()) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Should not try to find self'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_FIND_SELF);\n }\n const output = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_5__[\"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_9__[\"default\"])(source, Boolean), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.storeAddresses)(source, this.components.peerStore), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(source));\n if (output != null) {\n return output;\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(_errors_js__WEBPACK_IMPORTED_MODULE_2__.messages.NOT_FOUND), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No peer routers available'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n yield* (0,it_pipe__WEBPACK_IMPORTED_MODULE_6__.pipe)((0,it_merge__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(...this.routers.map(router => router.getClosestPeers(key, options))), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.storeAddresses)(source, this.components.peerStore), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.uniquePeers)(source), (source) => (0,_content_routing_utils_js__WEBPACK_IMPORTED_MODULE_3__.requirePeers)(source));\n }\n}\n//# sourceMappingURL=peer-routing.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/peer-routing.js?"); /***/ }), @@ -9417,7 +6513,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 */ \"PingService\": () => (/* binding */ PingService)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.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 it_pipe__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/ping/constants.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:ping');\nclass PingService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.protocol = `/${init.protocolPrefix}/${_constants_js__WEBPACK_IMPORTED_MODULE_7__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_7__.PROTOCOL_VERSION}`;\n this.init = init;\n }\n async start() {\n await this.components.registrar.handle(this.protocol, this.handleMessage, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.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_4__.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_3__.randomBytes)(_constants_js__WEBPACK_IMPORTED_MODULE_7__.PING_LENGTH);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_8__.abortableDuplex)(stream, signal);\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([data], source, async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const end = Date.now();\n if (result == null || !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__.equals)(data, result.subarray())) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Received wrong ping ack'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_WRONG_PING_ACK);\n }\n return end - start;\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/ping/index.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.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 it_pipe__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var it_first__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-first */ \"./node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/libp2p/dist/src/ping/constants.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:ping');\nclass PingService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.protocol = `/${init.protocolPrefix}/${_constants_js__WEBPACK_IMPORTED_MODULE_7__.PROTOCOL_NAME}/${_constants_js__WEBPACK_IMPORTED_MODULE_7__.PROTOCOL_VERSION}`;\n this.init = init;\n }\n async start() {\n await this.components.registrar.handle(this.protocol, this.handleMessage, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.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_4__.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_3__.randomBytes)(_constants_js__WEBPACK_IMPORTED_MODULE_7__.PING_LENGTH);\n const connection = await this.components.connectionManager.openConnection(peer, options);\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_9__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_8__.abortableDuplex)(stream, signal);\n const result = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([data], source, async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const end = Date.now();\n if (result == null || !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_6__.equals)(data, result.subarray())) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Received wrong ping ack'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_WRONG_PING_ACK);\n }\n return end - start;\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/dist/src/ping/index.js?"); /***/ }), @@ -9450,7 +6546,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 */ \"DefaultTransportManager\": () => (/* binding */ DefaultTransportManager)\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 p_settle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-settle */ \"./node_modules/p-settle/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/tracked-map */ \"./node_modules/@libp2p/tracked-map/dist/src/index.js\");\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:transports');\nclass DefaultTransportManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init = {}) {\n super();\n this.components = components;\n this.started = false;\n this.transports = new Map();\n this.listeners = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_6__.trackedMap)({\n name: 'libp2p_transport_manager_listeners',\n metrics: this.components.metrics\n });\n this.faultTolerance = init.faultTolerance ?? _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__.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 err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('Transport must have a valid tag'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_KEY);\n }\n if (this.transports.has(tag)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('There is already a transport with this tag'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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 async start() {\n // Listen on the provided transports for the provided addresses\n const addrs = this.components.addressManager.getListenAddrs();\n await this.listen(addrs);\n this.started = true;\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 err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(`No transport available for address ${String(ma)}`), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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_2__.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 * 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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('listener:listening', {\n detail: listener\n }));\n });\n listener.addEventListener('close', () => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('listener: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 (0,p_settle__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(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.isFulfilled);\n if ((isListening == null) && this.faultTolerance !== _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__.FaultTolerance.NO_FATAL) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(`Transport (${key}) could not listen on any available address`), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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_4__.FaultTolerance.FATAL_ALL) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(message), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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/libp2p/dist/src/transport-manager.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var p_settle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! p-settle */ \"./node_modules/p-settle/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/tracked-map */ \"./node_modules/@libp2p/tracked-map/dist/src/index.js\");\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:transports');\nclass DefaultTransportManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init = {}) {\n super();\n this.components = components;\n this.started = false;\n this.transports = new Map();\n this.listeners = (0,_libp2p_tracked_map__WEBPACK_IMPORTED_MODULE_6__.trackedMap)({\n name: 'libp2p_transport_manager_listeners',\n metrics: this.components.metrics\n });\n this.faultTolerance = init.faultTolerance ?? _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__.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 err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('Transport must have a valid tag'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_KEY);\n }\n if (this.transports.has(tag)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error('There is already a transport with this tag'), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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 async start() {\n // Listen on the provided transports for the provided addresses\n const addrs = this.components.addressManager.getListenAddrs();\n await this.listen(addrs);\n this.started = true;\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 err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(`No transport available for address ${String(ma)}`), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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_2__.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 * 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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('listener:listening', {\n detail: listener\n }));\n });\n listener.addEventListener('close', () => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('listener: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 (0,p_settle__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(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.isFulfilled);\n if ((isListening == null) && this.faultTolerance !== _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_4__.FaultTolerance.NO_FATAL) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(`Transport (${key}) could not listen on any available address`), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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_4__.FaultTolerance.FATAL_ALL) {\n throw err_code__WEBPACK_IMPORTED_MODULE_3__(new Error(message), _errors_js__WEBPACK_IMPORTED_MODULE_2__.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/libp2p/dist/src/transport-manager.js?"); /***/ }), @@ -9461,7 +6557,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 */ \"DefaultUpgrader\": () => (/* binding */ DefaultUpgrader)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/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/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxOutboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.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 extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init) {\n super();\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;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection denied'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(this.inboundUpgradeTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const abortableStream = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_9__.abortableDuplex)(maConn, timeoutController.signal);\n maConn.source = abortableStream.source;\n maConn.sink = abortableStream.sink;\n if (await this.components.connectionGater.denyInboundConnection(maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyInboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('inbound connection that skipped encryption must have a peer id'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 if (await this.components.connectionGater.denyInboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 timeoutController.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_6__.peerIdFromString)(idStr);\n if (await this.components.connectionGater.denyOutboundConnection(remotePeerId, maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by connectionGater.denyOutboundConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 if (await this.components.connectionGater.denyOutboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n if (remotePeerId == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Encryption was skipped but no peer id was passed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyOutboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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_2__.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 muxedStream.abort(err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));\n return;\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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Stream is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n log('%s: starting new stream on %s', direction, protocols);\n const muxedStream = await muxer.newStream();\n let controller;\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 controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(30000);\n options.signal = controller.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n }\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__.select(muxedStream, protocols, options);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount === outgoingLimit) {\n const err = err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n finally {\n if (controller != null) {\n controller.clear();\n }\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connectionEnd', {\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_4__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer: 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: () => muxer != null ? muxer.streams : errConnectionNotMultiplexed(),\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connection', {\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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/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/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.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 _registrar_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxOutboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.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 extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init) {\n super();\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;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection denied'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(this.inboundUpgradeTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const abortableStream = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_9__.abortableDuplex)(maConn, timeoutController.signal);\n maConn.source = abortableStream.source;\n maConn.sink = abortableStream.sink;\n if (await this.components.connectionGater.denyInboundConnection(maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyInboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('inbound connection that skipped encryption must have a peer id'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 if (await this.components.connectionGater.denyInboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 timeoutController.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_6__.peerIdFromString)(idStr);\n if (await this.components.connectionGater.denyOutboundConnection(remotePeerId, maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by connectionGater.denyOutboundConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 if (await this.components.connectionGater.denyOutboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n if (remotePeerId == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Encryption was skipped but no peer id was passed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyOutboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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_2__.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 muxedStream.abort(err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));\n return;\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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Stream is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n log('%s: starting new stream on %s', direction, protocols);\n const muxedStream = await muxer.newStream();\n let controller;\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 controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(30000);\n options.signal = controller.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n }\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__.select(muxedStream, protocols, options);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount === outgoingLimit) {\n const err = err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n finally {\n if (controller != null) {\n controller.clear();\n }\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connectionEnd', {\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_4__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer: 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: () => muxer != null ? muxer.streams : errConnectionNotMultiplexed(),\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connection', {\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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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?"); /***/ }), @@ -9498,311 +6594,80 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/libp2p/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/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/libp2p/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/node_modules/@libp2p/interface-transport/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/libp2p/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/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/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/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/node_modules/@libp2p/peer-collections/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/list.js": -/*!************************************************************************************!*\ - !*** ./node_modules/libp2p/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/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/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 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/node_modules/@libp2p/peer-collections/dist/src/list.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/map.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/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 */ \"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/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/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 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/node_modules/@libp2p/peer-collections/dist/src/map.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/set.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/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 */ \"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/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/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 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/node_modules/@libp2p/peer-collections/dist/src/set.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/util.js": -/*!************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/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 */ \"mapIterable\": () => (/* binding */ mapIterable)\n/* harmony export */ });\n/**\n * Calls the passed map function on every entry of the passed iterable iterator\n */\nfunction mapIterable(iter, map) {\n const iterator = {\n [Symbol.iterator]: () => {\n return iterator;\n },\n next: () => {\n const next = iter.next();\n const val = next.value;\n if (next.done === true || val == null) {\n const result = {\n done: true,\n value: undefined\n };\n return result;\n }\n return {\n done: false,\n value: map(val)\n };\n }\n };\n return iterator;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/util.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!****************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/libp2p/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/dist/src/index.js": /*!********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/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/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/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/node_modules/@libp2p/peer-record/dist/src/index.js?"); +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 */ \"IPFS\": () => (/* binding */ IPFS),\n/* harmony export */ \"P2P\": () => (/* binding */ P2P),\n/* harmony export */ \"QUIC\": () => (/* binding */ QUIC),\n/* harmony export */ \"Reliable\": () => (/* binding */ Reliable),\n/* harmony export */ \"Stardust\": () => (/* binding */ Stardust),\n/* harmony export */ \"TCP\": () => (/* binding */ TCP),\n/* harmony export */ \"UDP\": () => (/* binding */ UDP),\n/* harmony export */ \"UTP\": () => (/* binding */ UTP),\n/* harmony export */ \"WebRTC\": () => (/* binding */ WebRTC),\n/* harmony export */ \"WebRTCDirect\": () => (/* binding */ WebRTCDirect),\n/* harmony export */ \"WebRTCStar\": () => (/* binding */ WebRTCStar),\n/* harmony export */ \"WebSocketStar\": () => (/* binding */ WebSocketStar),\n/* harmony export */ \"WebSockets\": () => (/* binding */ WebSockets),\n/* harmony export */ \"WebSocketsSecure\": () => (/* binding */ WebSocketsSecure)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n/*\n * Valid combinations\n */\nconst DNS4 = base('dns4');\nconst DNS6 = base('dns6');\nconst DNSADDR = base('dnsaddr');\nconst DNS = or(base('dns'), DNSADDR, DNS4, DNS6);\nconst IP = or(base('ip4'), base('ip6'));\nconst TCP = or(and(IP, base('tcp')), and(DNS, base('tcp')));\nconst UDP = and(IP, base('udp'));\nconst UTP = and(UDP, base('utp'));\nconst QUIC = and(UDP, base('quic'));\nconst WebSockets = or(and(TCP, base('ws')), and(DNS, base('ws')));\nconst WebSocketsSecure = or(and(TCP, base('wss')), and(DNS, base('wss')), and(TCP, base('tls'), base('ws')), and(DNS, base('tls'), base('ws')));\nconst HTTP = or(and(TCP, base('http')), and(IP, base('http')), and(DNS, base('http')));\nconst HTTPS = or(and(TCP, base('https')), and(IP, base('https')), and(DNS, base('https')));\nconst _WebRTC = and(UDP, base('webrtc'), base('certhash'));\nconst WebRTC = or(and(_WebRTC, base('p2p')), _WebRTC);\nconst WebRTCStar = or(and(WebSockets, base('p2p-webrtc-star'), base('p2p')), and(WebSocketsSecure, base('p2p-webrtc-star'), base('p2p')), and(WebSockets, base('p2p-webrtc-star')), and(WebSocketsSecure, base('p2p-webrtc-star')));\nconst WebSocketStar = or(and(WebSockets, base('p2p-websocket-star'), base('p2p')), and(WebSocketsSecure, base('p2p-websocket-star'), base('p2p')), and(WebSockets, base('p2p-websocket-star')), and(WebSocketsSecure, base('p2p-websocket-star')));\nconst WebRTCDirect = or(and(HTTP, base('p2p-webrtc-direct'), base('p2p')), and(HTTPS, base('p2p-webrtc-direct'), base('p2p')), and(HTTP, base('p2p-webrtc-direct')), and(HTTPS, base('p2p-webrtc-direct')));\nconst Reliable = or(WebSockets, WebSocketsSecure, HTTP, HTTPS, WebRTCStar, WebRTCDirect, TCP, UTP, QUIC, DNS, WebRTC);\n// Unlike ws-star, stardust can run over any transport thus removing the requirement for websockets (but don't even think about running a stardust server over webrtc-star ;) )\nconst Stardust = or(and(Reliable, base('p2p-stardust'), base('p2p')), and(Reliable, base('p2p-stardust')));\nconst _P2P = or(and(Reliable, base('p2p')), WebRTCStar, WebRTCDirect, WebRTC, base('p2p'));\nconst _Circuit = or(and(_P2P, base('p2p-circuit'), _P2P), and(_P2P, base('p2p-circuit')), and(base('p2p-circuit'), _P2P), and(Reliable, base('p2p-circuit')), and(base('p2p-circuit'), Reliable), base('p2p-circuit'));\nconst CircuitRecursive = () => or(and(_Circuit, CircuitRecursive), _Circuit);\nconst Circuit = CircuitRecursive();\nconst P2P = or(and(Circuit, _P2P, Circuit), and(_P2P, Circuit), and(Circuit, _P2P), Circuit, _P2P);\nconst IPFS = P2P;\n/*\n * Validation funcs\n */\nfunction makeMatchesFunction(partialMatch) {\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const out = partialMatch(ma.protoNames());\n if (out === null) {\n return false;\n }\n if (out === true || out === false) {\n return out;\n }\n return out.length === 0;\n }\n return matches;\n}\nfunction and(...args) {\n function partialMatch(a) {\n if (a.length < args.length) {\n return null;\n }\n let out = a;\n args.some((arg) => {\n out = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (Array.isArray(out)) {\n a = out;\n }\n if (out === null) {\n return true;\n }\n return false;\n });\n return out;\n }\n return {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n}\nfunction or(...args) {\n function partialMatch(a) {\n let out = null;\n args.some((arg) => {\n const res = typeof arg === 'function'\n ? arg().partialMatch(a)\n : arg.partialMatch(a);\n if (res != null) {\n out = res;\n return true;\n }\n return false;\n });\n return out;\n }\n const result = {\n toString: function () { return '{ ' + args.join(' ') + ' }'; },\n input: args,\n matches: makeMatchesFunction(partialMatch),\n partialMatch\n };\n return result;\n}\nfunction base(n) {\n const name = n;\n function matches(a) {\n let ma;\n try {\n ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__.multiaddr)(a);\n }\n catch (err) { // catch error\n return false; // also if it's invalid it's probably not matching as well so return false\n }\n const pnames = ma.protoNames();\n if (pnames.length === 1 && pnames[0] === name) {\n return true;\n }\n return false;\n }\n function partialMatch(protos) {\n if (protos.length === 0) {\n return null;\n }\n if (protos[0] === name) {\n return protos.slice(1);\n }\n return null;\n }\n return {\n toString: function () { return name; },\n matches,\n partialMatch\n };\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js": /*!*********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/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 */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\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_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/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/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_3__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_0__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\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_1__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_4__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js": /*!***********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! \***********************************************************************************************************************/ /***/ ((__unused_webpack___webpack_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 _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/libp2p/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.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_1__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.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_11__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/libp2p/node_modules/@libp2p/peer-record/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/src/bases/base32.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 uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.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 varint__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/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/libp2p/node_modules/@multiformats/mafmt/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_8__.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_7__.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_7__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_9__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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(varint__WEBPACK_IMPORTED_MODULE_9__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_9__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_6__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_9__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_9__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.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_6__.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_8__.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/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js": /*!***************************************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-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 */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n multiaddr;\n netmask;\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js": /*!*********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/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 */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\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_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\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 if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_6__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (this.#string == null) {\n this.#string = _codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToString(this.bytes);\n }\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_7__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.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_7__.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_7__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_5__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_5__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_6__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (this.#tuples == null) {\n this.#tuples = _codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToTuples(this.bytes);\n }\n return this.#tuples;\n }\n stringTuples() {\n if (this.#stringTuples == null) {\n this.#stringTuples = _codec_js__WEBPACK_IMPORTED_MODULE_6__.tuplesToStringTuples(this.tuples());\n }\n return this.#stringTuples;\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_6__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_4__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_1__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n // on initialization, this.#path is undefined\n // after the first call, it is either a string or null\n if (this.#path === undefined) {\n try {\n this.#path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_7__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (this.#path == null) {\n this.#path = null;\n }\n }\n catch {\n this.#path = null;\n }\n }\n return this.#path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_3__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_0__.CodeError(`no available resolver for ${resolvableProto.name}`, 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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(${_codec_js__WEBPACK_IMPORTED_MODULE_6__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/ip.js": /*!******************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": +/***/ "./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": /*!*******************************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! + !*** ./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! \*******************************************************************************************************************************/ /***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc-direct'],\n [281, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!*******************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \*******************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!**********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/index.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"codes\": () => (/* binding */ codes),\n/* harmony export */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc-direct'],\n [281, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/mafmt/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); /***/ }), @@ -9824,7 +6689,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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/libp2p/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/libp2p/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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.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/libp2p/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); /***/ }), @@ -9835,7 +6700,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 */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js?"); /***/ }), @@ -9883,6 +6748,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/libp2p/node_modules/interface-datastore/dist/src/key.js": +/*!******************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/interface-datastore/dist/src/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 */ \"Key\": () => (/* binding */ Key)\n/* harmony export */ });\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\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/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\nconst pathSepS = '/';\nconst pathSepB = new TextEncoder().encode(pathSepS);\nconst pathSep = pathSepB[0];\n/**\n * A Key represents the unique identifier of an object.\n * Our Key scheme is inspired by file systems and Google App Engine key model.\n * Keys are meant to be unique across a system. Keys are hierarchical,\n * incorporating more and more specific namespaces. Thus keys can be deemed\n * 'children' or 'ancestors' of other keys:\n * - `new Key('/Comedy')`\n * - `new Key('/Comedy/MontyPython')`\n * Also, every namespace can be parametrized to embed relevant object\n * information. For example, the Key `name` (most specific namespace) could\n * include the object type:\n * - `new Key('/Comedy/MontyPython/Actor:JohnCleese')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop')`\n * - `new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')`\n *\n */\nclass Key {\n /**\n * @param {string | Uint8Array} s\n * @param {boolean} [clean]\n */\n constructor(s, clean) {\n if (typeof s === 'string') {\n this._buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(s);\n }\n else if (s instanceof Uint8Array) {\n this._buf = s;\n }\n else {\n throw new Error('Invalid key, should be String of Uint8Array');\n }\n if (clean == null) {\n clean = true;\n }\n if (clean) {\n this.clean();\n }\n if (this._buf.byteLength === 0 || this._buf[0] !== pathSep) {\n throw new Error('Invalid key');\n }\n }\n /**\n * Convert to the string representation\n *\n * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.\n * @returns {string}\n */\n toString(encoding = 'utf8') {\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_0__.toString)(this._buf, encoding);\n }\n /**\n * Return the Uint8Array representation of the key\n *\n * @returns {Uint8Array}\n */\n uint8Array() {\n return this._buf;\n }\n /**\n * Return string representation of the key\n *\n * @returns {string}\n */\n get [Symbol.toStringTag]() {\n return `Key(${this.toString()})`;\n }\n /**\n * Constructs a key out of a namespace array.\n *\n * @param {Array} list - The array of namespaces\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.withNamespaces(['one', 'two'])\n * // => Key('/one/two')\n * ```\n */\n static withNamespaces(list) {\n return new Key(list.join(pathSepS));\n }\n /**\n * Returns a randomly (uuid) generated key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * Key.random()\n * // => Key('/f98719ea086343f7b71f32ea9d9d521d')\n * ```\n */\n static random() {\n return new Key((0,nanoid__WEBPACK_IMPORTED_MODULE_2__.nanoid)().replace(/-/g, ''));\n }\n /**\n * @param {*} other\n */\n static asKey(other) {\n if (other instanceof Uint8Array || typeof other === 'string') {\n // we can create a key from this\n return new Key(other);\n }\n if (typeof other.uint8Array === 'function') {\n // this is an older version or may have crossed the esm/cjs boundary\n return new Key(other.uint8Array());\n }\n return null;\n }\n /**\n * Cleanup the current key\n *\n * @returns {void}\n */\n clean() {\n if (this._buf == null || this._buf.byteLength === 0) {\n this._buf = pathSepB;\n }\n if (this._buf[0] !== pathSep) {\n const bytes = new Uint8Array(this._buf.byteLength + 1);\n bytes.fill(pathSep, 0, 1);\n bytes.set(this._buf, 1);\n this._buf = bytes;\n }\n // normalize does not remove trailing slashes\n while (this._buf.byteLength > 1 && this._buf[this._buf.byteLength - 1] === pathSep) {\n this._buf = this._buf.subarray(0, -1);\n }\n }\n /**\n * Check if the given key is sorted lower than ourself.\n *\n * @param {Key} key - The other Key to check against\n * @returns {boolean}\n */\n less(key) {\n const list1 = this.list();\n const list2 = key.list();\n for (let i = 0; i < list1.length; i++) {\n if (list2.length < i + 1) {\n return false;\n }\n const c1 = list1[i];\n const c2 = list2[i];\n if (c1 < c2) {\n return true;\n }\n else if (c1 > c2) {\n return false;\n }\n }\n return list1.length < list2.length;\n }\n /**\n * Returns the key with all parts in reversed order.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').reverse()\n * // => Key('/Actor:JohnCleese/MontyPython/Comedy')\n * ```\n */\n reverse() {\n return Key.withNamespaces(this.list().slice().reverse());\n }\n /**\n * Returns the `namespaces` making up this Key.\n *\n * @returns {Array}\n */\n namespaces() {\n return this.list();\n }\n /** Returns the \"base\" namespace of this key.\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').baseNamespace()\n * // => 'Actor:JohnCleese'\n * ```\n */\n baseNamespace() {\n const ns = this.namespaces();\n return ns[ns.length - 1];\n }\n /**\n * Returns the `list` representation of this key.\n *\n * @returns {Array}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()\n * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']\n * ```\n */\n list() {\n return this.toString().split(pathSepS).slice(1);\n }\n /**\n * Returns the \"type\" of this key (value of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').type()\n * // => 'Actor'\n * ```\n */\n type() {\n return namespaceType(this.baseNamespace());\n }\n /**\n * Returns the \"name\" of this key (field of last namespace).\n *\n * @returns {string}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').name()\n * // => 'JohnCleese'\n * ```\n */\n name() {\n return namespaceValue(this.baseNamespace());\n }\n /**\n * Returns an \"instance\" of this type key (appends value to namespace).\n *\n * @param {string} s - The string to append.\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor').instance('JohnClesse')\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n instance(s) {\n return new Key(this.toString() + ':' + s);\n }\n /**\n * Returns the \"path\" of this key (parent + type).\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython/Actor:JohnCleese').path()\n * // => Key('/Comedy/MontyPython/Actor')\n * ```\n */\n path() {\n let p = this.parent().toString();\n if (!p.endsWith(pathSepS)) {\n p += pathSepS;\n }\n p += this.type();\n return new Key(p);\n }\n /**\n * Returns the `parent` Key of this Key.\n *\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key(\"/Comedy/MontyPython/Actor:JohnCleese\").parent()\n * // => Key(\"/Comedy/MontyPython\")\n * ```\n */\n parent() {\n const list = this.list();\n if (list.length === 1) {\n return new Key(pathSepS);\n }\n return new Key(list.slice(0, -1).join(pathSepS));\n }\n /**\n * Returns the `child` Key of this Key.\n *\n * @param {Key} key - The child Key to add\n * @returns {Key}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').child(new Key('Actor:JohnCleese'))\n * // => Key('/Comedy/MontyPython/Actor:JohnCleese')\n * ```\n */\n child(key) {\n if (this.toString() === pathSepS) {\n return key;\n }\n else if (key.toString() === pathSepS) {\n return this;\n }\n return new Key(this.toString() + key.toString(), false);\n }\n /**\n * Returns whether this key is a prefix of `other`\n *\n * @param {Key} other - The other key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy').isAncestorOf('/Comedy/MontyPython')\n * // => true\n * ```\n */\n isAncestorOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return other.toString().startsWith(this.toString());\n }\n /**\n * Returns whether this key is a contains another as prefix.\n *\n * @param {Key} other - The other Key to test against\n * @returns {boolean}\n *\n * @example\n * ```js\n * new Key('/Comedy/MontyPython').isDecendantOf('/Comedy')\n * // => true\n * ```\n */\n isDecendantOf(other) {\n if (other.toString() === this.toString()) {\n return false;\n }\n return this.toString().startsWith(other.toString());\n }\n /**\n * Checks if this key has only one namespace.\n *\n * @returns {boolean}\n *\n */\n isTopLevel() {\n return this.list().length === 1;\n }\n /**\n * Concats one or more Keys into one new Key.\n *\n * @param {Array} keys - The array of keys to concatenate\n * @returns {Key}\n */\n concat(...keys) {\n return Key.withNamespaces([...this.namespaces(), ...flatten(keys.map(key => key.namespaces()))]);\n }\n}\n/**\n * The first component of a namespace. `foo` in `foo:bar`\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceType(ns) {\n const parts = ns.split(':');\n if (parts.length < 2) {\n return '';\n }\n return parts.slice(0, -1).join(':');\n}\n/**\n * The last component of a namespace, `baz` in `foo:bar:baz`.\n *\n * @param {string} ns\n * @returns {string}\n */\nfunction namespaceValue(ns) {\n const parts = ns.split(':');\n return parts[parts.length - 1];\n}\n/**\n * Flatten array of arrays (only one level)\n *\n * @template T\n * @param {Array} arr\n * @returns {T[]}\n */\nfunction flatten(arr) {\n return ([]).concat(...arr);\n}\n//# sourceMappingURL=key.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/interface-datastore/dist/src/key.js?"); + +/***/ }), + /***/ "./node_modules/libp2p/node_modules/it-all/dist/src/index.js": /*!*******************************************************************!*\ !*** ./node_modules/libp2p/node_modules/it-all/dist/src/index.js ***! @@ -9894,311 +6770,47 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/libp2p/node_modules/it-first/dist/src/index.js": -/*!*********************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/it-first/dist/src/index.js ***! - \*********************************************************************/ +/***/ "./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/alloc.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/it-length-prefixed/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 */ \"default\": () => (/* binding */ first)\n/* harmony export */ });\n/**\n * Returns the first result from an (async) iterable, unless empty, in which\n * case returns `undefined`\n */\nasync function first(source) {\n for await (const entry of source) { // eslint-disable-line no-unreachable-loop\n return entry;\n }\n return undefined;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/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 */ \"alloc\": () => (/* binding */ alloc),\n/* harmony export */ \"allocUnsafe\": () => (/* binding */ allocUnsafe)\n/* harmony export */ });\nfunction alloc(len) {\n return new Uint8Array(len);\n}\nfunction allocUnsafe(len) {\n if (globalThis?.Buffer?.allocUnsafe != null) {\n return globalThis.Buffer.allocUnsafe(len);\n }\n return new Uint8Array(len);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/alloc.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base.js": -/*!*************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/src/bases/base.js ***! - \*************************************************************************/ +/***/ "./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/decode.js": +/*!********************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/decode.js ***! + \********************************************************************************/ /***/ ((__unused_webpack___webpack_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/libp2p/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/libp2p/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/bases/base.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* eslint max-depth: [\"error\", 6] */\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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(options) {\n const decoder = async function* (source) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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 for await (const buf of source) {\n buffer.append(buf);\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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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 (buffer.byteLength > 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error('unexpected end of input'), 'ERR_UNEXPECTED_EOF');\n }\n };\n return decoder;\n}\n/**\n * @param {*} reader\n * @param {import('./types').DecoderOptions} [options]\n * @returns\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({\n ...(options ?? {}),\n onLength\n })(varByteSource);\n};\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/decode.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base10.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/src/bases/base10.js ***! - \***************************************************************************/ +/***/ "./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/encode.js": +/*!********************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/encode.js ***! + \********************************************************************************/ /***/ ((__unused_webpack___webpack_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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base10.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 _alloc_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./alloc.js */ \"./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/alloc.js\");\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,_alloc_js__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encode(length, lengthBuf);\n defaultEncoder.bytes = lengthLength;\n return lengthBuf;\n};\ndefaultEncoder.bytes = 0;\nfunction encode(options) {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n const encoder = async function* (source) {\n for await (const chunk of source) {\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 };\n return encoder;\n}\nencode.single = (chunk, options) => {\n options = options ?? {};\n const encodeLength = options.lengthEncoder ?? defaultEncoder;\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/encode.js?"); /***/ }), -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base16.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/src/bases/base16.js ***! - \***************************************************************************/ +/***/ "./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/libp2p/node_modules/it-length-prefixed/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 */ \"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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base2.js": -/*!**************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base256emoji.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base32.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base36.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base64.js": -/*!***************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/base8.js": -/*!**************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/identity.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bases/interface.js": -/*!******************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/src/bases/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/libp2p/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/basics.js": -/*!*********************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/bytes.js": -/*!********************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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)\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/libp2p/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/cid.js": -/*!******************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/libp2p/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/libp2p/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/libp2p/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/libp2p/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/libp2p/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/codecs/json.js": -/*!**************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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 */ });\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/libp2p/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/codecs/raw.js": -/*!*************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/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/libp2p/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js": -/*!****************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/hashes/hasher.js": -/*!****************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/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/libp2p/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/hashes/identity.js": -/*!******************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/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/libp2p/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/index.js": -/*!********************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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_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/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/libp2p/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/libp2p/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/libp2p/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/libp2p/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/interface.js": -/*!************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/link/interface.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/src/link/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/libp2p/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/src/varint.js": -/*!*********************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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/libp2p/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/libp2p/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/vendor/base-x.js": -/*!************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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// 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/libp2p/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/multiformats/vendor/varint.js": -/*!************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/multiformats/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 */ });\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/libp2p/node_modules/multiformats/vendor/varint.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decode\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_1__.decode),\n/* harmony export */ \"encode\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_0__.encode)\n/* harmony export */ });\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/encode.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/decode.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/libp2p/node_modules/it-length-prefixed/dist/src/index.js?"); /***/ }), @@ -10334,6 +6946,303 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./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/src/bases/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/bases/interface.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/basics.js": +/*!*************************************************!*\ + !*** ./node_modules/multiformats/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_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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/bytes.js": +/*!************************************************!*\ + !*** ./node_modules/multiformats/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)\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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/cid.js": +/*!**********************************************!*\ + !*** ./node_modules/multiformats/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 _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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/codecs/json.js": +/*!******************************************************!*\ + !*** ./node_modules/multiformats/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 */ });\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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/codecs/raw.js": +/*!*****************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/hashes/digest.js": +/*!********************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/hashes/hasher.js": +/*!********************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/hashes/identity.js": +/*!**********************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/hashes/sha2-browser.js": +/*!**************************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/index.js": +/*!************************************************!*\ + !*** ./node_modules/multiformats/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_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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/interface.js": +/*!****************************************************!*\ + !*** ./node_modules/multiformats/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/interface.js?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/link/interface.js": +/*!*********************************************************!*\ + !*** ./node_modules/multiformats/src/link/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/src/varint.js": +/*!*************************************************!*\ + !*** ./node_modules/multiformats/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/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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/vendor/base-x.js": +/*!****************************************************!*\ + !*** ./node_modules/multiformats/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// 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?"); + +/***/ }), + +/***/ "./node_modules/multiformats/vendor/varint.js": +/*!****************************************************!*\ + !*** ./node_modules/multiformats/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 */ });\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?"); + +/***/ }), + /***/ "./node_modules/nanoid/index.browser.js": /*!**********************************************!*\ !*** ./node_modules/nanoid/index.browser.js ***! @@ -10429,7 +7338,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\": () => (/* binding */ PQueue)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/p-queue/node_modules/eventemitter3/index.js\");\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_pendingCount, _PQueue_concurrency, _PQueue_isPaused, _PQueue_throwOnTimeout, _PQueue_doesIntervalAllowAnother_get, _PQueue_doesConcurrentAllowAnother_get, _PQueue_next, _PQueue_emitEvents, _PQueue_onResumeInterval, _PQueue_isIntervalPaused_get, _PQueue_tryToStartAnother, _PQueue_initializeIntervalIfNeeded, _PQueue_onInterval, _PQueue_processQueue, _PQueue_onEvent;\n\n\n\nconst timeoutError = new p_timeout__WEBPACK_IMPORTED_MODULE_1__.TimeoutError();\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__ {\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_pendingCount.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 /**\n Adds a sync or async task to the queue. Always returns a promise.\n */\n async add(fn, options = {}) {\n return new Promise((resolve, reject) => {\n const run = async () => {\n var _a;\n var _b, _c;\n __classPrivateFieldSet(this, _PQueue_pendingCount, (_b = __classPrivateFieldGet(this, _PQueue_pendingCount, \"f\"), _b++, _b), \"f\");\n __classPrivateFieldSet(this, _PQueue_intervalCount, (_c = __classPrivateFieldGet(this, _PQueue_intervalCount, \"f\"), _c++, _c), \"f\");\n try {\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 reject(new AbortError('The task was aborted.'));\n return;\n }\n const operation = (this.timeout === undefined && options.timeout === undefined) ? fn({ signal: options.signal }) : (0,p_timeout__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(Promise.resolve(fn({ signal: options.signal })), (options.timeout === undefined ? this.timeout : options.timeout), () => {\n if (options.throwOnTimeout === undefined ? __classPrivateFieldGet(this, _PQueue_throwOnTimeout, \"f\") : options.throwOnTimeout) {\n reject(timeoutError);\n }\n return undefined;\n });\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n reject(error);\n this.emit('error', error);\n }\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_next).call(this);\n };\n __classPrivateFieldGet(this, _PQueue_queue, \"f\").enqueue(run, options);\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_tryToStartAnother).call(this);\n this.emit('add');\n });\n }\n /**\n Same as `.add()`, but accepts an array of sync or async functions.\n\n @returns A promise that resolves when all functions are resolved.\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_pendingCount, \"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_pendingCount, \"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_pendingCount = 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_pendingCount, \"f\") < __classPrivateFieldGet(this, _PQueue_concurrency, \"f\");\n}, _PQueue_next = function _PQueue_next() {\n var _a;\n __classPrivateFieldSet(this, _PQueue_pendingCount, (_a = __classPrivateFieldGet(this, _PQueue_pendingCount, \"f\"), _a--, _a), \"f\");\n __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_tryToStartAnother).call(this);\n this.emit('next');\n}, _PQueue_emitEvents = function _PQueue_emitEvents() {\n this.emit('empty');\n if (__classPrivateFieldGet(this, _PQueue_pendingCount, \"f\") === 0) {\n this.emit('idle');\n }\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_pendingCount, \"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 __classPrivateFieldGet(this, _PQueue_instances, \"m\", _PQueue_emitEvents).call(this);\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_pendingCount, \"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_pendingCount, \"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_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\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 */ \"AbortError\": () => (/* binding */ AbortError),\n/* harmony export */ \"default\": () => (/* binding */ PQueue)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/p-queue/node_modules/eventemitter3/index.js\");\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__ {\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\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-queue/dist/index.js?"); /***/ }), @@ -10495,7 +7404,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 */ \"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\t? new AbortError(errorMessage)\n\t: new 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\t? getDOMException('This operation was aborted.')\n\t\t: signal.reason;\n\n\treturn reason instanceof Error ? reason : getDOMException(reason);\n};\n\nfunction pTimeout(promise, options) {\n\tconst {\n\t\tmilliseconds,\n\t\tfallback,\n\t\tmessage,\n\t\tcustomTimers = {setTimeout, clearTimeout},\n\t} = options;\n\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\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 = customTimers.setTimeout.call(undefined, () => {\n\t\t\tif (fallback) {\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 errorMessage = typeof message === 'string' ? message : `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\tconst timeoutError = message instanceof Error ? message : new TimeoutError(errorMessage);\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\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\t\t}\n\t\t})();\n\t});\n\n\tcancelablePromise.clear = () => {\n\t\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-timeout/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 */ \"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\t? new AbortError(errorMessage)\n\t: new 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\t? getDOMException('This operation was aborted.')\n\t\t: signal.reason;\n\n\treturn reason instanceof Error ? reason : getDOMException(reason);\n};\n\nfunction pTimeout(promise, options) {\n\tconst {\n\t\tmilliseconds,\n\t\tfallback,\n\t\tmessage,\n\t\tcustomTimers = {setTimeout, clearTimeout},\n\t} = options;\n\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\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\t// We create the error outside of `setTimeout` to preserve the stack trace.\n\t\tconst timeoutError = new TimeoutError();\n\n\t\ttimer = customTimers.setTimeout.call(undefined, () => {\n\t\t\tif (fallback) {\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\tif (typeof promise.cancel === 'function') {\n\t\t\t\tpromise.cancel();\n\t\t\t}\n\n\t\t\tif (message === false) {\n\t\t\t\tresolve();\n\t\t\t} else if (message instanceof Error) {\n\t\t\t\treject(message);\n\t\t\t} else {\n\t\t\t\ttimeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\t\treject(timeoutError);\n\t\t\t}\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\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\t\t}\n\t\t})();\n\t});\n\n\tcancelablePromise.clear = () => {\n\t\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/p-timeout/index.js?"); /***/ }), @@ -10521,6 +7430,83 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/protons-runtime/dist/src/codec.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/codec.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/codecs/enum.js": +/*!**************************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/codecs/enum.js ***! + \**************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/codecs/enum.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/codecs/message.js": +/*!*****************************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/codecs/message.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/decode.js": +/*!*********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/decode.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/decode.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/encode.js": +/*!*********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/encode.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/encode.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/index.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/utils.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-example/./node_modules/protons-runtime/dist/src/utils.js?"); + +/***/ }), + /***/ "./node_modules/uint8-varint/dist/src/index.js": /*!*****************************************************!*\ !*** ./node_modules/uint8-varint/dist/src/index.js ***! @@ -10638,7 +7624,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/uint8arrays/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var _alloc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../alloc.js */ \"./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_js__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: 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/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/src/basics.js\");\n/* harmony import */ var _alloc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../alloc.js */ \"./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_js__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: 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/uint8arrays/dist/src/util/bases.js?"); /***/ }), @@ -10653,303 +7639,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base.js": -/*!******************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base10.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base16.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base2.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base256emoji.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base32.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base36.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base58.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base64.js": -/*!********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/base8.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/identity.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bases/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/src/bases/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/uint8arrays/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/basics.js": -/*!**************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js": -/*!*************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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)\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/uint8arrays/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/cid.js": -/*!***********************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/codecs/json.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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 */ });\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/uint8arrays/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/codecs/raw.js": -/*!******************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/hashes/digest.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/hashes/hasher.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/hashes/identity.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/index.js": -/*!*************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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_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/uint8arrays/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/uint8arrays/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/uint8arrays/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/interface.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/link/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/src/link/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/uint8arrays/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/src/varint.js": -/*!**************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/vendor/base-x.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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// 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/uint8arrays/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/uint8arrays/node_modules/multiformats/vendor/varint.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/uint8arrays/node_modules/multiformats/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 */ });\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/uint8arrays/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - /***/ "./node_modules/utf8-codec/index.mjs": /*!*******************************************!*\ !*** ./node_modules/utf8-codec/index.mjs ***! diff --git a/noise-rtc/index.js b/noise-rtc/index.js index 7a5da3f..185a03b 100644 --- a/noise-rtc/index.js +++ b/noise-rtc/index.js @@ -16,7 +16,128 @@ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _waku_create__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/create */ \"./node_modules/@waku/create/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_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_noise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/noise */ \"./node_modules/@waku/noise/dist/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! protobufjs */ \"./node_modules/protobufjs/index.js\");\n/* harmony import */ var protobufjs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(protobufjs__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! qrcode */ \"./node_modules/qrcode/lib/browser.js\");\n\n\n\n\n\n\n\n\n// Protobuf\nconst ProtoMessage = new (protobufjs__WEBPACK_IMPORTED_MODULE_5___default().Type)(\"Message\").add(\n new (protobufjs__WEBPACK_IMPORTED_MODULE_5___default().Field)(\"data\", 3, \"string\")\n);\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_create__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({ defaultBootstrap: true });\n\n try {\n await node.start();\n await (0,_waku_core__WEBPACK_IMPORTED_MODULE_2__.waitForRemotePeer)(node, [_waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.Protocols.Filter, _waku_interfaces__WEBPACK_IMPORTED_MODULE_3__.Protocols.LightPush]);\n\n ui.waku.connected();\n\n const responder = getResponder(node);\n const myStaticKey = _waku_noise__WEBPACK_IMPORTED_MODULE_4__.generateX25519KeyPair();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_4__.WakuPairing(\n node.lightPush,\n responder,\n myStaticKey,\n urlPairingInfo || new _waku_noise__WEBPACK_IMPORTED_MODULE_4__.ResponderParameters()\n );\n const pExecute = pairingObj.execute(120000); // timeout after 2m\n\n scheduleHandshakeAuthConfirmation(pairingObj, ui);\n\n let sendWakuMessage;\n let listenToWakuMessages;\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 [sendWakuMessage, listenToWakuMessages] = await buildWakuMessage(\n node,\n pExecute\n );\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 const { peerConnection, sendMessage: sendRTCMessage } = initRTC({\n ui,\n onReceive: ui.message.onReceive.bind(ui.message),\n });\n\n peerConnection.onicecandidate = async (event) => {\n if (event.candidate) {\n console.log(\"candidate sent\");\n try {\n ui.rtc.sendingCandidate();\n await sendWakuMessage({\n type: \"candidate\",\n candidate: event.candidate,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n }\n };\n\n const sendOffer = async () => {\n console.log(\"offer sent\");\n ui.rtc.sendingOffer();\n\n try {\n const offer = await peerConnection.createOffer();\n await peerConnection.setLocalDescription(offer);\n\n await sendWakuMessage({\n type: \"offer\",\n offer,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const sendAnswer = async (data) => {\n console.log(\"answer sent\");\n ui.rtc.sendingAnswer();\n try {\n await peerConnection.setRemoteDescription(\n new RTCSessionDescription(data.offer)\n );\n\n const answer = await peerConnection.createAnswer();\n peerConnection.setLocalDescription(answer);\n\n await sendWakuMessage({\n type: \"answer\",\n answer,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const receiveAnswer = async (data) => {\n try {\n console.log(\"answer received\");\n await peerConnection.setRemoteDescription(\n new RTCSessionDescription(data.answer)\n );\n console.log(\"answer saved\");\n\n await sendWakuMessage({\n type: \"ready\",\n text: \"received answer\",\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const receiveCandidate = async (data) => {\n try {\n console.log(\"candidate saved\");\n await peerConnection.addIceCandidate(\n new RTCIceCandidate(data.candidate)\n );\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const handleWakuMessages = async (data) => {\n if (data.type === \"offer\") {\n await sendAnswer(data);\n }\n\n if (data.type === \"answer\") {\n await receiveAnswer(data);\n }\n\n if (data.type === \"ready\") {\n console.log(\"RTC: partner is\", data.text);\n }\n\n if (data.type === \"candidate\") {\n await receiveCandidate(data);\n }\n };\n\n await listenToWakuMessages(handleWakuMessages);\n ui.message.onSend(sendRTCMessage);\n\n // if we are initiator of Noise handshake\n // let's initiate Web RTC as well\n if (!urlPairingInfo) {\n await sendOffer();\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_4__.InitiatorParameters(\n decodeURIComponent(qrCodeString),\n _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__.hexToBytes(messageNameTag)\n );\n}\n\nfunction getResponder(node) {\n const msgQueue = new Array();\n const subscriptions = new Map();\n const intervals = new Map();\n\n const responder = {\n async subscribe(decoder) {\n const subscription = await node.filter.subscribe(\n [decoder],\n (wakuMessage) => {\n msgQueue.push(wakuMessage);\n }\n );\n subscriptions.set(decoder.contentTopic, subscription);\n },\n async nextMessage(contentTopic) {\n if (msgQueue.length != 0) {\n const oldestMsg = msgQueue.shift();\n if (oldestMsg.contentTopic === contentTopic) {\n return oldestMsg;\n }\n }\n\n return new Promise((resolve) => {\n const interval = setInterval(() => {\n if (msgQueue.length != 0) {\n clearInterval(interval);\n const oldestMsg = msgQueue.shift();\n if (oldestMsg.contentTopic === contentTopic) {\n resolve(oldestMsg);\n }\n }\n }, 100);\n intervals.set(contentTopic, interval);\n });\n },\n async stop(contentTopic) {\n if (intervals.has(contentTopic)) {\n clearInterval(intervals.get(contentTopic));\n intervals.delete(contentTopic);\n }\n if (subscriptions.has(contentTopic)) {\n await subscriptions.get(contentTopic)();\n subscriptions.delete(contentTopic);\n } else {\n console.log(\"Subscriptipon doesnt exist\");\n }\n },\n };\n\n return responder;\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\nasync function buildWakuMessage(node, noiseExecute) {\n const [encoder, decoder] = await noiseExecute;\n\n const sendMessage = async (message) => {\n let payload = ProtoMessage.create({\n data: JSON.stringify(message),\n });\n payload = ProtoMessage.encode(payload).finish();\n\n return node.lightPush.send(encoder, { payload });\n };\n\n const listenToMessages = async (fn) => {\n return node.filter.subscribe([decoder], ({ payload }) => {\n const { data } = ProtoMessage.decode(payload);\n fn(JSON.parse(data));\n });\n };\n\n return [sendMessage, listenToMessages];\n}\n\nfunction initRTC({ ui, onReceive }) {\n const configuration = {\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n };\n const peerConnection = new RTCPeerConnection(configuration);\n const sendChannel = peerConnection.createDataChannel(\"chat\");\n\n let receiveChannel;\n\n sendChannel.onopen = (event) => {\n ui.rtc.ready();\n console.log(\"onopen send\", event);\n };\n\n peerConnection.ondatachannel = (event) => {\n receiveChannel = event.channel;\n\n receiveChannel.onmessage = (event) => {\n onReceive(JSON.parse(event.data));\n };\n\n receiveChannel.onopen = (event) => {\n ui.rtc.ready();\n console.log(\"onopen receive\", event);\n };\n };\n\n const sendMessage = (text, nick) => {\n sendChannel.send(JSON.stringify({ text, nick, timestamp: Date.now() }));\n };\n\n return {\n peerConnection,\n sendChannel,\n receiveChannel,\n sendMessage,\n };\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 const rtcStatus = document.getElementById(\"rtc-status\");\n const connectChat = document.getElementById(\"connect-chat-btn\");\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_6__.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(data) {\n const { timestamp, nick, text } = data;\n\n this._render({\n nick,\n time: timestamp,\n 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 rtc: {\n _val(msg) {\n rtcStatus.innerText = msg;\n },\n _class(name) {\n rtcStatus.className = name;\n },\n sendingOffer() {\n this._val(\"sending offer\");\n this._class(\"progress\");\n },\n sendingAnswer() {\n this._val(\"sending answer\");\n this._class(\"progress\");\n },\n sendingCandidate() {\n this._val(\"sending ice candidate\");\n this._class(\"progress\");\n },\n ready() {\n this._val(\"ready\");\n this._class(\"success\");\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n onConnect(cb) {\n connectChat.addEventListener(\"click\", cb);\n },\n },\n hide() {\n this.shareInfo.hide();\n chatArea.style.display = \"none\";\n },\n };\n}\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _waku_create__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/create */ \"./node_modules/@waku/create/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_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/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\n// Protobuf\nconst ProtoMessage = new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Type)(\"Message\").add(\n new (protobufjs__WEBPACK_IMPORTED_MODULE_4___default().Field)(\"data\", 3, \"string\")\n);\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_create__WEBPACK_IMPORTED_MODULE_0__.createLightNode)({ defaultBootstrap: true });\n\n try {\n await node.start();\n await (0,_waku_core__WEBPACK_IMPORTED_MODULE_2__.waitForRemotePeer)(node, [\"filter\", \"lightpush\"]);\n\n ui.waku.connected();\n\n const myStaticKey = _waku_noise__WEBPACK_IMPORTED_MODULE_3__.generateX25519KeyPair();\n const urlPairingInfo = getPairingInfoFromURL();\n\n const pairingObj = new _waku_noise__WEBPACK_IMPORTED_MODULE_3__.WakuPairing(\n node.lightPush,\n node.filter,\n myStaticKey,\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 sendWakuMessage;\n let listenToWakuMessages;\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 [sendWakuMessage, listenToWakuMessages] = await buildWakuMessage(\n node,\n pExecute\n );\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 const { peerConnection, sendMessage: sendRTCMessage } = initRTC({\n ui,\n onReceive: ui.message.onReceive.bind(ui.message),\n });\n\n peerConnection.onicecandidate = async (event) => {\n if (event.candidate) {\n console.log(\"candidate sent\");\n try {\n ui.rtc.sendingCandidate();\n await sendWakuMessage({\n type: \"candidate\",\n candidate: event.candidate,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n }\n };\n\n const sendOffer = async () => {\n console.log(\"offer sent\");\n ui.rtc.sendingOffer();\n\n try {\n const offer = await peerConnection.createOffer();\n await peerConnection.setLocalDescription(offer);\n\n await sendWakuMessage({\n type: \"offer\",\n offer,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const sendAnswer = async (data) => {\n console.log(\"answer sent\");\n ui.rtc.sendingAnswer();\n try {\n await peerConnection.setRemoteDescription(\n new RTCSessionDescription(data.offer)\n );\n\n const answer = await peerConnection.createAnswer();\n peerConnection.setLocalDescription(answer);\n\n await sendWakuMessage({\n type: \"answer\",\n answer,\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const receiveAnswer = async (data) => {\n try {\n console.log(\"answer received\");\n await peerConnection.setRemoteDescription(\n new RTCSessionDescription(data.answer)\n );\n console.log(\"answer saved\");\n\n await sendWakuMessage({\n type: \"ready\",\n text: \"received answer\",\n });\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const receiveCandidate = async (data) => {\n try {\n console.log(\"candidate saved\");\n await peerConnection.addIceCandidate(\n new RTCIceCandidate(data.candidate)\n );\n } catch (error) {\n ui.rtc.error(error.message);\n }\n };\n\n const handleWakuMessages = async (data) => {\n if (data.type === \"offer\") {\n await sendAnswer(data);\n }\n\n if (data.type === \"answer\") {\n await receiveAnswer(data);\n }\n\n if (data.type === \"ready\") {\n console.log(\"RTC: partner is\", data.text);\n }\n\n if (data.type === \"candidate\") {\n await receiveCandidate(data);\n }\n };\n\n await listenToWakuMessages(handleWakuMessages);\n ui.message.onSend(sendRTCMessage);\n\n // if we are initiator of Noise handshake\n // let's initiate Web RTC as well\n if (!urlPairingInfo) {\n await sendOffer();\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\nasync function buildWakuMessage(node, noiseExecute) {\n const [encoder, decoder] = await noiseExecute;\n\n const sendMessage = async (message) => {\n let payload = ProtoMessage.create({\n data: JSON.stringify(message),\n });\n payload = ProtoMessage.encode(payload).finish();\n\n return node.lightPush.send(encoder, { payload });\n };\n\n const listenToMessages = async (fn) => {\n return node.filter.subscribe([decoder], ({ payload }) => {\n const { data } = ProtoMessage.decode(payload);\n fn(JSON.parse(data));\n });\n };\n\n return [sendMessage, listenToMessages];\n}\n\nfunction initRTC({ ui, onReceive }) {\n const configuration = {\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n };\n const peerConnection = new RTCPeerConnection(configuration);\n const sendChannel = peerConnection.createDataChannel(\"chat\");\n\n let receiveChannel;\n\n sendChannel.onopen = (event) => {\n ui.rtc.ready();\n console.log(\"onopen send\", event);\n };\n\n peerConnection.ondatachannel = (event) => {\n receiveChannel = event.channel;\n\n receiveChannel.onmessage = (event) => {\n onReceive(JSON.parse(event.data));\n };\n\n receiveChannel.onopen = (event) => {\n ui.rtc.ready();\n console.log(\"onopen receive\", event);\n };\n };\n\n const sendMessage = (text, nick) => {\n sendChannel.send(JSON.stringify({ text, nick, timestamp: Date.now() }));\n };\n\n return {\n peerConnection,\n sendChannel,\n receiveChannel,\n sendMessage,\n };\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 const rtcStatus = document.getElementById(\"rtc-status\");\n const connectChat = document.getElementById(\"connect-chat-btn\");\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(data) {\n const { timestamp, nick, text } = data;\n\n this._render({\n nick,\n time: timestamp,\n 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 rtc: {\n _val(msg) {\n rtcStatus.innerText = msg;\n },\n _class(name) {\n rtcStatus.className = name;\n },\n sendingOffer() {\n this._val(\"sending offer\");\n this._class(\"progress\");\n },\n sendingAnswer() {\n this._val(\"sending answer\");\n this._class(\"progress\");\n },\n sendingCandidate() {\n this._val(\"sending ice candidate\");\n this._class(\"progress\");\n },\n ready() {\n this._val(\"ready\");\n this._class(\"success\");\n },\n error(msg) {\n this._val(msg);\n this._class(\"error\");\n },\n onConnect(cb) {\n connectChat.addEventListener(\"click\", cb);\n },\n },\n hide() {\n this.shareInfo.hide();\n chatArea.style.display = \"none\";\n },\n };\n}\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./index.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js ***! + \*************************************************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +eval("// minimal library entry point.\n\n\nmodule.exports = __webpack_require__(/*! ./src/index-minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js\");\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js\");\nprotobuf.BufferWriter = __webpack_require__(/*! ./writer_buffer */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js\");\nprotobuf.Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js\");\nprotobuf.BufferReader = __webpack_require__(/*! ./reader_buffer */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js\");\n\n// Utility\nprotobuf.util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js\");\nprotobuf.rpc = __webpack_require__(/*! ./rpc */ \"./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js\");\nprotobuf.roots = __webpack_require__(/*! ./roots */ \"./node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/index-minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader.js\");\n(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/reader_buffer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/roots.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/roots.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js\");\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/rpc/service.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/longbits.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/longbits.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js": +/*!**********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/util/minimal.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js": +/*!***********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/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/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer.js\");\n(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;\n\nvar util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs/src/writer_buffer.js?"); /***/ }), @@ -383,193 +504,6 @@ eval("\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protobufjs/minimal.js": -/*!********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protobufjs/minimal.js ***! - \********************************************************************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; -eval("// minimal library entry point.\n\n\nmodule.exports = __webpack_require__(/*! ./src/index-minimal */ \"./node_modules/@waku/core/node_modules/protobufjs/src/index-minimal.js\");\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protobufjs/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/index-minimal.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/protobufjs/src/writer.js\");\nprotobuf.BufferWriter = __webpack_require__(/*! ./writer_buffer */ \"./node_modules/@waku/core/node_modules/protobufjs/src/writer_buffer.js\");\nprotobuf.Reader = __webpack_require__(/*! ./reader */ \"./node_modules/@waku/core/node_modules/protobufjs/src/reader.js\");\nprotobuf.BufferReader = __webpack_require__(/*! ./reader_buffer */ \"./node_modules/@waku/core/node_modules/protobufjs/src/reader_buffer.js\");\n\n// Utility\nprotobuf.util = __webpack_require__(/*! ./util/minimal */ \"./node_modules/@waku/core/node_modules/protobufjs/src/util/minimal.js\");\nprotobuf.rpc = __webpack_require__(/*! ./rpc */ \"./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js\");\nprotobuf.roots = __webpack_require__(/*! ./roots */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/index-minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/reader.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/reader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/reader_buffer.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/reader_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/roots.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/roots.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js": -/*!********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/node_modules/protobufjs/src/rpc/service.js\");\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/rpc/service.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/rpc/service.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/util/longbits.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/util/longbits.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/util/minimal.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/util/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/writer.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/writer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protobufjs/src/writer_buffer.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/protobufjs/src/writer_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/longbits.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/longbits.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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, {\n constructor: {\n value: CustomError,\n writable: true,\n enumerable: false,\n configurable: true,\n },\n name: {\n get: function get() { return name; },\n set: undefined,\n enumerable: false,\n // configurable: false would accurately preserve the behavior of\n // the original, but I'm guessing that was not intentional.\n // For an actual error subclass, this property would\n // be configurable.\n configurable: true,\n },\n toString: {\n value: function value() { return this.name + \": \" + this.message; },\n writable: true,\n enumerable: false,\n configurable: true,\n },\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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js": -/*!***********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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/core/node_modules/protons-runtime/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-rtc/./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js?"); - -/***/ }), - /***/ "./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.js": /*!******************************************************************************!*\ !*** ./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/native.js ***! @@ -2294,13 +2228,13 @@ eval("/* (ignored) */\n\n//# sourceURL=webpack://@waku/noise-rtc/crypto_(ignored /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs ***! - \***************************************************************************************************/ +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs": +/*!***************************************************************************!*\ + !*** ./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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs?"); +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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.cjs?"); /***/ }), @@ -2348,6 +2282,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 */ \"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 */ \"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 * 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//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 it_pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/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 _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_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var _libp2p_topology__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/topology */ \"./node_modules/@libp2p/topology/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-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 _types_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./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\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_5__.EventEmitter {\n constructor(components, options = {}) {\n super();\n this.multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_21__.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_8__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPruneBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.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_8__.FloodsubID);\n }\n // From pubsub\n this.log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.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_12__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__.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_19__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.msgIdFnStrictSign;\n break;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.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_12__.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_9__.messageIdToString;\n this.mcache = options.messageCache || new _message_cache_js__WEBPACK_IMPORTED_MODULE_6__.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_8__.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_11__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_10__.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_2__.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_18__.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_21__.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.addressBook.add(p.id, p.addrs);\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_4__.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_8__.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_8__.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_8__.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 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_22__.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_8__.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_22__.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_24__.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_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 ? 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_2__.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_23__.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_5__.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_14__.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_14__.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_14__.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_5__.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_5__.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_14__.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_15__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.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_8__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_8__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_8__.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_8__.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_8__.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_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_8__.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_8__.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 || !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_8__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_9__.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_8__.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_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)) {\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) {\n return [];\n }\n return await Promise.all(prune.map((topic) => this.makePrune(id, topic, doPX)));\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_13__.ChurnReason.Unsub, 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 interval - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, interval) {\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() + interval;\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_8__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n if (expire < 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_9__.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 p = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(pi.peerID).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 const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.openAndCertify(pi.signedPeerRecord, 'libp2p-peer-record');\n const eid = envelope.peerId;\n if (!envelope.peerId.equals(p)) {\n this.log(\"bogus peer record obtained through px: peer ID %p doesn't match expected peer %p\", eid, p);\n return;\n }\n if (!(await this.components.peerStore.addressBook.consumePeerRecord(envelope))) {\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_2__.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 // 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 // TODO:rust-libp2p checks `self.backoffs.is_backoff_with_slack()`\n if (!this.direct.has(id) && this.score.score(id) >= 0) {\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);\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) {\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_15__.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_5__.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_5__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 if (acceptance === _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n const cacheEntry = this.mcache.validate(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource.toString(), msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource.toString(), originatingPeers);\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\n // Not valid\n else {\n const cacheEntry = this.mcache.remove(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.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.toString(), msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\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 const prune = [await this.makePrune(id, topic, this.opts.doPX)];\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_7__.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 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))));\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))));\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_9__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_8__.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_9__.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_8__.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_9__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id).protocol === _constants_js__WEBPACK_IMPORTED_MODULE_8__.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 is measured in milliseconds\n // The protobuf has it as a uint64\n const backoff = this.opts.pruneBackoff / 1000;\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_2__.peerIdFromString)(peerId);\n return {\n peerID: id.toBytes(),\n signedPeerRecord: await this.components.peerStore.addressBook.getRawEnvelope(id)\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_9__.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_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_20__.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_9__.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_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)) {\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_20__.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_20__.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) || 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_9__.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_5__.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_9__.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 for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\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_17__.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_8__.GossipsubIDv11;\nfunction gossipsub(init = {}) {\n return (components) => new GossipSub(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 /**\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-rtc/./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 */ \"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/@chainsafe/libp2p-gossipsub/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-rtc/./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 _rpc_cjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.cjs */ \"./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-rtc/./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 _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types.js */ \"./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 /// Peer unsubscribed.\n ChurnReason[\"Unsub\"] = \"unsubscribed\";\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 */\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: ['topic', 'reason']\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: ['topic', 'reason']\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 for each topic',\n labelNames: ['topic', 'acceptance']\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 // 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 msgPublishPeers: 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: ['topic', '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: ['topic', 'status']\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: ['topic', 'error']\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 labelNames: ['topic', 'p']\n }),\n /** Separate score weights */\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 /* 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({ topic, reason }, 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({ topic, reason }, count);\n },\n onReportValidationMcacheHit(hit) {\n this.asyncValidationMcacheHit.inc({ hit: hit ? 'hit' : 'miss' });\n },\n onReportValidation(topicStr, acceptance) {\n const topic = this.toTopic(topicStr);\n this.asyncValidationResult.inc({ topic: topic, acceptance });\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.msgPublishPeers.inc({ topic }, tosendCount);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'direct' }, tosendGroupCount.direct);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'floodsub' }, tosendGroupCount.floodsub);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'mesh' }, tosendGroupCount.mesh);\n this.msgPublishPeersByGroup.inc({ topic, 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.msgReceivedStatus.inc({ topic, 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({ topic, error }, 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-rtc/./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 ? 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-rtc/./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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js": +/*!**************************************************************************!*\ + !*** ./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/@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/@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/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants.js */ \"./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 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 firstSeen: 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-rtc/./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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./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-rtc/./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 _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./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-rtc/./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 _peer_score_params_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./peer-score-params.js */ \"./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/@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/@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/@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/@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 /**\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.firstSeen, _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.firstSeen, _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-rtc/./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) {\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-rtc/./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 abortable_iterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/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 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 }), (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode)(), 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, (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)(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-rtc/./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 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-rtc/./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_pubsub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./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-rtc/./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 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/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../types.js */ \"./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/@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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js": +/*!**************************************************************************!*\ + !*** ./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/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js\");\n/* harmony import */ var _messageIdToString_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./messageIdToString.js */ \"./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/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.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/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-rtc/./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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@chainsafe/libp2p-gossipsub/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/@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-rtc/./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 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-rtc/./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_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/@libp2p/interface-pubsub/dist/src/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_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-rtc/./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 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-rtc/./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-rtc/./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 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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/bytes.js": +/*!*****************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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)\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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/bytes.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/digest.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/digest.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/hasher.js": +/*!*************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/hasher.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/sha2-browser.js": +/*!*******************************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/hashes/sha2-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/varint.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/src/varint.js?"); + +/***/ }), + +/***/ "./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/vendor/varint.js": +/*!*********************************************************************************************!*\ + !*** ./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@chainsafe/libp2p-gossipsub/node_modules/multiformats/vendor/varint.js?"); + +/***/ }), + /***/ "./node_modules/@chainsafe/netmask/dist/src/cidr.js": /*!**********************************************************!*\ !*** ./node_modules/@chainsafe/netmask/dist/src/cidr.js ***! @@ -2520,7 +2806,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 */ \"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_to_string__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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// @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_2__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.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_2__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.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_2__.toString)(key, 'ascii'));\n cipher2.start({ iv: (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_2__.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_2__.toString)(data, 'ascii')));\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.fromString)(cipher2.output.getBytes(), 'ascii');\n }\n };\n}\n//# sourceMappingURL=ciphers-browser.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js?"); +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-rtc/./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js?"); /***/ }), @@ -2531,7 +2817,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 _ciphers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ciphers.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/ciphers-browser.js\");\n/* harmony import */ var _cipher_mode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cipher-mode.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/cipher-mode.js\");\n\n\nasync function create(key, iv) {\n const mode = (0,_cipher_mode_js__WEBPACK_IMPORTED_MODULE_1__.cipherMode)(key);\n const cipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_0__.createCipheriv(mode, key, iv);\n const decipher = _ciphers_js__WEBPACK_IMPORTED_MODULE_0__.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-rtc/./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 */ \"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-rtc/./node_modules/@libp2p/crypto/dist/src/aes/index.js?"); /***/ }), @@ -2542,7 +2828,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 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// 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 // 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', 'deriveBits']);\n const cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt']);\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 // 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', 'deriveBits']);\n const cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['decrypt']);\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-rtc/./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/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-rtc/./node_modules/@libp2p/crypto/dist/src/ciphers/aes-gcm.browser.js?"); /***/ }), @@ -2553,7 +2839,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 await 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-rtc/./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.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-rtc/./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js?"); /***/ }), @@ -2575,7 +2861,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 */ \"aes\": () => (/* reexport module object */ _aes_index_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ \"hmac\": () => (/* reexport module object */ _hmac_index_js__WEBPACK_IMPORTED_MODULE_0__),\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_4__[\"default\"]),\n/* harmony export */ \"randomBytes\": () => (/* reexport safe */ _random_bytes_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"])\n/* harmony export */ });\n/* harmony import */ var _hmac_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hmac/index.js */ \"./node_modules/@libp2p/crypto/dist/src/hmac/index-browser.js\");\n/* harmony import */ var _aes_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./aes/index.js */ \"./node_modules/@libp2p/crypto/dist/src/aes/index.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 _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 _pbkdf2_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbkdf2.js */ \"./node_modules/@libp2p/crypto/dist/src/pbkdf2.js\");\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/dist/src/index.js?"); +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-rtc/./node_modules/@libp2p/crypto/dist/src/index.js?"); /***/ }), @@ -2586,7 +2872,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 _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../webcrypto.js */ \"./node_modules/@libp2p/crypto/dist/src/webcrypto.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.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 uint8arrays_concat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.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_1__[\"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_1__[\"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_1__[\"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_1__[\"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_1__[\"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_4__.concat)([\n Uint8Array.from([4]),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.base64urlToBuffer)(jwk.x, byteLen),\n (0,_util_js__WEBPACK_IMPORTED_MODULE_2__.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_5__.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-rtc/./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_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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/ecdh-browser.js?"); /***/ }), @@ -2597,7 +2883,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 await _noble_ed25519__WEBPACK_IMPORTED_MODULE_0__.sign(msg, privateKeyRaw);\n}\nasync function hashAndVerify(publicKey, sig, msg) {\n return await _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-rtc/./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_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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-browser.js?"); /***/ }), @@ -2608,7 +2894,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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/identity.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 _keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.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\n\n\n\n\n\n\n\nclass Ed25519PublicKey {\n constructor(key) {\n this._key = ensureKey(key, _ed25519_js__WEBPACK_IMPORTED_MODULE_5__.publicKeyLength);\n }\n async verify(data, sig) {\n return await _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_6__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.KeyType.Ed25519,\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 { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Ed25519PrivateKey {\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 await _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_6__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.KeyType.Ed25519,\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 { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_2__.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_4__.identity.digest(this.public.bytes);\n return multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_3__.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 await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_7__.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-rtc/./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_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/@libp2p/crypto/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/@libp2p/crypto/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/@libp2p/crypto/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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/ed25519-class.js?"); /***/ }), @@ -2641,7 +2927,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/@libp2p/crypto/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 await cipher.decrypt(encryptedKey, password);\n}\n//# sourceMappingURL=importer.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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/@libp2p/crypto/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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/importer.js?"); /***/ }), @@ -2652,7 +2938,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_7__[\"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_6__.keyStretcher),\n/* harmony export */ \"keysPBM\": () => (/* reexport module object */ _keys_js__WEBPACK_IMPORTED_MODULE_0__),\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 _keys_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n/* harmony import */ var node_forge_lib_asn1_js__WEBPACK_IMPORTED_MODULE_1__ = __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_2__ = __webpack_require__(/*! node-forge/lib/pbe.js */ \"./node_modules/node-forge/lib/pbe.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _key_stretcher_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./key-stretcher.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.js\");\n/* harmony import */ var _ephemeral_keys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ephemeral-keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ephemeral-keys.js\");\n/* harmony import */ var _importer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./importer.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/importer.js\");\n/* harmony import */ var _rsa_class_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./rsa-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js\");\n/* harmony import */ var _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ed25519-class.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/ed25519-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_9__,\n ed25519: _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__,\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_4__.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 await 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_4__.CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE');\n }\n return await _ed25519_class_js__WEBPACK_IMPORTED_MODULE_10__.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_0__.PublicKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.RSA:\n return supportedKeys.rsa.unmarshalRsaPublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PublicKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.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_0__.PrivateKey.decode(buf);\n const data = decoded.Data ?? new Uint8Array();\n switch (decoded.Type) {\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.RSA:\n return await supportedKeys.rsa.unmarshalRsaPrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.KeyType.Ed25519:\n return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data);\n case _keys_js__WEBPACK_IMPORTED_MODULE_0__.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_8__.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_4__.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_5__.fromString)(der.getBytes(), 'ascii');\n return await supportedKeys.rsa.unmarshalRsaPrivateKey(der);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/dist/src/keys/index.js?"); +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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/index.js?"); /***/ }), @@ -2685,7 +2971,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 */ \"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/@libp2p/crypto/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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/keys.js?"); +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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/keys.js?"); /***/ }), @@ -2696,7 +2982,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_1__[\"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_4__)\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 _random_bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../random-bytes.js */ \"./node_modules/@libp2p/crypto/dist/src/random-bytes.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _rsa_utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rsa-utils.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\n\n\n\n\n\n\nasync function generateKey(bits) {\n const pair = await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_0__[\"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_0__[\"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_0__[\"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_0__[\"default\"].get().subtle.importKey('jwk', key, {\n name: 'RSASSA-PKCS1-v1_5',\n hash: { name: 'SHA-256' }\n }, false, ['verify']);\n return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_6__.CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS');\n }\n return await Promise.all([\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.exportKey('jwk', pair.privateKey),\n _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get().subtle.exportKey('jwk', pair.publicKey)\n ]);\n}\nasync function derivePublicFromPrivate(jwKey) {\n return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_0__[\"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_3__.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-rtc/./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 */ \"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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.js?"); /***/ }), @@ -2707,7 +2993,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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.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 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 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 node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! node-forge/lib/forge.js */ \"./node_modules/node-forge/lib/forge.js\");\n/* harmony import */ var _rsa_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rsa.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/rsa-browser.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 _exporter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n\n\n\n\n\n// @ts-expect-error types are missing\n\n\n\n\nclass RsaPublicKey {\n constructor(key) {\n this._key = key;\n }\n async verify(data, sig) {\n return await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.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_6__.encrypt(this._key, bytes);\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_0__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass RsaPrivateKey {\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey;\n }\n genSecret() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.getRandomValues(16);\n }\n async sign(message) {\n return await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.hashAndSign(this._key, message);\n }\n get public() {\n if (this._publicKey == null) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_6__.decrypt(this._key, bytes);\n }\n marshal() {\n return _rsa_js__WEBPACK_IMPORTED_MODULE_6__.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 async hash() {\n const { bytes } = await multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__.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 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_5__.util.ByteBuffer(this.marshal());\n const asn1 = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__.asn1.fromDer(buffer);\n const privateKey = node_forge_lib_forge_js__WEBPACK_IMPORTED_MODULE_5__.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_5__.pki.encryptRsaPrivateKey(privateKey, password, options);\n }\n else if (format === 'libp2p-key') {\n return await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_8__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_6__.utils.pkcs1ToJwk(bytes);\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nfunction unmarshalRsaPublicKey(bytes) {\n const jwk = _rsa_js__WEBPACK_IMPORTED_MODULE_6__.utils.pkixToJwk(bytes);\n return new RsaPublicKey(jwk);\n}\nasync function fromJwk(jwk) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.unmarshalPrivateKey(jwk);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\nasync function generateKeyPair(bits) {\n const keys = await _rsa_js__WEBPACK_IMPORTED_MODULE_6__.generateKey(bits);\n return new RsaPrivateKey(keys.privateKey, keys.publicKey);\n}\n//# sourceMappingURL=rsa-class.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"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/@libp2p/crypto/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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/rsa-class.js?"); /***/ }), @@ -2718,7 +3004,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 */ \"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 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 _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../util.js */ \"./node_modules/@libp2p/crypto/dist/src/util.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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n\n\n// @ts-expect-error types are missing\n\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_5__.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_3__.bigIntegerToUintBase64url)(privateKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.q),\n dp: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.dP),\n dq: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.bigIntegerToUintBase64url)(privateKey.dQ),\n qi: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.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_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_3__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.e),\n d: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.d),\n p: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.p),\n q: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.q),\n dP: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.dp),\n dQ: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.dq),\n qInv: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.qi)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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_5__.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_3__.bigIntegerToUintBase64url)(publicKey.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.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_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_3__.base64urlToBigInteger)(jwk.n),\n e: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__.base64urlToBigInteger)(jwk.e)\n });\n return (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_4__.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-rtc/./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 */ \"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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/rsa-utils.js?"); /***/ }), @@ -2729,7 +3015,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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/crypto/node_modules/multiformats/src/hashes/sha2-browser.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 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 _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./secp256k1.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/secp256k1.js\");\n/* harmony import */ var _exporter_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./exporter.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/exporter.js\");\n/* harmony import */ var _keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keys.js */ \"./node_modules/@libp2p/crypto/dist/src/keys/keys.js\");\n\n\n\n\n\n\n\nclass Secp256k1PublicKey {\n constructor(key) {\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePublicKey(key);\n this._key = key;\n }\n async verify(data, sig) {\n return await _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.hashAndVerify(this._key, sig, data);\n }\n marshal() {\n return _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.compressPublicKey(this._key);\n }\n get bytes() {\n return _keys_js__WEBPACK_IMPORTED_MODULE_6__.PublicKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.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_0__.sha256.digest(this.bytes);\n return bytes;\n }\n}\nclass Secp256k1PrivateKey {\n constructor(key, publicKey) {\n this._key = key;\n this._publicKey = publicKey ?? _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.computePublicKey(key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePrivateKey(this._key);\n _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.validatePublicKey(this._publicKey);\n }\n async sign(message) {\n return await _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.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_6__.PrivateKey.encode({\n Type: _keys_js__WEBPACK_IMPORTED_MODULE_6__.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_0__.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 await (0,_exporter_js__WEBPACK_IMPORTED_MODULE_5__.exporter)(this.bytes, password);\n }\n else {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.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_4__.generateKey();\n return new Secp256k1PrivateKey(privateKeyBytes);\n}\n//# sourceMappingURL=secp256k1-class.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.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_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/@libp2p/crypto/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-rtc/./node_modules/@libp2p/crypto/dist/src/keys/secp256k1-class.js?"); /***/ }), @@ -2751,7 +3037,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 */ pbkdf2)\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_pbkdf2_js__WEBPACK_IMPORTED_MODULE_0__ = __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_1__ = __webpack_require__(/*! node-forge/lib/util.js */ \"./node_modules/node-forge/lib/util.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// @ts-expect-error types are missing\n\n// @ts-expect-error types are missing\n\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_2__.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_0__(password, salt, iterations, keySize, hasher);\n return node_forge_lib_util_js__WEBPACK_IMPORTED_MODULE_1__.encode64(dek, null);\n}\n//# sourceMappingURL=pbkdf2.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"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-rtc/./node_modules/@libp2p/crypto/dist/src/pbkdf2.js?"); /***/ }), @@ -2762,7 +3048,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 _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/secp256k1 */ \"./node_modules/@noble/secp256k1/lib/esm/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\n\nfunction randomBytes(length) {\n if (isNaN(length) || length <= 0) {\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('random bytes length must be a Number bigger than 0', 'ERR_INVALID_LENGTH');\n }\n return _noble_secp256k1__WEBPACK_IMPORTED_MODULE_0__.utils.randomBytes(length);\n}\n//# sourceMappingURL=random-bytes.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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_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-rtc/./node_modules/@libp2p/crypto/dist/src/random-bytes.js?"); /***/ }), @@ -2773,7 +3059,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 */ \"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_from_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uint8arrays/from-string */ \"./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/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.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_5__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_4__.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_4__.toString)(buf, 'base16'), 16);\n}\nfunction base64urlToBuffer(str, len) {\n let buf = (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_3__.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_5__.concat)([new Uint8Array(len - buf.length), buf]);\n }\n return buf;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"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-rtc/./node_modules/@libp2p/crypto/dist/src/util.js?"); /***/ }), @@ -2920,83 +3206,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \******************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js ***! - \*************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/index.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@libp2p/crypto/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/crypto/node_modules/protons-runtime/dist/src/utils.js?"); - -/***/ }), - /***/ "./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js": /*!*************************************************************************!*\ !*** ./node_modules/@libp2p/interface-peer-discovery/dist/src/index.js ***! @@ -3008,6 +3217,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./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-rtc/./node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/interface-peer-store/dist/src/tags.js": /*!********************************************************************!*\ !*** ./node_modules/@libp2p/interface-peer-store/dist/src/tags.js ***! @@ -3019,6 +3239,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@libp2p/interface-pubsub/dist/src/index.js": +/*!*****************************************************************!*\ + !*** ./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-rtc/./node_modules/@libp2p/interface-pubsub/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/interface-registrar/dist/src/index.js": /*!********************************************************************!*\ !*** ./node_modules/@libp2p/interface-registrar/dist/src/index.js ***! @@ -3217,6 +3448,61 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./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-rtc/./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 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-rtc/./node_modules/@libp2p/peer-collections/dist/src/list.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/map.js": +/*!***************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/dist/src/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 */ \"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 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-rtc/./node_modules/@libp2p/peer-collections/dist/src/map.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/set.js": +/*!***************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/dist/src/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 */ \"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 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-rtc/./node_modules/@libp2p/peer-collections/dist/src/set.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-collections/dist/src/util.js": +/*!****************************************************************!*\ + !*** ./node_modules/@libp2p/peer-collections/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 */ \"mapIterable\": () => (/* binding */ mapIterable)\n/* harmony export */ });\n/**\n * Calls the passed map function on every entry of the passed iterable iterator\n */\nfunction mapIterable(iter, map) {\n const iterator = {\n [Symbol.iterator]: () => {\n return iterator;\n },\n next: () => {\n const next = iter.next();\n const val = next.value;\n if (next.done === true || val == null) {\n const result = {\n done: true,\n value: undefined\n };\n return result;\n }\n return {\n done: false,\n value: map(val)\n };\n }\n };\n return iterator;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-collections/dist/src/util.js?"); + +/***/ }), + /***/ "./node_modules/@libp2p/peer-id-factory/dist/src/index.js": /*!****************************************************************!*\ !*** ./node_modules/@libp2p/peer-id-factory/dist/src/index.js ***! @@ -3224,7 +3510,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 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_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/peer-id/dist/src/index.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 await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 await createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return await createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.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 await createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(pubKey);\n return await 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-rtc/./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_0__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.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_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.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 await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromKeys)((0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.marshalPublicKey)(publicKey));\n}\nasync function createFromPrivKey(privateKey) {\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 await createFromParts(id ?? new Uint8Array(0), privKey, pubKey);\n}\nasync function createFromJSON(obj) {\n return await createFromParts((0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.id, 'base58btc'), obj.privKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.fromString)(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_1__.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 await createFromPrivKey(key);\n }\n else if (pubKey != null) {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_0__.unmarshalPublicKey)(pubKey);\n return await 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-rtc/./node_modules/@libp2p/peer-id-factory/dist/src/index.js?"); /***/ }), @@ -3235,403 +3521,403 @@ 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 */ \"PeerIdProto\": () => (/* binding */ PeerIdProto)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-id-factory/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 PeerIdProto;\n(function (PeerIdProto) {\n let _codec;\n PeerIdProto.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.id != null) {\n w.uint32(10);\n w.bytes(obj.id);\n }\n if (obj.pubKey != null) {\n w.uint32(18);\n w.bytes(obj.pubKey);\n }\n if (obj.privKey != null) {\n w.uint32(26);\n w.bytes(obj.privKey);\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.id = reader.bytes();\n break;\n case 2:\n obj.pubKey = reader.bytes();\n break;\n case 3:\n obj.privKey = 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 PeerIdProto.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerIdProto.codec());\n };\n PeerIdProto.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerIdProto.codec());\n };\n})(PeerIdProto || (PeerIdProto = {}));\n//# sourceMappingURL=proto.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/dist/src/proto.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerIdProto\": () => (/* binding */ PeerIdProto)\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 PeerIdProto;\n(function (PeerIdProto) {\n let _codec;\n PeerIdProto.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.id != null) {\n w.uint32(10);\n w.bytes(obj.id);\n }\n if (obj.pubKey != null) {\n w.uint32(18);\n w.bytes(obj.pubKey);\n }\n if (obj.privKey != null) {\n w.uint32(26);\n w.bytes(obj.privKey);\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.id = reader.bytes();\n break;\n case 2:\n obj.pubKey = reader.bytes();\n break;\n case 3:\n obj.privKey = 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 PeerIdProto.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerIdProto.codec());\n };\n PeerIdProto.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerIdProto.codec());\n };\n})(PeerIdProto || (PeerIdProto = {}));\n//# sourceMappingURL=proto.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/dist/src/proto.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.js ***! - \*******************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/dist/src/index.js": +/*!********************************************************!*\ + !*** ./node_modules/@libp2p/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/peer-id/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base10.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base16.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base2.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base256emoji.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base36.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base64.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base8.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/identity.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/interface.js": +/***/ "./node_modules/@libp2p/peer-id/node_modules/@libp2p/interface-peer-id/dist/src/index.js": /*!***********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/interface.js ***! + !*** ./node_modules/@libp2p/peer-id/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// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/interface.js?"); +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-rtc/./node_modules/@libp2p/peer-id/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.js ***! - \**************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/basics.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 _vendor_base_x_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../vendor/base-x.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js ***! - \*************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base10.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base10.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js": +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base16.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base16.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base2.js": /*!***********************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js ***! + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base2.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/raw.js": +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base256emoji.js": /*!******************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/raw.js ***! + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/codecs/raw.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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base256emoji.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base32.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base32.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/hasher.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/hasher.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base36.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/hasher.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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base36.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.js ***! - \***********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base58.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"identity\": () => (/* binding */ identity)\n/* harmony export */ });\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/identity.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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base58.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/sha2-browser.js ***! - \***************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base64.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/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 */ \"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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base64.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/index.js ***! - \*************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base8.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@libp2p/peer-id-factory/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/@libp2p/peer-id-factory/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/index.js?"); +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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base8.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/interface.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/link/interface.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/link/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js": +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/identity.js": /*!**************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.js ***! + !*** ./node_modules/@libp2p/peer-id/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 */ \"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/@libp2p/peer-id-factory/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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/src/varint.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 _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/identity.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/interface.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/base-x.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bases/interface.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/varint.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/varint.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/basics.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"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-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/multiformats/vendor/varint.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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/basics.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bytes.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js?"); +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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bytes.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!***************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \***************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/cid.js": +/*!***************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js?"); +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/@libp2p/peer-id/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@libp2p/peer-id/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/@libp2p/peer-id/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/@libp2p/peer-id/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/cid.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js ***! - \******************************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/codecs/json.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js?"); +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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/codecs/json.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js ***! - \**********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/codecs/raw.js": +/*!**********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js?"); +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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/codecs/raw.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js ***! - \**********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/digest.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js?"); +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/@libp2p/peer-id/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/digest.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/index.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/hasher.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/index.js?"); +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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/hasher.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/identity.js": +/*!***************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-id-factory/node_modules/protons-runtime/dist/src/utils.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/@libp2p/peer-id/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/identity.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/sha2-browser.js": +/*!*******************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/hashes/sha2-browser.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/index.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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_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/@libp2p/peer-id/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@libp2p/peer-id/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@libp2p/peer-id/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/@libp2p/peer-id/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/interface.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/interface.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/link/interface.js": +/*!**************************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/src/link/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/link/interface.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/src/varint.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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/@libp2p/peer-id/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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/src/varint.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/vendor/base-x.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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// 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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/vendor/base-x.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-id/node_modules/multiformats/vendor/varint.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-id/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@libp2p/peer-id/node_modules/multiformats/vendor/varint.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": +/*!************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! + \************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Envelope\": () => (/* binding */ Envelope)\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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/dist/src/envelope/index.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-record/dist/src/envelope/envelope.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 uint8arraylist__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/dist/src/errors.js": +/*!*************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/errors.js?"); + +/***/ }), + +/***/ "./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-rtc/./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 ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\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 _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 _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 _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! + \******************************************************************************/ +/***/ ((__unused_webpack___webpack_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 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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); /***/ }), @@ -3642,7 +3928,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 */ \"PeerStoreAddressBook\": () => (/* binding */ PeerStoreAddressBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.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/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:address-book');\nconst EVENT_NAME = 'change:multiaddrs';\nasync function allowAll() {\n return true;\n}\nclass PeerStoreAddressBook {\n constructor(dispatchEvent, store, addressFilter) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n this.addressFilter = addressFilter ?? allowAll;\n }\n /**\n * ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.\n * This will return a boolean that indicates if the record was successfully processed and added\n * into the AddressBook.\n */\n async consumePeerRecord(envelope) {\n log.trace('consumePeerRecord await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('consumePeerRecord got write lock');\n let peerId;\n let peer;\n let updatedPeer;\n try {\n let peerRecord;\n try {\n peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(envelope.payload);\n }\n catch (err) {\n log.error('invalid peer record received');\n return false;\n }\n peerId = peerRecord.peerId;\n const multiaddrs = peerRecord.multiaddrs;\n // Verify peerId\n if (!peerId.equals(envelope.peerId)) {\n log('signing key does not match PeerId in the PeerRecord');\n return false;\n }\n // ensure the record has multiaddrs\n if (multiaddrs == null || multiaddrs.length === 0) {\n return false;\n }\n if (await this.store.has(peerId)) {\n peer = await this.store.load(peerId);\n if (peer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(peer.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 return false;\n }\n }\n }\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter, true);\n // Replace unsigned addresses by the new ones from the record\n // TODO: Once we have ttls for the addresses, we should merge these in\n updatedPeer = await this.store.patchOrCreate(peerId, {\n addresses,\n peerRecordEnvelope: envelope.marshal().subarray()\n });\n log('stored provided peer record for %p', peerRecord.peerId);\n }\n finally {\n log.trace('consumePeerRecord release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(({ multiaddr }) => multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n return true;\n }\n async getRawEnvelope(peerId) {\n log.trace('getRawEnvelope await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getRawEnvelope got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.peerRecordEnvelope;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getRawEnvelope release read lock');\n release();\n }\n }\n /**\n * Get an Envelope containing a PeerRecord for the given peer.\n * Returns undefined if no record exists.\n */\n async getPeerRecord(peerId) {\n const raw = await this.getRawEnvelope(peerId);\n if (raw == null) {\n return undefined;\n }\n return await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(raw);\n }\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.addresses;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let hasPeer = false;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length && addresses.length === peer.addresses.length) {\n // not changing anything, no need to update\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, { addresses });\n log('set multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set multiaddrs for %p', peerId);\n log('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (!hasPeer) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async add(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let hasPeer;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, { addresses });\n log('added multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (hasPeer === true) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n addresses: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: [],\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n }\n }\n}\nasync function filterMultiaddrs(peerId, multiaddrs, addressFilter, isCertified = false) {\n const output = [];\n await Promise.all(multiaddrs.map(async (multiaddr) => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(multiaddr)) {\n log.error('multiaddr must be an instance of Multiaddr');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddr must be an instance of Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const include = await addressFilter(peerId, multiaddr);\n if (!include) {\n return;\n }\n output.push({\n multiaddr,\n isCertified\n });\n }));\n return output;\n}\n//# sourceMappingURL=address-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/address-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreAddressBook\": () => (/* binding */ PeerStoreAddressBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.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/* 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 _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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:address-book');\nconst EVENT_NAME = 'change:multiaddrs';\nasync function allowAll() {\n return true;\n}\nclass PeerStoreAddressBook {\n constructor(dispatchEvent, store, addressFilter) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n this.addressFilter = addressFilter ?? allowAll;\n }\n /**\n * ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.\n * This will return a boolean that indicates if the record was successfully processed and added\n * into the AddressBook.\n */\n async consumePeerRecord(envelope) {\n log.trace('consumePeerRecord await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('consumePeerRecord got write lock');\n let peerId;\n let peer;\n let updatedPeer;\n try {\n let peerRecord;\n try {\n peerRecord = _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.PeerRecord.createFromProtobuf(envelope.payload);\n }\n catch (err) {\n log.error('invalid peer record received');\n return false;\n }\n peerId = peerRecord.peerId;\n const multiaddrs = peerRecord.multiaddrs;\n // Verify peerId\n if (!peerId.equals(envelope.peerId)) {\n log('signing key does not match PeerId in the PeerRecord');\n return false;\n }\n // ensure the record has multiaddrs\n if (multiaddrs == null || multiaddrs.length === 0) {\n return false;\n }\n if (await this.store.has(peerId)) {\n peer = await this.store.load(peerId);\n if (peer.peerRecordEnvelope != null) {\n const storedEnvelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(peer.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 return false;\n }\n }\n }\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter, true);\n // Replace unsigned addresses by the new ones from the record\n // TODO: Once we have ttls for the addresses, we should merge these in\n updatedPeer = await this.store.patchOrCreate(peerId, {\n addresses,\n peerRecordEnvelope: envelope.marshal().subarray()\n });\n log('stored provided peer record for %p', peerRecord.peerId);\n }\n finally {\n log.trace('consumePeerRecord release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(({ multiaddr }) => multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n return true;\n }\n async getRawEnvelope(peerId) {\n log.trace('getRawEnvelope await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getRawEnvelope got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.peerRecordEnvelope;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getRawEnvelope release read lock');\n release();\n }\n }\n /**\n * Get an Envelope containing a PeerRecord for the given peer.\n * Returns undefined if no record exists.\n */\n async getPeerRecord(peerId) {\n const raw = await this.getRawEnvelope(peerId);\n if (raw == null) {\n return undefined;\n }\n return await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_4__.RecordEnvelope.createFromProtobuf(raw);\n }\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.addresses;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let hasPeer = false;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length && addresses.length === peer.addresses.length) {\n // not changing anything, no need to update\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, { addresses });\n log('set multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set multiaddrs for %p', peerId);\n log('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (!hasPeer) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async add(peerId, multiaddrs) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(multiaddrs)) {\n log.error('multiaddrs must be an array of Multiaddrs');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddrs must be an array of Multiaddrs', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let hasPeer;\n let peer;\n let updatedPeer;\n try {\n const addresses = await filterMultiaddrs(peerId, multiaddrs, this.addressFilter);\n // No valid addresses found\n if (addresses.length === 0) {\n return;\n }\n try {\n peer = await this.store.load(peerId);\n hasPeer = true;\n if (new Set([\n ...addresses.map(({ multiaddr }) => multiaddr.toString()),\n ...peer.addresses.map(({ multiaddr }) => multiaddr.toString())\n ]).size === peer.addresses.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, { addresses });\n log('added multiaddrs for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n // Notify the existence of a new peer\n if (hasPeer === true) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent('peer', {\n detail: {\n id: peerId,\n multiaddrs: updatedPeer.addresses.map(addr => addr.multiaddr),\n protocols: updatedPeer.protocols\n }\n }));\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_5__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n addresses: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_6__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n multiaddrs: [],\n oldMultiaddrs: peer == null ? [] : peer.addresses.map(({ multiaddr }) => multiaddr)\n }\n }));\n }\n }\n}\nasync function filterMultiaddrs(peerId, multiaddrs, addressFilter, isCertified = false) {\n const output = [];\n await Promise.all(multiaddrs.map(async (multiaddr) => {\n if (!(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.isMultiaddr)(multiaddr)) {\n log.error('multiaddr must be an instance of Multiaddr');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('multiaddr must be an instance of Multiaddr', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n const include = await addressFilter(peerId, multiaddr);\n if (!include) {\n return;\n }\n output.push({\n multiaddr,\n isCertified\n });\n }));\n return output;\n}\n//# sourceMappingURL=address-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/address-book.js?"); /***/ }), @@ -3675,7 +3961,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 */ \"PeerStoreKeyBook\": () => (/* binding */ PeerStoreKeyBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:key-book');\nconst EVENT_NAME = 'change:pubkey';\nclass PeerStoreKeyBook {\n /**\n * The KeyBook is responsible for keeping the known public keys of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Set the Peer public key\n */\n async set(peerId, publicKey) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(publicKey instanceof Uint8Array)) {\n log.error('publicKey must be an instance of Uint8Array to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('publicKey must be an instance of PublicKey', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let updatedKey = false;\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n if ((peer.pubKey != null) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(peer.pubKey, publicKey)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: publicKey\n });\n updatedKey = true;\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n if (updatedKey) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n }\n /**\n * Get Public key of the given PeerId, if stored\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('get await write lock');\n const release = await this.store.lock.readLock();\n log.trace('get got write lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.pubKey;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log('get release write lock');\n release();\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: undefined\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey: undefined,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n}\n//# sourceMappingURL=key-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/key-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreKeyBook\": () => (/* binding */ PeerStoreKeyBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:key-book');\nconst EVENT_NAME = 'change:pubkey';\nclass PeerStoreKeyBook {\n /**\n * The KeyBook is responsible for keeping the known public keys of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Set the Peer public key\n */\n async set(peerId, publicKey) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(publicKey instanceof Uint8Array)) {\n log.error('publicKey must be an instance of Uint8Array to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('publicKey must be an instance of PublicKey', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let updatedKey = false;\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n if ((peer.pubKey != null) && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(peer.pubKey, publicKey)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: publicKey\n });\n updatedKey = true;\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n if (updatedKey) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n }\n /**\n * Get Public key of the given PeerId, if stored\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('get await write lock');\n const release = await this.store.lock.readLock();\n log.trace('get got write lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.pubKey;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log('get release write lock');\n release();\n }\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n pubKey: undefined\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n publicKey: undefined,\n oldPublicKey: peer == null ? undefined : peer.pubKey\n }\n }));\n }\n}\n//# sourceMappingURL=key-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/key-book.js?"); /***/ }), @@ -3686,7 +3972,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 */ \"PeerStoreMetadataBook\": () => (/* binding */ PeerStoreMetadataBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.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 _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:metadata-book');\nconst EVENT_NAME = 'change:metadata';\nclass PeerStoreMetadataBook {\n /**\n * The MetadataBook is responsible for keeping metadata\n * about known peers\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Get the known data of a provided peer\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(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 const peer = await this.store.load(peerId);\n return peer.metadata;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return new Map();\n }\n /**\n * Get specific metadata value, if it exists\n */\n async getValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('getValue await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getValue got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.metadata.get(key);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getValue release write lock');\n release();\n }\n }\n async set(peerId, metadata) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(metadata instanceof Map)) {\n log.error('valid metadata must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid metadata must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.mergeOrCreate(peerId, {\n metadata\n });\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n /**\n * Set metadata key and value of a provided peer\n */\n async setValue(peerId, key, value) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (typeof key !== 'string' || !(value instanceof Uint8Array)) {\n log.error('valid key and value must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid key and value must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('setValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('setValue got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const existingValue = peer.metadata.get(key);\n if (existingValue != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(value, existingValue)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n metadata: new Map([[key, value]])\n });\n }\n finally {\n log.trace('setValue release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: updatedPeer.metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n if (peer != null) {\n await this.store.patch(peerId, {\n metadata: new Map()\n });\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: new Map(),\n oldMetadata: peer.metadata\n }\n }));\n }\n }\n async deleteValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('deleteValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('deleteValue got write lock');\n let metadata;\n let peer;\n try {\n peer = await this.store.load(peerId);\n metadata = peer.metadata;\n metadata.delete(key);\n await this.store.patch(peerId, {\n metadata\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('deleteValue release write lock');\n release();\n }\n if (metadata != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n }\n}\n//# sourceMappingURL=metadata-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/metadata-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreMetadataBook\": () => (/* binding */ PeerStoreMetadataBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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 uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:metadata-book');\nconst EVENT_NAME = 'change:metadata';\nclass PeerStoreMetadataBook {\n /**\n * The MetadataBook is responsible for keeping metadata\n * about known peers\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n /**\n * Get the known data of a provided peer\n */\n async get(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(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 const peer = await this.store.load(peerId);\n return peer.metadata;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return new Map();\n }\n /**\n * Get specific metadata value, if it exists\n */\n async getValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('getValue await read lock');\n const release = await this.store.lock.readLock();\n log.trace('getValue got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.metadata.get(key);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('getValue release write lock');\n release();\n }\n }\n async set(peerId, metadata) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!(metadata instanceof Map)) {\n log.error('valid metadata must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid metadata must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.mergeOrCreate(peerId, {\n metadata\n });\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n /**\n * Set metadata key and value of a provided peer\n */\n async setValue(peerId, key, value) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (typeof key !== 'string' || !(value instanceof Uint8Array)) {\n log.error('valid key and value must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('valid key and value must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('setValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('setValue got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const existingValue = peer.metadata.get(key);\n if (existingValue != null && (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_4__.equals)(value, existingValue)) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n metadata: new Map([[key, value]])\n });\n }\n finally {\n log.trace('setValue release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: updatedPeer.metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n if (peer != null) {\n await this.store.patch(peerId, {\n metadata: new Map()\n });\n }\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata: new Map(),\n oldMetadata: peer.metadata\n }\n }));\n }\n }\n async deleteValue(peerId, key) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('deleteValue await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('deleteValue got write lock');\n let metadata;\n let peer;\n try {\n peer = await this.store.load(peerId);\n metadata = peer.metadata;\n metadata.delete(key);\n await this.store.patch(peerId, {\n metadata\n });\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('deleteValue release write lock');\n release();\n }\n if (metadata != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n metadata,\n oldMetadata: peer == null ? new Map() : peer.metadata\n }\n }));\n }\n }\n}\n//# sourceMappingURL=metadata-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/metadata-book.js?"); /***/ }), @@ -3697,7 +3983,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 */ \"Address\": () => (/* binding */ Address),\n/* harmony export */ \"Metadata\": () => (/* binding */ Metadata),\n/* harmony export */ \"Peer\": () => (/* binding */ Peer)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 _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.metadata != null) {\n for (const value of obj.metadata) {\n w.uint32(26);\n Metadata.codec().encode(value, w);\n }\n }\n if (obj.pubKey != null) {\n w.uint32(34);\n w.bytes(obj.pubKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: []\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 3:\n obj.metadata.push(Metadata.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pubKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = 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.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 Metadata;\n(function (Metadata) {\n let _codec;\n Metadata.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 Metadata.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Metadata.codec());\n };\n Metadata.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Metadata.codec());\n };\n})(Metadata || (Metadata = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"Address\": () => (/* binding */ Address),\n/* harmony export */ \"Metadata\": () => (/* binding */ Metadata),\n/* harmony export */ \"Peer\": () => (/* binding */ Peer)\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 _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.metadata != null) {\n for (const value of obj.metadata) {\n w.uint32(26);\n Metadata.codec().encode(value, w);\n }\n }\n if (obj.pubKey != null) {\n w.uint32(34);\n w.bytes(obj.pubKey);\n }\n if (obj.peerRecordEnvelope != null) {\n w.uint32(42);\n w.bytes(obj.peerRecordEnvelope);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n addresses: [],\n protocols: [],\n metadata: []\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 3:\n obj.metadata.push(Metadata.codec().decode(reader, reader.uint32()));\n break;\n case 4:\n obj.pubKey = reader.bytes();\n break;\n case 5:\n obj.peerRecordEnvelope = 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.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 Metadata;\n(function (Metadata) {\n let _codec;\n Metadata.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 Metadata.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Metadata.codec());\n };\n Metadata.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Metadata.codec());\n };\n})(Metadata || (Metadata = {}));\n//# sourceMappingURL=peer.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/pb/peer.js?"); /***/ }), @@ -3708,7 +3994,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 */ \"Tag\": () => (/* binding */ Tag),\n/* harmony export */ \"Tags\": () => (/* binding */ Tags)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 Tags;\n(function (Tags) {\n let _codec;\n Tags.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.tags != null) {\n for (const value of obj.tags) {\n w.uint32(10);\n Tag.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n tags: []\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.tags.push(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 Tags.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tags.codec());\n };\n Tags.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tags.codec());\n };\n})(Tags || (Tags = {}));\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.name != null && obj.name !== '')) {\n w.uint32(10);\n w.string(obj.name);\n }\n if (obj.value != null) {\n w.uint32(16);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(24);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n name: ''\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.name = reader.string();\n break;\n case 2:\n obj.value = reader.uint32();\n break;\n case 3:\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=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/pb/tags.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Tag\": () => (/* binding */ Tag),\n/* harmony export */ \"Tags\": () => (/* binding */ Tags)\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 Tags;\n(function (Tags) {\n let _codec;\n Tags.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.tags != null) {\n for (const value of obj.tags) {\n w.uint32(10);\n Tag.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n tags: []\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.tags.push(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 Tags.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Tags.codec());\n };\n Tags.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Tags.codec());\n };\n})(Tags || (Tags = {}));\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.name != null && obj.name !== '')) {\n w.uint32(10);\n w.string(obj.name);\n }\n if (obj.value != null) {\n w.uint32(16);\n w.uint32(obj.value);\n }\n if (obj.expiry != null) {\n w.uint32(24);\n w.uint64(obj.expiry);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n name: ''\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.name = reader.string();\n break;\n case 2:\n obj.value = reader.uint32();\n break;\n case 3:\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=tags.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/pb/tags.js?"); /***/ }), @@ -3719,7 +4005,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 */ \"PeerStoreProtoBook\": () => (/* binding */ PeerStoreProtoBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/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\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:proto-book');\nconst EVENT_NAME = 'change:protocols';\nclass PeerStoreProtoBook {\n /**\n * The ProtoBook is responsible for keeping the known supported\n * protocols of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n async get(peerId) {\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.protocols;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n log('stored provided protocols for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async add(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...peer.protocols,\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n protocols\n });\n log('added provided protocols for %p', peerId);\n }\n finally {\n log.trace('add release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async remove(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('remove await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('remove got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const protocolSet = new Set(peer.protocols);\n for (const protocol of protocols) {\n protocolSet.delete(protocol);\n }\n if (peer.protocols.length === protocolSet.size) {\n return;\n }\n protocols = Array.from(protocolSet);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n }\n finally {\n log.trace('remove release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n protocols: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: [],\n oldProtocols: peer.protocols\n }\n }));\n }\n }\n}\n//# sourceMappingURL=proto-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/proto-book.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerStoreProtoBook\": () => (/* binding */ PeerStoreProtoBook)\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_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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 _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_interfaces_events__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:proto-book');\nconst EVENT_NAME = 'change:protocols';\nclass PeerStoreProtoBook {\n /**\n * The ProtoBook is responsible for keeping the known supported\n * protocols of a peer\n */\n constructor(dispatchEvent, store) {\n this.dispatchEvent = dispatchEvent;\n this.store = store;\n }\n async get(peerId) {\n log.trace('get wait for read lock');\n const release = await this.store.lock.readLock();\n log.trace('get got read lock');\n try {\n const peer = await this.store.load(peerId);\n return peer.protocols;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n finally {\n log.trace('get release read lock');\n release();\n }\n return [];\n }\n async set(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('set await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('set got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n log('stored provided protocols for %p', peerId);\n }\n finally {\n log.trace('set release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async add(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('add await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('add got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n if (new Set([\n ...peer.protocols,\n ...protocols\n ]).size === peer.protocols.length) {\n return;\n }\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.mergeOrCreate(peerId, {\n protocols\n });\n log('added provided protocols for %p', peerId);\n }\n finally {\n log.trace('add release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async remove(peerId, protocols) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n if (!Array.isArray(protocols)) {\n log.error('protocols must be provided to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_1__.CodeError('protocols must be provided', _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_INVALID_PARAMETERS);\n }\n log.trace('remove await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('remove got write lock');\n let peer;\n let updatedPeer;\n try {\n try {\n peer = await this.store.load(peerId);\n const protocolSet = new Set(peer.protocols);\n for (const protocol of protocols) {\n protocolSet.delete(protocol);\n }\n if (peer.protocols.length === protocolSet.size) {\n return;\n }\n protocols = Array.from(protocolSet);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n updatedPeer = await this.store.patchOrCreate(peerId, {\n protocols\n });\n }\n finally {\n log.trace('remove release write lock');\n release();\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: updatedPeer.protocols,\n oldProtocols: peer == null ? [] : peer.protocols\n }\n }));\n }\n async delete(peerId) {\n peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_3__.peerIdFromPeerId)(peerId);\n log.trace('delete await write lock');\n const release = await this.store.lock.writeLock();\n log.trace('delete got write lock');\n let peer;\n try {\n try {\n peer = await this.store.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_2__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n }\n await this.store.patchOrCreate(peerId, {\n protocols: []\n });\n }\n finally {\n log.trace('delete release write lock');\n release();\n }\n if (peer != null) {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent(EVENT_NAME, {\n detail: {\n peerId,\n protocols: [],\n oldProtocols: peer.protocols\n }\n }));\n }\n }\n}\n//# sourceMappingURL=proto-book.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/proto-book.js?"); /***/ }), @@ -3730,172 +4016,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 */ \"PersistentStore\": () => (/* binding */ PersistentStore)\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-store/node_modules/@libp2p/peer-id/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 _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/peer-store/dist/src/errors.js\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:store');\nconst NAMESPACE_COMMON = '/peers/';\nclass PersistentStore {\n constructor(components) {\n this.components = components;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n _peerIdToDatastoreKey(peerId) {\n if (peerId.type == null) {\n log.error('peerId must be an instance of peer-id to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('peerId must be an instance of peer-id', _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_4__.Key(`${NAMESPACE_COMMON}${b32key}`);\n }\n async has(peerId) {\n return await this.components.datastore.has(this._peerIdToDatastoreKey(peerId));\n }\n async delete(peerId) {\n await this.components.datastore.delete(this._peerIdToDatastoreKey(peerId));\n }\n async load(peerId) {\n const buf = await this.components.datastore.get(this._peerIdToDatastoreKey(peerId));\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.decode(buf);\n const metadata = new Map();\n for (const meta of peer.metadata) {\n metadata.set(meta.key, meta.value);\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_6__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata,\n pubKey: peer.pubKey ?? undefined,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined\n };\n }\n async save(peer) {\n if (peer.pubKey != null && peer.id.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__.equals)(peer.pubKey, peer.id.publicKey)) {\n log.error('peer publicKey bytes do not match peer id publicKey bytes');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n // dedupe addresses\n const addressSet = new Set();\n const addresses = peer.addresses\n .filter(address => {\n if (addressSet.has(address.multiaddr.toString())) {\n return false;\n }\n addressSet.add(address.multiaddr.toString());\n return true;\n })\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ multiaddr, isCertified }) => ({\n multiaddr: multiaddr.bytes,\n isCertified\n }));\n const metadata = [];\n [...peer.metadata.keys()].sort().forEach(key => {\n const value = peer.metadata.get(key);\n if (value != null) {\n metadata.push({ key, value });\n }\n });\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.encode({\n addresses,\n protocols: peer.protocols.sort(),\n pubKey: peer.pubKey,\n metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope\n });\n await this.components.datastore.put(this._peerIdToDatastoreKey(peer.id), buf.subarray());\n return await this.load(peer.id);\n }\n async patch(peerId, data) {\n const peer = await this.load(peerId);\n return await this._patch(peerId, data, peer);\n }\n async patchOrCreate(peerId, data) {\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._patch(peerId, data, peer);\n }\n async _patch(peerId, data, peer) {\n return await this.save({\n ...peer,\n ...data,\n id: peerId\n });\n }\n async merge(peerId, data) {\n const peer = await this.load(peerId);\n return await this._merge(peerId, data, peer);\n }\n async mergeOrCreate(peerId, data) {\n /** @type {Peer} */\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._merge(peerId, data, peer);\n }\n async _merge(peerId, data, peer) {\n // if the peer has certified addresses, use those in\n // favour of the supplied versions\n const addresses = new Map();\n peer.addresses.forEach((addr) => {\n addresses.set(addr.multiaddr.toString(), addr.isCertified);\n });\n (data.addresses ?? []).forEach(addr => {\n const addrString = addr.multiaddr.toString();\n const isAlreadyCertified = Boolean(addresses.get(addrString));\n const isCertified = isAlreadyCertified || addr.isCertified;\n addresses.set(addrString, isCertified);\n });\n return await this.save({\n id: peerId,\n addresses: Array.from(addresses.entries()).map(([addrStr, isCertified]) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addrStr),\n isCertified\n };\n }),\n protocols: Array.from(new Set([\n ...(peer.protocols ?? []),\n ...(data.protocols ?? [])\n ])),\n metadata: new Map([\n ...(peer.metadata?.entries() ?? []),\n ...(data.metadata?.entries() ?? [])\n ]),\n pubKey: data.pubKey ?? (peer != null ? peer.pubKey : undefined),\n peerRecordEnvelope: data.peerRecordEnvelope ?? (peer != null ? peer.peerRecordEnvelope : undefined)\n });\n }\n async *all() {\n for await (const key of this.components.datastore.queryKeys({\n prefix: NAMESPACE_COMMON\n })) {\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_5__.base32.decode(base32Str);\n yield this.load((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(buf));\n }\n }\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/store.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \********************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*****************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/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-store/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-store/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@libp2p/peer-store/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js": -/*!*********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***********************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.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_1__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.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_11__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.toString)(addrBytes, 'base32');\n const port = bytes2port(portBytes);\n return `${addr}:${port}`;\n}\n//# sourceMappingURL=convert.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js": -/*!***************************************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-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 */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js": -/*!*********************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!******************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!*******************************************************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \*******************************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc-direct'],\n [281, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); +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_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 _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.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/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@libp2p/peer-store/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/@libp2p/peer-store/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/peer.js */ \"./node_modules/@libp2p/peer-store/dist/src/pb/peer.js\");\n/* harmony import */ var mortice__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! mortice */ \"./node_modules/mortice/dist/src/index.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:peer-store:store');\nconst NAMESPACE_COMMON = '/peers/';\nclass PersistentStore {\n constructor(components) {\n this.components = components;\n this.lock = (0,mortice__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n name: 'peer-store',\n singleProcess: true\n });\n }\n _peerIdToDatastoreKey(peerId) {\n if (peerId.type == null) {\n log.error('peerId must be an instance of peer-id to store data');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('peerId must be an instance of peer-id', _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_4__.Key(`${NAMESPACE_COMMON}${b32key}`);\n }\n async has(peerId) {\n return await this.components.datastore.has(this._peerIdToDatastoreKey(peerId));\n }\n async delete(peerId) {\n await this.components.datastore.delete(this._peerIdToDatastoreKey(peerId));\n }\n async load(peerId) {\n const buf = await this.components.datastore.get(this._peerIdToDatastoreKey(peerId));\n const peer = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.decode(buf);\n const metadata = new Map();\n for (const meta of peer.metadata) {\n metadata.set(meta.key, meta.value);\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_6__.multiaddr)(ma),\n isCertified: isCertified ?? false\n };\n }),\n metadata,\n pubKey: peer.pubKey ?? undefined,\n peerRecordEnvelope: peer.peerRecordEnvelope ?? undefined\n };\n }\n async save(peer) {\n if (peer.pubKey != null && peer.id.publicKey != null && !(0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_9__.equals)(peer.pubKey, peer.id.publicKey)) {\n log.error('peer publicKey bytes do not match peer id publicKey bytes');\n throw new _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_2__.CodeError('publicKey bytes do not match peer id publicKey bytes', _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_PARAMETERS);\n }\n // dedupe addresses\n const addressSet = new Set();\n const addresses = peer.addresses\n .filter(address => {\n if (addressSet.has(address.multiaddr.toString())) {\n return false;\n }\n addressSet.add(address.multiaddr.toString());\n return true;\n })\n .sort((a, b) => {\n return a.multiaddr.toString().localeCompare(b.multiaddr.toString());\n })\n .map(({ multiaddr, isCertified }) => ({\n multiaddr: multiaddr.bytes,\n isCertified\n }));\n const metadata = [];\n [...peer.metadata.keys()].sort().forEach(key => {\n const value = peer.metadata.get(key);\n if (value != null) {\n metadata.push({ key, value });\n }\n });\n const buf = _pb_peer_js__WEBPACK_IMPORTED_MODULE_7__.Peer.encode({\n addresses,\n protocols: peer.protocols.sort(),\n pubKey: peer.pubKey,\n metadata,\n peerRecordEnvelope: peer.peerRecordEnvelope\n });\n await this.components.datastore.put(this._peerIdToDatastoreKey(peer.id), buf.subarray());\n return await this.load(peer.id);\n }\n async patch(peerId, data) {\n const peer = await this.load(peerId);\n return await this._patch(peerId, data, peer);\n }\n async patchOrCreate(peerId, data) {\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._patch(peerId, data, peer);\n }\n async _patch(peerId, data, peer) {\n return await this.save({\n ...peer,\n ...data,\n id: peerId\n });\n }\n async merge(peerId, data) {\n const peer = await this.load(peerId);\n return await this._merge(peerId, data, peer);\n }\n async mergeOrCreate(peerId, data) {\n /** @type {Peer} */\n let peer;\n try {\n peer = await this.load(peerId);\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NOT_FOUND) {\n throw err;\n }\n peer = { id: peerId, addresses: [], protocols: [], metadata: new Map() };\n }\n return await this._merge(peerId, data, peer);\n }\n async _merge(peerId, data, peer) {\n // if the peer has certified addresses, use those in\n // favour of the supplied versions\n const addresses = new Map();\n peer.addresses.forEach((addr) => {\n addresses.set(addr.multiaddr.toString(), addr.isCertified);\n });\n (data.addresses ?? []).forEach(addr => {\n const addrString = addr.multiaddr.toString();\n const isAlreadyCertified = Boolean(addresses.get(addrString));\n const isCertified = isAlreadyCertified || addr.isCertified;\n addresses.set(addrString, isCertified);\n });\n return await this.save({\n id: peerId,\n addresses: Array.from(addresses.entries()).map(([addrStr, isCertified]) => {\n return {\n multiaddr: (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addrStr),\n isCertified\n };\n }),\n protocols: Array.from(new Set([\n ...(peer.protocols ?? []),\n ...(data.protocols ?? [])\n ])),\n metadata: new Map([\n ...(peer.metadata?.entries() ?? []),\n ...(data.metadata?.entries() ?? [])\n ]),\n pubKey: data.pubKey ?? (peer != null ? peer.pubKey : undefined),\n peerRecordEnvelope: data.peerRecordEnvelope ?? (peer != null ? peer.peerRecordEnvelope : undefined)\n });\n }\n async *all() {\n for await (const key of this.components.datastore.queryKeys({\n prefix: NAMESPACE_COMMON\n })) {\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_5__.base32.decode(base32Str);\n yield this.load((0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromBytes)(buf));\n }\n }\n}\n//# sourceMappingURL=store.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/dist/src/store.js?"); /***/ }), @@ -4251,80 +4372,102 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.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 /**\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-rtc/./node_modules/@libp2p/pubsub/dist/src/errors.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.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 */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js?"); +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 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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/sha2-browser.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@libp2p/pubsub/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/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_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_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_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_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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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-rtc/./node_modules/@libp2p/pubsub/dist/src/utils.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js ***! - \*************************************************************************************************/ +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/src/bytes.js": +/*!****************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js?"); +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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/src/bytes.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/digest.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js?"); +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/@libp2p/pubsub/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@libp2p/pubsub/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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/digest.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js ***! - \*****************************************************************************************/ +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/hasher.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js?"); +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/@libp2p/pubsub/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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/hasher.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/index.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/index.js ***! - \****************************************************************************************/ +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/sha2-browser.js": +/*!******************************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/index.js?"); +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/@libp2p/pubsub/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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/src/hashes/sha2-browser.js?"); /***/ }), -/***/ "./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.js ***! - \****************************************************************************************/ +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/src/varint.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@libp2p/peer-store/node_modules/protons-runtime/dist/src/utils.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/@libp2p/pubsub/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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/src/varint.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/pubsub/node_modules/multiformats/vendor/varint.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@libp2p/pubsub/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@libp2p/pubsub/node_modules/multiformats/vendor/varint.js?"); + +/***/ }), + +/***/ "./node_modules/@libp2p/topology/dist/src/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/@libp2p/topology/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 */ \"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 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 get [_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol]() {\n return true;\n }\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-rtc/./node_modules/@libp2p/topology/dist/src/index.js?"); /***/ }), @@ -5567,7 +5710,7 @@ 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 */ \"ConnectionManager\": () => (/* reexport safe */ _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__.ConnectionManager),\n/* harmony export */ \"DefaultPubSubTopic\": () => (/* reexport safe */ _lib_constants_js__WEBPACK_IMPORTED_MODULE_0__.DefaultPubSubTopic),\n/* harmony export */ \"DefaultUserAgent\": () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__.DefaultUserAgent),\n/* harmony export */ \"KeepAliveManager\": () => (/* reexport safe */ _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__.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_7__.PageDirection),\n/* harmony export */ \"StoreCodec\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.StoreCodec),\n/* harmony export */ \"WakuNode\": () => (/* reexport safe */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__.WakuNode),\n/* harmony export */ \"createCursor\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_8__.waitForRemotePeer),\n/* harmony export */ \"waku\": () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__),\n/* harmony export */ \"wakuFilter\": () => (/* reexport safe */ _lib_filter_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ \"wakuGossipSub\": () => (/* reexport safe */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuGossipSub),\n/* harmony export */ \"wakuLightPush\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuLightPush),\n/* harmony export */ \"wakuRelay\": () => (/* reexport safe */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuRelay),\n/* harmony export */ \"wakuStore\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_relay\": () => (/* reexport module object */ _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ \"waku_store\": () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__)\n/* harmony export */ });\n/* harmony import */ var _lib_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/waku.js */ \"./node_modules/@waku/core/dist/lib/waku.js\");\n/* harmony import */ var _lib_message_version_0_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/message/version_0.js */ \"./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/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/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/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_relay_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/relay/index.js */ \"./node_modules/@waku/core/dist/lib/relay/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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_9__.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_10__.KeepAliveManager),\n/* harmony export */ \"LightPushCodec\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__.LightPushCodec),\n/* harmony export */ \"PageDirection\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.PageDirection),\n/* harmony export */ \"StoreCodec\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.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_7__.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_8__.waitForRemotePeer),\n/* harmony export */ \"waku\": () => (/* reexport module object */ _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__),\n/* harmony export */ \"wakuFilterV1\": () => (/* reexport safe */ _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__.wakuFilter),\n/* harmony export */ \"wakuFilterV2\": () => (/* reexport safe */ _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__.wakuFilterV2),\n/* harmony export */ \"wakuLightPush\": () => (/* reexport safe */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__.wakuLightPush),\n/* harmony export */ \"wakuStore\": () => (/* reexport safe */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__.wakuStore),\n/* harmony export */ \"waku_filter_v1\": () => (/* reexport module object */ _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__),\n/* harmony export */ \"waku_filter_v2\": () => (/* reexport module object */ _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__),\n/* harmony export */ \"waku_light_push\": () => (/* reexport module object */ _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ \"waku_store\": () => (/* reexport module object */ _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__)\n/* harmony export */ });\n/* harmony import */ var _lib_waku_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/waku.js */ \"./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/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/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/core/dist/lib/message/index.js\");\n/* harmony import */ var _lib_filter_v1_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/filter/v1/index.js */ \"./node_modules/@waku/core/dist/lib/filter/v1/index.js\");\n/* harmony import */ var _lib_filter_v2_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/filter/v2/index.js */ \"./node_modules/@waku/core/dist/lib/filter/v2/index.js\");\n/* harmony import */ var _lib_light_push_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/light_push/index.js */ \"./node_modules/@waku/core/dist/lib/light_push/index.js\");\n/* harmony import */ var _lib_store_index_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lib/store/index.js */ \"./node_modules/@waku/core/dist/lib/store/index.js\");\n/* harmony import */ var _lib_wait_for_remote_peer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./lib/wait_for_remote_peer.js */ \"./node_modules/@waku/core/dist/lib/wait_for_remote_peer.js\");\n/* harmony import */ var _lib_connection_manager_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lib/connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n/* harmony import */ var _lib_keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./lib/keep_alive_manager.js */ \"./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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/index.js?"); /***/ }), @@ -5578,7 +5721,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 constructor(multicodec, peerStore, getConnections) {\n this.multicodec = multicodec;\n this.peerStore = peerStore;\n this.getConnections = getConnections;\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.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-rtc/./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_libp2p__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/libp2p */ \"./node_modules/@waku/core/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 peerStore;\n getConnections;\n constructor(multicodec, peerStore, getConnections) {\n this.multicodec = multicodec;\n this.peerStore = peerStore;\n this.getConnections = getConnections;\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.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-rtc/./node_modules/@waku/core/dist/lib/base_protocol.js?"); /***/ }), @@ -5589,7 +5732,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 */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nclass ConnectionManager {\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 constructor(libp2pComponents, keepAliveOptions, relay, options) {\n this.dialAttemptsForPeer = new Map();\n this.onEventHandlers = {\n \"peer:discovery\": async (evt) => {\n const { id: peerId } = evt.detail;\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => log(`Error dialing peer ${peerId.toString()} : ${err}`));\n },\n \"peer:connect\": (evt) => {\n {\n this.keepAliveManager.start(evt.detail.remotePeer, this.libp2pComponents.ping.bind(this));\n }\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail.remotePeer);\n };\n },\n };\n this.libp2pComponents = libp2pComponents;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__.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 }\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.libp2pComponents.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2pComponents.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2pComponents.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n let dialAttempt = 0;\n while (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()}`);\n await this.libp2pComponents.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.libp2pComponents\n .getConnections(peerId)\n .forEach((conn) => (conn.tags = Array.from(new Set([...conn.tags, ...tags]))));\n this.dialAttemptsForPeer.delete(peerId.toString());\n return;\n }\n catch (error) {\n log(`\n Error dialing peer ${peerId.toString()}`);\n dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);\n if (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n log(`Reattempting dial (${dialAttempt})`);\n }\n }\n }\n try {\n log(`Deleting undialable peer ${peerId.toString()} from peer store`);\n return await this.libp2pComponents.peerStore.delete(peerId);\n }\n catch (error) {\n throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;\n }\n }\n startPeerDiscoveryListener() {\n this.libp2pComponents.peerStore.addEventListener(\"peer\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2pComponents.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.libp2pComponents.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\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.libp2pComponents.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2pComponents\n .getConnections()\n .filter((conn) => {\n 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 /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n const tags = (await this.libp2pComponents.peerStore.getTags(peerId)).map((tag) => tag.name);\n return tags;\n }\n}\nConnectionManager.instances = new Map();\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/connection_manager.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 */ });\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./keep_alive_manager.js */ \"./node_modules/@waku/core/dist/lib/keep_alive_manager.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:connection-manager\");\nconst DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;\nconst DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;\nclass ConnectionManager {\n static instances = new Map();\n keepAliveManager;\n options;\n libp2pComponents;\n dialAttemptsForPeer = new Map();\n dialErrorsForPeer = new Map();\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 constructor(libp2pComponents, keepAliveOptions, relay, options) {\n this.libp2pComponents = libp2pComponents;\n this.options = {\n maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,\n maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,\n ...options,\n };\n this.keepAliveManager = new _keep_alive_manager_js__WEBPACK_IMPORTED_MODULE_2__.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 }\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.libp2pComponents.removeEventListener(\"peer:connect\", this.onEventHandlers[\"peer:connect\"]);\n this.libp2pComponents.removeEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n this.libp2pComponents.removeEventListener(\"peer:discovery\", this.onEventHandlers[\"peer:discovery\"]);\n }\n async dialPeer(peerId) {\n let dialAttempt = 0;\n while (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n try {\n log(`Dialing peer ${peerId.toString()}`);\n await this.libp2pComponents.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.libp2pComponents\n .getConnections(peerId)\n .forEach((conn) => (conn.tags = Array.from(new Set([...conn.tags, ...tags]))));\n this.dialAttemptsForPeer.delete(peerId.toString());\n return;\n }\n catch (e) {\n const error = e;\n this.dialErrorsForPeer.set(peerId.toString(), error);\n log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);\n dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;\n this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);\n if (dialAttempt <= this.options.maxDialAttemptsForPeer) {\n log(`Reattempting dial (${dialAttempt})`);\n }\n }\n }\n try {\n log(`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${JSON.stringify(this.dialErrorsForPeer.get(peerId.toString()).errors[0])}\n }`);\n this.dialErrorsForPeer.delete(peerId.toString());\n return await this.libp2pComponents.peerStore.delete(peerId);\n }\n catch (error) {\n throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;\n }\n }\n startPeerDiscoveryListener() {\n this.libp2pComponents.peerStore.addEventListener(\"peer\", this.onEventHandlers[\"peer:discovery\"]);\n }\n startPeerConnectionListener() {\n this.libp2pComponents.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.libp2pComponents.addEventListener(\"peer:disconnect\", this.onEventHandlers[\"peer:disconnect\"]);\n }\n onEventHandlers = {\n \"peer:discovery\": async (evt) => {\n const { id: peerId } = evt.detail;\n if (!(await this.shouldDialPeer(peerId)))\n return;\n this.dialPeer(peerId).catch((err) => log(`Error dialing peer ${peerId.toString()} : ${err}`));\n },\n \"peer:connect\": (evt) => {\n {\n this.keepAliveManager.start(evt.detail.remotePeer, this.libp2pComponents.ping.bind(this));\n }\n },\n \"peer:disconnect\": () => {\n return (evt) => {\n this.keepAliveManager.stop(evt.detail.remotePeer);\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.libp2pComponents.getConnections(peerId).length > 0;\n if (isConnected)\n return false;\n const isBootstrap = (await this.getTagNamesForPeer(peerId)).some((tagName) => tagName === _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Tags.BOOTSTRAP);\n if (isBootstrap) {\n const currentBootstrapConnections = this.libp2pComponents\n .getConnections()\n .filter((conn) => {\n 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 /**\n * Fetches the tag names for a given peer\n */\n async getTagNamesForPeer(peerId) {\n const tags = (await this.libp2pComponents.peerStore.getTags(peerId)).map((tag) => tag.name);\n return tags;\n }\n}\n\n//# sourceMappingURL=connection_manager.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/connection_manager.js?"); /***/ }), @@ -5604,36 +5747,47 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/filter/filter_rpc.js": -/*!***************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/filter/filter_rpc.js ***! - \***************************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v1/filter_rpc.js": +/*!******************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v1/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 */ \"FilterRpc\": () => (/* binding */ FilterRpc)\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 uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterRPC represents a message conforming to the Waku Filter protocol\n */\nclass FilterRpc {\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(topic, contentFilters, requestId, subscribe = true) {\n return new FilterRpc({\n requestId: requestId || (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n subscribe,\n topic,\n contentFilters,\n },\n push: undefined,\n });\n }\n /**\n *\n * @param bytes Uint8Array of bytes from a FilterRPC message\n * @returns FilterRpc\n */\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.decode(bytes);\n return new FilterRpc(res);\n }\n /**\n * Encode the current FilterRPC request to bytes\n * @returns Uint8Array\n */\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.encode(this.proto);\n }\n get push() {\n return this.proto.push;\n }\n get requestId() {\n return this.proto.requestId;\n }\n}\n//# sourceMappingURL=filter_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"FilterRpc\": () => (/* binding */ FilterRpc)\n/* harmony export */ });\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js\");\n\n\n/**\n * FilterRPC represents a message conforming to the Waku Filter protocol\n */\nclass FilterRpc {\n proto;\n constructor(proto) {\n this.proto = proto;\n }\n static createRequest(topic, contentFilters, requestId, subscribe = true) {\n return new FilterRpc({\n requestId: requestId || (0,uuid__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(),\n request: {\n subscribe,\n topic,\n contentFilters,\n },\n push: undefined,\n });\n }\n /**\n *\n * @param bytes Uint8Array of bytes from a FilterRPC message\n * @returns FilterRpc\n */\n static decode(bytes) {\n const res = _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.decode(bytes);\n return new FilterRpc(res);\n }\n /**\n * Encode the current FilterRPC request to bytes\n * @returns Uint8Array\n */\n encode() {\n return _waku_proto__WEBPACK_IMPORTED_MODULE_0__.proto_filter.FilterRpc.encode(this.proto);\n }\n get push() {\n return this.proto.push;\n }\n get requestId() {\n return this.proto.requestId;\n }\n}\n//# sourceMappingURL=filter_rpc.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/filter/v1/filter_rpc.js?"); /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/filter/index.js": -/*!**********************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/filter/index.js ***! - \**********************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v1/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v1/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 */ \"FilterCodec\": () => (/* binding */ FilterCodec),\n/* harmony export */ \"wakuFilter\": () => (/* binding */ wakuFilter)\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 it_all__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.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 _base_protocol_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../group_by.js */ \"./node_modules/@waku/core/dist/lib/group_by.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/core/dist/lib/filter/filter_rpc.js\");\n\n\n\n\n\n\n\n\n\nconst FilterCodec = \"/vac/waku/filter/2.0.0-beta1\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:filter\");\n/**\n * Implements client side of the [Waku v2 Filter protocol](https://rfc.vac.dev/spec/12/).\n *\n * Note this currently only works in NodeJS when the Waku node is listening on a port, see:\n * - https://github.com/status-im/go-waku/issues/245\n * - https://github.com/status-im/nwaku/issues/948\n */\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_4__.BaseProtocol {\n constructor(libp2p, options) {\n super(FilterCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options ?? {};\n this.subscriptions = new Map();\n this.libp2p\n .handle(this.multicodec, this.onRequest.bind(this))\n .catch((e) => log(\"Failed to register filter protocol\", e));\n }\n /**\n * @param decoders Decoder or array of Decoders to use to decode messages, it also specifies the content topics.\n * @param callback A function that will be called on each message returned by the filter.\n * @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.\n * @returns Unsubscribe function that can be used to end the subscription.\n */\n async subscribe(decoders, callback, opts) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPubSubTopic } = this.options;\n const contentTopics = Array.from((0,_group_by_js__WEBPACK_IMPORTED_MODULE_6__.groupByContentTopic)(decodersArray).keys());\n const contentFilters = contentTopics.map((contentTopic) => ({\n contentTopic,\n }));\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(pubSubTopic, contentFilters, undefined, true);\n const requestId = request.requestId;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n try {\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([request.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode(), stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode(), async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(source));\n log(\"response\", res);\n }\n catch (e) {\n log(\"Error subscribing to peer \", peer.id.toString(), \"for content topics\", contentTopics, \": \", e);\n throw e;\n }\n const subscription = {\n callback,\n decoders: decodersArray,\n pubSubTopic,\n };\n this.subscriptions.set(requestId, subscription);\n return async () => {\n await this.unsubscribe(pubSubTopic, contentFilters, requestId, peer);\n this.subscriptions.delete(requestId);\n };\n }\n getActiveSubscriptions() {\n const map = new Map();\n const subscriptions = this.subscriptions;\n for (const item of subscriptions.values()) {\n const values = map.get(item.pubSubTopic) || [];\n const nextValues = item.decoders.map((decoder) => decoder.contentTopic);\n map.set(item.pubSubTopic, [...values, ...nextValues]);\n }\n return map;\n }\n onRequest(streamData) {\n log(\"Receiving message push\");\n try {\n (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)(streamData.stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode(), async (source) => {\n for await (const bytes of source) {\n const res = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.decode(bytes.slice());\n if (res.requestId && res.push?.messages?.length) {\n await this.pushMessages(res.requestId, res.push.messages);\n }\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 async pushMessages(requestId, messages) {\n const subscription = this.subscriptions.get(requestId);\n if (!subscription) {\n log(`No subscription locally registered for request ID ${requestId}`);\n return;\n }\n const { decoders, callback, pubSubTopic } = subscription;\n if (!decoders || !decoders.length) {\n log(`No decoder registered for request ID ${requestId}`);\n return;\n }\n for (const protoMessage of messages) {\n const contentTopic = protoMessage.contentTopic;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__.toProtoMessage)(protoMessage));\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n }\n }\n async unsubscribe(topic, contentFilters, requestId, peer) {\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(topic, contentFilters, requestId, false);\n const stream = await this.newStream(peer);\n try {\n await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([unsubscribeRequest.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode(), stream.sink);\n }\n catch (e) {\n log(\"Error unsubscribing\", e);\n throw e;\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"FilterCodec\": () => (/* binding */ FilterCodec),\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/core/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/@waku/core/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 _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../base_protocol.js */ \"./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/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/core/dist/lib/filter/v1/filter_rpc.js\");\n\n\n\n\n\n\n\n\n\n\nconst FilterCodec = \"/vac/waku/filter/2.0.0-beta1\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter\");\n/**\n * Implements client side of the [Waku v2 Filter protocol](https://rfc.vac.dev/spec/12/).\n *\n * Note this currently only works in NodeJS when the Waku node is listening on a port, see:\n * - https://github.com/status-im/go-waku/issues/245\n * - https://github.com/status-im/nwaku/issues/948\n */\nclass Filter extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n libp2p;\n options;\n subscriptions;\n constructor(libp2p, options) {\n super(FilterCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options ?? {};\n this.subscriptions = new Map();\n this.libp2p\n .handle(this.multicodec, this.onRequest.bind(this))\n .catch((e) => log(\"Failed to register filter protocol\", e));\n }\n /**\n * @param decoders Decoder or array of Decoders to use to decode messages, it also specifies the content topics.\n * @param callback A function that will be called on each message returned by the filter.\n * @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.\n * @returns Unsubscribe function that can be used to end the subscription.\n */\n async subscribe(decoders, callback, opts) {\n const decodersArray = Array.isArray(decoders) ? decoders : [decoders];\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_6__.DefaultPubSubTopic } = this.options;\n const contentTopics = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.groupByContentTopic)(decodersArray).keys());\n const contentFilters = contentTopics.map((contentTopic) => ({\n contentTopic,\n }));\n const request = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(pubSubTopic, contentFilters, undefined, true);\n const requestId = request.requestId;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\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 log(\"response\", res);\n }\n catch (e) {\n log(\"Error subscribing to peer \", peer.id.toString(), \"for content topics\", contentTopics, \": \", e);\n throw e;\n }\n const subscription = {\n callback,\n decoders: decodersArray,\n pubSubTopic,\n };\n this.subscriptions.set(requestId, subscription);\n return async () => {\n await this.unsubscribe(pubSubTopic, contentFilters, requestId, peer);\n this.subscriptions.delete(requestId);\n };\n }\n toSubscriptionIterator(decoders, opts) {\n return (0,_waku_utils__WEBPACK_IMPORTED_MODULE_0__.toAsyncIterator)(this, decoders, opts);\n }\n getActiveSubscriptions() {\n const map = new Map();\n const subscriptions = this.subscriptions;\n for (const item of subscriptions.values()) {\n const values = map.get(item.pubSubTopic) || [];\n const nextValues = item.decoders.map((decoder) => decoder.contentTopic);\n map.set(item.pubSubTopic, [...values, ...nextValues]);\n }\n return map;\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 res = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.decode(bytes.slice());\n if (res.requestId && res.push?.messages?.length) {\n await this.pushMessages(res.requestId, res.push.messages);\n }\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 async pushMessages(requestId, messages) {\n const subscription = this.subscriptions.get(requestId);\n if (!subscription) {\n log(`No subscription locally registered for request ID ${requestId}`);\n return;\n }\n const { decoders, callback, pubSubTopic } = subscription;\n if (!decoders || !decoders.length) {\n log(`No decoder registered for request ID ${requestId}`);\n return;\n }\n for (const protoMessage of messages) {\n const contentTopic = protoMessage.contentTopic;\n if (!contentTopic) {\n log(\"Message has no content topic, skipping\");\n return;\n }\n let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, (0,_to_proto_message_js__WEBPACK_IMPORTED_MODULE_7__.toProtoMessage)(protoMessage));\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n }\n }\n async unsubscribe(topic, contentFilters, requestId, peer) {\n const unsubscribeRequest = _filter_rpc_js__WEBPACK_IMPORTED_MODULE_8__.FilterRpc.createRequest(topic, contentFilters, requestId, false);\n const stream = await this.newStream(peer);\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 (e) {\n log(\"Error unsubscribing\", e);\n throw e;\n }\n }\n}\nfunction wakuFilter(init = {}) {\n return (libp2p) => new Filter(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/filter/v1/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/dist/lib/group_by.js": -/*!******************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/group_by.js ***! - \******************************************************/ +/***/ "./node_modules/@waku/core/dist/lib/filter/v2/filter_rpc.js": +/*!******************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v2/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 */ \"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-rtc/./node_modules/@waku/core/dist/lib/group_by.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/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/dist/lib/filter/v2/filter_rpc.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/dist/lib/filter/v2/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/core/dist/lib/filter/v2/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 */ \"wakuFilterV2\": () => (/* binding */ wakuFilterV2)\n/* harmony export */ });\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/@waku/core/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 _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../base_protocol.js */ \"./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/core/dist/lib/constants.js\");\n/* harmony import */ var _filter_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filter_rpc.js */ \"./node_modules/@waku/core/dist/lib/filter/v2/filter_rpc.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:filter:v2\");\nconst FilterV2Codecs = {\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 FilterV2 extends _base_protocol_js__WEBPACK_IMPORTED_MODULE_5__.BaseProtocol {\n libp2p;\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(FilterV2Codecs.SUBSCRIBE, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.libp2p\n .handle(FilterV2Codecs.PUSH, this.onRequest.bind(this))\n .catch((e) => {\n log(\"Failed to register \", FilterV2Codecs.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 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 wakuFilterV2(init = {}) {\n return (libp2p) => new FilterV2(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 let didDecodeMsg = false;\n // We don't want to wait for decoding failure, just attempt to decode\n // all messages and do the call back on the one that works\n // noinspection ES6MissingAwait\n decoders.forEach(async (dec) => {\n if (didDecodeMsg)\n return;\n const decoded = await dec.fromProtoObj(pubSubTopic, message);\n // const decoded = await dec.fromProtoObj(pubSubTopic, message);\n if (!decoded) {\n log(\"Not able to decode message\");\n return;\n }\n // This is just to prevent more decoding attempt\n // TODO: Could be better if we were to abort promises\n didDecodeMsg = Boolean(decoded);\n await callback(decoded);\n });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/filter/v2/index.js?"); /***/ }), @@ -5644,7 +5798,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 */ });\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/core/dist/index.js\");\n/* harmony import */ var _relay_constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./relay/constants.js */ \"./node_modules/@waku/core/dist/lib/relay/constants.js\");\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_0__(\"waku:keep-alive\");\nclass KeepAliveManager {\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(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: _relay_constants_js__WEBPACK_IMPORTED_MODULE_2__.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-rtc/./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 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/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(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-rtc/./node_modules/@waku/core/dist/lib/keep_alive_manager.js?"); /***/ }), @@ -5655,7 +5809,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_0__.PushResponse),\n/* harmony export */ \"wakuLightPush\": () => (/* binding */ wakuLightPush)\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/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/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/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./push_rpc.js */ \"./node_modules/@waku/core/dist/lib/light_push/push_rpc.js\");\n\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"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_6__.BaseProtocol {\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\n this.options = options || {};\n }\n async send(encoder, message, opts) {\n const { pubSubTopic = _constants_js__WEBPACK_IMPORTED_MODULE_7__.DefaultPubSubTopic } = this.options;\n const peer = await this.getPeer(opts?.peerId);\n const stream = await this.newStream(peer);\n const recipients = [];\n try {\n const protoMessage = await encoder.toProtoObj(message);\n if (!protoMessage) {\n log(\"Failed to encode to protoMessage, aborting push\");\n return { recipients };\n }\n const query = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.createRequest(protoMessage, pubSubTopic);\n const res = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_4__.pipe)([query.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 try {\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_5__.Uint8ArrayList();\n res.forEach((chunk) => {\n bytes.append(chunk);\n });\n const response = _push_rpc_js__WEBPACK_IMPORTED_MODULE_8__.PushRpc.decode(bytes).response;\n if (!response) {\n log(\"No response in PushRPC\");\n return { recipients };\n }\n if (response.isSuccess) {\n recipients.push(peer.id);\n }\n }\n catch (err) {\n log(\"Failed to decode push reply\", err);\n }\n }\n catch (err) {\n log(\"Failed to send waku light push request\", err);\n }\n return { recipients };\n }\n}\nfunction wakuLightPush(init = {}) {\n return (libp2p) => new LightPush(libp2p, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"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/interfaces/dist/index.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/@waku/core/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 _base_protocol_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../base_protocol.js */ \"./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/core/dist/lib/constants.js\");\n/* harmony import */ var _push_rpc_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./push_rpc.js */ \"./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 libp2p;\n options;\n constructor(libp2p, options) {\n super(LightPushCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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-rtc/./node_modules/@waku/core/dist/lib/light_push/index.js?"); /***/ }), @@ -5666,7 +5820,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/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/node_modules/uuid/dist/esm-browser/v4.js\");\n\n\nclass PushRpc {\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-rtc/./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/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/dist/lib/light_push/push_rpc.js?"); /***/ }), @@ -5677,18 +5831,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 */ \"topic_only_message\": () => (/* reexport module object */ _topic_only_message_js__WEBPACK_IMPORTED_MODULE_1__),\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/core/dist/lib/message/version_0.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./topic_only_message.js */ \"./node_modules/@waku/core/dist/lib/message/topic_only_message.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/message/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/message/topic_only_message.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/message/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 */ \"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/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 constructor(pubSubTopic, proto) {\n this.pubSubTopic = pubSubTopic;\n this.proto = proto;\n this.payload = new Uint8Array();\n }\n get contentTopic() {\n return this.proto.contentTopic;\n }\n}\nclass TopicOnlyDecoder {\n constructor() {\n this.contentTopic = \"\";\n }\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-rtc/./node_modules/@waku/core/dist/lib/message/topic_only_message.js?"); +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/core/dist/lib/message/version_0.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/message/index.js?"); /***/ }), @@ -5699,40 +5842,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 */ \"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 }\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 }\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-rtc/./node_modules/@waku/core/dist/lib/message/version_0.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/constants.js": -/*!*************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/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 */ \"RelayCodecs\": () => (/* binding */ RelayCodecs),\n/* harmony export */ \"RelayFanoutTTL\": () => (/* binding */ RelayFanoutTTL),\n/* harmony export */ \"RelayGossipFactor\": () => (/* binding */ RelayGossipFactor),\n/* harmony export */ \"RelayHeartbeatInitialDelay\": () => (/* binding */ RelayHeartbeatInitialDelay),\n/* harmony export */ \"RelayHeartbeatInterval\": () => (/* binding */ RelayHeartbeatInterval),\n/* harmony export */ \"RelayMaxIHaveLength\": () => (/* binding */ RelayMaxIHaveLength),\n/* harmony export */ \"RelayOpportunisticGraftPeers\": () => (/* binding */ RelayOpportunisticGraftPeers),\n/* harmony export */ \"RelayOpportunisticGraftTicks\": () => (/* binding */ RelayOpportunisticGraftTicks),\n/* harmony export */ \"RelayPingContentTopic\": () => (/* binding */ RelayPingContentTopic),\n/* harmony export */ \"RelayPruneBackoff\": () => (/* binding */ RelayPruneBackoff),\n/* harmony export */ \"RelayPrunePeers\": () => (/* binding */ RelayPrunePeers),\n/* harmony export */ \"minute\": () => (/* binding */ minute),\n/* harmony export */ \"second\": () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n/**\n * RelayCodec is the libp2p identifier for the waku relay protocol\n */\nconst RelayCodecs = [\"/vac/waku/relay/2.0.0\"];\nconst RelayPingContentTopic = \"/relay-ping/1/ping/null\";\n/**\n * RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or\n * RelayDlazy, whichever is greater.\n */\nconst RelayGossipFactor = 0.25;\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst RelayHeartbeatInitialDelay = 100;\n/**\n * RelayHeartbeatInterval controls the time between heartbeats.\n */\nconst RelayHeartbeatInterval = second;\n/**\n * RelayPrunePeers 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 RelayPrunePeers other peers that we\n * know of.\n */\nconst RelayPrunePeers = 16;\n/**\n * RelayPruneBackoff 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 RelayPruneBackoff 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 RelayPruneBackoff\n * before attempting to re-graft.\n */\nconst RelayPruneBackoff = minute;\n/**\n * RelayFanoutTTL controls how long we keep track of the fanout state. If it's been\n * RelayFanoutTTL 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 RelayFanoutTTL = minute;\n/**\n * RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every RelayOpportunisticGraftTicks 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 RelayOpportunisticGraftTicks = 60;\n/**\n * RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst RelayOpportunisticGraftPeers = 2;\n/**\n * RelayMaxIHaveLength 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 RelayMaxIHaveLength = 5000;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/dist/lib/relay/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/index.js": -/*!*********************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/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 */ \"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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _group_by_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../group_by.js */ \"./node_modules/@waku/core/dist/lib/group_by.js\");\n/* harmony import */ var _message_topic_only_message_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../message/topic_only_message.js */ \"./node_modules/@waku/core/dist/lib/message/topic_only_message.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/core/dist/lib/relay/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/core/dist/lib/relay/message_validator.js\");\n\n\n\n\n\n\n\n\nconst log = debug__WEBPACK_IMPORTED_MODULE_2__(\"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 constructor(libp2p, options) {\n if (!this.isRelayPubSub(libp2p.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.pubsub;\n this.pubSubTopic = options?.pubSubTopic ?? _constants_js__WEBPACK_IMPORTED_MODULE_3__.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 _message_topic_only_message_js__WEBPACK_IMPORTED_MODULE_5__.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 const msg = await encoder.toWire(message);\n if (!msg) {\n log(\"Failed to encode message, aborting publish\");\n return { recipients: [] };\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 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(async ({ decoder, callback }) => {\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 callback(msg);\n }\n else {\n log(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\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\", async (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}\nRelay.multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_6__.RelayCodecs[0];\nfunction wakuRelay(init = {}) {\n return (libp2p) => new Relay(libp2p, init);\n}\nfunction wakuGossipSub(init = {}) {\n return (components) => {\n init = {\n ...init,\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,_group_by_js__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-rtc/./node_modules/@waku/core/dist/lib/relay/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/dist/lib/relay/message_validator.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@waku/core/dist/lib/relay/message_validator.js ***! - \*********************************************************************/ -/***/ ((__unused_webpack___webpack_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/core/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/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-rtc/./node_modules/@waku/core/dist/lib/relay/message_validator.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/core/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-rtc/./node_modules/@waku/core/dist/lib/message/version_0.js?"); /***/ }), @@ -5743,7 +5853,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/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/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 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-rtc/./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/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/dist/lib/store/history_rpc.js?"); /***/ }), @@ -5754,7 +5864,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 */ \"DefaultPageSize\": () => (/* binding */ DefaultPageSize),\n/* harmony export */ \"PageDirection\": () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__.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_0__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.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 _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 debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-all */ \"./node_modules/@waku/core/node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./history_rpc.js */ \"./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_1__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_4__(\"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_9__.BaseProtocol {\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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_2__.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_12__.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_10__.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_12__.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_12__.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_7__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.encode(), stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.decode(), async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_8__.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_11__.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_10__.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_3__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_0__.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,\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-rtc/./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 */ \"DefaultPageSize\": () => (/* binding */ DefaultPageSize),\n/* harmony export */ \"PageDirection\": () => (/* reexport safe */ _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__.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_0__ = __webpack_require__(/*! @noble/hashes/sha256 */ \"./node_modules/@noble/hashes/esm/sha256.js\");\n/* harmony import */ var _waku_proto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/proto */ \"./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/core/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/core/node_modules/@waku/utils/dist/bytes/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var it_all__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! it-all */ \"./node_modules/it-all/dist/src/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/index.js\");\n/* harmony import */ var it_pipe__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! it-pipe */ \"./node_modules/it-pipe/dist/src/index.js\");\n/* harmony import */ var uint8arraylist__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/dist/src/index.js\");\n/* harmony import */ var _base_protocol_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../base_protocol.js */ \"./node_modules/@waku/core/dist/lib/base_protocol.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants.js */ \"./node_modules/@waku/core/dist/lib/constants.js\");\n/* harmony import */ var _to_proto_message_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../to_proto_message.js */ \"./node_modules/@waku/core/dist/lib/to_proto_message.js\");\n/* harmony import */ var _history_rpc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./history_rpc.js */ \"./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_1__.proto_store.HistoryResponse.HistoryError;\nconst log = debug__WEBPACK_IMPORTED_MODULE_4__(\"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_9__.BaseProtocol {\n libp2p;\n options;\n constructor(libp2p, options) {\n super(StoreCodec, libp2p.peerStore, libp2p.getConnections.bind(libp2p));\n this.libp2p = libp2p;\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_2__.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_12__.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_10__.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_12__.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_12__.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_7__.pipe)([historyRpcQuery.encode()], it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.encode, stream, it_length_prefixed__WEBPACK_IMPORTED_MODULE_6__.decode, async (source) => await (0,it_all__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(source));\n const bytes = new uint8arraylist__WEBPACK_IMPORTED_MODULE_8__.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_11__.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_10__.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_3__.utf8ToBytes)(message.contentTopic);\n const digest = (0,_noble_hashes_sha256__WEBPACK_IMPORTED_MODULE_0__.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,\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-rtc/./node_modules/@waku/core/dist/lib/store/index.js?"); /***/ }), @@ -5787,854 +5897,238 @@ 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 */ \"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 _waku_interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/interfaces */ \"./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 _connection_manager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connection_manager.js */ \"./node_modules/@waku/core/dist/lib/connection_manager.js\");\n\n\n\nconst DefaultPingKeepAliveValueSecs = 0;\nconst DefaultRelayKeepAliveValueSecs = 5 * 60;\nconst DefaultUserAgent = \"js-waku\";\nconst log = debug__WEBPACK_IMPORTED_MODULE_1__(\"waku:waku\");\nclass WakuNode {\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_2__.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 if (typeof protocols === \"undefined\") {\n this.relay && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Relay);\n this.store && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Store);\n this.filter && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.Filter);\n this.lightPush && _protocols.push(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.Protocols.LightPush);\n }\n const codecs = [];\n if (_protocols.includes(_waku_interfaces__WEBPACK_IMPORTED_MODULE_0__.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_0__.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_0__.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_0__.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 ${peer.toString()} with protocols ${_protocols}`);\n return this.libp2p.dialProtocol(peer, 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}\n//# sourceMappingURL=waku.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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 */ \"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/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/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-rtc/./node_modules/@waku/core/dist/lib/waku.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js ***! - \************************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js": +/*!************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"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 */ \"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 */ \"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 * 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//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.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_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/core/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/core/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/core/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/core/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/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.js ***! - \********************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"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/it-pipe/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.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_topology__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/topology */ \"./node_modules/@waku/core/node_modules/@libp2p/topology/dist/src/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _message_cache_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./message-cache.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js\");\n/* harmony import */ var _message_rpc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message/rpc.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/constants.js\");\n/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utils/index.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js\");\n/* harmony import */ var _score_index_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./score/index.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js\");\n/* harmony import */ var _tracer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tracer.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js\");\n/* harmony import */ var _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils/time-cache.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js\");\n/* harmony import */ var _metrics_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./metrics.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js\");\n/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./types.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\n/* harmony import */ var _utils_buildRawMessage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./utils/buildRawMessage.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js\");\n/* harmony import */ var _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./utils/msgIdFn.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js\");\n/* harmony import */ var _score_scoreMetrics_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./score/scoreMetrics.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js\");\n/* harmony import */ var _utils_publishConfig_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./utils/publishConfig.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n/* harmony import */ var _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @libp2p/interface-pubsub */ \"./node_modules/@waku/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js\");\n/* harmony import */ var _utils_set_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./utils/set.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js\");\n/* harmony import */ var it_pushable__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! it-pushable */ \"./node_modules/it-pushable/dist/src/index.js\");\n/* harmony import */ var _stream_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./stream.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js\");\n/* harmony import */ var _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./message/decodeRpc.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js\");\n/* harmony import */ var _utils_multiaddr_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./utils/multiaddr.js */ \"./node_modules/@waku/core/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\n\nconst multicodec = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_5__.EventEmitter {\n constructor(components, options = {}) {\n super();\n this.multicodecs = [_constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIDv11, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_21__.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_8__.GossipsubD,\n Dlo: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlo,\n Dhi: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDhi,\n Dscore: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDscore,\n Dout: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDout,\n Dlazy: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDlazy,\n heartbeatInterval: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHeartbeatInterval,\n fanoutTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubFanoutTTL,\n mcacheLength: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryLength,\n mcacheGossip: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubHistoryGossip,\n seenTTL: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubSeenTTL,\n gossipsubIWantFollowupMs: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubIWantFollowupTime,\n prunePeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPrunePeers,\n pruneBackoff: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubPruneBackoff,\n graftFloodThreshold: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubGraftFloodThreshold,\n opportunisticGraftPeers: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftPeers,\n opportunisticGraftTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubOpportunisticGraftTicks,\n directConnectTicks: _constants_js__WEBPACK_IMPORTED_MODULE_8__.GossipsubDirectConnectTicks,\n ...options,\n scoreParams: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreParams)(options.scoreParams),\n scoreThresholds: (0,_score_index_js__WEBPACK_IMPORTED_MODULE_10__.createPeerScoreThresholds)(options.scoreThresholds)\n };\n this.components = components;\n this.decodeRpcLimits = opts.decodeRpcLimits ?? _message_decodeRpc_js__WEBPACK_IMPORTED_MODULE_23__.defaultDecodeRpcLimits;\n this.globalSignaturePolicy = opts.globalSignaturePolicy ?? _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.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_8__.FloodsubID);\n }\n // From pubsub\n this.log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_3__.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_12__.SimpleTimeCache({ validityMs: opts.seenTTL });\n this.publishedMessageIds = new _utils_time_cache_js__WEBPACK_IMPORTED_MODULE_12__.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_19__.StrictSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.msgIdFnStrictSign;\n break;\n case _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.StrictNoSign:\n this.msgIdFn = _utils_msgIdFn_js__WEBPACK_IMPORTED_MODULE_16__.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_12__.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_9__.messageIdToString;\n this.mcache = options.messageCache || new _message_cache_js__WEBPACK_IMPORTED_MODULE_6__.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_8__.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_11__.IWantTracer(this.opts.gossipsubIWantFollowupMs, this.msgIdToStrFn, this.metrics);\n /**\n * libp2p\n */\n this.score = new _score_index_js__WEBPACK_IMPORTED_MODULE_10__.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_2__.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_18__.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_21__.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.addressBook.add(p.id, p.addrs);\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_4__.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_8__.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_8__.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_8__.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 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_22__.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_8__.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_22__.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_24__.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_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 ? 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_2__.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_23__.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 await this.handleReceivedRpc(peerId, rpc);\n }\n else {\n this.handleReceivedRpc(peerId, rpc).catch((err) => this.log(err));\n }\n }\n catch (e) {\n this.log(e);\n }\n }\n });\n }\n catch (err) {\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 this.log('rpc from %p', from);\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_5__.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) => this.log(err));\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_14__.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_14__.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_14__.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_5__.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_5__.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_14__.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_15__.validateToRawMessage)(this.globalSignaturePolicy, rpcMsg);\n if (!validationResult.valid) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.MessageStatus.invalid, reason: _types_js__WEBPACK_IMPORTED_MODULE_14__.RejectReason.Error, error: _types_js__WEBPACK_IMPORTED_MODULE_14__.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_14__.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_8__.ERR_TOPIC_VALIDATOR_IGNORE)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n if (errCode === _constants_js__WEBPACK_IMPORTED_MODULE_8__.ERR_TOPIC_VALIDATOR_REJECT)\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Reject;\n else\n acceptance = _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Ignore;\n }\n if (acceptance !== _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.MessageStatus.invalid, reason: (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.rejectReasonFromAcceptance)(acceptance), msgIdStr };\n }\n }\n return { code: _types_js__WEBPACK_IMPORTED_MODULE_14__.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 this.sendRpc(id, { messages: ihave, control: { iwant, prune } });\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_8__.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_8__.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_8__.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_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_8__.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_8__.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 || !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_8__.GossipsubMaxIHaveLength) {\n iask = _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_9__.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 this.gossipTracer.addPromise(id, iwantList);\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_8__.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_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)) {\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) {\n return [];\n }\n return await Promise.all(prune.map((topic) => this.makePrune(id, topic, doPX)));\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_13__.ChurnReason.Unsub, 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 interval - backoff duration in milliseconds\n */\n doAddBackoff(id, topic, interval) {\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() + interval;\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_8__.GossipsubPruneBackoffTicks !== 0) {\n return;\n }\n const now = Date.now();\n this.backoff.forEach((backoff, topic) => {\n backoff.forEach((expire, id) => {\n if (expire < 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_9__.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 p = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromBytes)(pi.peerID).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 const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_1__.RecordEnvelope.openAndCertify(pi.signedPeerRecord, 'libp2p-peer-record');\n const eid = envelope.peerId;\n if (!envelope.peerId.equals(p)) {\n this.log(\"bogus peer record obtained through px: peer ID %p doesn't match expected peer %p\", eid, p);\n return;\n }\n if (!(await this.components.peerStore.addressBook.consumePeerRecord(envelope))) {\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_2__.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 // 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 // TODO:rust-libp2p checks `self.backoffs.is_backoff_with_slack()`\n if (!this.direct.has(id) && this.score.score(id) >= 0) {\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);\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) {\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_15__.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_5__.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_5__.CustomEvent('message', { detail: msg }));\n }\n return {\n recipients: Array.from(tosend.values()).map((str) => (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.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 if (acceptance === _libp2p_interface_pubsub__WEBPACK_IMPORTED_MODULE_19__.TopicValidatorResult.Accept) {\n const cacheEntry = this.mcache.validate(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry != null) {\n const { message: rawMsg, originatingPeers } = cacheEntry;\n // message is fully validated inform peer_score\n this.score.deliverMessage(propagationSource.toString(), msgId, rawMsg.topic);\n this.forwardMessage(msgId, cacheEntry.message, propagationSource.toString(), originatingPeers);\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\n // Not valid\n else {\n const cacheEntry = this.mcache.remove(msgId);\n this.metrics?.onReportValidationMcacheHit(cacheEntry !== null);\n if (cacheEntry) {\n const rejectReason = (0,_types_js__WEBPACK_IMPORTED_MODULE_14__.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.toString(), msgId, rawMsg.topic, rejectReason);\n for (const peer of originatingPeers) {\n this.score.rejectMessage(peer, msgId, rawMsg.topic, rejectReason);\n }\n this.metrics?.onReportValidation(rawMsg.topic, acceptance);\n }\n // else, Message not in cache. Ignoring forwarding\n }\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 const prune = [await this.makePrune(id, topic, this.opts.doPX)];\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_7__.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 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))));\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))));\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_9__.shuffle)(messageIDs);\n // if we are emitting more than GossipsubMaxIHaveLength ids, truncate the list\n if (messageIDs.length > _constants_js__WEBPACK_IMPORTED_MODULE_8__.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_8__.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_9__.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_8__.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_9__.shuffle)(peerMessageIDs.slice()).slice(0, _constants_js__WEBPACK_IMPORTED_MODULE_8__.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) {\n this.score.prune(id, topic);\n if (this.streamsOutbound.get(id).protocol === _constants_js__WEBPACK_IMPORTED_MODULE_8__.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 is measured in milliseconds\n // The protobuf has it as a uint64\n const backoff = this.opts.pruneBackoff / 1000;\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_2__.peerIdFromString)(peerId);\n return {\n peerID: id.toBytes(),\n signedPeerRecord: await this.components.peerStore.addressBook.getRawEnvelope(id)\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_9__.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_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_20__.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_9__.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_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)) {\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_20__.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_20__.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) || 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_9__.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_5__.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_9__.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 for (const backoff of this.backoff.values()) {\n backoffSize += backoff.size;\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_17__.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_8__.GossipsubIDv11;\nfunction gossipsub(init = {}) {\n return (components) => new GossipSub(components, init);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/index.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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js": -/*!********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/decodeRpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/message/rpc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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 /// Peer unsubscribed.\n ChurnReason[\"Unsub\"] = \"unsubscribed\";\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 */\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: ['topic', 'reason']\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: ['topic', 'reason']\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 for each topic',\n labelNames: ['topic', 'acceptance']\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 // 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 /** 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 msgPublishPeers: 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: ['topic', '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 /** 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: ['topic', 'status']\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: ['topic', 'error']\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 labelNames: ['topic', 'p']\n }),\n /** Separate score weights */\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 /* 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({ topic, reason }, 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({ topic, reason }, count);\n },\n onReportValidationMcacheHit(hit) {\n this.asyncValidationMcacheHit.inc({ hit: hit ? 'hit' : 'miss' });\n },\n onReportValidation(topicStr, acceptance) {\n const topic = this.toTopic(topicStr);\n this.asyncValidationResult.inc({ topic: topic, acceptance });\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.msgPublishPeers.inc({ topic }, tosendCount);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'direct' }, tosendGroupCount.direct);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'floodsub' }, tosendGroupCount.floodsub);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'mesh' }, tosendGroupCount.mesh);\n this.msgPublishPeersByGroup.inc({ topic, peerGroup: 'fanout' }, tosendGroupCount.fanout);\n },\n onMsgRecvPreValidation(topicStr) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedPreValidation.inc({ topic }, 1);\n },\n onMsgRecvResult(topicStr, status) {\n const topic = this.toTopic(topicStr);\n this.msgReceivedStatus.inc({ topic, 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({ topic, error }, 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 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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/metrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/compute-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/constants.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js": -/*!***************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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 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 firstSeen: 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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/message-deliveries.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-params.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js": -/*!******************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score-thresholds.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/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/core/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/core/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 /**\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.firstSeen, _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.firstSeen, _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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js": -/*!*********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/score/scoreMetrics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/abortable-iterator/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 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 }), (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.encode)(), 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, (0,it_length_prefixed__WEBPACK_IMPORTED_MODULE_3__.decode)(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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/stream.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/tracer.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/types.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js": -/*!************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/buildRawMessage.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/messageIdToString.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/msgIdFn.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/multiaddr.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js": -/*!**********************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/core/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/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/publishConfig.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/set.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js": -/*!****************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/shuffle.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js": -/*!*******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/dist/src/utils/time-cache.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***********************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***********************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"convertToString\": () => (/* binding */ convertToString)\n/* harmony export */ });\n/* harmony import */ var _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/core/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/**\n * @packageDocumentation\n *\n * Provides methods for converting\n */\n\n\n\n\n\n\n\n\n\n\n\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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.fromString)(str, 'base16'); // no clue. convert from hex\n }\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.toString)(addrBytes, 'base32');\n const port = bytes2port(portBytes);\n return `${addr}:${port}`;\n}\n//# sourceMappingURL=convert.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!******************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!*******************************************************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \*******************************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc'],\n [281, 0, 'webrtc-w3c'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@chainsafe/libp2p-gossipsub/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@libp2p/interface-pubsub/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter_v2.js": /*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js ***! + !*** ./node_modules/@waku/core/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/core/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/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 */ \"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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/filter_v2.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \************************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/light_push.js": +/*!*********************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@waku/core/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/index.js ***! - \*********************************************************************************************/ +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/message.js": +/*!******************************************************************************!*\ + !*** ./node_modules/@waku/core/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/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 */ \"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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/message.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/peer_exchange.js": /*!************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.js ***! + !*** ./node_modules/@waku/core/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 */ \"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/@waku/core/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/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/index.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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/peer_exchange.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\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 _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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!******************************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \******************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/@waku/core/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/errors.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/utils.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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 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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@waku/core/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/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_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_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_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_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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('RPC message was missing from', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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_interfaces_errors__WEBPACK_IMPORTED_MODULE_6__.CodeError('Signed RPC message was missing key', _errors_js__WEBPACK_IMPORTED_MODULE_5__.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-rtc/./node_modules/@waku/core/node_modules/@libp2p/pubsub/dist/src/utils.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/@libp2p/topology/dist/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/@libp2p/topology/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 */ \"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 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 get [_libp2p_interface_registrar__WEBPACK_IMPORTED_MODULE_0__.topologySymbol]() {\n return true;\n }\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-rtc/./node_modules/@waku/core/node_modules/@libp2p/topology/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/it-all/dist/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/it-all/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\": () => (/* binding */ all)\n/* harmony export */ });\n/**\n * Collects all values from an (async) iterable and returns them as an array\n */\nasync function all(source) {\n const arr = [];\n for await (const entry of source) {\n arr.push(entry);\n }\n return arr;\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/it-all/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base10.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base16.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base2.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base256emoji.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base32.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base36.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base64.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/base8.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/identity.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bases/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/bases/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/basics.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/bytes.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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)\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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/cid.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/core/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/@waku/core/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/@waku/core/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/codecs/json.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/codecs/raw.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/hasher.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/identity.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/index.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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_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/@waku/core/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/core/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/core/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/@waku/core/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/interface.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/store.js": /*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/interface.js ***! + !*** ./node_modules/@waku/core/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// this is dummy module overlayed by interface.ts\n\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/multiformats/src/interface.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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/store.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/link/interface.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/src/link/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/src/varint.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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/@waku/core/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-rtc/./node_modules/@waku/core/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/vendor/base-x.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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// 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-rtc/./node_modules/@waku/core/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/multiformats/vendor/varint.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/core/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \**************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js": +/***/ "./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/topic_only_message.js": /*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js ***! + !*** ./node_modules/@waku/core/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/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-rtc/./node_modules/@waku/core/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.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/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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js?"); +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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/group_by.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/index.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/index.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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/index.js?"); +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/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\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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/index.js?"); /***/ }), -/***/ "./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/@waku/core/node_modules/protons-runtime/node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/protons-runtime/dist/src/utils.js?"); +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-rtc/./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 */ \"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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/is_size_valid.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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/common/random_subset.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, 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-rtc/./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 */ \"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/core/node_modules/@waku/utils/dist/common/index.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/@waku/utils/dist/libp2p/index.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/@waku/utils/dist/libp2p/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 */ \"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-rtc/./node_modules/@waku/core/node_modules/@waku/utils/dist/libp2p/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/decode.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/decode.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/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__.unsigned.decode(buf);\n defaultDecoder.bytes = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n return length;\n};\ndefaultDecoder.bytes = 0;\nfunction decode(source, options) {\n const buffer = new uint8arraylist__WEBPACK_IMPORTED_MODULE_0__.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_2__(new Error('invalid message length'), 'ERR_INVALID_MSG_LENGTH');\n }\n if (dataLength > maxDataLength) {\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(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_2__(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_2__(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_2__(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-rtc/./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/decode.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/encode.js": +/*!************************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/encode.js ***! + \************************************************************************************/ +/***/ ((__unused_webpack___webpack_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 uint8arraylist__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arraylist */ \"./node_modules/uint8arraylist/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 uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/alloc */ \"./node_modules/uint8arrays/dist/src/alloc.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/utils.js\");\n\n\n\n\nconst defaultEncoder = (length) => {\n const lengthLength = uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.encodingLength(length);\n const lengthBuf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_2__.allocUnsafe)(lengthLength);\n uint8_varint__WEBPACK_IMPORTED_MODULE_1__.unsigned.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_0__.Uint8ArrayList(encodeLength(chunk.byteLength), chunk);\n};\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/encode.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/index.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/it-length-prefixed/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\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_1__.decode),\n/* harmony export */ \"encode\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_0__.encode)\n/* harmony export */ });\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/encode.js\");\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/decode.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/utils.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/core/node_modules/it-length-prefixed/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 */ \"isAsyncIterable\": () => (/* binding */ isAsyncIterable)\n/* harmony export */ });\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/core/node_modules/it-length-prefixed/dist/src/utils.js?"); /***/ }), @@ -6645,7 +6139,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 */ \"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/@waku/create/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/@waku/create/node_modules/@libp2p/mplex/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/websockets */ \"./node_modules/@waku/create/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/@waku/create/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/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 libp2p__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! libp2p */ \"./node_modules/libp2p/dist/src/index.js\");\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 * **Note: This is NOT compatible with nwaku v0.11**\n *\n * @see https://github.com/status-im/nwaku/issues/1085\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_core__WEBPACK_IMPORTED_MODULE_4__.wakuGossipSub)(options), libp2pOptions, options?.userAgent);\n const relay = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.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_core__WEBPACK_IMPORTED_MODULE_4__.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_core__WEBPACK_IMPORTED_MODULE_4__.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 libp2pOpts = Object.assign({\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 identify: {\n host: {\n agentVersion: userAgent ?? _waku_core__WEBPACK_IMPORTED_MODULE_4__.DefaultUserAgent,\n },\n },\n }, wakuGossipSub ? { pubsub: wakuGossipSub } : {}, options ?? {});\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_6__.createLibp2p)(libp2pOpts);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/dist/index.js?"); +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/@waku/create/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/@waku/create/node_modules/@libp2p/mplex/dist/src/index.js\");\n/* harmony import */ var _libp2p_websockets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/websockets */ \"./node_modules/@waku/create/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/@waku/create/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/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/libp2p/dist/src/index.js\");\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 * If `useFilterV1` is set to true, the node will use Filter V1 protocol.\n * If `useFilterV1` is set to false or undefined, the node will use Filter V2 protocol. (default behavior)\n *\n * **Note: This is NOT compatible with nwaku v0.11**\n *\n * @see https://github.com/status-im/nwaku/issues/1085\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 let filter;\n if (options?.useFilterV1) {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV1)(options);\n }\n else {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV2)();\n }\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 * Implements generics to allow for conditional type checking for Filter V1 and V2 protocols.\n * If `useFilterV1` is set to true, the node will use Filter V1 protocol.\n * If `useFilterV1` is set to false or undefined, the node will use Filter V2 protocol. (default behavior)\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 let filter;\n if (!options?.useFilterV1) {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV2)();\n }\n else {\n filter = (0,_waku_core__WEBPACK_IMPORTED_MODULE_4__.wakuFilterV1)(options);\n }\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 libp2pOpts = Object.assign({\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 identify: {\n host: {\n agentVersion: userAgent ?? _waku_core__WEBPACK_IMPORTED_MODULE_4__.DefaultUserAgent,\n },\n },\n }, wakuGossipSub ? { pubsub: wakuGossipSub } : {}, options ?? {});\n return (0,libp2p__WEBPACK_IMPORTED_MODULE_7__.createLibp2p)(libp2pOpts);\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/dist/index.js?"); /***/ }), @@ -6799,7 +6293,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/@waku/create/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-rtc/./node_modules/@waku/create/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/* 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-rtc/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/proto/payload.js?"); /***/ }), @@ -6810,7 +6304,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 */ \"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/@waku/create/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/@waku/create/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 await privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return await (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-rtc/./node_modules/@waku/create/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/@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/@waku/create/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 await privateKey.sign(payload);\n}\nasync function getPeerIdFromPayload(payload) {\n return await (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-rtc/./node_modules/@waku/create/node_modules/@chainsafe/libp2p-noise/dist/src/utils.js?"); /***/ }), @@ -6825,17 +6319,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/@waku/create/node_modules/@libp2p/interface-transport/dist/src/index.js": /*!**********************************************************************************************!*\ !*** ./node_modules/@waku/create/node_modules/@libp2p/interface-transport/dist/src/index.js ***! @@ -6924,17 +6407,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/create/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/create/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/create/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/create/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/create/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - /***/ "./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.js": /*!*****************************************************************************************!*\ !*** ./node_modules/@waku/create/node_modules/@libp2p/websockets/dist/src/constants.js ***! @@ -7056,380 +6528,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base10.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base16.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base2.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base256emoji.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base32.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base36.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base58.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base64.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/base8.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/identity.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bases/interface.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/src/bases/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/basics.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/bytes.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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)\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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/cid.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/create/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/@waku/create/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/@waku/create/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/codecs/json.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/codecs/raw.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/digest.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/hasher.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/identity.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/index.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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_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/@waku/create/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/create/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/create/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/@waku/create/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/interface.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/link/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/src/link/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/src/varint.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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/@waku/create/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-rtc/./node_modules/@waku/create/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/vendor/base-x.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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// 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-rtc/./node_modules/@waku/create/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/multiformats/vendor/varint.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/create/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \****************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js ***! - \***********************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/index.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/create/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/create/node_modules/protons-runtime/dist/src/utils.js?"); - -/***/ }), - /***/ "./node_modules/@waku/dns-discovery/dist/dns.js": /*!******************************************************!*\ !*** ./node_modules/@waku/dns-discovery/dist/dns.js ***! @@ -7437,7 +6535,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 */ \"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 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._errorTolerance = 10;\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-rtc/./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/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-rtc/./node_modules/@waku/dns-discovery/dist/dns.js?"); /***/ }), @@ -7448,7 +6546,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 */ \"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 /**\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-rtc/./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_bytes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/dist/dns_over_https.js?"); /***/ }), @@ -7459,7 +6557,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 */ \"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/@waku/dns-discovery/node_modules/uint8arrays/dist/src/from-string.js\");\n\n\n\n\n\nclass ENRTree {\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}\nENRTree.RECORD_PREFIX = _waku_enr__WEBPACK_IMPORTED_MODULE_0__.ENR.RECORD_PREFIX;\nENRTree.TREE_PREFIX = \"enrtree:\";\nENRTree.BRANCH_PREFIX = \"enrtree-branch:\";\nENRTree.ROOT_PREFIX = \"enrtree-root:\";\n//# sourceMappingURL=enrtree.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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/enr/dist/index.js\");\n/* harmony import */ var _waku_utils_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @waku/utils/bytes */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/dist/enrtree.js?"); /***/ }), @@ -7481,348 +6579,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 */ \"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 = 120000;\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 constructor(components, options) {\n super();\n this._started = false;\n this._components = components;\n this._options = options;\n const { enrUrl } = options;\n log(\"Use following EIP-1459 ENR Tree URL: \", enrUrl);\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 const { enrUrl, wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, [enrUrl], wantedNodeCapabilityCount);\n }\n for await (const peer of this.nextPeer()) {\n if (!this._started)\n return;\n const peerInfo = peer.peerInfo;\n if (!peerInfo)\n continue;\n if ((await this._components.peerStore.getTags(peerInfo.id)).find(({ name }) => name === DEFAULT_BOOTSTRAP_TAG_NAME))\n continue;\n await this._components.peerStore.tagPeer(peerInfo.id, DEFAULT_BOOTSTRAP_TAG_NAME, {\n value: this._options.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL,\n });\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent(\"peer\", { detail: peerInfo }));\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__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrl, wantedNodeCapabilityCount) {\n return (components) => new PeerDiscoveryDns(components, { enrUrl, wantedNodeCapabilityCount });\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/dns-discovery/dist/index.js?"); +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 = 120000;\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 { enrUrl } = options;\n log(\"Use following EIP-1459 ENR Tree URL: \", enrUrl);\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 const { enrUrl, wantedNodeCapabilityCount } = this._options;\n const dns = await _dns_js__WEBPACK_IMPORTED_MODULE_3__.DnsNodeDiscovery.dnsOverHttp();\n this.nextPeer = dns.getNextPeer.bind(dns, [enrUrl], wantedNodeCapabilityCount);\n }\n for await (const peer of this.nextPeer()) {\n if (!this._started)\n return;\n const peerInfo = peer.peerInfo;\n if (!peerInfo)\n continue;\n if ((await this._components.peerStore.getTags(peerInfo.id)).find(({ name }) => name === DEFAULT_BOOTSTRAP_TAG_NAME))\n continue;\n await this._components.peerStore.tagPeer(peerInfo.id, DEFAULT_BOOTSTRAP_TAG_NAME, {\n value: this._options.tagValue ?? DEFAULT_BOOTSTRAP_TAG_VALUE,\n ttl: this._options.tagTTL ?? DEFAULT_BOOTSTRAP_TAG_TTL,\n });\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent(\"peer\", { detail: peerInfo }));\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__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return \"@waku/bootstrap\";\n }\n}\nfunction wakuDnsDiscovery(enrUrl, wantedNodeCapabilityCount) {\n return (components) => new PeerDiscoveryDns(components, { enrUrl, wantedNodeCapabilityCount });\n}\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/dns-discovery/dist/index.js?"); /***/ }), -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base10.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base16.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base2.js": +/***/ "./node_modules/@waku/dns-discovery/node_modules/@waku/utils/dist/bytes/index.js": /*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base2.js ***! + !*** ./node_modules/@waku/dns-discovery/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 */ \"base2\": () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base256emoji.js": -/*!**********************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base36.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base58.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base64.js": -/*!****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base8.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/identity.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/interface.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/basics.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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)\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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/cid.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/raw.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/hasher.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/identity.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***********************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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_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/@waku/dns-discovery/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/dns-discovery/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/dns-discovery/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/@waku/dns-discovery/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/interface.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/link/interface.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/src/link/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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/@waku/dns-discovery/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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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// 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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/varint.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/dns-discovery/node_modules/multiformats/vendor/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/alloc.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/* harmony import */ var _util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/as-uint8array.js */ \"./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n if (globalThis.Buffer?.alloc != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__.asUint8Array)(globalThis.Buffer.alloc(size));\n }\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 if (globalThis.Buffer?.allocUnsafe != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__.asUint8Array)(globalThis.Buffer.allocUnsafe(size));\n }\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/alloc.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/from-string.js": -/*!*******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/dns-discovery/node_modules/uint8arrays/dist/src/util/bases.js\");\n/* harmony import */ var _util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util/as-uint8array.js */ \"./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\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 if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(globalThis.Buffer.from(string, 'utf-8'));\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-rtc/./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/from-string.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/util/as-uint8array.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/@waku/dns-discovery/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 if (globalThis.Buffer != null) {\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n }\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/util/as-uint8array.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/dns-discovery/node_modules/uint8arrays/dist/src/util/bases.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/dns-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/@waku/dns-discovery/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var _alloc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../alloc.js */ \"./node_modules/@waku/dns-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_js__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: 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-rtc/./node_modules/@waku/dns-discovery/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 */ \"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-rtc/./node_modules/@waku/dns-discovery/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), @@ -7844,7 +6612,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 */ \"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-rtc/./node_modules/@waku/enr/dist/creator.js?"); +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/enr/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-rtc/./node_modules/@waku/enr/dist/creator.js?"); /***/ }), @@ -7855,7 +6623,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 */ \"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-rtc/./node_modules/@waku/enr/dist/crypto.js?"); +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/enr/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-rtc/./node_modules/@waku/enr/dist/crypto.js?"); /***/ }), @@ -7866,7 +6634,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 */ \"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-rtc/./node_modules/@waku/enr/dist/decoder.js?"); +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/enr/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-rtc/./node_modules/@waku/enr/dist/decoder.js?"); /***/ }), @@ -7877,7 +6645,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 */ \"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 constructor() {\n super(...arguments);\n this.getLocationMultiaddr = _get_multiaddr_js__WEBPACK_IMPORTED_MODULE_3__.locationMultiaddrFromEnrFields.bind({}, this);\n }\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 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}\nENR.RECORD_PREFIX = \"enr:\";\n//# sourceMappingURL=enr.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/enr/dist/enr.js?"); +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-rtc/./node_modules/@waku/enr/dist/enr.js?"); /***/ }), @@ -7932,7 +6700,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 */ \"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/@waku/enr/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-rtc/./node_modules/@waku/enr/dist/peer_id.js?"); +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-rtc/./node_modules/@waku/enr/dist/peer_id.js?"); /***/ }), @@ -7943,7 +6711,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 */ \"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 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-rtc/./node_modules/@waku/enr/dist/raw_enr.js?"); +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/enr/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-rtc/./node_modules/@waku/enr/dist/raw_enr.js?"); /***/ }), @@ -7954,7 +6722,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 */ \"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-rtc/./node_modules/@waku/enr/dist/v4.js?"); +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/enr/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-rtc/./node_modules/@waku/enr/dist/v4.js?"); /***/ }), @@ -7969,322 +6737,14 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/@waku/enr/node_modules/@libp2p/interface-peer-id/dist/src/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/@libp2p/interface-peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/@waku/enr/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/@waku/enr/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/@waku/enr/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/@waku/enr/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/@waku/enr/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/@waku/enr/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/@waku/enr/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/enr/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/enr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base10.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base16.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base2.js": +/***/ "./node_modules/@waku/enr/node_modules/@waku/utils/dist/bytes/index.js": /*!*****************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/src/bases/base2.js ***! + !*** ./node_modules/@waku/enr/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 */ \"base2\": () => (/* binding */ base2)\n/* harmony export */ });\n/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base256emoji.js": -/*!************************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base32.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base36.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base58.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base64.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/base8.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/identity.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/enr/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/@waku/enr/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bases/interface.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/src/bases/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/basics.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/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/@waku/enr/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/bytes.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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)\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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/cid.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/enr/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/enr/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/@waku/enr/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/@waku/enr/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/enr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/codecs/json.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/codecs/raw.js": -/*!****************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/hashes/digest.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/hashes/hasher.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/hashes/identity.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/index.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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_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/@waku/enr/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/enr/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/enr/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/enr/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/@waku/enr/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/interface.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/link/interface.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/src/link/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/src/varint.js": -/*!************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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/@waku/enr/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-rtc/./node_modules/@waku/enr/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/vendor/base-x.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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// 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-rtc/./node_modules/@waku/enr/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/enr/node_modules/multiformats/vendor/varint.js": -/*!***************************************************************************!*\ - !*** ./node_modules/@waku/enr/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/enr/node_modules/multiformats/vendor/varint.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/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-rtc/./node_modules/@waku/enr/node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), @@ -8328,7 +6788,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 */ \"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 */ \"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/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./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/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./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/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./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/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/interfaces/dist/receiver.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/interfaces/dist/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\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/interfaces/dist/enr.js\");\n/* harmony import */ var _filter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./filter.js */ \"./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/interfaces/dist/light_push.js\");\n/* harmony import */ var _message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message.js */ \"./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/interfaces/dist/peer_exchange.js\");\n/* harmony import */ var _protocols_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./protocols.js */ \"./node_modules/@waku/interfaces/dist/protocols.js\");\n/* harmony import */ var _relay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./relay.js */ \"./node_modules/@waku/interfaces/dist/relay.js\");\n/* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./store.js */ \"./node_modules/@waku/interfaces/dist/store.js\");\n/* harmony import */ var _waku_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./waku.js */ \"./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/interfaces/dist/connection_manager.js\");\n/* harmony import */ var _sender_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sender.js */ \"./node_modules/@waku/interfaces/dist/sender.js\");\n/* harmony import */ var _receiver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./receiver.js */ \"./node_modules/@waku/interfaces/dist/receiver.js\");\n/* harmony import */ var _misc_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./misc.js */ \"./node_modules/@waku/interfaces/dist/misc.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-rtc/./node_modules/@waku/interfaces/dist/index.js?"); /***/ }), @@ -8354,6 +6814,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n//# sourceMappingURL=messag /***/ }), +/***/ "./node_modules/@waku/interfaces/dist/misc.js": +/*!****************************************************!*\ + !*** ./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-rtc/./node_modules/@waku/interfaces/dist/misc.js?"); + +/***/ }), + /***/ "./node_modules/@waku/interfaces/dist/peer_exchange.js": /*!*************************************************************!*\ !*** ./node_modules/@waku/interfaces/dist/peer_exchange.js ***! @@ -8372,7 +6843,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 */ });\nvar Protocols;\n(function (Protocols) {\n Protocols[\"Relay\"] = \"relay\";\n Protocols[\"Store\"] = \"store\";\n Protocols[\"LightPush\"] = \"lightpush\";\n Protocols[\"Filter\"] = \"filter\";\n})(Protocols || (Protocols = {}));\n//# sourceMappingURL=protocols.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/interfaces/dist/protocols.js?"); +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-rtc/./node_modules/@waku/interfaces/dist/protocols.js?"); /***/ }), @@ -8438,7 +6909,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 */ \"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 */\n constructor(contentTopic, hsResult, ephemeral = true) {\n this.contentTopic = contentTopic;\n this.hsResult = hsResult;\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 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 return {\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 }\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-rtc/./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/noise/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-rtc/./node_modules/@waku/noise/dist/codec.js?"); /***/ }), @@ -8526,7 +6997,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 */\n constructor(sender, responder, myStaticKey, pairingParameters, myEphemeralKey = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_7__.generateX25519KeyPair)()) {\n this.sender = sender;\n this.responder = responder;\n this.myStaticKey = myStaticKey;\n this.myEphemeralKey = myEphemeralKey;\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(contentTopic, messageNametag) {\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 hsMessage = await this.responder.nextMessage(contentTopic);\n const step = this.handshake.stepHandshake({\n readPayloadV2: hsMessage.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 await this.responder.subscribe(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.contentTopic, this.handshake.hs.toMessageNametag());\n await this.responder.stop(this.contentTopic);\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);\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 await this.responder.subscribe(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.contentTopic, this.qrMessageNameTag);\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.contentTopic, this.handshake.hs.toMessageNametag());\n await this.responder.stop(this.contentTopic);\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);\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 * @returns an array with [NoiseSecureTransferEncoder, NoiseSecureTransferDecoder]\n */\n static getSecureCodec(contentTopic, hsResult) {\n const secureEncoder = new _codec_js__WEBPACK_IMPORTED_MODULE_6__.NoiseSecureTransferEncoder(contentTopic, hsResult);\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-rtc/./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 * @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-rtc/./node_modules/@waku/noise/dist/pairing.js?"); /***/ }), @@ -8585,6 +7056,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/@waku/noise/node_modules/@waku/core/dist/lib/message/version_0.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/noise/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/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-rtc/./node_modules/@waku/noise/node_modules/@waku/core/dist/lib/message/version_0.js?"); + +/***/ }), + /***/ "./node_modules/@waku/proto/dist/index.js": /*!************************************************!*\ !*** ./node_modules/@waku/proto/dist/index.js ***! @@ -8603,7 +7085,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 */ \"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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/filter.js?"); /***/ }), @@ -8614,7 +7096,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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), @@ -8625,7 +7107,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 */ \"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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/message.js?"); /***/ }), @@ -8636,7 +7118,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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/peer_exchange.js?"); /***/ }), @@ -8647,7 +7129,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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/store.js?"); /***/ }), @@ -8658,84 +7140,216 @@ 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/@waku/proto/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-rtc/./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-rtc/./node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js": +/***/ "./node_modules/@waku/relay/dist/constants.js": +/*!****************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"RelayCodecs\": () => (/* binding */ RelayCodecs),\n/* harmony export */ \"RelayFanoutTTL\": () => (/* binding */ RelayFanoutTTL),\n/* harmony export */ \"RelayGossipFactor\": () => (/* binding */ RelayGossipFactor),\n/* harmony export */ \"RelayHeartbeatInitialDelay\": () => (/* binding */ RelayHeartbeatInitialDelay),\n/* harmony export */ \"RelayHeartbeatInterval\": () => (/* binding */ RelayHeartbeatInterval),\n/* harmony export */ \"RelayMaxIHaveLength\": () => (/* binding */ RelayMaxIHaveLength),\n/* harmony export */ \"RelayOpportunisticGraftPeers\": () => (/* binding */ RelayOpportunisticGraftPeers),\n/* harmony export */ \"RelayOpportunisticGraftTicks\": () => (/* binding */ RelayOpportunisticGraftTicks),\n/* harmony export */ \"RelayPruneBackoff\": () => (/* binding */ RelayPruneBackoff),\n/* harmony export */ \"RelayPrunePeers\": () => (/* binding */ RelayPrunePeers),\n/* harmony export */ \"minute\": () => (/* binding */ minute),\n/* harmony export */ \"second\": () => (/* binding */ second)\n/* harmony export */ });\nconst second = 1000;\nconst minute = 60 * second;\n/**\n * RelayCodec is the libp2p identifier for the waku relay protocol\n */\nconst RelayCodecs = [\"/vac/waku/relay/2.0.0\"];\n/**\n * RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.\n * We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or\n * RelayDlazy, whichever is greater.\n */\nconst RelayGossipFactor = 0.25;\n/**\n * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins\n * after the router is initialized.\n */\nconst RelayHeartbeatInitialDelay = 100;\n/**\n * RelayHeartbeatInterval controls the time between heartbeats.\n */\nconst RelayHeartbeatInterval = second;\n/**\n * RelayPrunePeers 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 RelayPrunePeers other peers that we\n * know of.\n */\nconst RelayPrunePeers = 16;\n/**\n * RelayPruneBackoff 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 RelayPruneBackoff 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 RelayPruneBackoff\n * before attempting to re-graft.\n */\nconst RelayPruneBackoff = minute;\n/**\n * RelayFanoutTTL controls how long we keep track of the fanout state. If it's been\n * RelayFanoutTTL 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 RelayFanoutTTL = minute;\n/**\n * RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh\n * with opportunistic grafting. Every RelayOpportunisticGraftTicks 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 RelayOpportunisticGraftTicks = 60;\n/**\n * RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.\n */\nconst RelayOpportunisticGraftPeers = 2;\n/**\n * RelayMaxIHaveLength 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 RelayMaxIHaveLength = 5000;\n//# sourceMappingURL=constants.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/relay/dist/constants.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/index.js": +/*!************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"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/@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/@chainsafe/libp2p-gossipsub/dist/src/types.js\");\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_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @waku/core */ \"./node_modules/@waku/core/dist/index.js\");\n/* harmony import */ var _waku_interfaces__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @waku/interfaces */ \"./node_modules/@waku/interfaces/dist/index.js\");\n/* harmony import */ var _waku_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @waku/utils */ \"./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js\");\n/* harmony import */ var debug__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants.js */ \"./node_modules/@waku/relay/dist/constants.js\");\n/* harmony import */ var _message_validator_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./message_validator.js */ \"./node_modules/@waku/relay/dist/message_validator.js\");\n/* harmony import */ var _topic_only_message_js__WEBPACK_IMPORTED_MODULE_9__ = __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_6__(\"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_7__.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.pubsub)) {\n throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);\n }\n this.gossipSub = libp2p.pubsub;\n this.pubSubTopic = options?.pubSubTopic ?? _waku_core__WEBPACK_IMPORTED_MODULE_3__.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_9__.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_5__.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_4__.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_4__.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_5__.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(async ({ decoder, callback }) => {\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 callback(msg);\n }\n else {\n log(\"Failed to decode messages on\", topicOnlyMsg.contentTopic);\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\", async (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_8__.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_2__.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_7__.RelayCodecs;\n return pubsub;\n };\n}\nfunction toObservers(decoders, callback) {\n const contentTopicToDecoders = Array.from((0,_waku_utils__WEBPACK_IMPORTED_MODULE_5__.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-rtc/./node_modules/@waku/relay/dist/index.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/message_validator.js": +/*!************************************************************!*\ + !*** ./node_modules/@waku/relay/dist/message_validator.js ***! + \************************************************************/ +/***/ ((__unused_webpack___webpack_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/@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-rtc/./node_modules/@waku/relay/dist/message_validator.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/dist/topic_only_message.js": +/*!*************************************************************!*\ + !*** ./node_modules/@waku/relay/dist/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 */ \"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-rtc/./node_modules/@waku/relay/dist/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 ***! + \*************************************************************************/ +/***/ ((__unused_webpack___webpack_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-rtc/./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-rtc/./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/proto/node_modules/protons-runtime/dist/src/codec.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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js?"); +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-rtc/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/filter_v2.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.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 */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.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-rtc/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/light_push.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/message.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-rtc/./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-rtc/./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-rtc/./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/proto/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/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-rtc/./node_modules/@waku/relay/node_modules/@waku/proto/dist/lib/topic_only_message.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/group_by.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js?"); +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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/group_by.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js ***! - \**********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/index.js": +/*!********************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js?"); +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/relay/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/relay/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/relay/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/relay/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/relay/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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/index.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js ***! - \*********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_defined.js": +/*!*************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/index.js?"); +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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_defined.js?"); /***/ }), -/***/ "./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js ***! - \*********************************************************************************/ +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_size_valid.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/proto/node_modules/protons-runtime/dist/src/utils.js?"); +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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/is_size_valid.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/random_subset.js": +/*!****************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/random_subset.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/to_async_iterator.js": +/*!********************************************************************************************!*\ + !*** ./node_modules/@waku/relay/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, 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-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/common/to_async_iterator.js?"); + +/***/ }), + +/***/ "./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@waku/relay/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 */ \"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/relay/node_modules/@waku/utils/dist/common/index.js\");\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/relay/node_modules/@waku/utils/dist/index.js?"); /***/ }), @@ -8746,414 +7360,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/@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-rtc/./node_modules/@waku/utils/dist/bytes/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/common/index.js": -/*!*******************************************************!*\ - !*** ./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 */ \"getPseudoRandomSubset\": () => (/* reexport safe */ _random_subset_js__WEBPACK_IMPORTED_MODULE_1__.getPseudoRandomSubset),\n/* harmony export */ \"isDefined\": () => (/* reexport safe */ _is_defined_js__WEBPACK_IMPORTED_MODULE_0__.isDefined)\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\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/utils/dist/common/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/common/is_defined.js": -/*!************************************************************!*\ - !*** ./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-rtc/./node_modules/@waku/utils/dist/common/is_defined.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/common/random_subset.js": -/*!***************************************************************!*\ - !*** ./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-rtc/./node_modules/@waku/utils/dist/common/random_subset.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/index.js": -/*!************************************************!*\ - !*** ./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 */ \"getPseudoRandomSubset\": () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.getPseudoRandomSubset),\n/* harmony export */ \"isDefined\": () => (/* reexport safe */ _common_index_js__WEBPACK_IMPORTED_MODULE_0__.isDefined)\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-rtc/./node_modules/@waku/utils/dist/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/dist/libp2p/index.js": -/*!*******************************************************!*\ - !*** ./node_modules/@waku/utils/dist/libp2p/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 */ \"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-rtc/./node_modules/@waku/utils/dist/libp2p/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/node_modules/multiformats/vendor/base-x.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/utils/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base10.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base10.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base16.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base16.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base2.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base2.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base256emoji.js": -/*!**************************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base256emoji.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base32.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base32.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base36.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base36.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base58.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base58.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base64.js": -/*!********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base64.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/base8.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/base8.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/identity.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/utils/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/@waku/utils/node_modules/multiformats/src/bases/base.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../bytes.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bases/interface.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/src/bases/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bases/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/basics.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bases/identity.js */ \"./node_modules/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/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/@waku/utils/node_modules/multiformats/src/codecs/json.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./index.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/basics.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/bytes.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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)\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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/bytes.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/cid.js": -/*!***********************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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 _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/utils/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/@waku/utils/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/@waku/utils/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/@waku/utils/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/utils/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/cid.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/codecs/json.js": -/*!*******************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/codecs/json.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/codecs/raw.js": -/*!******************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/codecs/raw.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/hashes/digest.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/hashes/digest.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/hashes/hasher.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/hashes/hasher.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/hashes/identity.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digest.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/hashes/identity.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/hashes/sha2-browser.js": -/*!***************************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/hashes/sha2-browser.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/index.js": -/*!*************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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_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/@waku/utils/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/@waku/utils/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/@waku/utils/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _hashes_hasher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hashes/hasher.js */ \"./node_modules/@waku/utils/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/@waku/utils/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./interface.js */ \"./node_modules/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/interface.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/link/interface.js": -/*!**********************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/src/link/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/link/interface.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/src/varint.js": -/*!**************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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/@waku/utils/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-rtc/./node_modules/@waku/utils/node_modules/multiformats/src/varint.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/vendor/base-x.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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// 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-rtc/./node_modules/@waku/utils/node_modules/multiformats/vendor/base-x.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/multiformats/vendor/varint.js": -/*!*****************************************************************************!*\ - !*** ./node_modules/@waku/utils/node_modules/multiformats/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 */ });\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-rtc/./node_modules/@waku/utils/node_modules/multiformats/vendor/varint.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/* harmony import */ var _util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/as-uint8array.js */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\n/**\n * Returns a `Uint8Array` of the requested size. Referenced memory will\n * be initialized to 0.\n */\nfunction alloc(size = 0) {\n if (globalThis.Buffer?.alloc != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__.asUint8Array)(globalThis.Buffer.alloc(size));\n }\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 if (globalThis.Buffer?.allocUnsafe != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_0__.asUint8Array)(globalThis.Buffer.allocUnsafe(size));\n }\n return new Uint8Array(size);\n}\n//# sourceMappingURL=alloc.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./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/* harmony import */ var _util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util/as-uint8array.js */ \"./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/as-uint8array.js\");\n\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 if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {\n return (0,_util_as_uint8array_js__WEBPACK_IMPORTED_MODULE_1__.asUint8Array)(globalThis.Buffer.from(string, 'utf-8'));\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-rtc/./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 if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {\n return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8');\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-rtc/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/to-string.js?"); - -/***/ }), - -/***/ "./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/as-uint8array.js": -/*!******************************************************************************************!*\ - !*** ./node_modules/@waku/utils/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 if (globalThis.Buffer != null) {\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n }\n return buf;\n}\n//# sourceMappingURL=as-uint8array.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/@waku/utils/node_modules/uint8arrays/dist/src/util/as-uint8array.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/@waku/utils/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var _alloc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../alloc.js */ \"./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_js__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: 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-rtc/./node_modules/@waku/utils/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 */ \"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-rtc/./node_modules/@waku/utils/dist/bytes/index.js?"); /***/ }), @@ -9366,6 +7573,17 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/it-all/dist/src/index.js": +/*!***********************************************!*\ + !*** ./node_modules/it-all/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 */ });\nfunction isAsyncIterable(thing) {\n return thing[Symbol.asyncIterator] != null;\n}\nfunction all(source) {\n if (isAsyncIterable(source)) {\n return (async () => {\n const arr = [];\n for await (const entry of source) {\n arr.push(entry);\n }\n return arr;\n })();\n }\n const arr = [];\n for (const entry of source) {\n arr.push(entry);\n }\n return arr;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (all);\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/it-all/dist/src/index.js?"); + +/***/ }), + /***/ "./node_modules/it-batched-bytes/dist/src/index.js": /*!*********************************************************!*\ !*** ./node_modules/it-batched-bytes/dist/src/index.js ***! @@ -9659,7 +7877,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 */ \"DefaultAddressManager\": () => (/* binding */ DefaultAddressManager)\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 _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\nconst defaultAddressFilter = (addrs) => addrs;\nclass DefaultAddressManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\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 super();\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 Set();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n * Signal that we have confidence an observed multiaddr is publicly dialable -\n * this will make it appear in the output of getAddresses()\n */\n confirmObservedAddr(addr) {\n }\n /**\n * Signal that we do not have confidence an observed multiaddr is publicly dialable -\n * this will remove it from the output of getObservedAddrs()\n */\n removeObservedAddr(addr) {\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(addr);\n const remotePeer = ma.getPeerId();\n // strip our peer id if it has been passed\n if (remotePeer != null) {\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(remotePeer);\n // use same encoding for comparison\n if (remotePeerId.equals(this.components.peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(`/p2p/${this.components.peerId.toString()}`));\n }\n }\n const addrString = ma.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.add(addrString);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('change:addresses'));\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 addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()));\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_1__.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-rtc/./node_modules/libp2p/dist/src/address-manager/index.js?"); +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_interfaces_events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/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\n\n\nconst defaultAddressFilter = (addrs) => addrs;\nclass DefaultAddressManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter {\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 super();\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 Set();\n this.announceFilter = init.announceFilter ?? defaultAddressFilter;\n }\n /**\n * Get peer listen multiaddrs\n */\n getListenAddrs() {\n return Array.from(this.listen).map((a) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.multiaddr)(a));\n }\n /**\n * Add peer observed addresses\n * Signal that we have confidence an observed multiaddr is publicly dialable -\n * this will make it appear in the output of getAddresses()\n */\n confirmObservedAddr(addr) {\n }\n /**\n * Signal that we do not have confidence an observed multiaddr is publicly dialable -\n * this will remove it from the output of getObservedAddrs()\n */\n removeObservedAddr(addr) {\n }\n /**\n * Add peer observed addresses\n */\n addObservedAddr(addr) {\n let ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(addr);\n const remotePeer = ma.getPeerId();\n // strip our peer id if it has been passed\n if (remotePeer != null) {\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__.peerIdFromString)(remotePeer);\n // use same encoding for comparison\n if (remotePeerId.equals(this.components.peerId)) {\n ma = ma.decapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(`/p2p/${this.components.peerId.toString()}`));\n }\n }\n const addrString = ma.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.add(addrString);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('change:addresses'));\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 addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()));\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_1__.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-rtc/./node_modules/libp2p/dist/src/address-manager/index.js?"); /***/ }), @@ -9681,7 +7899,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 */ \"canHop\": () => (/* binding */ canHop),\n/* harmony export */ \"handleCanHop\": () => (/* binding */ handleCanHop),\n/* harmony export */ \"handleHop\": () => (/* binding */ handleHop),\n/* harmony export */ \"hop\": () => (/* binding */ hop)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/utils.js\");\n/* harmony import */ var _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _stop_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:hop');\nasync function handleHop(hopRequest) {\n const { connection, request, streamHandler, circuit, connectionManager } = hopRequest;\n // Ensure hop is enabled\n if (!circuit.hopEnabled()) {\n log('HOP request received but we are not acting as a relay');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n }\n // Validate the HOP request has the required input\n try {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.validateAddrs)(request, streamHandler);\n }\n catch (err) {\n log.error('invalid hop request via peer %p %o', connection.remotePeer, err);\n return;\n }\n if (request.dstPeer == null) {\n log('HOP request received but we do not receive a dstPeer');\n return;\n }\n // Get the connection to the destination (stop) peer\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__.peerIdFromBytes)(request.dstPeer.id);\n const destinationConnections = connectionManager.getConnections(destinationPeer);\n if (destinationConnections.length === 0 && !circuit.hopActive()) {\n log('HOP request received but we are not connected to the destination peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // TODO: Handle being an active relay\n if (destinationConnections.length === 0) {\n log('did not have connection to remote peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // Handle the incoming HOP request by performing a STOP request\n const stopRequest = {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP,\n dstPeer: request.dstPeer,\n srcPeer: request.srcPeer\n };\n let destinationStream;\n try {\n log('performing STOP request');\n const result = await (0,_stop_js__WEBPACK_IMPORTED_MODULE_7__.stop)({\n connection: destinationConnections[0],\n request: stopRequest\n });\n if (result == null) {\n throw new Error('Could not stop');\n }\n destinationStream = result;\n }\n catch (err) {\n log.error(err);\n return;\n }\n log('hop request from %p is valid', connection.remotePeer);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS\n });\n const sourceStream = streamHandler.rest();\n log('creating related connections');\n // Short circuit the two streams to create the relayed connection\n return await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(sourceStream, destinationStream, sourceStream);\n}\n/**\n * Performs a HOP request to a relay peer, to request a connection to another\n * peer. A new, virtual, connection will be created between the two via the relay.\n */\nasync function hop(options) {\n const { connection, request, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write(request);\n const response = await streamHandler.read();\n if (response == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('HOP request had no response'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n }\n if (response.code === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n log('hop request was successful');\n return streamHandler.rest();\n }\n log('hop request failed with code %d, closing stream', response.code);\n streamHandler.close();\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`HOP request failed with code \"${response.code ?? 'unknown'}\"`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n}\n/**\n * Performs a CAN_HOP request to a relay peer, in order to understand its capabilities\n */\nasync function canHop(options) {\n const { connection, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP\n });\n const response = await streamHandler.read();\n await streamHandler.close();\n if (response == null || response.code !== _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n return false;\n }\n return true;\n}\n/**\n * Creates an unencoded CAN_HOP response based on the Circuits configuration\n */\nfunction handleCanHop(options) {\n const { connection, streamHandler, circuit } = options;\n const canHop = circuit.hopEnabled();\n log('can hop (%s) request from %p', canHop, connection.remotePeer);\n streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: canHop ? _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS : _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n}\n//# sourceMappingURL=hop.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/circuit/hop.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"canHop\": () => (/* binding */ canHop),\n/* harmony export */ \"handleCanHop\": () => (/* binding */ handleCanHop),\n/* harmony export */ \"handleHop\": () => (/* binding */ handleHop),\n/* harmony export */ \"hop\": () => (/* binding */ hop)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/utils.js\");\n/* harmony import */ var _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _stop_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:circuit:hop');\nasync function handleHop(hopRequest) {\n const { connection, request, streamHandler, circuit, connectionManager } = hopRequest;\n // Ensure hop is enabled\n if (!circuit.hopEnabled()) {\n log('HOP request received but we are not acting as a relay');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n }\n // Validate the HOP request has the required input\n try {\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.validateAddrs)(request, streamHandler);\n }\n catch (err) {\n log.error('invalid hop request via peer %p %o', connection.remotePeer, err);\n return;\n }\n if (request.dstPeer == null) {\n log('HOP request received but we do not receive a dstPeer');\n return;\n }\n // Get the connection to the destination (stop) peer\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_9__.peerIdFromBytes)(request.dstPeer.id);\n const destinationConnections = connectionManager.getConnections(destinationPeer);\n if (destinationConnections.length === 0 && !circuit.hopActive()) {\n log('HOP request received but we are not connected to the destination peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // TODO: Handle being an active relay\n if (destinationConnections.length === 0) {\n log('did not have connection to remote peer');\n return streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_NO_CONN_TO_DST\n });\n }\n // Handle the incoming HOP request by performing a STOP request\n const stopRequest = {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP,\n dstPeer: request.dstPeer,\n srcPeer: request.srcPeer\n };\n let destinationStream;\n try {\n log('performing STOP request');\n const result = await (0,_stop_js__WEBPACK_IMPORTED_MODULE_7__.stop)({\n connection: destinationConnections[0],\n request: stopRequest\n });\n if (result == null) {\n throw new Error('Could not stop');\n }\n destinationStream = result;\n }\n catch (err) {\n log.error(err);\n return;\n }\n log('hop request from %p is valid', connection.remotePeer);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS\n });\n const sourceStream = streamHandler.rest();\n log('creating related connections');\n // Short circuit the two streams to create the relayed connection\n return await (0,it_pipe__WEBPACK_IMPORTED_MODULE_5__.pipe)(sourceStream, destinationStream, sourceStream);\n}\n/**\n * Performs a HOP request to a relay peer, to request a connection to another\n * peer. A new, virtual, connection will be created between the two via the relay.\n */\nasync function hop(options) {\n const { connection, request, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write(request);\n const response = await streamHandler.read();\n if (response == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('HOP request had no response'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n }\n if (response.code === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n log('hop request was successful');\n return streamHandler.rest();\n }\n log('hop request failed with code %d, closing stream', response.code);\n streamHandler.close();\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`HOP request failed with code \"${response.code ?? 'unknown'}\"`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_HOP_REQUEST_FAILED);\n}\n/**\n * Performs a CAN_HOP request to a relay peer, in order to understand its capabilities\n */\nasync function canHop(options) {\n const { connection, signal } = options;\n // Create a new stream to the relay\n const stream = await connection.newStream(_multicodec_js__WEBPACK_IMPORTED_MODULE_8__.RELAY_CODEC, {\n signal\n });\n // Send the HOP request\n const streamHandler = new _stream_handler_js__WEBPACK_IMPORTED_MODULE_3__.StreamHandler({ stream });\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP\n });\n const response = await streamHandler.read();\n await streamHandler.close();\n if (response == null || response.code !== _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS) {\n return false;\n }\n return true;\n}\n/**\n * Creates an unencoded CAN_HOP response based on the Circuits configuration\n */\nfunction handleCanHop(options) {\n const { connection, streamHandler, circuit } = options;\n const canHop = circuit.hopEnabled();\n log('can hop (%s) request from %p', canHop, connection.remotePeer);\n streamHandler.end({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: canHop ? _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.SUCCESS : _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY\n });\n}\n//# sourceMappingURL=hop.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/circuit/hop.js?"); /***/ }), @@ -9747,7 +7965,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 */ \"createListener\": () => (/* binding */ createListener)\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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nfunction createListener(options) {\n const listeningAddrs = new Map();\n /**\n * Add swarm handler and listen for incoming connections\n */\n async function listen(addr) {\n const addrString = addr.toString().split('/p2p-circuit').find(a => a !== '');\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(addrString);\n const relayPeerStr = ma.getPeerId();\n if (relayPeerStr == null) {\n throw new Error('Could not determine relay peer from multiaddr');\n }\n const relayPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(relayPeerStr);\n await options.peerStore.addressBook.add(relayPeerId, [ma]);\n const relayConn = await options.connectionManager.openConnection(relayPeerId);\n const relayedAddr = relayConn.remoteAddr.encapsulate('/p2p-circuit');\n listeningAddrs.set(relayConn.remotePeer.toString(), relayedAddr);\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('listening'));\n }\n /**\n * Get fixed up multiaddrs\n *\n * NOTE: This method will grab the peers multiaddrs and expand them such that:\n *\n * a) If it's an existing /p2p-circuit address for a specific relay i.e.\n * `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit` this method will expand the\n * address to `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer` where\n * `QmPeer` is this peers id\n * b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit\n * addr, such when dialing over a relay with this address, it will create the circuit using\n * the encapsulated transport address. This is useful when for example, a peer should only\n * be dialed over TCP rather than any other transport\n *\n * @returns {Multiaddr[]}\n */\n function getAddrs() {\n const addrs = [];\n for (const addr of listeningAddrs.values()) {\n addrs.push(addr);\n }\n return addrs;\n }\n const listener = Object.assign(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter(), {\n close: async () => await Promise.resolve(),\n listen,\n getAddrs\n });\n // Remove listeningAddrs when a peer disconnects\n options.connectionManager.addEventListener('peer:disconnect', (evt) => {\n const { detail: connection } = evt;\n const deleted = listeningAddrs.delete(connection.remotePeer.toString());\n if (deleted) {\n // Announce listen addresses change\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('close'));\n }\n });\n return listener;\n}\n//# sourceMappingURL=listener.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/listener.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"createListener\": () => (/* binding */ createListener)\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 _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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nfunction createListener(options) {\n const listeningAddrs = new Map();\n /**\n * Add swarm handler and listen for incoming connections\n */\n async function listen(addr) {\n const addrString = addr.toString().split('/p2p-circuit').find(a => a !== '');\n const ma = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.multiaddr)(addrString);\n const relayPeerStr = ma.getPeerId();\n if (relayPeerStr == null) {\n throw new Error('Could not determine relay peer from multiaddr');\n }\n const relayPeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_1__.peerIdFromString)(relayPeerStr);\n await options.peerStore.addressBook.add(relayPeerId, [ma]);\n const relayConn = await options.connectionManager.openConnection(relayPeerId);\n const relayedAddr = relayConn.remoteAddr.encapsulate('/p2p-circuit');\n listeningAddrs.set(relayConn.remotePeer.toString(), relayedAddr);\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('listening'));\n }\n /**\n * Get fixed up multiaddrs\n *\n * NOTE: This method will grab the peers multiaddrs and expand them such that:\n *\n * a) If it's an existing /p2p-circuit address for a specific relay i.e.\n * `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit` this method will expand the\n * address to `/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer` where\n * `QmPeer` is this peers id\n * b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit\n * addr, such when dialing over a relay with this address, it will create the circuit using\n * the encapsulated transport address. This is useful when for example, a peer should only\n * be dialed over TCP rather than any other transport\n *\n * @returns {Multiaddr[]}\n */\n function getAddrs() {\n const addrs = [];\n for (const addr of listeningAddrs.values()) {\n addrs.push(addr);\n }\n return addrs;\n }\n const listener = Object.assign(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.EventEmitter(), {\n close: async () => await Promise.resolve(),\n listen,\n getAddrs\n });\n // Remove listeningAddrs when a peer disconnects\n options.connectionManager.addEventListener('peer:disconnect', (evt) => {\n const { detail: connection } = evt;\n const deleted = listeningAddrs.delete(connection.remotePeer.toString());\n if (deleted) {\n // Announce listen addresses change\n listener.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_0__.CustomEvent('close'));\n }\n });\n return listener;\n}\n//# sourceMappingURL=listener.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/listener.js?"); /***/ }), @@ -9780,7 +7998,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 */ \"Circuit\": () => (/* binding */ Circuit)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/utils/stream-to-ma-conn */ \"./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/libp2p/dist/src/circuit/listener.js\");\n/* harmony import */ var _circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./circuit/hop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/hop.js\");\n/* harmony import */ var _circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./circuit/stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\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_0__.logger)('libp2p:circuit');\nclass Circuit {\n constructor(components, init) {\n this._init = init;\n this.components = components;\n this._started = false;\n }\n isStarted() {\n return this._started;\n }\n async start() {\n if (this._started) {\n return;\n }\n this._started = true;\n await this.components.registrar.handle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC, (data) => {\n void this._onProtocol(data).catch(err => {\n log.error(err);\n });\n }, { ...this._init })\n .catch(err => {\n log.error(err);\n });\n }\n async stop() {\n await this.components.registrar.unhandle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC);\n }\n hopEnabled() {\n return true;\n }\n hopActive() {\n return true;\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return 'libp2p/circuit-relay-v1';\n }\n async _onProtocol(data) {\n const { connection, stream } = data;\n const controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__.TimeoutController(this._init.hop.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_16__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n try {\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_14__.abortableDuplex)(stream, controller.signal);\n const streamHandler = new _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__.StreamHandler({\n stream: {\n ...stream,\n ...source\n }\n });\n const request = await streamHandler.read();\n if (request == null) {\n log('request was invalid, could not read from stream');\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n let virtualConnection;\n switch (request.type) {\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP: {\n log('received CAN_HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleCanHop)({ circuit: this, connection, streamHandler });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP: {\n log('received HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleHop)({\n connection,\n request,\n streamHandler,\n circuit: this,\n connectionManager: this.components.connectionManager\n });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP: {\n log('received STOP request from %p', connection.remotePeer);\n virtualConnection = await (0,_circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__.handleStop)({\n connection,\n request,\n streamHandler\n });\n break;\n }\n default: {\n log('Request of type %s not supported', request.type);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n }\n if (virtualConnection != null) {\n const remoteAddr = connection.remoteAddr\n .encapsulate('/p2p-circuit')\n .encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.dstPeer?.addrs[0]));\n const localAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.srcPeer?.addrs[0]);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr,\n localAddr\n });\n const type = request.type === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP ? 'relay' : 'inbound';\n log('new %s connection %s', type, maConn.remoteAddr);\n const conn = await this.components.upgrader.upgradeInbound(maConn);\n log('%s connection %s upgraded', type, maConn.remoteAddr);\n if (this.handler != null) {\n this.handler(conn);\n }\n }\n }\n finally {\n controller.clear();\n }\n }\n /**\n * Dial a peer over a relay\n */\n async dial(ma, options = {}) {\n // Check the multiaddr to see if it contains a relay and a destination peer\n const addrs = ma.toString().split('/p2p-circuit');\n const relayAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[0]);\n const destinationAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[addrs.length - 1]);\n const relayId = relayAddr.getPeerId();\n const destinationId = destinationAddr.getPeerId();\n if (relayId == null || destinationId == null) {\n const errMsg = 'Circuit relay dial failed as addresses did not have peer id';\n log.error(errMsg);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(errMsg), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_RELAYED_DIAL);\n }\n const relayPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(relayId);\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(destinationId);\n let disconnectOnFailure = false;\n const relayConnections = this.components.connectionManager.getConnections(relayPeer);\n let relayConnection = relayConnections[0];\n if (relayConnection == null) {\n await this.components.peerStore.addressBook.add(relayPeer, [relayAddr]);\n relayConnection = await this.components.connectionManager.openConnection(relayPeer, options);\n disconnectOnFailure = true;\n }\n try {\n const virtualConnection = await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.hop)({\n ...options,\n connection: relayConnection,\n request: {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP,\n srcPeer: {\n id: this.components.peerId.toBytes(),\n addrs: this.components.addressManager.getAddresses().map(addr => addr.bytes)\n },\n dstPeer: {\n id: destinationPeer.toBytes(),\n addrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(destinationAddr).bytes]\n }\n }\n });\n const localAddr = relayAddr.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr: ma,\n localAddr\n });\n log('new outbound connection %s', maConn.remoteAddr);\n return await this.components.upgrader.upgradeOutbound(maConn);\n }\n catch (err) {\n log.error('Circuit relay dial failed', err);\n disconnectOnFailure && await relayConnection.close();\n throw err;\n }\n }\n /**\n * Create a listener\n */\n createListener(options) {\n // Called on successful HOP and STOP requests\n this.handler = options.handler;\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_8__.createListener)({\n connectionManager: this.components.connectionManager,\n peerStore: this.components.peerStore\n });\n }\n /**\n * Filter check for all Multiaddrs that this transport can dial on\n *\n * @param {Multiaddr[]} multiaddrs\n * @returns {Multiaddr[]}\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n return multiaddrs.filter((ma) => {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__.Circuit.matches(ma);\n });\n }\n}\n//# sourceMappingURL=transport.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/transport.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Circuit\": () => (/* binding */ Circuit)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @multiformats/mafmt */ \"./node_modules/@multiformats/mafmt/dist/src/index.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pb/index.js */ \"./node_modules/libp2p/dist/src/circuit/pb/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 _libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/utils/stream-to-ma-conn */ \"./node_modules/@libp2p/utils/dist/src/stream-to-ma-conn.js\");\n/* harmony import */ var _multicodec_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./multicodec.js */ \"./node_modules/libp2p/dist/src/circuit/multicodec.js\");\n/* harmony import */ var _listener_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./listener.js */ \"./node_modules/libp2p/dist/src/circuit/listener.js\");\n/* harmony import */ var _circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./circuit/hop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/hop.js\");\n/* harmony import */ var _circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./circuit/stop.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stop.js\");\n/* harmony import */ var _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/stream-handler.js */ \"./node_modules/libp2p/dist/src/circuit/circuit/stream-handler.js\");\n/* harmony import */ var _libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-transport */ \"./node_modules/libp2p/node_modules/@libp2p/interface-transport/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\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_0__.logger)('libp2p:circuit');\nclass Circuit {\n constructor(components, init) {\n this._init = init;\n this.components = components;\n this._started = false;\n }\n isStarted() {\n return this._started;\n }\n async start() {\n if (this._started) {\n return;\n }\n this._started = true;\n await this.components.registrar.handle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC, (data) => {\n void this._onProtocol(data).catch(err => {\n log.error(err);\n });\n }, { ...this._init })\n .catch(err => {\n log.error(err);\n });\n }\n async stop() {\n await this.components.registrar.unhandle(_multicodec_js__WEBPACK_IMPORTED_MODULE_7__.RELAY_CODEC);\n }\n hopEnabled() {\n return true;\n }\n hopActive() {\n return true;\n }\n get [_libp2p_interface_transport__WEBPACK_IMPORTED_MODULE_12__.symbol]() {\n return true;\n }\n get [Symbol.toStringTag]() {\n return 'libp2p/circuit-relay-v1';\n }\n async _onProtocol(data) {\n const { connection, stream } = data;\n const controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_15__.TimeoutController(this._init.hop.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_16__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n try {\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_14__.abortableDuplex)(stream, controller.signal);\n const streamHandler = new _circuit_stream_handler_js__WEBPACK_IMPORTED_MODULE_11__.StreamHandler({\n stream: {\n ...stream,\n ...source\n }\n });\n const request = await streamHandler.read();\n if (request == null) {\n log('request was invalid, could not read from stream');\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n let virtualConnection;\n switch (request.type) {\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.CAN_HOP: {\n log('received CAN_HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleCanHop)({ circuit: this, connection, streamHandler });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP: {\n log('received HOP request from %p', connection.remotePeer);\n await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.handleHop)({\n connection,\n request,\n streamHandler,\n circuit: this,\n connectionManager: this.components.connectionManager\n });\n break;\n }\n case _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STOP: {\n log('received STOP request from %p', connection.remotePeer);\n virtualConnection = await (0,_circuit_stop_js__WEBPACK_IMPORTED_MODULE_10__.handleStop)({\n connection,\n request,\n streamHandler\n });\n break;\n }\n default: {\n log('Request of type %s not supported', request.type);\n streamHandler.write({\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.STATUS,\n code: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Status.MALFORMED_MESSAGE\n });\n streamHandler.close();\n return;\n }\n }\n if (virtualConnection != null) {\n const remoteAddr = connection.remoteAddr\n .encapsulate('/p2p-circuit')\n .encapsulate((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.dstPeer?.addrs[0]));\n const localAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(request.srcPeer?.addrs[0]);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr,\n localAddr\n });\n const type = request.type === _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP ? 'relay' : 'inbound';\n log('new %s connection %s', type, maConn.remoteAddr);\n const conn = await this.components.upgrader.upgradeInbound(maConn);\n log('%s connection %s upgraded', type, maConn.remoteAddr);\n if (this.handler != null) {\n this.handler(conn);\n }\n }\n }\n finally {\n controller.clear();\n }\n }\n /**\n * Dial a peer over a relay\n */\n async dial(ma, options = {}) {\n // Check the multiaddr to see if it contains a relay and a destination peer\n const addrs = ma.toString().split('/p2p-circuit');\n const relayAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[0]);\n const destinationAddr = (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(addrs[addrs.length - 1]);\n const relayId = relayAddr.getPeerId();\n const destinationId = destinationAddr.getPeerId();\n if (relayId == null || destinationId == null) {\n const errMsg = 'Circuit relay dial failed as addresses did not have peer id';\n log.error(errMsg);\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(errMsg), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_RELAYED_DIAL);\n }\n const relayPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(relayId);\n const destinationPeer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_13__.peerIdFromString)(destinationId);\n let disconnectOnFailure = false;\n const relayConnections = this.components.connectionManager.getConnections(relayPeer);\n let relayConnection = relayConnections[0];\n if (relayConnection == null) {\n await this.components.peerStore.addressBook.add(relayPeer, [relayAddr]);\n relayConnection = await this.components.connectionManager.openConnection(relayPeer, options);\n disconnectOnFailure = true;\n }\n try {\n const virtualConnection = await (0,_circuit_hop_js__WEBPACK_IMPORTED_MODULE_9__.hop)({\n ...options,\n connection: relayConnection,\n request: {\n type: _pb_index_js__WEBPACK_IMPORTED_MODULE_4__.CircuitRelay.Type.HOP,\n srcPeer: {\n id: this.components.peerId.toBytes(),\n addrs: this.components.addressManager.getAddresses().map(addr => addr.bytes)\n },\n dstPeer: {\n id: destinationPeer.toBytes(),\n addrs: [(0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.multiaddr)(destinationAddr).bytes]\n }\n }\n });\n const localAddr = relayAddr.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`);\n const maConn = (0,_libp2p_utils_stream_to_ma_conn__WEBPACK_IMPORTED_MODULE_6__.streamToMaConnection)({\n stream: virtualConnection,\n remoteAddr: ma,\n localAddr\n });\n log('new outbound connection %s', maConn.remoteAddr);\n return await this.components.upgrader.upgradeOutbound(maConn);\n }\n catch (err) {\n log.error('Circuit relay dial failed', err);\n disconnectOnFailure && await relayConnection.close();\n throw err;\n }\n }\n /**\n * Create a listener\n */\n createListener(options) {\n // Called on successful HOP and STOP requests\n this.handler = options.handler;\n return (0,_listener_js__WEBPACK_IMPORTED_MODULE_8__.createListener)({\n connectionManager: this.components.connectionManager,\n peerStore: this.components.peerStore\n });\n }\n /**\n * Filter check for all Multiaddrs that this transport can dial on\n *\n * @param {Multiaddr[]} multiaddrs\n * @returns {Multiaddr[]}\n */\n filter(multiaddrs) {\n multiaddrs = Array.isArray(multiaddrs) ? multiaddrs : [multiaddrs];\n return multiaddrs.filter((ma) => {\n return _multiformats_mafmt__WEBPACK_IMPORTED_MODULE_2__.Circuit.matches(ma);\n });\n }\n}\n//# sourceMappingURL=transport.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/circuit/transport.js?"); /***/ }), @@ -9857,7 +8075,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 */ \"DefaultConnectionManager\": () => (/* binding */ DefaultConnectionManager)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./latency-monitor.js */ \"./node_modules/libp2p/dist/src/connection-manager/latency-monitor.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-connection/status */ \"./node_modules/libp2p/node_modules/@libp2p/interface-connection/dist/src/status.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-peer-store/tags */ \"./node_modules/@libp2p/interface-peer-store/dist/src/tags.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager');\nconst defaultOptions = {\n maxConnections: Infinity,\n minConnections: 0,\n maxEventLoopDelay: Infinity,\n pollInterval: 2000,\n autoDialInterval: 10000,\n inboundConnectionThreshold: 5,\n maxIncomingPendingConnections: 10\n};\nconst STARTUP_RECONNECT_TIMEOUT = 60000;\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.EventEmitter {\n constructor(components, init) {\n super();\n this.opts = merge_options__WEBPACK_IMPORTED_MODULE_2__[\"default\"].call({ ignoreUndefined: true }, defaultOptions, init);\n if (this.opts.maxConnections < this.opts.minConnections) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Connection Manager maxConnections must be greater than minConnections'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n log('options: %o', this.opts);\n this.components = components;\n /**\n * Map of connections per peer\n */\n this.connections = new Map();\n this.started = false;\n if (init.maxEventLoopDelay != null && init.maxEventLoopDelay > 0 && init.maxEventLoopDelay !== Infinity) {\n this.latencyMonitor = new _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__.LatencyMonitor({\n latencyCheckIntervalMs: init.pollInterval,\n dataEmitIntervalMs: init.pollInterval\n });\n }\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this);\n }\n catch { }\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.startupReconnectTimeout = init.startupReconnectTimeout ?? STARTUP_RECONNECT_TIMEOUT;\n this.dialTimeout = init.dialTimeout ?? 30000;\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.inboundConnectionRateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__.RateLimiterMemory({\n points: this.opts.inboundConnectionThreshold,\n duration: 1\n });\n this.incomingPendingConnections = 0;\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.components.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.components.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.components.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 // latency monitor\n this.latencyMonitor?.start();\n this._onLatencyMeasure = this._onLatencyMeasure.bind(this);\n this.latencyMonitor?.addEventListener('data', this._onLatencyMeasure);\n this.started = true;\n log('started');\n }\n async afterStart() {\n this.components.upgrader.addEventListener('connection', this.onConnect);\n this.components.upgrader.addEventListener('connectionEnd', this.onDisconnect);\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = [];\n for (const peer of await this.components.peerStore.all()) {\n const tags = await this.components.peerStore.getTags(peer.id);\n const hasKeepAlive = tags.filter(tag => tag.name === _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__.KEEP_ALIVE).length > 0;\n if (hasKeepAlive) {\n keepAlivePeers.push(peer.id);\n }\n }\n this.connectOnStartupController?.clear();\n this.connectOnStartupController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.startupReconnectTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this.connectOnStartupController.signal);\n }\n catch { }\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer, {\n signal: this.connectOnStartupController?.signal\n })\n .catch(err => {\n log.error(err);\n });\n }));\n })\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n this.connectOnStartupController?.clear();\n });\n }\n async beforeStop() {\n // if we are still dialing KEEP_ALIVE peers, abort those dials\n this.connectOnStartupController?.abort();\n this.components.upgrader.removeEventListener('connection', this.onConnect);\n this.components.upgrader.removeEventListener('connectionEnd', this.onDisconnect);\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.latencyMonitor?.removeEventListener('data', this._onLatencyMeasure);\n this.latencyMonitor?.stop();\n this.started = false;\n await this._close();\n log('stopped');\n }\n /**\n * Cleans up the connections\n */\n async _close() {\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 }\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 peerIdStr = peerId.toString();\n const storedConns = this.connections.get(peerIdStr);\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n this.connections.set(peerIdStr, [connection]);\n }\n if (peerId.publicKey != null) {\n await this.components.peerStore.keyBook.set(peerId, peerId.publicKey);\n }\n const numConnections = this.getConnections().length;\n const toPrune = numConnections - this.opts.maxConnections;\n await this._checkMaxLimit('maxConnections', numConnections, toPrune);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:connect', { detail: connection }));\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.toString();\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:disconnect', { detail: connection }));\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId.toString()) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_14__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId == null && multiaddr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new TypeError('Can only open connections to PeerIds or Multiaddrs'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n if (peerId != null) {\n log('dial to', 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 let timeoutController;\n if (options?.signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.dialTimeout);\n options.signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\n try {\n const connection = await this.components.dialer.dial(peerIdOrMultiaddr, options);\n let peerConnections = this.connections.get(connection.remotePeer.toString());\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer.toString(), 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 finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n }\n }\n async closeConnections(peerId) {\n const connections = this.connections.get(peerId.toString()) ?? [];\n await Promise.all(connections.map(async (connection) => {\n return await connection.close();\n }));\n }\n /**\n * Get all open connections with a peer\n */\n getAll(peerId) {\n if (!(0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__.isPeerId)(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('peerId must be an instance of peer-id'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n const id = peerId.toString();\n const connections = this.connections.get(id);\n // Return all open connections\n if (connections != null) {\n return connections.filter(connection => connection.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__.OPEN);\n }\n return [];\n }\n /**\n * If the event loop is slow, maybe close a connection\n */\n _onLatencyMeasure(evt) {\n const { detail: summary } = evt;\n this._checkMaxLimit('maxEventLoopDelay', summary.avgMs, 1)\n .catch(err => {\n log.error(err);\n });\n }\n /**\n * If the `value` of `name` has exceeded its limit, maybe close a connection\n */\n async _checkMaxLimit(name, value, toPrune = 1) {\n const limit = this.opts[name];\n if (limit == null) {\n log.trace('limit %s was not set so it cannot be applied', name);\n return;\n }\n log.trace('checking limit of %s. current value: %d of %d', name, value, limit);\n if (value > limit) {\n log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune);\n await this._pruneConnections(toPrune);\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 _pruneConnections(toPrune) {\n const connections = this.getConnections();\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__.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 const tags = await this.components.peerStore.getTags(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, tags.reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\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 toClose.push(connection);\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 // TODO: should not need to invoke this manually\n this.onDisconnect(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('connectionEnd', {\n detail: connection\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 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.opts.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.opts.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}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/connection-manager/index.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./latency-monitor.js */ \"./node_modules/libp2p/dist/src/connection-manager/latency-monitor.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 _errors_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n/* harmony import */ var _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-connection/status */ \"./node_modules/libp2p/node_modules/@libp2p/interface-connection/dist/src/status.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @libp2p/interface-peer-store/tags */ \"./node_modules/@libp2p/interface-peer-store/dist/src/tags.js\");\n/* harmony import */ var rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! rate-limiter-flexible */ \"./node_modules/rate-limiter-flexible/index.js\");\n/* harmony import */ var _get_peer_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../get-peer.js */ \"./node_modules/libp2p/dist/src/get-peer.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p:connection-manager');\nconst defaultOptions = {\n maxConnections: Infinity,\n minConnections: 0,\n maxEventLoopDelay: Infinity,\n pollInterval: 2000,\n autoDialInterval: 10000,\n inboundConnectionThreshold: 5,\n maxIncomingPendingConnections: 10\n};\nconst STARTUP_RECONNECT_TIMEOUT = 60000;\n/**\n * Responsible for managing known connections.\n */\nclass DefaultConnectionManager extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.EventEmitter {\n constructor(components, init) {\n super();\n this.opts = merge_options__WEBPACK_IMPORTED_MODULE_2__[\"default\"].call({ ignoreUndefined: true }, defaultOptions, init);\n if (this.opts.maxConnections < this.opts.minConnections) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Connection Manager maxConnections must be greater than minConnections'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n log('options: %o', this.opts);\n this.components = components;\n /**\n * Map of connections per peer\n */\n this.connections = new Map();\n this.started = false;\n if (init.maxEventLoopDelay != null && init.maxEventLoopDelay > 0 && init.maxEventLoopDelay !== Infinity) {\n this.latencyMonitor = new _latency_monitor_js__WEBPACK_IMPORTED_MODULE_3__.LatencyMonitor({\n latencyCheckIntervalMs: init.pollInterval,\n dataEmitIntervalMs: init.pollInterval\n });\n }\n try {\n // This emitter gets listened to a lot\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this);\n }\n catch { }\n this.onConnect = this.onConnect.bind(this);\n this.onDisconnect = this.onDisconnect.bind(this);\n this.startupReconnectTimeout = init.startupReconnectTimeout ?? STARTUP_RECONNECT_TIMEOUT;\n this.dialTimeout = init.dialTimeout ?? 30000;\n this.allow = (init.allow ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.deny = (init.deny ?? []).map(ma => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_9__.multiaddr)(ma));\n this.inboundConnectionRateLimiter = new rate_limiter_flexible__WEBPACK_IMPORTED_MODULE_13__.RateLimiterMemory({\n points: this.opts.inboundConnectionThreshold,\n duration: 1\n });\n this.incomingPendingConnections = 0;\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.components.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.components.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.components.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 // latency monitor\n this.latencyMonitor?.start();\n this._onLatencyMeasure = this._onLatencyMeasure.bind(this);\n this.latencyMonitor?.addEventListener('data', this._onLatencyMeasure);\n this.started = true;\n log('started');\n }\n async afterStart() {\n this.components.upgrader.addEventListener('connection', this.onConnect);\n this.components.upgrader.addEventListener('connectionEnd', this.onDisconnect);\n // re-connect to any peers with the KEEP_ALIVE tag\n void Promise.resolve()\n .then(async () => {\n const keepAlivePeers = [];\n for (const peer of await this.components.peerStore.all()) {\n const tags = await this.components.peerStore.getTags(peer.id);\n const hasKeepAlive = tags.filter(tag => tag.name === _libp2p_interface_peer_store_tags__WEBPACK_IMPORTED_MODULE_12__.KEEP_ALIVE).length > 0;\n if (hasKeepAlive) {\n keepAlivePeers.push(peer.id);\n }\n }\n this.connectOnStartupController?.clear();\n this.connectOnStartupController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.startupReconnectTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, this.connectOnStartupController.signal);\n }\n catch { }\n await Promise.all(keepAlivePeers.map(async (peer) => {\n await this.openConnection(peer, {\n signal: this.connectOnStartupController?.signal\n })\n .catch(err => {\n log.error(err);\n });\n }));\n })\n .catch(err => {\n log.error(err);\n })\n .finally(() => {\n this.connectOnStartupController?.clear();\n });\n }\n async beforeStop() {\n // if we are still dialing KEEP_ALIVE peers, abort those dials\n this.connectOnStartupController?.abort();\n this.components.upgrader.removeEventListener('connection', this.onConnect);\n this.components.upgrader.removeEventListener('connectionEnd', this.onDisconnect);\n }\n /**\n * Stops the Connection Manager\n */\n async stop() {\n this.latencyMonitor?.removeEventListener('data', this._onLatencyMeasure);\n this.latencyMonitor?.stop();\n this.started = false;\n await this._close();\n log('stopped');\n }\n /**\n * Cleans up the connections\n */\n async _close() {\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 }\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 peerIdStr = peerId.toString();\n const storedConns = this.connections.get(peerIdStr);\n if (storedConns != null) {\n storedConns.push(connection);\n }\n else {\n this.connections.set(peerIdStr, [connection]);\n }\n if (peerId.publicKey != null) {\n await this.components.peerStore.keyBook.set(peerId, peerId.publicKey);\n }\n const numConnections = this.getConnections().length;\n const toPrune = numConnections - this.opts.maxConnections;\n await this._checkMaxLimit('maxConnections', numConnections, toPrune);\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:connect', { detail: connection }));\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.toString();\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('peer:disconnect', { detail: connection }));\n }\n }\n getConnections(peerId) {\n if (peerId != null) {\n return this.connections.get(peerId.toString()) ?? [];\n }\n let conns = [];\n for (const c of this.connections.values()) {\n conns = conns.concat(c);\n }\n return conns;\n }\n async openConnection(peerIdOrMultiaddr, options = {}) {\n const { peerId, multiaddr } = (0,_get_peer_js__WEBPACK_IMPORTED_MODULE_14__.getPeerAddress)(peerIdOrMultiaddr);\n if (peerId == null && multiaddr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new TypeError('Can only open connections to PeerIds or Multiaddrs'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n if (peerId != null) {\n log('dial to', 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 let timeoutController;\n if (options?.signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_11__.TimeoutController(this.dialTimeout);\n options.signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_7__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\n try {\n const connection = await this.components.dialer.dial(peerIdOrMultiaddr, options);\n let peerConnections = this.connections.get(connection.remotePeer.toString());\n if (peerConnections == null) {\n peerConnections = [];\n this.connections.set(connection.remotePeer.toString(), 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 finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n }\n }\n async closeConnections(peerId) {\n const connections = this.connections.get(peerId.toString()) ?? [];\n await Promise.all(connections.map(async (connection) => {\n return await connection.close();\n }));\n }\n /**\n * Get all open connections with a peer\n */\n getAll(peerId) {\n if (!(0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_6__.isPeerId)(peerId)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('peerId must be an instance of peer-id'), _errors_js__WEBPACK_IMPORTED_MODULE_5__.codes.ERR_INVALID_PARAMETERS);\n }\n const id = peerId.toString();\n const connections = this.connections.get(id);\n // Return all open connections\n if (connections != null) {\n return connections.filter(connection => connection.stat.status === _libp2p_interface_connection_status__WEBPACK_IMPORTED_MODULE_8__.OPEN);\n }\n return [];\n }\n /**\n * If the event loop is slow, maybe close a connection\n */\n _onLatencyMeasure(evt) {\n const { detail: summary } = evt;\n this._checkMaxLimit('maxEventLoopDelay', summary.avgMs, 1)\n .catch(err => {\n log.error(err);\n });\n }\n /**\n * If the `value` of `name` has exceeded its limit, maybe close a connection\n */\n async _checkMaxLimit(name, value, toPrune = 1) {\n const limit = this.opts[name];\n if (limit == null) {\n log.trace('limit %s was not set so it cannot be applied', name);\n return;\n }\n log.trace('checking limit of %s. current value: %d of %d', name, value, limit);\n if (value > limit) {\n log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune);\n await this._pruneConnections(toPrune);\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 _pruneConnections(toPrune) {\n const connections = this.getConnections();\n const peerValues = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_10__.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 const tags = await this.components.peerStore.getTags(remotePeer);\n // sum all tag values\n peerValues.set(remotePeer, tags.reduce((acc, curr) => {\n return acc + curr.value;\n }, 0));\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 toClose.push(connection);\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 // TODO: should not need to invoke this manually\n this.onDisconnect(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_4__.CustomEvent('connectionEnd', {\n detail: connection\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 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.opts.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.opts.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}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/connection-manager/index.js?"); /***/ }), @@ -10011,7 +8229,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 */ \"getPeerAddress\": () => (/* binding */ getPeerAddress)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n\n\n\n\n\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__.isPeerId)(peer)) {\n return {\n peerId: peer\n };\n }\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.isMultiaddr)(peer)) {\n const peerId = peer.getPeerId();\n return {\n multiaddr: peer,\n peerId: peerId == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(peerId)\n };\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error(`${peer} is not a PeerId or a Multiaddr`), // eslint-disable-line @typescript-eslint/restrict-template-expressions\n _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/get-peer.js?"); +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_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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.js\");\n\n\n\n\n\n/**\n * Extracts a PeerId and/or multiaddr from the passed PeerId or Multiaddr\n */\nfunction getPeerAddress(peer) {\n if ((0,_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_4__.isPeerId)(peer)) {\n return {\n peerId: peer\n };\n }\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_1__.isMultiaddr)(peer)) {\n const peerId = peer.getPeerId();\n return {\n multiaddr: peer,\n peerId: peerId == null ? undefined : (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_0__.peerIdFromString)(peerId)\n };\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_2__(new Error(`${peer} is not a PeerId or a Multiaddr`), // eslint-disable-line @typescript-eslint/restrict-template-expressions\n _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n}\n//# sourceMappingURL=get-peer.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/get-peer.js?"); /***/ }), @@ -10033,7 +8251,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 */ \"IdentifyService\": () => (/* binding */ IdentifyService),\n/* harmony export */ \"Message\": () => (/* binding */ Message),\n/* harmony export */ \"multicodecs\": () => (/* binding */ multicodecs)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.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 it_first__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/libp2p/dist/src/identify/pb/message.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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;\nclass IdentifyService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.init = init;\n this.identifyProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.IDENTIFY_PROTOCOL_VERSION}`,\n ...init.host\n };\n // When a new connection happens, trigger identify\n this.components.connectionManager.addEventListener('peer:connect', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(log.error);\n });\n // When self multiaddrs change, trigger identify-push\n this.components.peerStore.addEventListener('change:multiaddrs', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n // When self protocols change, trigger identify-push\n this.components.peerStore.addEventListener('change:protocols', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.agentVersion));\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.protocolVersion));\n await this.components.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.maxOutboundStreams\n });\n await this.components.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxPushIncomingStreams,\n maxOutboundStreams: this.init.maxPushOutgoingStreams\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.identifyProtocolStr);\n await this.components.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async push(connections) {\n const signedPeerRecord = await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId);\n const listenAddrs = this.components.addressManager.getAddresses().map((ma) => ma.bytes);\n const protocols = await this.components.peerStore.protoBook.get(this.components.peerId);\n const pushes = connections.map(async (connection) => {\n let stream;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyPushProtocolStr], {\n signal: timeoutController.signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n await source.sink((0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([_pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.encode({\n listenAddrs,\n signedPeerRecord,\n protocols\n })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode()));\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 timeoutController.clear();\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async pushToPeerStore() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n for (const conn of this.components.connectionManager.getConnections()) {\n const peerId = conn.remotePeer;\n const peer = await this.components.peerStore.get(peerId);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n continue;\n }\n connections.push(conn);\n }\n await this.push(connections);\n }\n async _identify(connection, options = {}) {\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_13__.abortableDuplex)(stream, signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data could be retrieved'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_CONNECTION_ENDED);\n }\n try {\n return _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n catch (err) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_MESSAGE);\n }\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Requests the `Identify` message from peer associated with the given `connection`.\n * If the identified peer does not match the `PeerId` associated with the connection,\n * an error will be thrown.\n */\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;\n if (publicKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('public key was missing from identify message'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PUBLIC_KEY);\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (this.components.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer is our own peer id?'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);\n if (signedPeerRecord != null) {\n log('received signed peer record from %p', id);\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (!envelope.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n return;\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('no signed peer record received from %p', id);\n }\n log('falling back to legacy addresses from %p', id);\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n // TODO: Add and score our observed addr\n log('received observed address of %s', cleanObservedAddr?.toString());\n // this.components.addressManager.addObservedAddr(observedAddr)\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 timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const publicKey = this.components.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.components.peerStore.get(this.components.peerId);\n const multiaddrs = this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.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_8__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n signedPeerRecord = envelope.marshal().subarray();\n }\n const message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.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_13__.abortableDuplex)(stream, timeoutController.signal);\n const msgWithLenPrefix = (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([message], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode());\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 timeoutController.clear();\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n let message;\n try {\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data != null) {\n message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n }\n catch (err) {\n return log.error('received invalid message', err);\n }\n finally {\n stream.close();\n timeoutController.clear();\n }\n if (message == null) {\n return log.error('received invalid message');\n }\n const id = connection.remotePeer;\n if (this.components.peerId.equals(id)) {\n log('received push from ourselves?');\n return;\n }\n log('received push from %p', id);\n if (message.signedPeerRecord != null) {\n log('received signedPeerRecord in push');\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(message.signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n log('consumed signedPeerRecord sent in push');\n await this.components.peerStore.protoBook.set(id, message.protocols);\n return;\n }\n else {\n log('failed to consume signedPeerRecord sent in push');\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('did not receive signedPeerRecord in push');\n }\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, message.listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n // Update the protocols\n try {\n await this.components.peerStore.protoBook.set(id, message.protocols);\n }\n catch (err) {\n log.error('received invalid protocols', err);\n }\n log('handled push from %p', id);\n }\n /**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\n static getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr);\n }\n catch {\n }\n }\n }\n}\n/**\n * The protocols the IdentifyService supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH\n};\nconst Message = { Identify: _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify };\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/identify/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"IdentifyService\": () => (/* binding */ IdentifyService),\n/* harmony export */ \"Message\": () => (/* binding */ Message),\n/* harmony export */ \"multicodecs\": () => (/* binding */ multicodecs)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! it-length-prefixed */ \"./node_modules/it-length-prefixed/dist/src/index.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 it_first__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! it-first */ \"./node_modules/libp2p/node_modules/it-first/dist/src/index.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var _pb_message_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pb/message.js */ \"./node_modules/libp2p/dist/src/identify/pb/message.js\");\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/dist/src/identify/consts.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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;\nclass IdentifyService {\n constructor(components, init) {\n this.components = components;\n this.started = false;\n this.init = init;\n this.identifyProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;\n this.identifyPushProtocolStr = `/${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;\n // Store self host metadata\n this.host = {\n protocolVersion: `${init.protocolPrefix}/${_consts_js__WEBPACK_IMPORTED_MODULE_9__.IDENTIFY_PROTOCOL_VERSION}`,\n ...init.host\n };\n // When a new connection happens, trigger identify\n this.components.connectionManager.addEventListener('peer:connect', (evt) => {\n const connection = evt.detail;\n this.identify(connection).catch(log.error);\n });\n // When self multiaddrs change, trigger identify-push\n this.components.peerStore.addEventListener('change:multiaddrs', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n // When self protocols change, trigger identify-push\n this.components.peerStore.addEventListener('change:protocols', (evt) => {\n const { peerId } = evt.detail;\n if (this.components.peerId.equals(peerId)) {\n void this.pushToPeerStore().catch(err => log.error(err));\n }\n });\n }\n isStarted() {\n return this.started;\n }\n async start() {\n if (this.started) {\n return;\n }\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.agentVersion));\n await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(this.host.protocolVersion));\n await this.components.registrar.handle(this.identifyProtocolStr, (data) => {\n void this._handleIdentify(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxInboundStreams,\n maxOutboundStreams: this.init.maxOutboundStreams\n });\n await this.components.registrar.handle(this.identifyPushProtocolStr, (data) => {\n void this._handlePush(data).catch(err => {\n log.error(err);\n });\n }, {\n maxInboundStreams: this.init.maxPushIncomingStreams,\n maxOutboundStreams: this.init.maxPushOutgoingStreams\n });\n this.started = true;\n }\n async stop() {\n await this.components.registrar.unhandle(this.identifyProtocolStr);\n await this.components.registrar.unhandle(this.identifyPushProtocolStr);\n this.started = false;\n }\n /**\n * Send an Identify Push update to the list of connections\n */\n async push(connections) {\n const signedPeerRecord = await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId);\n const listenAddrs = this.components.addressManager.getAddresses().map((ma) => ma.bytes);\n const protocols = await this.components.peerStore.protoBook.get(this.components.peerId);\n const pushes = connections.map(async (connection) => {\n let stream;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n stream = await connection.newStream([this.identifyPushProtocolStr], {\n signal: timeoutController.signal\n });\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n await source.sink((0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([_pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.encode({\n listenAddrs,\n signedPeerRecord,\n protocols\n })], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode()));\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 timeoutController.clear();\n }\n });\n await Promise.all(pushes);\n }\n /**\n * Calls `push` on all peer connections\n */\n async pushToPeerStore() {\n // Do not try to push if we are not running\n if (!this.isStarted()) {\n return;\n }\n const connections = [];\n for (const conn of this.components.connectionManager.getConnections()) {\n const peerId = conn.remotePeer;\n const peer = await this.components.peerStore.get(peerId);\n if (!peer.protocols.includes(this.identifyPushProtocolStr)) {\n continue;\n }\n connections.push(conn);\n }\n await this.push(connections);\n }\n async _identify(connection, options = {}) {\n let timeoutController;\n let signal = options.signal;\n let stream;\n // create a timeout if no abort signal passed\n if (signal == null) {\n timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n signal = timeoutController.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n }\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_13__.abortableDuplex)(stream, signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('No data could be retrieved'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_CONNECTION_ENDED);\n }\n try {\n return _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n catch (err) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_MESSAGE);\n }\n }\n finally {\n if (timeoutController != null) {\n timeoutController.clear();\n }\n if (stream != null) {\n stream.close();\n }\n }\n }\n /**\n * Requests the `Identify` message from peer associated with the given `connection`.\n * If the identified peer does not match the `PeerId` associated with the connection,\n * an error will be thrown.\n */\n async identify(connection, options = {}) {\n const message = await this._identify(connection, options);\n const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;\n if (publicKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('public key was missing from identify message'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_MISSING_PUBLIC_KEY);\n }\n const id = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.peerIdFromKeys)(publicKey);\n if (!connection.remotePeer.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (this.components.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer is our own peer id?'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n // Get the observedAddr if there is one\n const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);\n if (signedPeerRecord != null) {\n log('received signed peer record from %p', id);\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (!envelope.peerId.equals(id)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('identified peer does not match the expected peer'), _errors_js__WEBPACK_IMPORTED_MODULE_10__.codes.ERR_INVALID_PEER);\n }\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n return;\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('no signed peer record received from %p', id);\n }\n log('falling back to legacy addresses from %p', id);\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n await this.components.peerStore.protoBook.set(id, protocols);\n if (agentVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(agentVersion));\n }\n if (protocolVersion != null) {\n await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_5__.fromString)(protocolVersion));\n }\n log('identify completed for peer %p and protocols %o', id, protocols);\n // TODO: Add and score our observed addr\n log('received observed address of %s', cleanObservedAddr?.toString());\n // this.components.addressManager.addObservedAddr(observedAddr)\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 timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const publicKey = this.components.peerId.publicKey ?? new Uint8Array(0);\n const peerData = await this.components.peerStore.get(this.components.peerId);\n const multiaddrs = this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.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_8__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n signedPeerRecord = envelope.marshal().subarray();\n }\n const message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.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_13__.abortableDuplex)(stream, timeoutController.signal);\n const msgWithLenPrefix = (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([message], it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.encode());\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 timeoutController.clear();\n }\n }\n /**\n * Reads the Identify Push message from the given `connection`\n */\n async _handlePush(data) {\n const { connection, stream } = data;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_12__.TimeoutController(this.init.timeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_14__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n let message;\n try {\n // make stream abortable\n const source = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_13__.abortableDuplex)(stream, timeoutController.signal);\n const data = await (0,it_pipe__WEBPACK_IMPORTED_MODULE_3__.pipe)([], source, it_length_prefixed__WEBPACK_IMPORTED_MODULE_2__.decode({\n maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE\n }), async (source) => await (0,it_first__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(source));\n if (data != null) {\n message = _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify.decode(data);\n }\n }\n catch (err) {\n return log.error('received invalid message', err);\n }\n finally {\n stream.close();\n timeoutController.clear();\n }\n if (message == null) {\n return log.error('received invalid message');\n }\n const id = connection.remotePeer;\n if (this.components.peerId.equals(id)) {\n log('received push from ourselves?');\n return;\n }\n log('received push from %p', id);\n if (message.signedPeerRecord != null) {\n log('received signedPeerRecord in push');\n try {\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.RecordEnvelope.openAndCertify(message.signedPeerRecord, _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_8__.PeerRecord.DOMAIN);\n if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {\n log('consumed signedPeerRecord sent in push');\n await this.components.peerStore.protoBook.set(id, message.protocols);\n return;\n }\n else {\n log('failed to consume signedPeerRecord sent in push');\n }\n }\n catch (err) {\n log('received invalid envelope, discard it and fallback to listenAddrs is available', err);\n }\n }\n else {\n log('did not receive signedPeerRecord in push');\n }\n // LEGACY: Update peers data in PeerStore\n try {\n await this.components.peerStore.addressBook.set(id, message.listenAddrs.map((addr) => (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr)));\n }\n catch (err) {\n log.error('received invalid addrs', err);\n }\n // Update the protocols\n try {\n await this.components.peerStore.protoBook.set(id, message.protocols);\n }\n catch (err) {\n log.error('received invalid protocols', err);\n }\n log('handled push from %p', id);\n }\n /**\n * Takes the `addr` and converts it to a Multiaddr if possible\n */\n static getCleanMultiaddr(addr) {\n if (addr != null && addr.length > 0) {\n try {\n return (0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_6__.multiaddr)(addr);\n }\n catch {\n }\n }\n }\n}\n/**\n * The protocols the IdentifyService supports\n */\nconst multicodecs = {\n IDENTIFY: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY,\n IDENTIFY_PUSH: _consts_js__WEBPACK_IMPORTED_MODULE_9__.MULTICODEC_IDENTIFY_PUSH\n};\nconst Message = { Identify: _pb_message_js__WEBPACK_IMPORTED_MODULE_7__.Identify };\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/identify/index.js?"); /***/ }), @@ -10077,7 +8295,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 */ \"KeyChain\": () => (/* binding */ KeyChain)\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 sanitize_filename__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sanitize-filename */ \"./node_modules/sanitize-filename/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _cms_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cms.js */ \"./node_modules/libp2p/dist/src/keychain/cms.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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 _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_crypto__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* eslint max-nested-callbacks: [\"error\", 5] */\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_1__(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_3__.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_3__.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 KeyChain {\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_2__[\"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_10__.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 this.started = false;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n const dsname = DsInfoName('self');\n if (!(await this.components.datastore.has(dsname))) {\n await this.importPeer('self', this.components.peerId);\n }\n this.started = true;\n }\n stop() {\n this.started = false;\n }\n /**\n * Gets an object that can encrypt/decrypt protected data\n * using the Cryptographic Message Syntax (CMS).\n *\n * CMS describes an encapsulation syntax for data protection. It\n * is used to digitally sign, digest, authenticate, or encrypt\n * arbitrary message content\n */\n get cms() {\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n return new _cms_js__WEBPACK_IMPORTED_MODULE_4__.CMS(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_7__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_10__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key name'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (typeof type !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key type'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Key name already exists'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid RSA key size'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_9__.generateKeyPair)(type, size);\n const kid = await keypair.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await keypair.export(dek);\n keyInfo = {\n name: 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_7__.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 return keys.find((k) => k.id === id);\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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res));\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old key name '${oldName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_OLD_KEY_NAME_INVALID);\n }\n if (!validateKeyName(newName) || newName === 'self') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new key name '${newName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${newName}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (password == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Password is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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_9__.importKey)(pem, password);\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (pem == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PEM encoded key is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n let privateKey;\n try {\n privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.importKey)(pem, password);\n }\n catch (err) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Cannot read the key, most likely the password is wrong'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (peer == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n if (peer.privateKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId.privKey is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await privateKey.export(dek);\n const keyInfo = {\n name: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old pass type '${typeof oldPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_OLD_PASS_TYPE);\n }\n if (typeof newPass !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new pass type '${typeof newPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_NEW_PASS_TYPE);\n }\n if (newPass.length < 20) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid pass length ${newPass.length}`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PASS_LENGTH);\n }\n log('recreating keychain');\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_10__.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_7__.toString)(res);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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-rtc/./node_modules/libp2p/dist/src/keychain/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"KeyChain\": () => (/* binding */ KeyChain)\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 sanitize_filename__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sanitize-filename */ \"./node_modules/sanitize-filename/index.js\");\n/* harmony import */ var merge_options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! merge-options */ \"./node_modules/merge-options/index.mjs\");\n/* harmony import */ var interface_datastore_key__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! interface-datastore/key */ \"./node_modules/interface-datastore/dist/src/key.js\");\n/* harmony import */ var _cms_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cms.js */ \"./node_modules/libp2p/dist/src/keychain/cms.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.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 _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_crypto__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @libp2p/crypto */ \"./node_modules/@libp2p/crypto/dist/src/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* eslint max-nested-callbacks: [\"error\", 5] */\n\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_1__(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_3__.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_3__.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 KeyChain {\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_2__[\"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_10__.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 this.started = false;\n }\n isStarted() {\n return this.started;\n }\n async start() {\n const dsname = DsInfoName('self');\n if (!(await this.components.datastore.has(dsname))) {\n await this.importPeer('self', this.components.peerId);\n }\n this.started = true;\n }\n stop() {\n this.started = false;\n }\n /**\n * Gets an object that can encrypt/decrypt protected data\n * using the Cryptographic Message Syntax (CMS).\n *\n * CMS describes an encapsulation syntax for data protection. It\n * is used to digitally sign, digest, authenticate, or encrypt\n * arbitrary message content\n */\n get cms() {\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n return new _cms_js__WEBPACK_IMPORTED_MODULE_4__.CMS(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_7__.toString)((0,_libp2p_crypto__WEBPACK_IMPORTED_MODULE_10__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key name'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (typeof type !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid key type'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Key name already exists'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Invalid RSA key size'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_9__.generateKeyPair)(type, size);\n const kid = await keypair.id();\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await keypair.export(dek);\n keyInfo = {\n name: 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_7__.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 return keys.find((k) => k.id === id);\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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res));\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old key name '${oldName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_OLD_KEY_NAME_INVALID);\n }\n if (!validateKeyName(newName) || newName === 'self') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new key name '${newName}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${newName}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (password == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Password is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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_9__.importKey)(pem, password);\n return await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_11__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (pem == null) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PEM encoded key is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n let privateKey;\n try {\n privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.importKey)(pem, password);\n }\n catch (err) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('Cannot read the key, most likely the password is wrong'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_KEY_NAME);\n }\n if (peer == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n if (peer.privateKey == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('PeerId.privKey is required'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_MISSING_PRIVATE_KEY);\n }\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' already exists`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_KEY_ALREADY_EXISTS);\n }\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PARAMETERS);\n }\n const dek = cached.dek;\n const pem = await privateKey.export(dek);\n const keyInfo = {\n name: 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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid key name '${name}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_7__.toString)(res);\n }\n catch (err) {\n await randomDelay();\n log.error(err);\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Key '${name}' does not exist.`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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 err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid old pass type '${typeof oldPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_OLD_PASS_TYPE);\n }\n if (typeof newPass !== 'string') {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid new pass type '${typeof newPass}'`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_NEW_PASS_TYPE);\n }\n if (newPass.length < 20) {\n await randomDelay();\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`Invalid pass length ${newPass.length}`), _errors_js__WEBPACK_IMPORTED_MODULE_6__.codes.ERR_INVALID_PASS_LENGTH);\n }\n log('recreating keychain');\n const cached = privates.get(this);\n if (cached == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error('dek missing'), _errors_js__WEBPACK_IMPORTED_MODULE_6__.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_10__.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_7__.toString)(res);\n const privateKey = await (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_9__.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-rtc/./node_modules/libp2p/dist/src/keychain/index.js?"); /***/ }), @@ -10099,7 +8317,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 */ \"Libp2pNode\": () => (/* binding */ Libp2pNode),\n/* harmony export */ \"createLibp2pNode\": () => (/* binding */ createLibp2pNode)\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_interfaces_events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/startable */ \"./node_modules/@libp2p/interfaces/dist/src/startable.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/datastore-core/src/memory.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./content-routing/index.js */ \"./node_modules/libp2p/dist/src/content-routing/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./connection-manager/auto-dialler.js */ \"./node_modules/libp2p/dist/src/connection-manager/auto-dialler.js\");\n/* harmony import */ var _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/transport.js */ \"./node_modules/libp2p/dist/src/circuit/transport.js\");\n/* harmony import */ var _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./circuit/index.js */ \"./node_modules/libp2p/dist/src/circuit/index.js\");\n/* harmony import */ var _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./keychain/index.js */ \"./node_modules/libp2p/dist/src/keychain/index.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/libp2p/dist/src/upgrader.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _identify_index_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./identify/index.js */ \"./node_modules/libp2p/dist/src/identify/index.js\");\n/* harmony import */ var _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./fetch/index.js */ \"./node_modules/libp2p/dist/src/fetch/index.js\");\n/* harmony import */ var _ping_index_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ping/index.js */ \"./node_modules/libp2p/dist/src/ping/index.js\");\n/* harmony import */ var _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./nat-manager.js */ \"./node_modules/libp2p/dist/src/nat-manager.js\");\n/* harmony import */ var _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./peer-record-updater.js */ \"./node_modules/libp2p/dist/src/peer-record-updater.js\");\n/* harmony import */ var _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./dht/dht-peer-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-peer-routing.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./dht/dht-content-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-content-routing.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./components.js */ \"./node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./config.js */ \"./node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./dht/dummy-dht.js */ \"./node_modules/libp2p/dist/src/dht/dummy-dht.js\");\n/* harmony import */ var _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./pubsub/dummy-pubsub.js */ \"./node_modules/libp2p/dist/src/pubsub/dummy-pubsub.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./connection-manager/dialer/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p');\nclass Libp2pNode extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter {\n constructor(init) {\n super();\n this.started = false;\n this.peerId = init.peerId;\n const components = this.components = new _components_js__WEBPACK_IMPORTED_MODULE_25__.DefaultComponents({\n peerId: init.peerId,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__.MemoryDatastore(),\n connectionGater: {\n denyDialPeer: async () => await Promise.resolve(false),\n denyDialMultiaddr: async () => await Promise.resolve(false),\n denyInboundConnection: async () => await Promise.resolve(false),\n denyOutboundConnection: async () => await Promise.resolve(false),\n denyInboundEncryptedConnection: async () => await Promise.resolve(false),\n denyOutboundEncryptedConnection: async () => await Promise.resolve(false),\n denyInboundUpgradedConnection: async () => await Promise.resolve(false),\n denyOutboundUpgradedConnection: async () => await Promise.resolve(false),\n filterMultiaddrForPeer: async () => await Promise.resolve(true),\n ...init.connectionGater\n }\n });\n components.peerStore = new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n });\n this.services = [\n components\n ];\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.components.metrics = this.configureComponent(init.metrics(this.components));\n }\n this.peerStore = this.components.peerStore;\n this.peerStore.addEventListener('peer', evt => {\n const { detail: peerData } = evt;\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peerData }));\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.components.connectionProtector = init.connectionProtector(components);\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_15__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map(fn => this.configureComponent(fn(this.components))),\n muxers: (init.streamMuxers ?? []).map(fn => this.configureComponent(fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Create the dialer\n this.components.dialer = new _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__.DefaultDialer(this.components, init.connectionManager);\n // Create the Connection Manager\n this.connectionManager = this.components.connectionManager = new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__.DefaultConnectionManager(this.components, init.connectionManager);\n // forward connection manager events\n this.components.connectionManager.addEventListener('peer:disconnect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:disconnect', { detail: event.detail }));\n });\n this.components.connectionManager.addEventListener('peer:connect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:connect', { detail: event.detail }));\n });\n // Create the Registrar\n this.registrar = this.components.registrar = new _registrar_js__WEBPACK_IMPORTED_MODULE_16__.DefaultRegistrar(this.components);\n // Setup the transport manager\n this.components.transportManager = new _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__.DefaultTransportManager(this.components, init.transportManager);\n // Addresses {listen, announce, noAnnounce}\n this.components.addressManager = new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__.DefaultAddressManager(this.components, init.addresses);\n // update our peer record when addresses change\n this.configureComponent(new _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__.PeerRecordUpdater(this.components));\n this.configureComponent(new _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__.AutoDialler(this.components, {\n enabled: init.connectionManager.autoDial,\n minConnections: init.connectionManager.minConnections,\n autoDialInterval: init.connectionManager.autoDialInterval\n }));\n // Create keychain\n const keychainOpts = _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions();\n this.keychain = this.configureComponent(new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain(this.components, {\n ...keychainOpts,\n ...init.keychain\n }));\n // Create the Nat Manager\n this.services.push(new _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__.NatManager(this.components, init.nat));\n init.transports.forEach((fn) => {\n this.components.transportManager.add(this.configureComponent(fn(this.components)));\n });\n // Add the identify service\n this.identifyService = new _identify_index_js__WEBPACK_IMPORTED_MODULE_17__.IdentifyService(this.components, {\n ...init.identify\n });\n this.configureComponent(this.identifyService);\n // dht provided components (peerRouting, contentRouting, dht)\n if (init.dht != null) {\n this.dht = this.components.dht = init.dht(this.components);\n }\n else {\n this.dht = new _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__.DummyDHT();\n }\n // Create pubsub if provided\n if (init.pubsub != null) {\n this.pubsub = this.components.pubsub = init.pubsub(this.components);\n }\n else {\n this.pubsub = new _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__.DummyPubSub();\n }\n // Attach remaining APIs\n // peer and content routing will automatically get modules from _modules and _dht\n const peerRouters = (init.peerRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n peerRouters.push(this.configureComponent(new _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__.DHTPeerRouting(this.dht)));\n // use dht for peer discovery\n this.dht.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n this.peerRouting = this.components.peerRouting = this.configureComponent(new _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPeerRouting(this.components, {\n ...init.peerRouting,\n routers: peerRouters\n }));\n const contentRouters = (init.contentRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n contentRouters.push(this.configureComponent(new _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__.DHTContentRouting(this.dht)));\n }\n this.contentRouting = this.components.contentRouting = this.configureComponent(new _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n if (init.relay.enabled) {\n this.components.transportManager.add(this.configureComponent(new _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__.Circuit(this.components, init.relay)));\n this.configureComponent(new _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__.Relay(this.components, {\n addressSorter: init.connectionManager.addressSorter,\n ...init.relay\n }));\n }\n this.fetchService = this.configureComponent(new _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__.FetchService(this.components, {\n ...init.fetch\n }));\n this.pingService = this.configureComponent(new _ping_index_js__WEBPACK_IMPORTED_MODULE_19__.PingService(this.components, {\n ...init.ping\n }));\n // Discovery modules\n for (const fn of init.peerDiscovery ?? []) {\n const service = this.configureComponent(fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n }\n configureComponent(component) {\n if ((0,_libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__.isStartable)(component)) {\n this.services.push(component);\n }\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 try {\n await Promise.all(this.services.map(async (service) => {\n if (service.beforeStart != null) {\n await service.beforeStart();\n }\n }));\n // start any startables\n await Promise.all(this.services.map(service => service.start()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStart != null) {\n await service.afterStart();\n }\n }));\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 Promise.all(this.services.map(async (service) => {\n if (service.beforeStop != null) {\n await service.beforeStop();\n }\n }));\n await Promise.all(this.services.map(service => service.stop()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStop != null) {\n await service.afterStop();\n }\n }));\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 getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__.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 await this.components.connectionManager.openConnection(peer, options);\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return await 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_3__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.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.pubKey != null) {\n return peerInfo.pubKey;\n }\n if (this.dht == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('Public key was not in the peer store and the DHT is not enabled'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search the dht\n for await (const event of this.dht.get(peerKey, options)) {\n if (event.name === 'VALUE') {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__.unmarshalPublicKey)(event.value);\n await this.peerStore.keyBook.set(peer, event.value);\n return key.bytes;\n }\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error(`Node not responding with its public key: ${peer.toString()}`), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_RECORD);\n }\n async fetch(peer, key, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.fetchService.fetch(peer, key, options);\n }\n async ping(peer, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.pingService.ping(peer, options);\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 await this.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.registrar.unregister(id);\n }\n /**\n * Called whenever peer discovery services emit `peer` events.\n * Known peers may be emitted.\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_7__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n if (peer.multiaddrs.length > 0) {\n void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => log.error(err));\n }\n if (peer.protocols.length > 0) {\n void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => log.error(err));\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peer }));\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 // @ts-expect-error missing the peer id property\n const keyChain = new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain({\n datastore\n }, {\n ..._keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions(),\n ...(options.keychain ?? {})\n });\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_27__.createEd25519PeerId)();\n }\n return new Libp2pNode((0,_config_js__WEBPACK_IMPORTED_MODULE_26__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/libp2p.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/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 _libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/interfaces/startable */ \"./node_modules/@libp2p/interfaces/dist/src/startable.js\");\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n/* harmony import */ var datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! datastore-core/memory */ \"./node_modules/datastore-core/src/memory.js\");\n/* harmony import */ var _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./peer-routing.js */ \"./node_modules/libp2p/dist/src/peer-routing.js\");\n/* harmony import */ var _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./content-routing/index.js */ \"./node_modules/libp2p/dist/src/content-routing/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./errors.js */ \"./node_modules/libp2p/dist/src/errors.js\");\n/* harmony import */ var _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./address-manager/index.js */ \"./node_modules/libp2p/dist/src/address-manager/index.js\");\n/* harmony import */ var _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./connection-manager/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/index.js\");\n/* harmony import */ var _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./connection-manager/auto-dialler.js */ \"./node_modules/libp2p/dist/src/connection-manager/auto-dialler.js\");\n/* harmony import */ var _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./circuit/transport.js */ \"./node_modules/libp2p/dist/src/circuit/transport.js\");\n/* harmony import */ var _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./circuit/index.js */ \"./node_modules/libp2p/dist/src/circuit/index.js\");\n/* harmony import */ var _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./keychain/index.js */ \"./node_modules/libp2p/dist/src/keychain/index.js\");\n/* harmony import */ var _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./transport-manager.js */ \"./node_modules/libp2p/dist/src/transport-manager.js\");\n/* harmony import */ var _upgrader_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./upgrader.js */ \"./node_modules/libp2p/dist/src/upgrader.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var _identify_index_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./identify/index.js */ \"./node_modules/libp2p/dist/src/identify/index.js\");\n/* harmony import */ var _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./fetch/index.js */ \"./node_modules/libp2p/dist/src/fetch/index.js\");\n/* harmony import */ var _ping_index_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ping/index.js */ \"./node_modules/libp2p/dist/src/ping/index.js\");\n/* harmony import */ var _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./nat-manager.js */ \"./node_modules/libp2p/dist/src/nat-manager.js\");\n/* harmony import */ var _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./peer-record-updater.js */ \"./node_modules/libp2p/dist/src/peer-record-updater.js\");\n/* harmony import */ var _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./dht/dht-peer-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-peer-routing.js\");\n/* harmony import */ var _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @libp2p/peer-store */ \"./node_modules/@libp2p/peer-store/dist/src/index.js\");\n/* harmony import */ var _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./dht/dht-content-routing.js */ \"./node_modules/libp2p/dist/src/dht/dht-content-routing.js\");\n/* harmony import */ var _components_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./components.js */ \"./node_modules/libp2p/dist/src/components.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./config.js */ \"./node_modules/libp2p/dist/src/config.js\");\n/* harmony import */ var _libp2p_peer_id_factory__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @libp2p/peer-id-factory */ \"./node_modules/@libp2p/peer-id-factory/dist/src/index.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./dht/dummy-dht.js */ \"./node_modules/libp2p/dist/src/dht/dummy-dht.js\");\n/* harmony import */ var _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./pubsub/dummy-pubsub.js */ \"./node_modules/libp2p/dist/src/pubsub/dummy-pubsub.js\");\n/* harmony import */ var _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @libp2p/peer-collections */ \"./node_modules/@libp2p/peer-collections/dist/src/index.js\");\n/* harmony import */ var _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./connection-manager/dialer/index.js */ \"./node_modules/libp2p/dist/src/connection-manager/dialer/index.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/@libp2p/peer-id/dist/src/index.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\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.logger)('libp2p');\nclass Libp2pNode extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter {\n constructor(init) {\n super();\n this.started = false;\n this.peerId = init.peerId;\n const components = this.components = new _components_js__WEBPACK_IMPORTED_MODULE_25__.DefaultComponents({\n peerId: init.peerId,\n datastore: init.datastore ?? new datastore_core_memory__WEBPACK_IMPORTED_MODULE_4__.MemoryDatastore(),\n connectionGater: {\n denyDialPeer: async () => await Promise.resolve(false),\n denyDialMultiaddr: async () => await Promise.resolve(false),\n denyInboundConnection: async () => await Promise.resolve(false),\n denyOutboundConnection: async () => await Promise.resolve(false),\n denyInboundEncryptedConnection: async () => await Promise.resolve(false),\n denyOutboundEncryptedConnection: async () => await Promise.resolve(false),\n denyInboundUpgradedConnection: async () => await Promise.resolve(false),\n denyOutboundUpgradedConnection: async () => await Promise.resolve(false),\n filterMultiaddrForPeer: async () => await Promise.resolve(true),\n ...init.connectionGater\n }\n });\n components.peerStore = new _libp2p_peer_store__WEBPACK_IMPORTED_MODULE_23__.PersistentPeerStore(components, {\n addressFilter: this.components.connectionGater.filterMultiaddrForPeer,\n ...init.peerStore\n });\n this.services = [\n components\n ];\n // Create Metrics\n if (init.metrics != null) {\n this.metrics = this.components.metrics = this.configureComponent(init.metrics(this.components));\n }\n this.peerStore = this.components.peerStore;\n this.peerStore.addEventListener('peer', evt => {\n const { detail: peerData } = evt;\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peerData }));\n });\n // Set up connection protector if configured\n if (init.connectionProtector != null) {\n this.components.connectionProtector = init.connectionProtector(components);\n }\n // Set up the Upgrader\n this.components.upgrader = new _upgrader_js__WEBPACK_IMPORTED_MODULE_15__.DefaultUpgrader(this.components, {\n connectionEncryption: (init.connectionEncryption ?? []).map(fn => this.configureComponent(fn(this.components))),\n muxers: (init.streamMuxers ?? []).map(fn => this.configureComponent(fn(this.components))),\n inboundUpgradeTimeout: init.connectionManager.inboundUpgradeTimeout\n });\n // Create the dialer\n this.components.dialer = new _connection_manager_dialer_index_js__WEBPACK_IMPORTED_MODULE_35__.DefaultDialer(this.components, init.connectionManager);\n // Create the Connection Manager\n this.connectionManager = this.components.connectionManager = new _connection_manager_index_js__WEBPACK_IMPORTED_MODULE_9__.DefaultConnectionManager(this.components, init.connectionManager);\n // forward connection manager events\n this.components.connectionManager.addEventListener('peer:disconnect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:disconnect', { detail: event.detail }));\n });\n this.components.connectionManager.addEventListener('peer:connect', (event) => {\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:connect', { detail: event.detail }));\n });\n // Create the Registrar\n this.registrar = this.components.registrar = new _registrar_js__WEBPACK_IMPORTED_MODULE_16__.DefaultRegistrar(this.components);\n // Setup the transport manager\n this.components.transportManager = new _transport_manager_js__WEBPACK_IMPORTED_MODULE_14__.DefaultTransportManager(this.components, init.transportManager);\n // Addresses {listen, announce, noAnnounce}\n this.components.addressManager = new _address_manager_index_js__WEBPACK_IMPORTED_MODULE_8__.DefaultAddressManager(this.components, init.addresses);\n // update our peer record when addresses change\n this.configureComponent(new _peer_record_updater_js__WEBPACK_IMPORTED_MODULE_21__.PeerRecordUpdater(this.components));\n this.configureComponent(new _connection_manager_auto_dialler_js__WEBPACK_IMPORTED_MODULE_10__.AutoDialler(this.components, {\n enabled: init.connectionManager.autoDial,\n minConnections: init.connectionManager.minConnections,\n autoDialInterval: init.connectionManager.autoDialInterval\n }));\n // Create keychain\n const keychainOpts = _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions();\n this.keychain = this.configureComponent(new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain(this.components, {\n ...keychainOpts,\n ...init.keychain\n }));\n // Create the Nat Manager\n this.services.push(new _nat_manager_js__WEBPACK_IMPORTED_MODULE_20__.NatManager(this.components, init.nat));\n init.transports.forEach((fn) => {\n this.components.transportManager.add(this.configureComponent(fn(this.components)));\n });\n // Add the identify service\n this.identifyService = new _identify_index_js__WEBPACK_IMPORTED_MODULE_17__.IdentifyService(this.components, {\n ...init.identify\n });\n this.configureComponent(this.identifyService);\n // dht provided components (peerRouting, contentRouting, dht)\n if (init.dht != null) {\n this.dht = this.components.dht = init.dht(this.components);\n }\n else {\n this.dht = new _dht_dummy_dht_js__WEBPACK_IMPORTED_MODULE_32__.DummyDHT();\n }\n // Create pubsub if provided\n if (init.pubsub != null) {\n this.pubsub = this.components.pubsub = init.pubsub(this.components);\n }\n else {\n this.pubsub = new _pubsub_dummy_pubsub_js__WEBPACK_IMPORTED_MODULE_33__.DummyPubSub();\n }\n // Attach remaining APIs\n // peer and content routing will automatically get modules from _modules and _dht\n const peerRouters = (init.peerRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n peerRouters.push(this.configureComponent(new _dht_dht_peer_routing_js__WEBPACK_IMPORTED_MODULE_22__.DHTPeerRouting(this.dht)));\n // use dht for peer discovery\n this.dht.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n this.peerRouting = this.components.peerRouting = this.configureComponent(new _peer_routing_js__WEBPACK_IMPORTED_MODULE_5__.DefaultPeerRouting(this.components, {\n ...init.peerRouting,\n routers: peerRouters\n }));\n const contentRouters = (init.contentRouters ?? []).map(fn => this.configureComponent(fn(this.components)));\n if (init.dht != null) {\n // add dht to routers\n contentRouters.push(this.configureComponent(new _dht_dht_content_routing_js__WEBPACK_IMPORTED_MODULE_24__.DHTContentRouting(this.dht)));\n }\n this.contentRouting = this.components.contentRouting = this.configureComponent(new _content_routing_index_js__WEBPACK_IMPORTED_MODULE_6__.CompoundContentRouting(this.components, {\n routers: contentRouters\n }));\n if (init.relay.enabled) {\n this.components.transportManager.add(this.configureComponent(new _circuit_transport_js__WEBPACK_IMPORTED_MODULE_11__.Circuit(this.components, init.relay)));\n this.configureComponent(new _circuit_index_js__WEBPACK_IMPORTED_MODULE_12__.Relay(this.components, {\n addressSorter: init.connectionManager.addressSorter,\n ...init.relay\n }));\n }\n this.fetchService = this.configureComponent(new _fetch_index_js__WEBPACK_IMPORTED_MODULE_18__.FetchService(this.components, {\n ...init.fetch\n }));\n this.pingService = this.configureComponent(new _ping_index_js__WEBPACK_IMPORTED_MODULE_19__.PingService(this.components, {\n ...init.ping\n }));\n // Discovery modules\n for (const fn of init.peerDiscovery ?? []) {\n const service = this.configureComponent(fn(this.components));\n service.addEventListener('peer', (evt) => {\n this.onDiscoveryPeer(evt);\n });\n }\n }\n configureComponent(component) {\n if ((0,_libp2p_interfaces_startable__WEBPACK_IMPORTED_MODULE_2__.isStartable)(component)) {\n this.services.push(component);\n }\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 try {\n await Promise.all(this.services.map(async (service) => {\n if (service.beforeStart != null) {\n await service.beforeStart();\n }\n }));\n // start any startables\n await Promise.all(this.services.map(service => service.start()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStart != null) {\n await service.afterStart();\n }\n }));\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 Promise.all(this.services.map(async (service) => {\n if (service.beforeStop != null) {\n await service.beforeStop();\n }\n }));\n await Promise.all(this.services.map(service => service.stop()));\n await Promise.all(this.services.map(async (service) => {\n if (service.afterStop != null) {\n await service.afterStop();\n }\n }));\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 getPeers() {\n const peerSet = new _libp2p_peer_collections__WEBPACK_IMPORTED_MODULE_34__.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 await this.components.connectionManager.openConnection(peer, options);\n }\n async dialProtocol(peer, protocols, options = {}) {\n if (protocols == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n protocols = Array.isArray(protocols) ? protocols : [protocols];\n if (protocols.length === 0) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('no protocols were provided to open a stream'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);\n }\n const connection = await this.dial(peer, options);\n return await 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_3__.isMultiaddr)(peer)) {\n peer = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.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.pubKey != null) {\n return peerInfo.pubKey;\n }\n if (this.dht == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error('Public key was not in the peer store and the DHT is not enabled'), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_NO_ROUTERS_AVAILABLE);\n }\n const peerKey = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_28__.concat)([\n (0,uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_29__.fromString)('/pk/'),\n peer.multihash.digest\n ]);\n // search the dht\n for await (const event of this.dht.get(peerKey, options)) {\n if (event.name === 'VALUE') {\n const key = (0,_libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_31__.unmarshalPublicKey)(event.value);\n await this.peerStore.keyBook.set(peer, event.value);\n return key.bytes;\n }\n }\n throw err_code__WEBPACK_IMPORTED_MODULE_30__(new Error(`Node not responding with its public key: ${peer.toString()}`), _errors_js__WEBPACK_IMPORTED_MODULE_7__.codes.ERR_INVALID_RECORD);\n }\n async fetch(peer, key, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.fetchService.fetch(peer, key, options);\n }\n async ping(peer, options = {}) {\n if ((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_3__.isMultiaddr)(peer)) {\n const peerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_36__.peerIdFromString)(peer.getPeerId() ?? '');\n await this.components.peerStore.addressBook.add(peerId, [peer]);\n peer = peerId;\n }\n return await this.pingService.ping(peer, options);\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 await this.registrar.register(protocol, topology);\n }\n unregister(id) {\n this.registrar.unregister(id);\n }\n /**\n * Called whenever peer discovery services emit `peer` events.\n * Known peers may be emitted.\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_7__.codes.ERR_DISCOVERED_SELF));\n return;\n }\n if (peer.multiaddrs.length > 0) {\n void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => log.error(err));\n }\n if (peer.protocols.length > 0) {\n void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => log.error(err));\n }\n this.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_1__.CustomEvent('peer:discovery', { detail: peer }));\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 // @ts-expect-error missing the peer id property\n const keyChain = new _keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain({\n datastore\n }, {\n ..._keychain_index_js__WEBPACK_IMPORTED_MODULE_13__.KeyChain.generateOptions(),\n ...(options.keychain ?? {})\n });\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_27__.createEd25519PeerId)();\n }\n return new Libp2pNode((0,_config_js__WEBPACK_IMPORTED_MODULE_26__.validateConfig)(options));\n}\n//# sourceMappingURL=libp2p.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/libp2p.js?"); /***/ }), @@ -10121,7 +8339,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 */ \"PeerRecordUpdater\": () => (/* binding */ PeerRecordUpdater)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:peer-record-updater');\nclass PeerRecordUpdater {\n constructor(components) {\n this.components = components;\n this.started = false;\n this.update = this.update.bind(this);\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n this.components.transportManager.addEventListener('listener:listening', this.update);\n this.components.transportManager.addEventListener('listener:close', this.update);\n this.components.addressManager.addEventListener('change:addresses', this.update);\n }\n async stop() {\n this.started = false;\n this.components.transportManager.removeEventListener('listener:listening', this.update);\n this.components.transportManager.removeEventListener('listener:close', this.update);\n this.components.addressManager.removeEventListener('change:addresses', this.update);\n }\n /**\n * Create (or update if existing) self peer record and store it in the AddressBook.\n */\n update() {\n Promise.resolve()\n .then(async () => {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs: this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.protocols)('p2p').code))\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n })\n .catch(err => {\n log.error('Could not update self peer record: %o', err);\n });\n }\n}\n//# sourceMappingURL=peer-record-updater.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/peer-record-updater.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PeerRecordUpdater\": () => (/* binding */ PeerRecordUpdater)\n/* harmony export */ });\n/* harmony import */ var _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/peer-record */ \"./node_modules/@libp2p/peer-record/dist/src/index.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/libp2p/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_1__.logger)('libp2p:peer-record-updater');\nclass PeerRecordUpdater {\n constructor(components) {\n this.components = components;\n this.started = false;\n this.update = this.update.bind(this);\n }\n isStarted() {\n return this.started;\n }\n async start() {\n this.started = true;\n this.components.transportManager.addEventListener('listener:listening', this.update);\n this.components.transportManager.addEventListener('listener:close', this.update);\n this.components.addressManager.addEventListener('change:addresses', this.update);\n }\n async stop() {\n this.started = false;\n this.components.transportManager.removeEventListener('listener:listening', this.update);\n this.components.transportManager.removeEventListener('listener:close', this.update);\n this.components.addressManager.removeEventListener('change:addresses', this.update);\n }\n /**\n * Create (or update if existing) self peer record and store it in the AddressBook.\n */\n update() {\n Promise.resolve()\n .then(async () => {\n const peerRecord = new _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.PeerRecord({\n peerId: this.components.peerId,\n multiaddrs: this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode((0,_multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_2__.protocols)('p2p').code))\n });\n const envelope = await _libp2p_peer_record__WEBPACK_IMPORTED_MODULE_0__.RecordEnvelope.seal(peerRecord, this.components.peerId);\n await this.components.peerStore.addressBook.consumePeerRecord(envelope);\n })\n .catch(err => {\n log.error('Could not update self peer record: %o', err);\n });\n }\n}\n//# sourceMappingURL=peer-record-updater.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/peer-record-updater.js?"); /***/ }), @@ -10198,7 +8416,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 */ \"DefaultUpgrader\": () => (/* binding */ DefaultUpgrader)\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 err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/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/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _registrar_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxOutboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.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 extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init) {\n super();\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;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection denied'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(this.inboundUpgradeTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const abortableStream = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_9__.abortableDuplex)(maConn, timeoutController.signal);\n maConn.source = abortableStream.source;\n maConn.sink = abortableStream.sink;\n if (await this.components.connectionGater.denyInboundConnection(maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyInboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('inbound connection that skipped encryption must have a peer id'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 if (await this.components.connectionGater.denyInboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 timeoutController.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_6__.peerIdFromString)(idStr);\n if (await this.components.connectionGater.denyOutboundConnection(remotePeerId, maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by connectionGater.denyOutboundConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 if (await this.components.connectionGater.denyOutboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n if (remotePeerId == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Encryption was skipped but no peer id was passed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyOutboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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_2__.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 muxedStream.abort(err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));\n return;\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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Stream is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n log('%s: starting new stream on %s', direction, protocols);\n const muxedStream = await muxer.newStream();\n let controller;\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 controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(30000);\n options.signal = controller.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n }\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__.select(muxedStream, protocols, options);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount === outgoingLimit) {\n const err = err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n finally {\n if (controller != null) {\n controller.clear();\n }\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connectionEnd', {\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_4__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer: 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: () => muxer != null ? muxer.streams : errConnectionNotMultiplexed(),\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connection', {\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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n}\n//# sourceMappingURL=upgrader.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/upgrader.js?"); +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_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @libp2p/logger */ \"./node_modules/@libp2p/logger/dist/src/index.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/multistream-select */ \"./node_modules/@libp2p/multistream-select/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/* harmony import */ var _connection_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connection/index.js */ \"./node_modules/libp2p/dist/src/connection/index.js\");\n/* harmony import */ var _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @libp2p/interfaces/events */ \"./node_modules/@libp2p/interfaces/dist/src/events.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 _registrar_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./registrar.js */ \"./node_modules/libp2p/dist/src/registrar.js\");\n/* harmony import */ var timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! timeout-abort-controller */ \"./node_modules/timeout-abort-controller/index.js\");\n/* harmony import */ var abortable_iterator__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! abortable-iterator */ \"./node_modules/abortable-iterator/dist/src/index.js\");\n/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! events */ \"./node_modules/events/events.js\");\n\n\n\n\n\n\n\n\n\n\n\nconst log = (0,_libp2p_logger__WEBPACK_IMPORTED_MODULE_0__.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_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_MAX_INBOUND_STREAMS;\n}\nfunction findOutgoingStreamLimit(protocol, registrar) {\n try {\n const { options } = registrar.getHandler(protocol);\n return options.maxOutboundStreams;\n }\n catch (err) {\n if (err.code !== _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_NO_HANDLER_FOR_PROTOCOL) {\n throw err;\n }\n }\n return _registrar_js__WEBPACK_IMPORTED_MODULE_7__.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 extends _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.EventEmitter {\n constructor(components, init) {\n super();\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;\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection denied'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_DENIED);\n }\n let encryptedConn;\n let remotePeer;\n let upgradedConn;\n let muxerFactory;\n let cryptoProtocol;\n const timeoutController = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(this.inboundUpgradeTimeout);\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, timeoutController.signal);\n }\n catch { }\n try {\n const abortableStream = (0,abortable_iterator__WEBPACK_IMPORTED_MODULE_9__.abortableDuplex)(maConn, timeoutController.signal);\n maConn.source = abortableStream.source;\n maConn.sink = abortableStream.sink;\n if (await this.components.connectionGater.denyInboundConnection(maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyInboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n const idStr = maConn.remoteAddr.getPeerId();\n if (idStr == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('inbound connection that skipped encryption must have a peer id'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_INVALID_MULTIADDR);\n }\n const remotePeerId = (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 if (await this.components.connectionGater.denyInboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 timeoutController.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_6__.peerIdFromString)(idStr);\n if (await this.components.connectionGater.denyOutboundConnection(remotePeerId, maConn)) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by connectionGater.denyOutboundConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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 if (await this.components.connectionGater.denyOutboundEncryptedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\n }\n else {\n if (remotePeerId == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Encryption was skipped but no peer id was passed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 if (await this.components.connectionGater.denyOutboundUpgradedConnection(remotePeer, {\n ...protectedConn,\n ...encryptedConn\n })) {\n throw err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('The multiaddr connection is blocked by gater.acceptEncryptedConnection'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_INTERCEPTED);\n }\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_2__.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 muxedStream.abort(err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many inbound protocol streams for protocol \"${protocol}\" - limit ${incomingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));\n return;\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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('Stream is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n log('%s: starting new stream on %s', direction, protocols);\n const muxedStream = await muxer.newStream();\n let controller;\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 controller = new timeout_abort_controller__WEBPACK_IMPORTED_MODULE_8__.TimeoutController(30000);\n options.signal = controller.signal;\n try {\n // fails on node < 15.4\n (0,events__WEBPACK_IMPORTED_MODULE_10__.setMaxListeners)?.(Infinity, controller.signal);\n }\n catch { }\n }\n const { stream, protocol } = await _libp2p_multistream_select__WEBPACK_IMPORTED_MODULE_2__.select(muxedStream, protocols, options);\n const outgoingLimit = findOutgoingStreamLimit(protocol, this.components.registrar);\n const streamCount = countStreams(protocol, 'outbound', connection);\n if (streamCount === outgoingLimit) {\n const err = err_code__WEBPACK_IMPORTED_MODULE_1__(new Error(`Too many outbound protocol streams for protocol \"${protocol}\" - limit ${outgoingLimit}`), _errors_js__WEBPACK_IMPORTED_MODULE_3__.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 this.components.peerStore.protoBook.add(remotePeer, [protocol]).catch(err => log.error(err));\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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_UNSUPPORTED_PROTOCOL);\n }\n finally {\n if (controller != null) {\n controller.clear();\n }\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connectionEnd', {\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 err_code__WEBPACK_IMPORTED_MODULE_1__(new Error('connection is not multiplexed'), _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_CONNECTION_NOT_MULTIPLEXED);\n };\n // Create the connection\n connection = (0,_connection_index_js__WEBPACK_IMPORTED_MODULE_4__.createConnection)({\n remoteAddr: maConn.remoteAddr,\n remotePeer: 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: () => muxer != null ? muxer.streams : errConnectionNotMultiplexed(),\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.dispatchEvent(new _libp2p_interfaces_events__WEBPACK_IMPORTED_MODULE_5__.CustomEvent('connection', {\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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.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_2__.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 err_code__WEBPACK_IMPORTED_MODULE_1__(err, _errors_js__WEBPACK_IMPORTED_MODULE_3__.codes.ERR_MUXER_UNAVAILABLE);\n }\n }\n}\n//# sourceMappingURL=upgrader.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/dist/src/upgrader.js?"); /***/ }), @@ -10257,292 +8475,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js": -/*!*************************************************************************************!*\ - !*** ./node_modules/libp2p/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/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/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/node_modules/@libp2p/peer-collections/dist/src/list.js\");\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/list.js": -/*!************************************************************************************!*\ - !*** ./node_modules/libp2p/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/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/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 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-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/list.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/map.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/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 */ \"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/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/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 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-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/map.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/set.js": -/*!***********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/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 */ \"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/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/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 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-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/set.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/util.js": -/*!************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-collections/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 */ \"mapIterable\": () => (/* binding */ mapIterable)\n/* harmony export */ });\n/**\n * Calls the passed map function on every entry of the passed iterable iterator\n */\nfunction mapIterable(iter, map) {\n const iterator = {\n [Symbol.iterator]: () => {\n return iterator;\n },\n next: () => {\n const next = iter.next();\n const val = next.value;\n if (next.done === true || val == null) {\n const result = {\n done: true,\n value: undefined\n };\n return result;\n }\n return {\n done: false,\n value: map(val)\n };\n }\n };\n return iterator;\n}\n//# sourceMappingURL=util.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-collections/dist/src/util.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js": -/*!****************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/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 */ \"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 multiformats_cid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/libp2p/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var multiformats_hashes_identity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/hashes/identity */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/identity.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 multiformats_hashes_sha2__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/sha2 */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/sha2-browser.js\");\n/* harmony import */ var _libp2p_interfaces_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @libp2p/interfaces/errors */ \"./node_modules/@libp2p/interfaces/dist/src/errors.js\");\n/* harmony import */ var _libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @libp2p/interface-peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/interface-peer-id/dist/src/index.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_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 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 get [_libp2p_interface_peer_id__WEBPACK_IMPORTED_MODULE_8__.symbol]() {\n return true;\n }\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_0__.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_5__.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_5__.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 constructor(init) {\n super({ ...init, type: 'RSA' });\n this.type = 'RSA';\n this.publicKey = init.publicKey;\n }\n}\nclass Ed25519PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'Ed25519' });\n this.type = 'Ed25519';\n this.publicKey = init.multihash.digest;\n }\n}\nclass Secp256k1PeerIdImpl extends PeerIdImpl {\n constructor(init) {\n super({ ...init, type: 'secp256k1' });\n this.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_7__.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_7__.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_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_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_6__.sha256.code) {\n return new RSAPeerIdImpl({ multihash });\n }\n }\n catch {\n return peerIdFromCID(multiformats_cid__WEBPACK_IMPORTED_MODULE_0__.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_6__.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_6__.sha256.digest(publicKey), publicKey, privateKey });\n}\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js ***! - \********************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Envelope\": () => (/* binding */ Envelope)\n/* harmony export */ });\n/* harmony import */ var protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/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 Envelope;\n(function (Envelope) {\n let _codec;\n Envelope.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.publicKey != null && obj.publicKey.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.publicKey);\n }\n if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) {\n w.uint32(18);\n w.bytes(obj.payloadType);\n }\n if ((obj.payload != null && obj.payload.byteLength > 0)) {\n w.uint32(26);\n w.bytes(obj.payload);\n }\n if ((obj.signature != null && obj.signature.byteLength > 0)) {\n w.uint32(42);\n w.bytes(obj.signature);\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n publicKey: new Uint8Array(0),\n payloadType: new Uint8Array(0),\n payload: new Uint8Array(0),\n signature: 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.publicKey = reader.bytes();\n break;\n case 2:\n obj.payloadType = reader.bytes();\n break;\n case 3:\n obj.payload = reader.bytes();\n break;\n case 5:\n obj.signature = 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 Envelope.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, Envelope.codec());\n };\n Envelope.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, Envelope.codec());\n };\n})(Envelope || (Envelope = {}));\n//# sourceMappingURL=envelope.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/index.js": -/*!*****************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/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 */ \"RecordEnvelope\": () => (/* binding */ RecordEnvelope)\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_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _libp2p_crypto_keys__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @libp2p/crypto/keys */ \"./node_modules/@libp2p/crypto/dist/src/keys/index.js\");\n/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js\");\n/* harmony import */ var _envelope_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./envelope.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/envelope.js\");\n/* harmony import */ var _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/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 uint8_varint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uint8-varint */ \"./node_modules/uint8-varint/dist/src/index.js\");\nvar _a;\n\n\n\n\n\n\n\n\n\nclass RecordEnvelope {\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_5__.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_3__.unmarshalPublicKey)(this.peerId.publicKey);\n return await key.verify(signData.subarray(), this.signature);\n }\n}\n_a = RecordEnvelope;\n/**\n * Unmarshal a serialized Envelope protobuf message\n */\nRecordEnvelope.createFromProtobuf = async (data) => {\n const envelopeData = _envelope_js__WEBPACK_IMPORTED_MODULE_5__.Envelope.decode(data);\n const peerId = await (0,_libp2p_peer_id__WEBPACK_IMPORTED_MODULE_6__.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 */\nRecordEnvelope.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_3__.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 */\nRecordEnvelope.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_0__.CodeError('envelope signature is not valid for the given domain', _errors_js__WEBPACK_IMPORTED_MODULE_4__.codes.ERR_SIGNATURE_NOT_VALID);\n }\n return envelope;\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_1__.fromString)(domain);\n const domainLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(domainUint8Array.byteLength);\n const payloadTypeLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payloadType.length);\n const payloadLength = uint8_varint__WEBPACK_IMPORTED_MODULE_8__.unsigned.encode(payload.length);\n return new uint8arraylist__WEBPACK_IMPORTED_MODULE_7__.Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/envelope/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js": -/*!*********************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/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 ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'\n};\n//# sourceMappingURL=errors.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/errors.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js": -/*!********************************************************************************!*\ - !*** ./node_modules/libp2p/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/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/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js\");\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js": -/*!*********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/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 */ \"ENVELOPE_DOMAIN_PEER_RECORD\": () => (/* binding */ ENVELOPE_DOMAIN_PEER_RECORD),\n/* harmony export */ \"ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\": () => (/* binding */ ENVELOPE_PAYLOAD_TYPE_PEER_RECORD)\n/* harmony export */ });\n// The domain string used for peer records contained in a Envelope.\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record';\n// The type hint used to identify peer records in a Envelope.\n// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv\n// with name \"libp2p-peer-record\"\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1]);\n//# sourceMappingURL=consts.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js": -/*!********************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/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\": () => (/* binding */ PeerRecord)\n/* harmony export */ });\n/* harmony import */ var _multiformats_multiaddr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiformats/multiaddr */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 _libp2p_peer_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @libp2p/peer-id */ \"./node_modules/libp2p/node_modules/@libp2p/peer-id/dist/src/index.js\");\n/* harmony import */ var _peer_record_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./peer-record.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js\");\n/* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./consts.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/consts.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 constructor(init) {\n this.domain = PeerRecord.DOMAIN;\n this.codec = PeerRecord.CODEC;\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_3__.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/**\n * Unmarshal Peer Record Protobuf\n */\nPeerRecord.createFromProtobuf = (buf) => {\n const peerRecord = _peer_record_js__WEBPACK_IMPORTED_MODULE_3__.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};\nPeerRecord.DOMAIN = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_DOMAIN_PEER_RECORD;\nPeerRecord.CODEC = _consts_js__WEBPACK_IMPORTED_MODULE_4__.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD;\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js": -/*!**************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js ***! - \**************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 protons_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protons-runtime */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/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 PeerRecord;\n(function (PeerRecord) {\n let AddressInfo;\n (function (AddressInfo) {\n let _codec;\n AddressInfo.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 (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 default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return obj;\n });\n }\n return _codec;\n };\n AddressInfo.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, AddressInfo.codec());\n };\n AddressInfo.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, AddressInfo.codec());\n };\n })(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));\n let _codec;\n PeerRecord.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 && obj.peerId.byteLength > 0)) {\n w.uint32(10);\n w.bytes(obj.peerId);\n }\n if ((obj.seq != null && obj.seq !== 0n)) {\n w.uint32(16);\n w.uint64(obj.seq);\n }\n if (obj.addresses != null) {\n for (const value of obj.addresses) {\n w.uint32(26);\n PeerRecord.AddressInfo.codec().encode(value, w);\n }\n }\n if (opts.lengthDelimited !== false) {\n w.ldelim();\n }\n }, (reader, length) => {\n const obj = {\n peerId: new Uint8Array(0),\n seq: 0n,\n addresses: []\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.peerId = reader.bytes();\n break;\n case 2:\n obj.seq = reader.uint64();\n break;\n case 3:\n obj.addresses.push(PeerRecord.AddressInfo.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 PeerRecord.encode = (obj) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.encodeMessage)(obj, PeerRecord.codec());\n };\n PeerRecord.decode = (buf) => {\n return (0,protons_runtime__WEBPACK_IMPORTED_MODULE_0__.decodeMessage)(buf, PeerRecord.codec());\n };\n})(PeerRecord || (PeerRecord = {}));\n//# sourceMappingURL=peer-record.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/dist/src/peer-record/peer-record.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js": -/*!*********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"ParseError\": () => (/* binding */ ParseError),\n/* harmony export */ \"bytesToString\": () => (/* binding */ bytesToString),\n/* harmony export */ \"bytesToTuples\": () => (/* binding */ bytesToTuples),\n/* harmony export */ \"cleanPath\": () => (/* binding */ cleanPath),\n/* harmony export */ \"fromBytes\": () => (/* binding */ fromBytes),\n/* harmony export */ \"fromString\": () => (/* binding */ fromString),\n/* harmony export */ \"isValidBytes\": () => (/* binding */ isValidBytes),\n/* harmony export */ \"protoFromTuple\": () => (/* binding */ protoFromTuple),\n/* harmony export */ \"sizeForAddr\": () => (/* binding */ sizeForAddr),\n/* harmony export */ \"stringToBytes\": () => (/* binding */ stringToBytes),\n/* harmony export */ \"stringToStringTuples\": () => (/* binding */ stringToStringTuples),\n/* harmony export */ \"stringTuplesToString\": () => (/* binding */ stringTuplesToString),\n/* harmony export */ \"stringTuplesToTuples\": () => (/* binding */ stringTuplesToTuples),\n/* harmony export */ \"tuplesToBytes\": () => (/* binding */ tuplesToBytes),\n/* harmony export */ \"tuplesToStringTuples\": () => (/* binding */ tuplesToStringTuples),\n/* harmony export */ \"validateBytes\": () => (/* binding */ validateBytes)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./convert.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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_to_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\n\n\n/**\n * string -> [[str name, str addr]... ]\n */\nfunction stringToStringTuples(str) {\n const tuples = [];\n const parts = str.split('/').slice(1); // skip first empty elem\n if (parts.length === 1 && parts[0] === '') {\n return [];\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_1__.getProtocol)(part);\n if (proto.size === 0) {\n tuples.push([part]);\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 tuples.push([\n part,\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 cleanPath(parts.slice(p).join('/'))\n ]);\n break;\n }\n tuples.push([part, parts[p]]);\n }\n return tuples;\n}\n/**\n * [[str name, str addr]... ] -> string\n */\nfunction stringTuplesToString(tuples) {\n const parts = [];\n tuples.map((tup) => {\n const proto = protoFromTuple(tup);\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 * [[str name, str addr]... ] -> [[int code, Uint8Array]... ]\n */\nfunction stringTuplesToTuples(tuples) {\n return tuples.map((tup) => {\n if (!Array.isArray(tup)) {\n tup = [tup];\n }\n const proto = protoFromTuple(tup);\n if (tup.length > 1) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToBytes)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * Convert tuples to string tuples\n *\n * [[int code, Uint8Array]... ] -> [[int code, str addr]... ]\n */\nfunction tuplesToStringTuples(tuples) {\n return tuples.map(tup => {\n const proto = protoFromTuple(tup);\n if (tup[1] != null) {\n return [proto.code, (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToString)(proto.code, tup[1])];\n }\n return [proto.code];\n });\n}\n/**\n * [[int code, Uint8Array ]... ] -> Uint8Array\n */\nfunction tuplesToBytes(tuples) {\n return fromBytes((0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.concat)(tuples.map((tup) => {\n const proto = protoFromTuple(tup);\n let buf = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_2__.encode(proto.code));\n if (tup.length > 1 && tup[1] != null) {\n buf = (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_3__.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 = varint__WEBPACK_IMPORTED_MODULE_2__.decode(addr);\n return size + (varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0);\n }\n}\nfunction bytesToTuples(buf) {\n const tuples = [];\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_4__.toString)(buf, 'base16'));\n }\n // ok, tuple seems good.\n tuples.push([code, addr]);\n }\n return tuples;\n}\n/**\n * Uint8Array -> String\n */\nfunction bytesToString(buf) {\n const a = bytesToTuples(buf);\n const b = tuplesToStringTuples(a);\n return stringTuplesToString(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction stringToBytes(str) {\n str = cleanPath(str);\n const a = stringToStringTuples(str);\n const b = stringTuplesToTuples(a);\n return tuplesToBytes(b);\n}\n/**\n * String -> Uint8Array\n */\nfunction fromString(str) {\n return stringToBytes(str);\n}\n/**\n * Uint8Array -> Uint8Array\n */\nfunction fromBytes(buf) {\n const err = validateBytes(buf);\n if (err != null) {\n throw err;\n }\n return Uint8Array.from(buf); // copy\n}\nfunction validateBytes(buf) {\n try {\n bytesToTuples(buf); // try to parse. will throw if breaks\n }\n catch (err) {\n return err;\n }\n}\nfunction isValidBytes(buf) {\n return validateBytes(buf) === undefined;\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}\nfunction protoFromTuple(tup) {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tup[0]);\n return proto;\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js": -/*!***********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js ***! - \***********************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 _ip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ip.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/bases/base32 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var multiformats_basics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! multiformats/basics */ \"./node_modules/libp2p/node_modules/multiformats/src/basics.js\");\n/* harmony import */ var multiformats_hashes_digest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! multiformats/hashes/digest */ \"./node_modules/libp2p/node_modules/multiformats/src/hashes/digest.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.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 uint8arrays_from_string__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! uint8arrays/from-string */ \"./node_modules/uint8arrays/dist/src/from-string.js\");\n/* harmony import */ var uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! uint8arrays/concat */ \"./node_modules/uint8arrays/dist/src/concat.js\");\n/* harmony import */ var _chainsafe_netmask__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @chainsafe/netmask */ \"./node_modules/@chainsafe/netmask/dist/src/index.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_1__.getProtocol)('ip4');\nconst ip6Protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\nconst ipcidrProtocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_8__.toString)(buf, 'base16'); // no clue. convert to hex\n }\n}\nfunction convertToBytes(proto, str) {\n const protocol = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_9__.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_11__.IpNet(addr, mask);\n}\nconst decoders = Object.values(multiformats_basics__WEBPACK_IMPORTED_MODULE_5__.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_0__.isIP(ipString)) {\n throw new Error('invalid ip address');\n }\n return _ip_js__WEBPACK_IMPORTED_MODULE_0__.toBytes(ipString);\n}\nfunction bytes2ip(ipBuff) {\n const ipString = _ip_js__WEBPACK_IMPORTED_MODULE_0__.toString(ipBuff, 0, ipBuff.length);\n if (ipString == null) {\n throw new Error('ipBuff is required');\n }\n if (!_ip_js__WEBPACK_IMPORTED_MODULE_0__.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_9__.fromString)(str);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(buf.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, buf], size.length + buf.length);\n}\nfunction bytes2str(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n buf = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (buf.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_6__.decode(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${hash}`)).bytes;\n }\n else {\n mh = multiformats_cid__WEBPACK_IMPORTED_MODULE_2__.CID.parse(hash).multihash.bytes;\n }\n // the address is a varint prefixed multihash string representation\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mh.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mh], size.length + mh.length);\n}\nfunction mb2bytes(mbstr) {\n const mb = anybaseDecoder.decode(mbstr);\n const size = Uint8Array.from(varint__WEBPACK_IMPORTED_MODULE_7__.encode(mb.length));\n return (0,uint8arrays_concat__WEBPACK_IMPORTED_MODULE_10__.concat)([size, mb], size.length + mb.length);\n}\nfunction bytes2mb(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const hash = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (hash.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return 'u' + (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.toString)(hash, 'base64url');\n}\n/**\n * Converts bytes to bas58btc string\n */\nfunction bytes2mh(buf) {\n const size = varint__WEBPACK_IMPORTED_MODULE_7__.decode(buf);\n const address = buf.slice(varint__WEBPACK_IMPORTED_MODULE_7__.decode.bytes);\n if (address.length !== size) {\n throw new Error('inconsistent lengths');\n }\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_8__.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_3__.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_10__.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_3__.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_10__.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_8__.toString)(addrBytes, 'base32');\n const port = bytes2port(portBytes);\n return `${addr}:${port}`;\n}\n//# sourceMappingURL=convert.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js": -/*!***************************************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-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 */ \"MultiaddrFilter\": () => (/* binding */ MultiaddrFilter)\n/* harmony export */ });\n/* harmony import */ var _convert_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../convert.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/convert.js\");\n/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js\");\n\n\n/**\n * A utility class to determine if a Multiaddr contains another\n * multiaddr.\n *\n * This can be used with ipcidr ranges to determine if a given\n * multiaddr is in a ipcidr range.\n *\n * @example\n *\n * ```js\n * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'\n *\n * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')\n * const filter = new MultiaddrFilter(range)\n *\n * const input = multiaddr('/ip4/192.168.10.2/udp/60')\n * console.info(filter.contains(input)) // true\n * ```\n */\nclass MultiaddrFilter {\n constructor(input) {\n this.multiaddr = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n this.netmask = (0,_convert_js__WEBPACK_IMPORTED_MODULE_0__.convertToIpNet)(this.multiaddr);\n }\n contains(input) {\n if (input == null)\n return false;\n const m = (0,_index_js__WEBPACK_IMPORTED_MODULE_1__.multiaddr)(input);\n let ip;\n for (const [code, value] of m.stringTuples()) {\n if (code === 4 || code === 41) {\n ip = value;\n break;\n }\n }\n if (ip === undefined)\n return false;\n return this.netmask.contains(ip);\n }\n}\n//# sourceMappingURL=multiaddr-filter.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js": -/*!*********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/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 */ \"MultiaddrFilter\": () => (/* reexport safe */ _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__.MultiaddrFilter),\n/* harmony export */ \"fromNodeAddress\": () => (/* binding */ fromNodeAddress),\n/* harmony export */ \"isMultiaddr\": () => (/* binding */ isMultiaddr),\n/* harmony export */ \"isName\": () => (/* binding */ isName),\n/* harmony export */ \"multiaddr\": () => (/* binding */ multiaddr),\n/* harmony export */ \"protocols\": () => (/* reexport safe */ _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol),\n/* harmony export */ \"resolvers\": () => (/* binding */ resolvers)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/codec.js\");\n/* harmony import */ var _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./protocols-table.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js\");\n/* harmony import */ var varint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! varint */ \"./node_modules/varint/index.js\");\n/* harmony import */ var multiformats_cid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! multiformats/cid */ \"./node_modules/libp2p/node_modules/multiformats/src/cid.js\");\n/* harmony import */ var multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! multiformats/bases/base58 */ \"./node_modules/libp2p/node_modules/multiformats/src/bases/base58.js\");\n/* harmony import */ var err_code__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! err-code */ \"./node_modules/err-code/index.js\");\n/* harmony import */ var uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n/* harmony import */ var uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uint8arrays/equals */ \"./node_modules/uint8arrays/dist/src/equals.js\");\n/* harmony import */ var _filter_multiaddr_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./filter/multiaddr-filter.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.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 */\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 __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 _DefaultMultiaddr_string, _DefaultMultiaddr_tuples, _DefaultMultiaddr_stringTuples, _a;\n\n\n\n\n\n\n\n\nconst inspect = Symbol.for('nodejs.util.inspect.custom');\nconst DNS_CODES = [\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns4').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6').code,\n (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dnsaddr').code\n];\n/**\n * All configured {@link Resolver}s\n */\nconst resolvers = new Map();\nconst symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');\n\n/**\n * Creates a Multiaddr from a node-friendly address object\n *\n * @example\n * ```js\n * import { fromNodeAddress } from '@multiformats/multiaddr'\n *\n * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n */\nfunction fromNodeAddress(addr, transport) {\n if (addr == null) {\n throw new Error('requires node address object');\n }\n if (transport == null) {\n throw new Error('requires transport protocol');\n }\n let ip;\n let host = addr.address;\n switch (addr.family) {\n case 4:\n ip = 'ip4';\n break;\n case 6:\n ip = 'ip6';\n if (host.includes('%')) {\n const parts = host.split('%');\n if (parts.length !== 2) {\n throw Error('Multiple ip6 zones in multiaddr');\n }\n host = parts[0];\n const zone = parts[1];\n ip = `/ip6zone/${zone}/ip6`;\n }\n break;\n default:\n throw Error('Invalid addr family, should be 4 or 6.');\n }\n return new DefaultMultiaddr('/' + [ip, host, transport, addr.port].join('/'));\n}\n/**\n * Returns if something is a {@link Multiaddr} that is a resolvable name\n *\n * @example\n *\n * ```js\n * import { isName, multiaddr } from '@multiformats/multiaddr'\n *\n * isName(multiaddr('/ip4/127.0.0.1'))\n * // false\n * isName(multiaddr('/dns/ipfs.io'))\n * // true\n * ```\n */\nfunction isName(addr) {\n if (!isMultiaddr(addr)) {\n return false;\n }\n // if a part of the multiaddr is resolvable, then return true\n return addr.protos().some((proto) => proto.resolvable);\n}\n/**\n * Check if object is a {@link Multiaddr} instance\n *\n * @example\n *\n * ```js\n * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'\n *\n * isMultiaddr(5)\n * // false\n * isMultiaddr(multiaddr('/ip4/127.0.0.1'))\n * // true\n * ```\n */\nfunction isMultiaddr(value) {\n return Boolean(value?.[symbol]);\n}\n/**\n * Creates a {@link Multiaddr} from a {@link MultiaddrInput}\n */\nclass DefaultMultiaddr {\n constructor(addr) {\n _DefaultMultiaddr_string.set(this, void 0);\n _DefaultMultiaddr_tuples.set(this, void 0);\n _DefaultMultiaddr_stringTuples.set(this, void 0);\n this[_a] = true;\n // default\n if (addr == null) {\n addr = '';\n }\n if (addr instanceof Uint8Array) {\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(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 this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromString(addr);\n }\n else if (isMultiaddr(addr)) { // Multiaddr\n this.bytes = _codec_js__WEBPACK_IMPORTED_MODULE_0__.fromBytes(addr.bytes); // validate + copy buffer\n }\n else {\n throw new Error('addr must be a string, Buffer, or another Multiaddr');\n }\n }\n toString() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_string, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_string, \"f\");\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_1__.getProtocol)('tcp');\n const udp = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('udp');\n const ip4 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip4');\n const ip6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('ip6');\n const dns6 = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)('dns6');\n const ip6zone = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.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_1__.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_1__.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.protoCodes().map(code => Object.assign({}, (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code)));\n }\n protoCodes() {\n const codes = [];\n const buf = this.bytes;\n let i = 0;\n while (i < buf.length) {\n const code = varint__WEBPACK_IMPORTED_MODULE_2__.decode(buf, i);\n const n = varint__WEBPACK_IMPORTED_MODULE_2__.decode.bytes ?? 0;\n const p = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(code);\n const size = _codec_js__WEBPACK_IMPORTED_MODULE_0__.sizeForAddr(p, buf.slice(i + n));\n i += (size + n);\n codes.push(code);\n }\n return codes;\n }\n protoNames() {\n return this.protos().map(proto => proto.name);\n }\n tuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_tuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToTuples(this.bytes), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_tuples, \"f\");\n }\n stringTuples() {\n if (__classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\") == null) {\n __classPrivateFieldSet(this, _DefaultMultiaddr_stringTuples, _codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToStringTuples(this.tuples()), \"f\");\n }\n return __classPrivateFieldGet(this, _DefaultMultiaddr_stringTuples, \"f\");\n }\n encapsulate(addr) {\n addr = new DefaultMultiaddr(addr);\n return new DefaultMultiaddr(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 DefaultMultiaddr(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 DefaultMultiaddr(_codec_js__WEBPACK_IMPORTED_MODULE_0__.tuplesToBytes(tuples.slice(0, i)));\n }\n }\n return this;\n }\n getPeerId() {\n try {\n const tuples = this.stringTuples().filter((tuple) => {\n if (tuple[0] === _protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.names.ipfs.code) {\n return true;\n }\n return false;\n });\n // Get the last ipfs tuple ['ipfs', '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_6__.toString)(multiformats_bases_base58__WEBPACK_IMPORTED_MODULE_4__.base58btc.decode(`z${peerIdStr}`), 'base58btc');\n }\n // try to parse peer id as CID\n return (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_6__.toString)(multiformats_cid__WEBPACK_IMPORTED_MODULE_3__.CID.parse(peerIdStr).multihash.bytes, 'base58btc');\n }\n return null;\n }\n catch (e) {\n return null;\n }\n }\n getPath() {\n let path = null;\n try {\n path = this.stringTuples().filter((tuple) => {\n const proto = (0,_protocols_table_js__WEBPACK_IMPORTED_MODULE_1__.getProtocol)(tuple[0]);\n if (proto.path === true) {\n return true;\n }\n return false;\n })[0][1];\n if (path == null) {\n path = null;\n }\n }\n catch {\n path = null;\n }\n return path;\n }\n equals(addr) {\n return (0,uint8arrays_equals__WEBPACK_IMPORTED_MODULE_7__.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 = resolvers.get(resolvableProto.name);\n if (resolver == null) {\n throw err_code__WEBPACK_IMPORTED_MODULE_5__(new Error(`no available resolver for ${resolvableProto.name}`), 'ERR_NO_AVAILABLE_RESOLVER');\n }\n const addresses = await resolver(this, options);\n return addresses.map((a) => new DefaultMultiaddr(a));\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 [(_DefaultMultiaddr_string = new WeakMap(), _DefaultMultiaddr_tuples = new WeakMap(), _DefaultMultiaddr_stringTuples = new WeakMap(), _a = symbol, inspect)]() {\n return `Multiaddr(${_codec_js__WEBPACK_IMPORTED_MODULE_0__.bytesToString(this.bytes)})`;\n }\n}\n/**\n * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}\n *\n * @example\n * ```js\n * import { multiaddr } from '@libp2p/multiaddr'\n *\n * multiaddr('/ip4/127.0.0.1/tcp/4001')\n * // Multiaddr(/ip4/127.0.0.1/tcp/4001)\n * ```\n *\n * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)\n */\nfunction multiaddr(addr) {\n return new DefaultMultiaddr(addr);\n}\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js": -/*!******************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/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 */ \"isIP\": () => (/* reexport safe */ _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIP),\n/* harmony export */ \"isV4\": () => (/* binding */ isV4),\n/* harmony export */ \"isV6\": () => (/* binding */ isV6),\n/* harmony export */ \"toBytes\": () => (/* binding */ toBytes),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\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 uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uint8arrays/to-string */ \"./node_modules/uint8arrays/dist/src/to-string.js\");\n\n\n\nconst isV4 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv4;\nconst isV6 = _chainsafe_is_ip__WEBPACK_IMPORTED_MODULE_0__.isIPv6;\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7\n// but with buf/offset args removed because we don't use them\nconst toBytes = function (ip) {\n let offset = 0;\n ip = ip.toString().trim();\n if (isV4(ip)) {\n const bytes = new Uint8Array(offset + 4);\n ip.split(/\\./g).forEach((byte) => {\n bytes[offset++] = parseInt(byte, 10) & 0xff;\n });\n return bytes;\n }\n if (isV6(ip)) {\n const sections = ip.split(':', 8);\n let i;\n for (i = 0; i < sections.length; i++) {\n const isv4 = isV4(sections[i]);\n let v4Buffer;\n if (isv4) {\n v4Buffer = toBytes(sections[i]);\n sections[i] = (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(0, 2), 'base16');\n }\n if (v4Buffer != null && ++i < 8) {\n sections.splice(i, 0, (0,uint8arrays_to_string__WEBPACK_IMPORTED_MODULE_1__.toString)(v4Buffer.slice(2, 4), 'base16'));\n }\n }\n if (sections[0] === '') {\n while (sections.length < 8)\n sections.unshift('0');\n }\n else if (sections[sections.length - 1] === '') {\n while (sections.length < 8)\n sections.push('0');\n }\n else if (sections.length < 8) {\n for (i = 0; i < sections.length && sections[i] !== ''; i++)\n ;\n const argv = [i, 1];\n for (i = 9 - sections.length; i > 0; i--) {\n argv.push('0');\n }\n sections.splice.apply(sections, argv);\n }\n const bytes = new Uint8Array(offset + 16);\n for (i = 0; i < sections.length; i++) {\n const word = parseInt(sections[i], 16);\n bytes[offset++] = (word >> 8) & 0xff;\n bytes[offset++] = word & 0xff;\n }\n return bytes;\n }\n throw new Error('invalid ip address');\n};\n// Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63\nconst toString = function (buf, offset = 0, length) {\n offset = ~~offset;\n length = length ?? (buf.length - offset);\n const view = new DataView(buf.buffer);\n if (length === 4) {\n const result = [];\n // IPv4\n for (let i = 0; i < length; i++) {\n result.push(buf[offset + i]);\n }\n return result.join('.');\n }\n if (length === 16) {\n const result = [];\n // IPv6\n for (let i = 0; i < length; i += 2) {\n result.push(view.getUint16(offset + i).toString(16));\n }\n return result.join(':')\n .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')\n .replace(/:{3,4}/, '::');\n }\n return '';\n};\n//# sourceMappingURL=ip.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/ip.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js": -/*!*******************************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js ***! - \*******************************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_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 */ \"createProtocol\": () => (/* binding */ createProtocol),\n/* harmony export */ \"getProtocol\": () => (/* binding */ getProtocol),\n/* harmony export */ \"names\": () => (/* binding */ names),\n/* harmony export */ \"table\": () => (/* binding */ table)\n/* harmony export */ });\nconst V = -1;\nconst names = {};\nconst codes = {};\nconst table = [\n [4, 32, 'ip4'],\n [6, 16, 'tcp'],\n [33, 16, 'dccp'],\n [41, 128, 'ip6'],\n [42, V, 'ip6zone'],\n [43, 8, 'ipcidr'],\n [53, V, 'dns', true],\n [54, V, 'dns4', true],\n [55, V, 'dns6', true],\n [56, V, 'dnsaddr', true],\n [132, 16, 'sctp'],\n [273, 16, 'udp'],\n [275, 0, 'p2p-webrtc-star'],\n [276, 0, 'p2p-webrtc-direct'],\n [277, 0, 'p2p-stardust'],\n [280, 0, 'webrtc-direct'],\n [281, 0, 'webrtc'],\n [290, 0, 'p2p-circuit'],\n [301, 0, 'udt'],\n [302, 0, 'utp'],\n [400, V, 'unix', false, true],\n // `ipfs` is added before `p2p` for legacy support.\n // All text representations will default to `p2p`, but `ipfs` will\n // still be supported\n [421, V, 'ipfs'],\n // `p2p` is the preferred name for 421, and is now the default\n [421, V, 'p2p'],\n [443, 0, 'https'],\n [444, 96, 'onion'],\n [445, 296, 'onion3'],\n [446, V, 'garlic64'],\n [448, 0, 'tls'],\n [449, V, 'sni'],\n [460, 0, 'quic'],\n [461, 0, 'quic-v1'],\n [465, 0, 'webtransport'],\n [466, V, 'certhash'],\n [477, 0, 'ws'],\n [478, 0, 'wss'],\n [479, 0, 'p2p-websocket-star'],\n [480, 0, 'http'],\n [777, V, 'memory']\n];\n// populate tables\ntable.forEach(row => {\n const proto = createProtocol(...row);\n codes[proto.code] = proto;\n names[proto.name] = proto;\n});\nfunction createProtocol(code, size, name, resolvable, path) {\n return {\n code,\n size,\n name,\n resolvable: Boolean(resolvable),\n path: Boolean(path)\n };\n}\n/**\n * For the passed proto string or number, return a {@link Protocol}\n *\n * @example\n *\n * ```js\n * import { protocol } from '@multiformats/multiaddr'\n *\n * console.info(protocol(4))\n * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }\n * ```\n */\nfunction getProtocol(proto) {\n if (typeof proto === 'number') {\n if (codes[proto] != null) {\n return codes[proto];\n }\n throw new Error(`no protocol with code: ${proto}`);\n }\n else if (typeof proto === 'string') {\n if (names[proto] != null) {\n return names[proto];\n }\n throw new Error(`no protocol with name: ${proto}`);\n }\n throw new Error(`invalid protocol id type: ${typeof proto}`);\n}\n//# sourceMappingURL=protocols-table.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js": -/*!*******************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js ***! - \*******************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js": -/*!**********************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js": -/*!**************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js ***! - \**************************************************************************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/index.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/index.js?"); - -/***/ }), - -/***/ "./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js": -/*!*************************************************************************************************************!*\ - !*** ./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/libp2p/node_modules/@libp2p/peer-record/node_modules/protons-runtime/dist/src/utils.js?"); - -/***/ }), - /***/ "./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/codec.js": /*!************************************************************************************!*\ !*** ./node_modules/libp2p/node_modules/@multiformats/multiaddr/dist/src/codec.js ***! @@ -11258,6 +9190,83 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./node_modules/protons-runtime/dist/src/codec.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/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 */ \"CODEC_TYPES\": () => (/* binding */ CODEC_TYPES),\n/* harmony export */ \"createCodec\": () => (/* binding */ createCodec)\n/* harmony export */ });\n// https://developers.google.com/protocol-buffers/docs/encoding#structure\nvar CODEC_TYPES;\n(function (CODEC_TYPES) {\n CODEC_TYPES[CODEC_TYPES[\"VARINT\"] = 0] = \"VARINT\";\n CODEC_TYPES[CODEC_TYPES[\"BIT64\"] = 1] = \"BIT64\";\n CODEC_TYPES[CODEC_TYPES[\"LENGTH_DELIMITED\"] = 2] = \"LENGTH_DELIMITED\";\n CODEC_TYPES[CODEC_TYPES[\"START_GROUP\"] = 3] = \"START_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"END_GROUP\"] = 4] = \"END_GROUP\";\n CODEC_TYPES[CODEC_TYPES[\"BIT32\"] = 5] = \"BIT32\";\n})(CODEC_TYPES || (CODEC_TYPES = {}));\nfunction createCodec(name, type, encode, decode) {\n return {\n name,\n type,\n encode,\n decode\n };\n}\n//# sourceMappingURL=codec.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/codec.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/codecs/enum.js": +/*!**************************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/codecs/enum.js ***! + \**************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"enumeration\": () => (/* binding */ enumeration)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction enumeration(v) {\n function findValue(val) {\n // Use the reverse mapping to look up the enum key for the stored value\n // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings\n if (v[val.toString()] == null) {\n throw new Error('Invalid enum value');\n }\n return v[val];\n }\n const encode = function enumEncode(val, writer) {\n const enumValue = findValue(val);\n writer.int32(enumValue);\n };\n const decode = function enumDecode(reader) {\n const val = reader.int32();\n return findValue(val);\n };\n // @ts-expect-error yeah yeah\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('enum', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.VARINT, encode, decode);\n}\n//# sourceMappingURL=enum.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/codecs/enum.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/codecs/message.js": +/*!*****************************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/codecs/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 */ \"message\": () => (/* binding */ message)\n/* harmony export */ });\n/* harmony import */ var _codec_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../codec.js */ \"./node_modules/protons-runtime/dist/src/codec.js\");\n\nfunction message(encode, decode) {\n return (0,_codec_js__WEBPACK_IMPORTED_MODULE_0__.createCodec)('message', _codec_js__WEBPACK_IMPORTED_MODULE_0__.CODEC_TYPES.LENGTH_DELIMITED, encode, decode);\n}\n//# sourceMappingURL=message.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/codecs/message.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/decode.js": +/*!*********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/decode.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeMessage\": () => (/* binding */ decodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction decodeMessage(buf, codec) {\n const r = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.reader)(buf instanceof Uint8Array ? buf : buf.subarray());\n return codec.decode(r);\n}\n//# sourceMappingURL=decode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/decode.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/encode.js": +/*!*********************************************************!*\ + !*** ./node_modules/protons-runtime/dist/src/encode.js ***! + \*********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"encodeMessage\": () => (/* binding */ encodeMessage)\n/* harmony export */ });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\nfunction encodeMessage(message, codec) {\n const w = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.writer)();\n codec.encode(message, w, {\n lengthDelimited: false\n });\n return w.finish();\n}\n//# sourceMappingURL=encode.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/encode.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/index.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/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 */ \"decodeMessage\": () => (/* reexport safe */ _decode_js__WEBPACK_IMPORTED_MODULE_0__.decodeMessage),\n/* harmony export */ \"encodeMessage\": () => (/* reexport safe */ _encode_js__WEBPACK_IMPORTED_MODULE_1__.encodeMessage),\n/* harmony export */ \"enumeration\": () => (/* reexport safe */ _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__.enumeration),\n/* harmony export */ \"message\": () => (/* reexport safe */ _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__.message),\n/* harmony export */ \"reader\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.reader),\n/* harmony export */ \"writer\": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_4__.writer)\n/* harmony export */ });\n/* harmony import */ var _decode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode.js */ \"./node_modules/protons-runtime/dist/src/decode.js\");\n/* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./encode.js */ \"./node_modules/protons-runtime/dist/src/encode.js\");\n/* harmony import */ var _codecs_enum_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./codecs/enum.js */ \"./node_modules/protons-runtime/dist/src/codecs/enum.js\");\n/* harmony import */ var _codecs_message_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./codecs/message.js */ \"./node_modules/protons-runtime/dist/src/codecs/message.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ \"./node_modules/protons-runtime/dist/src/utils.js\");\n\n\n\n\n\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/protons-runtime/dist/src/utils.js": +/*!********************************************************!*\ + !*** ./node_modules/protons-runtime/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 */ \"reader\": () => (/* binding */ reader),\n/* harmony export */ \"writer\": () => (/* binding */ writer)\n/* harmony export */ });\n/* harmony import */ var protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! protobufjs/src/reader.js */ \"./node_modules/protobufjs/src/reader.js\");\n/* harmony import */ var protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! protobufjs/src/reader_buffer.js */ \"./node_modules/protobufjs/src/reader_buffer.js\");\n/* harmony import */ var protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! protobufjs/src/util/minimal.js */ \"./node_modules/protobufjs/src/util/minimal.js\");\n/* harmony import */ var protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! protobufjs/src/writer.js */ \"./node_modules/protobufjs/src/writer.js\");\n/* harmony import */ var protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! protobufjs/src/writer_buffer.js */ \"./node_modules/protobufjs/src/writer_buffer.js\");\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\n// @ts-expect-error no types\n\nfunction configure() {\n protobufjs_src_util_minimal_js__WEBPACK_IMPORTED_MODULE_2__._configure();\n protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__._configure(protobufjs_src_reader_buffer_js__WEBPACK_IMPORTED_MODULE_1__);\n protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__._configure(protobufjs_src_writer_buffer_js__WEBPACK_IMPORTED_MODULE_4__);\n}\n// Set up buffer utility according to the environment\nconfigure();\n// monkey patch the reader to add native bigint support\nconst methods = [\n 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'\n];\nfunction patchReader(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function () {\n return BigInt(original.call(this).toString());\n };\n }\n return obj;\n}\nfunction reader(buf) {\n return patchReader(new protobufjs_src_reader_js__WEBPACK_IMPORTED_MODULE_0__(buf));\n}\nfunction patchWriter(obj) {\n for (const method of methods) {\n if (obj[method] == null) {\n continue;\n }\n const original = obj[method];\n obj[method] = function (val) {\n return original.call(this, val.toString());\n };\n }\n return obj;\n}\nfunction writer() {\n return patchWriter(protobufjs_src_writer_js__WEBPACK_IMPORTED_MODULE_3__.create());\n}\n//# sourceMappingURL=utils.js.map\n\n//# sourceURL=webpack://@waku/noise-rtc/./node_modules/protons-runtime/dist/src/utils.js?"); + +/***/ }), + /***/ "./node_modules/uint8-varint/dist/src/index.js": /*!*****************************************************!*\ !*** ./node_modules/uint8-varint/dist/src/index.js ***! @@ -11551,7 +9560,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 */ \"CID\": () => (/* binding */ CID),\n/* harmony export */ \"format\": () => (/* binding */ format)\n/* harmony export */ });\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./varint.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/uint8arrays/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/** @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 {\n code: this.code,\n version: this.version,\n hash: this.multihash.bytes\n }\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 returs 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 // 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-rtc/./node_modules/uint8arrays/node_modules/multiformats/src/cid.js?"); +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/uint8arrays/node_modules/multiformats/src/varint.js\");\n/* harmony import */ var _hashes_digest_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hashes/digest.js */ \"./node_modules/uint8arrays/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/uint8arrays/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/uint8arrays/node_modules/multiformats/src/bases/base32.js\");\n/* harmony import */ var _bytes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bytes.js */ \"./node_modules/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _link_interface_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./link/interface.js */ \"./node_modules/uint8arrays/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-rtc/./node_modules/uint8arrays/node_modules/multiformats/src/cid.js?"); /***/ }), @@ -11584,7 +9593,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 */ \"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/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/uint8arrays/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 alogrithm 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-rtc/./node_modules/uint8arrays/node_modules/multiformats/src/hashes/digest.js?"); +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/uint8arrays/node_modules/multiformats/src/bytes.js\");\n/* harmony import */ var _varint_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../varint.js */ \"./node_modules/uint8arrays/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-rtc/./node_modules/uint8arrays/node_modules/multiformats/src/hashes/digest.js?"); /***/ }),