aaa7da985871813f51ad6708ce8e24bff95050707460825b51ca6c3a56c1e87a.json raw

   1  {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport browser from 'webextension-polyfill';\n// Inject the script that will provide window.nostr\n// The script needs to run before any other scripts from the real\n// page run (and maybe check for window.nostr).\nconst script = document.createElement('script');\nscript.setAttribute('async', 'false');\nscript.setAttribute('type', 'text/javascript');\nscript.setAttribute('src', browser.runtime.getURL('smesh-signer-extension.js'));\n(document.head || document.documentElement).appendChild(script);\n// listen for messages from that script\nwindow.addEventListener('message', /*#__PURE__*/function () {\n  var _ref = _asyncToGenerator(function* (message) {\n    // We will also receive our own messages, that we sent.\n    // We have to ignore them (they will not have a params field).\n    if (message.source !== window) return;\n    if (!message.data) return;\n    if (!message.data.params) return;\n    if (message.data.ext !== 'smesh-signer') return;\n    // pass on to background\n    let response;\n    try {\n      const request = {\n        method: message.data.method,\n        params: message.data.params,\n        host: location.host\n      };\n      response = yield browser.runtime.sendMessage(request);\n    } catch (error) {\n      response = {\n        error\n      };\n    }\n    // return response\n    window.postMessage({\n      id: message.data.id,\n      ext: 'smesh-signer',\n      response\n    }, message.origin);\n  });\n  return function (_x) {\n    return _ref.apply(this, arguments);\n  };\n}());\n// Relay MLS push messages from background → page.\n// The extension background pushes events (publish, DM, subscribe, status)\n// when the marmot WASM produces output asynchronously.\nbrowser.runtime.onMessage.addListener(message => {\n  if (message?.ext === 'smesh-signer' && message?.type === 'mls-push') {\n    window.postMessage(message, '*');\n  }\n});","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}