{"_id":"@ampproject/viewer-messaging","_rev":"15-377792d660e50421e18f53a1ec409c5e","name":"@ampproject/viewer-messaging","dist-tags":{"latest":"1.1.2"},"versions":{"1.1.0":{"name":"@ampproject/viewer-messaging","version":"1.1.0","description":"Messaging between an AMP Doc and a Viewer","author":{"name":"The AMP HTML Authors"},"license":"Apache-2.0","main":"messaging.js","types":"messaging.d.ts","keywords":["amp"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"extensions/amp-viewer-integration/0.1/messaging"},"homepage":"https://github.com/ampproject/amphtml/tree/master/extensions/amp-viewer-integration/0.1/messaging","bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"_id":"@ampproject/viewer-messaging@1.1.0","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-SoR1dGl2Pl8eJlyGCU/9Gz/orOggmW/13wUh7NnuGvDYqLdlhnRBzvEGqEAlq/fQKel9ZM6RNtu85Jw8WC3K2Q==","shasum":"404f92c5754bac61014ed2272dd5e87174b9af84","tarball":"https://registry.npmjs.org/@ampproject/viewer-messaging/-/viewer-messaging-1.1.0.tgz","fileCount":5,"unpackedSize":29197,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJduZEDCRA9TVsSAnZWagAA0g0P/3J+l23RMfQeMNF00g3l\nDtrvo9Q3AcLyVsdyPy7pDpMEgflHZvnLmiw0I68fI7olELD3C4UnFVIAF/Vk\ndrCdWWs6OXJgroPi6jEeZOFd5IDV09ojtwwxiDqUP9ccvmagvlKj5gxhXYTX\nfmCV3kkf6toJfl4bqaizMNyl31pgwlUPJJ+FgURnoYUWSNNr+o8CO85/+o5o\n5M6ZIOqkHoArB/Pox1X0EPzsK7EovvW7xp9ZK7aCfDqUmcfWlyF4fw4fgY/q\n9d80wi1soIlV7ASLZphC9t5aEoVQ88tAV4Pf/vYkbHmYhu5HOHIPJW2SnJQm\nHmpoPjgnWoCEHtax7lnk5pdc4kdOJIbzmaP7k3MGCAte7iTwYPOtV8vFtEd4\nJKRBQXbLp0wZD2/rereuOkGZZGRPHXRZsRUCWXMg6R4Q86PDUHDOoU5Y4BJJ\n6/yYTILilZr6Ww3IAH0tUJCvbaO9h91SPcLCCvknbbFPEzTjwxYAnCt8DzEe\nGqZBXa0ccau0qrMzhW6KNZ0PWqiAHYXkNFdyPpEuYRogoRdbLxwatSlhYM+M\nSCDLvJrrv9ghjZMhdHEvvYkBmJA3Dc4Dg1ME5si1k1bbwjRQBNR/sni1WoTZ\nwB3PkUMA9TASiAElfQloB+iCR+LofBMN98MwKpFp5JSWeLh07BeqiPli1SFp\ngCS+\r\n=92Xg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGqOUEsGXuB4E887MWACuEcuPCaVJm7excCxF6rupBszAiEApEmw6443YV9xHQZu3xpgb1F4gHVoiML3H2HHtNTxZic="}]},"maintainers":[{"name":"fstanis","email":"filip@stanis.me"},{"name":"amp-toolbox","email":"amp-toolbox-eng@google.com"},{"name":"prateekbh","email":"prateek89born@gmail.com"},{"name":"choumx","email":"willchou@google.com"},{"name":"sepandparhami","email":"sparhami@google.com"},{"name":"ampproject-admin","email":"admin@ampproject.org"},{"name":"kristoferbaxter","email":"kbax@me.com"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"}],"_npmUser":{"name":"fstanis","email":"filip@stanis.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/viewer-messaging_1.1.0_1572442370121_0.748759300555538"},"_hasShrinkwrap":false},"1.1.2":{"name":"@ampproject/viewer-messaging","version":"1.1.2","description":"Messaging between an AMP Doc and a Viewer","author":{"name":"The AMP HTML Authors"},"license":"Apache-2.0","main":"messaging.js","types":"messaging.d.ts","keywords":["amp"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"extensions/amp-viewer-integration/0.1/messaging"},"homepage":"https://github.com/ampproject/amphtml/tree/master/extensions/amp-viewer-integration/0.1/messaging","bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"_id":"@ampproject/viewer-messaging@1.1.2","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"integrity":"sha512-oOlju4AQkgel/h4h8ZPRk0xIsE1xtFsn2IAvFOAB6GTa8IXLp+XNDzAUKKU/HpJbrbh/c+AUjYvcKds+c7C+uQ==","shasum":"d122ad205fe359766875b2a528b1fed86792518f","tarball":"https://registry.npmjs.org/@ampproject/viewer-messaging/-/viewer-messaging-1.1.2.tgz","fileCount":5,"unpackedSize":29454,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgExnYCRA9TVsSAnZWagAAzHoP/2wdekD57MX/OgSPewIp\nKI8wsDqof8nHTcMiN9dw/514xa08sKCA2Apz+WZsaZY82FOH0nOyRkd4Hc8W\nEeeQw6exvS8UisdwHC2dpuMChRjwgBG/BxIPvxGhEuyz0YpVgL0IfYXLAlCq\nX4gCRK3miWAEvm1uT0L8J+qbBXny74I1f7thZg3UCzw+ehFc8Q8CqISEdP0L\nMirp70VuFb19I11RtYHiX+PjolZ34ad6Px/dkE95HOJh0TIjq/wTiSWgf4jf\ndrXStPh4NyyC8rH5v+YIAdU3dB2uE3xn6YKpJb+DGj2F+2QZOLp1ORK3XbgB\ntSYRh6VoJ2FxU2pkCOjR/SGeMEB3z0bOo0XjGH6vncGm2td5hOeH+7Q5hsXR\njbgPAjfmgA0vUXgE1E6lOmbvooFG9b1j59Y3qP3VJpWT3xmazADTgbCOz0eg\n5Deh4gGPNzQR5q2AU2PaBJudfjTL0mP2uYk/tBd42T1axV1jc4dg+JyM1Okz\ned9y0PhamqqZMJYmKVeX/KoCk5aDKX0uxfNeFVriqGEozAumeLToPCh+txuD\nznIokBEGdixpYq5h/7dSdmRY9qO+8Y/DW+85CAdAyvFTmqymRO5Y6DGTA0WR\nC35vh6Lfz8zDfJESWId1te52VHcdNA3+fF/lmYuyD10vLRG8hSwHNZSfQBbD\nniPg\r\n=Ux1e\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCItf47luIW6BPqHMbkwmsjD4OdrGYKD6NeSAfwCnkVagIgVLVdD4cnTXLJAjjGXWUc11qapVBpLrvvhxOcs7JJv/E="}]},"_npmUser":{"name":"kristoferbaxter","email":"kbax@me.com"},"directories":{},"maintainers":[{"name":"ampproject-admin","email":"admin@ampproject.org"},{"name":"kristoferbaxter","email":"kbax@me.com"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"},{"name":"choumx","email":"willchou@google.com"},{"name":"amp-toolbox","email":"amp-toolbox-eng@google.com"},{"name":"fstanis","email":"filip@stanis.me"},{"name":"erwinmombay","email":"erwin.mombay@gmail.com"},{"name":"samouri","email":"jzfisgreat@gmail.com"},{"name":"caroqliu","email":"carolineliu@google.com"},{"name":"rsimha","email":"rsimha@amp.dev"},{"name":"dvoytenko","email":"dvoytenko@gmail.com"},{"name":"patrickkettner","email":"patrickkettner@gmail.com"},{"name":"alanorozco","email":"orozcoalan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/viewer-messaging_1.1.2_1611864535681_0.1648056068609436"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-30T13:32:49.629Z","1.1.0":"2019-10-30T13:32:50.956Z","modified":"2022-04-04T13:52:54.420Z","1.1.2":"2021-01-28T20:08:55.849Z"},"maintainers":[{"email":"esther@amp.dev","name":"esth"},{"email":"bot@amp.dev","name":"ampprojectbot"},{"email":"kdwan@google.com","name":"kdwan"},{"email":"admin@ampproject.org","name":"ampproject-admin"},{"email":"kbax@me.com","name":"kristoferbaxter"},{"email":"justin+npm@ridgewell.name","name":"jridgewell"},{"email":"willchou@google.com","name":"choumx"},{"email":"amp-toolbox-eng@google.com","name":"amp-toolbox"},{"email":"filip@stanis.me","name":"fstanis"},{"email":"erwin.mombay@gmail.com","name":"erwinmombay"},{"email":"jzfisgreat@gmail.com","name":"samouri"},{"email":"carolineliu@google.com","name":"caroqliu"},{"email":"rsimha@amp.dev","name":"rsimha"},{"email":"dvoytenko@gmail.com","name":"dvoytenko"},{"email":"patrickkettner@gmail.com","name":"patrickkettner"},{"email":"orozcoalan@gmail.com","name":"alanorozco"}],"description":"Messaging between an AMP Doc and a Viewer","homepage":"https://github.com/ampproject/amphtml/tree/master/extensions/amp-viewer-integration/0.1/messaging","keywords":["amp"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"extensions/amp-viewer-integration/0.1/messaging"},"author":{"name":"The AMP HTML Authors"},"bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"license":"Apache-2.0","readme":"# AMP Viewer Messaging\n\n[![npm version](https://badge.fury.io/js/%40ampproject%2Fviewer-messaging.svg)](https://badge.fury.io/js/%40ampproject%2Fviewer-messaging)\n\nThe AMP Viewer Messaging library allows an AMP Viewer to establish a\ncommunication channel with an AMP document.\n\nSee [Connecting AMP Viewers with AMP pages](https://github.com/ampproject/amphtml/blob/master/extensions/amp-viewer-integration/integrating-viewer-with-amp-doc-guide.md)\nfor more information.\n\n## Installation\n\nInstall via:\n\n```sh\nnpm i @ampproject/viewer-messaging\n```\n\n## Usage\n\nAssuming you have an AMP document hosted on `https://example.com/amp-document`:\n\n```js\nimport {Messaging} from '@ampproject/viewer-messaging';\n\nconst iframe = document.createElement('iframe');\niframe.setAttribute(\n  'src',\n  `https://example.com/amp-document#origin=${window.location.origin}`\n);\ndocument.body.appendChild(iframe);\n\nconst messaging = await Messaging.waitForHandshakeFromDocument(\n  /* source window */ window,\n  /* target window */ iframe.contentWindow,\n  /* target origin */ 'https://example.com'\n);\nmessaging.setDefaultHandler((name, data, rsvp) => {\n  console.log(`Received message: ${name}`);\n});\n// use messaging.sendRequest(...) to make requests to the AMP document\n```\n\nNote: The AMP document needs to include the `amp-viewer-integration` script:\n\n<!-- prettier-ignore-start -->\n```html\n<script async src=\"https://cdn.ampproject.org/v0/amp-viewer-integration-0.1.js\"></script>\n```\n<!-- prettier-ignore-end -->\n","readmeFilename":"README.md"}