@ethersphere/bee-js
Version:
Javascript client for Bee
16 lines • 622 B
JavaScript
import { System } from 'cafe-utility';
import WebSocket from 'isomorphic-ws';
import { uploadSingleOwnerChunk } from "../chunk/soc.js";
const endpoint = 'gsoc';
export async function send(requestOptions, soc, stamp, options) {
return uploadSingleOwnerChunk(requestOptions, soc, stamp, options);
}
export function subscribe(url, reference, headers) {
const wsUrl = url.replace(/^http/i, 'ws');
if (System.whereAmI() === 'browser') {
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`);
}
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`, {
headers
});
}