UNPKG

@wepublish/api

Version:
37 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createOutgoingPeerRequestToken = void 0; const tslib_1 = require("tslib"); const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch")); const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag")); const graphql_1 = require("graphql"); const CreateIncomingPeerRequestMutation = (0, graphql_tag_1.default) ` mutation CreateIncomingPeerRequest($input: PeerRequestInput!) { createIncomingPeerRequest(input: $input) { token } } `; function createOutgoingPeerRequestToken(url, hostURL) { var _a, _b; return tslib_1.__awaiter(this, void 0, void 0, function* () { const response = yield (0, cross_fetch_1.default)(`${url}/admin`, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify({ query: (0, graphql_1.print)(CreateIncomingPeerRequestMutation), variables: { input: { hostURL } } }) }).then(r => r.json()); return (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.createIncomingPeerRequest) === null || _b === void 0 ? void 0 : _b.token; }); } exports.createOutgoingPeerRequestToken = createOutgoingPeerRequestToken; //# sourceMappingURL=peering.js.map