@ethersphere/bee-js
Version:
Javascript client for Bee
26 lines (25 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.postEnvelope = void 0;
const cafe_utility_1 = require("cafe-utility");
const http_1 = require("../utils/http");
const ENVELOPE_ENDPOINT = 'envelope';
async function postEnvelope(requestOptions, postageBatchId, reference) {
const response = await (0, http_1.http)(requestOptions, {
method: 'post',
responseType: 'json',
url: `${ENVELOPE_ENDPOINT}/${reference}`,
headers: {
'swarm-postage-batch-id': postageBatchId.toHex(),
},
});
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
return {
issuer: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.issuer, { name: 'issuer', byteLength: 20 })),
index: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.index, { name: 'index', byteLength: 8 })),
timestamp: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.timestamp, { name: 'timestamp', byteLength: 8 })),
signature: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.signature, { name: 'signature', byteLength: 65 })),
batchId: postageBatchId,
};
}
exports.postEnvelope = postEnvelope;