var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { extractUploadHeaders } from "../utils/headers.js"; import { http } from "../utils/http.js"; const socEndpoint = 'soc'; /** * Upload single owner chunk (SOC) to a Bee node * * @param ky Ky instance * @param owner Owner's ethereum address in hex * @param identifier Arbitrary identifier in hex * @param signature Signature in hex * @param data Content addressed chunk data to be uploaded * @param postageBatchId Postage BatchId that will be assigned to uploaded data * @param options Additional options like tag, encryption, pinning */ export function upload(ky, owner, identifier, signature, data, postageBatchId, options) { return __awaiter(this, void 0, void 0, function* () { const response = yield http(ky, { method: 'post', path: `${socEndpoint}/${owner}/${identifier}`, body: data, headers: Object.assign({ 'content-type': 'application/octet-stream' }, extractUploadHeaders(postageBatchId, options)), responseType: 'json', searchParams: { sig: signature } }); return response.data.reference; }); }