{"id":16818590,"url":"https://github.com/taylorhakes/postmessage-plus","last_synced_at":"2025-04-11T02:42:59.726Z","repository":{"id":15965307,"uuid":"18707998","full_name":"taylorhakes/postmessage-plus","owner":"taylorhakes","description":"Simple postmessage library","archived":false,"fork":false,"pushed_at":"2014-06-03T19:43:47.000Z","size":240,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T00:38:01.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taylorhakes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-12T16:02:45.000Z","updated_at":"2020-04-09T12:38:17.000Z","dependencies_parsed_at":"2022-09-26T20:41:29.427Z","dependency_job_id":null,"html_url":"https://github.com/taylorhakes/postmessage-plus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorhakes%2Fpostmessage-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorhakes%2Fpostmessage-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorhakes%2Fpostmessage-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorhakes%2Fpostmessage-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taylorhakes","download_url":"https://codeload.github.com/taylorhakes/postmessage-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248068195,"owners_count":21042445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T10:50:37.078Z","updated_at":"2025-04-11T02:42:59.706Z","avatar_url":"https://github.com/taylorhakes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"postmessage-plus [![Build Status](https://travis-ci.org/taylorhakes/postmessage-plus.png?branch=master)](https://travis-ci.org/taylorhakes/postmessage-plus)\n================\n\nSimple postmessage library. Provides a common API for interacting the window.postMessage and security against listening to dangerous messages.\n\n\nGenerally, window communications take the form of a client/server interaction. The `client` window sends messages to the server. The `server` listens to one or more client's messages.\n\npostmessage-plus supports client-server as well as client-client interactions.\n\n## How to use\nHere is a standard setup\n\n#### Server\n```js\n// Create an instance\nvar pm = new PMPlus({\n  listenDomain: 'http://clientDomain.com' // string, array or regex\n});\n\n// Listen to a channel\npm.listen('myChannel', function(data, respond) {\n  //... do something async or sync\n  \n  respond(\n    true,  // true for success, false for error\n    'Got your message' // Response or Error\n  );\n});\n```\n\n#### Client\n```js\n// Create an instance\nvar pm = new PMPlus({\n  sendDomain: 'http://serverDomain.com' \n  // only string allowed, default that can be changed on individual messages\n});\n\n// Send a message\npm.send({\n  w: iframe.contentWindow // window reference\n  channel: 'myChannel',\n  data: 'Here you go',\n  callback: function(success, info) {\n    if(success) {\n      console.log('Sucess: ', info);\n    } else {\n      console.log('Error: ', info);\n    }\n  }\n});\n```\n\nA single window can be both a server and a client. To send and receive messages, use sendDomain and listenDomain.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylorhakes%2Fpostmessage-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaylorhakes%2Fpostmessage-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylorhakes%2Fpostmessage-plus/lists"}