mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
33ff98f789
- @tryghost/magic-link@0.1.0 - @tryghost/members-api@0.4.0 - @tryghost/members-auth-pages@1.1.1 - @tryghost/members-browser-auth@0.2.1 - @tryghost/members-gateway-api@0.1.5 - @tryghost/members-gateway-protocol@0.1.3 - @tryghost/members-ssr@0.3.0 - @tryghost/members-theme-bindings@0.2.4 |
||
---|---|---|
.. | ||
test | ||
.eslintrc.js | ||
index.js | ||
LICENSE | ||
package.json | ||
README.md |
Members Gateway Protocol
This package provides a low-level wrapper around the gateway iframe, which is used to communicate with the members api.
Install
npm install @tryghost/members-gateway-protocol --save
or
yarn add @tryghost/members-gateway-protocol
Usage
const gatewayProtocol = require('@tryghost/members-gateway-protocol');
const gatewayFrame = document.querySelector('iframe');
const { call, listen } = gatewayProtocol(gatewayFrame);
// Add listener for gateway events - limited to only once
// returns boolean indicating whether listener was added
listen(function ({event, payload}) {
// Called for every event emitted from the gateway
});
// Call method in gateway
call('getToken', {audience: 'whatever'}, function (err, result) {
// Called once when gateway responds
});
Develop
This is a mono repository, managed with lerna.
Follow the instructions for the top-level repo.
git clone
this repo &cd
into it as usual- Run
yarn
to install top-level dependencies.
Run
yarn dev
Test
yarn lint
run just eslintyarn test
run lint and tests
Copyright & License
Copyright (c) 2019 Ghost Foundation - Released under the MIT license.