UNPKG

@ethersphere/bee-js

Version:
25 lines (24 loc) 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.subscribe = exports.send = void 0; const cafe_utility_1 = require("cafe-utility"); const isomorphic_ws_1 = __importDefault(require("isomorphic-ws")); const soc_1 = require("../chunk/soc"); const endpoint = 'gsoc'; async function send(requestOptions, soc, stamp, options) { return (0, soc_1.uploadSingleOwnerChunk)(requestOptions, soc, stamp, options); } exports.send = send; function subscribe(url, reference, headers) { const wsUrl = url.replace(/^http/i, 'ws'); if (cafe_utility_1.System.whereAmI() === 'browser') { return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`); } return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`, { headers, }); } exports.subscribe = subscribe;