Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
15
Maintainers
3
Versions
89
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0-rc1 to 0.7.0-rc2

src/signing/chains/AlgorandSigner.d.ts

6

file/bundleData.js

@@ -31,6 +31,6 @@ "use strict";

async function bundleAndSignData(dataItems, signer, dir) {
const headerFile = await tmp_promise_1.file({ dir });
const headerFile = await (0, tmp_promise_1.file)({ dir });
const headerStream = fs.createWriteStream(headerFile.path);
const files = new Array(dataItems.length);
headerStream.write(utils_1.longTo32ByteArray(dataItems.length));
headerStream.write((0, utils_1.longTo32ByteArray)(dataItems.length));
for (const [index, item] of dataItems.entries()) {

@@ -43,3 +43,3 @@ let dataItem;

files[index] = dataItem.filename;
headerStream.write(Buffer.concat([utils_1.longTo32ByteArray(await dataItem.size()), dataItem.rawId]));
headerStream.write(Buffer.concat([(0, utils_1.longTo32ByteArray)(await dataItem.size()), dataItem.rawId]));
}

@@ -46,0 +46,0 @@ await new Promise((resolve) => headerStream.end(resolve));

@@ -41,3 +41,3 @@ "use strict";

var _a, _b, _c, _d, _e;
const filename = await tmp_promise_1.tmpName();
const filename = await (0, tmp_promise_1.tmpName)();
const stream = fs.createWriteStream(filename);

@@ -47,4 +47,4 @@ const _owner = signer.publicKey;

const _anchor = (opts === null || opts === void 0 ? void 0 : opts.anchor) ? Buffer.from(opts.anchor) : null;
const _tags = ((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? await parser_1.serializeTags(opts.tags) : null;
stream.write(utils_1.shortTo2ByteArray(signer.signatureType));
const _tags = ((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? await (0, parser_1.serializeTags)(opts.tags) : null;
stream.write((0, utils_1.shortTo2ByteArray)(signer.signatureType));
stream.write(new Uint8Array(signer.signatureLength).fill(0));

@@ -69,4 +69,4 @@ if (_owner.byteLength != signer.ownerLength) {

}
stream.write(utils_1.longTo8ByteArray((_d = (_c = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0));
const bytesCount = utils_1.longTo8ByteArray((_e = _tags === null || _tags === void 0 ? void 0 : _tags.byteLength) !== null && _e !== void 0 ? _e : 0);
stream.write((0, utils_1.longTo8ByteArray)((_d = (_c = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0));
const bytesCount = (0, utils_1.longTo8ByteArray)((_e = _tags === null || _tags === void 0 ? void 0 : _tags.byteLength) !== null && _e !== void 0 ? _e : 0);
stream.write(bytesCount);

@@ -78,3 +78,3 @@ if (_tags) {

"function") {
await promises_1.pipeline(data, stream);
await (0, promises_1.pipeline)(data, stream);
}

@@ -81,0 +81,0 @@ else {

@@ -56,13 +56,13 @@ "use strict";

let tagsStart = 512 + 512 + 2;
const targetPresent = await exports.read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);
const targetPresent = await (0, exports.read)(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = targetPresent ? 1057 : 1025;
const anchorPresent = await exports.read(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then((value) => value.buffer[0] == 1);
const anchorPresent = await (0, exports.read)(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then((value) => value.buffer[0] == 1);
tagsStart += anchorPresent ? 32 : 0;
const numberOfTags = utils_1.byteArrayToLong(await exports.read(fd, Buffer.alloc(8), tagsStart, 8, 0).then((value) => value.buffer));
const numberOfTags = (0, utils_1.byteArrayToLong)(await (0, exports.read)(fd, Buffer.alloc(8), tagsStart, 8, 0).then((value) => value.buffer));
let tags = [];
if (numberOfTags > 0) {
const numberOfTagBytesArray = await exports.read(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await exports.read(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then((value) => value.buffer);
const numberOfTagBytesArray = await (0, exports.read)(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then((value) => value.buffer);
const numberOfTagBytes = (0, utils_1.byteArrayToLong)(numberOfTagBytesArray);
const tagBytes = await (0, exports.read)(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then((value) => value.buffer);
tags = parser_1.tagsParser.fromBuffer(tagBytes);

@@ -89,5 +89,5 @@ }

const fd = await fileToFd(file);
const headerBuffer = await exports.read(fd.fd, Buffer.allocUnsafe(32), 0, 32, 0).then((v) => v.buffer);
const headerBuffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(32), 0, 32, 0).then((v) => v.buffer);
await fd.close();
return utils_1.byteArrayToLong(headerBuffer);
return (0, utils_1.byteArrayToLong)(headerBuffer);
}

@@ -97,5 +97,5 @@ exports.numberOfItems = numberOfItems;

const fd = await fileToFd(file);
const headerBuffer = await exports.read(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
const headerBuffer = await (0, exports.read)(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
return {
offset: utils_1.byteArrayToLong(headerBuffer.subarray(0, 32)),
offset: (0, utils_1.byteArrayToLong)(headerBuffer.subarray(0, 32)),
id: base64url_1.default.encode(headerBuffer.subarray(32, 64)),

@@ -116,3 +116,3 @@ };

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
const buffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -126,3 +126,3 @@ return buffer;

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
const buffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -136,3 +136,3 @@ return buffer;

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(512), offset + 512, 512, null).then((r) => r.buffer);
const buffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(512), offset + 512, 512, null).then((r) => r.buffer);
await fd.close();

@@ -147,7 +147,7 @@ return base64url_1.default.encode(buffer);

const targetStart = offset + 1024;
const targetPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), targetStart, 1, null).then((value) => value.buffer[0] == 1);
const targetPresent = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(1), targetStart, 1, null).then((value) => value.buffer[0] == 1);
if (!targetPresent) {
return undefined;
}
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(32), targetStart + 1, 32, null).then((r) => r.buffer);
const buffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(32), targetStart + 1, 32, null).then((r) => r.buffer);
await fd.close();

@@ -161,3 +161,3 @@ return base64url_1.default.encode(buffer);

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const targetPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), 1024, 1, null).then((value) => value.buffer[0] == 1);
const targetPresent = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(1), 1024, 1, null).then((value) => value.buffer[0] == 1);
let anchorStart = offset + 1025;

@@ -167,7 +167,7 @@ if (targetPresent) {

}
const anchorPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), anchorStart, 1, null).then((value) => value.buffer[0] == 1);
const anchorPresent = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(1), anchorStart, 1, null).then((value) => value.buffer[0] == 1);
if (!anchorPresent) {
return undefined;
}
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(32), anchorStart + 1, 32, null).then((r) => r.buffer);
const buffer = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(32), anchorStart + 1, 32, null).then((r) => r.buffer);
await fd.close();

@@ -182,14 +182,14 @@ return base64url_1.default.encode(buffer);

let tagsStart = 512 + 512 + 2 + ((_b = options === null || options === void 0 ? void 0 : options.offset) !== null && _b !== void 0 ? _b : 0);
const targetPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), 0, 1, offset + 1024).then((value) => value.buffer[0] == 1);
const targetPresent = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(1), 0, 1, offset + 1024).then((value) => value.buffer[0] == 1);
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = offset + (targetPresent ? 1057 : 1025);
const anchorPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), 0, 1, anchorPresentByte).then((value) => value.buffer[0] == 1);
const anchorPresent = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(1), 0, 1, anchorPresentByte).then((value) => value.buffer[0] == 1);
tagsStart += anchorPresent ? 32 : 0;
const numberOfTags = utils_1.byteArrayToLong(await exports.read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((value) => value.buffer));
const numberOfTags = (0, utils_1.byteArrayToLong)(await (0, exports.read)(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((value) => value.buffer));
if (numberOfTags == 0) {
return [];
}
const numberOfTagBytesArray = await exports.read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await exports.read(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then((value) => value.buffer);
const numberOfTagBytesArray = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((value) => value.buffer);
const numberOfTagBytes = (0, utils_1.byteArrayToLong)(numberOfTagBytesArray);
const tagBytes = await (0, exports.read)(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then((value) => value.buffer);
await fd.close();

@@ -196,0 +196,0 @@ return parser_1.tagsParser.fromBuffer(tagBytes);

@@ -49,5 +49,5 @@ "use strict";

const handle = await fs.promises.open(this.headerFile, "r");
const lengthBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, 0).then((r) => r.buffer);
const lengthBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(32), 0, 32, 0).then((r) => r.buffer);
await handle.close();
return utils_1.byteArrayToLong(lengthBuffer);
return (0, utils_1.byteArrayToLong)(lengthBuffer);
}

@@ -95,3 +95,3 @@ get items() {

const stream = multistream_1.default.obj(streams);
const tx = await promises_1.pipeline(stream, arweave_stream_tx_1.createTransactionAsync(attributes, arweave, jwk));
const tx = await (0, promises_1.pipeline)(stream, (0, arweave_stream_tx_1.createTransactionAsync)(attributes, arweave, jwk));
tx.addTag("Bundle-Format", "binary");

@@ -114,3 +114,3 @@ tx.addTag("Bundle-Version", "2.0.0");

const stream2 = multistream_1.default.obj(streams2);
await promises_1.pipeline(stream2, arweave_stream_tx_1.uploadTransactionAsync(tx, arweave, true));
await (0, promises_1.pipeline)(stream2, (0, arweave_stream_tx_1.uploadTransactionAsync)(tx, arweave, true));
return tx;

@@ -122,4 +122,4 @@ }

yield {
offset: utils_1.byteArrayToLong(await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then((r) => r.buffer)),
id: await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then((r) => base64url_1.default.encode(r.buffer)),
offset: (0, utils_1.byteArrayToLong)(await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then((r) => r.buffer)),
id: await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then((r) => base64url_1.default.encode(r.buffer)),
};

@@ -126,0 +126,0 @@ }

@@ -75,4 +75,4 @@ "use strict";

const tagsStart = await item.getTagsStart();
const numberOfTags = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => utils_1.byteArrayToLong(r.buffer));
const numberOfTagsBytes = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => utils_1.byteArrayToLong(r.buffer));
const numberOfTags = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => (0, utils_1.byteArrayToLong)(r.buffer));
const numberOfTagsBytes = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => (0, utils_1.byteArrayToLong)(r.buffer));
if (numberOfTagsBytes > 2048) {

@@ -82,3 +82,3 @@ await handle.close();

}
const tagsBytes = await file_1.read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
const tagsBytes = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
if (numberOfTags > 0) {

@@ -95,6 +95,6 @@ try {

const owner = await item.rawOwner();
const signatureData = await src_1.deepHash([
utils_2.stringToBuffer("dataitem"),
utils_2.stringToBuffer("1"),
utils_2.stringToBuffer(sigType.toString()),
const signatureData = await (0, src_1.deepHash)([
(0, utils_2.stringToBuffer)("dataitem"),
(0, utils_2.stringToBuffer)("1"),
(0, utils_2.stringToBuffer)(sigType.toString()),
owner,

@@ -127,5 +127,5 @@ await item.rawTarget(),

const handle = await fs.promises.open(this.filename, "r");
const buffer = await file_1.read(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0).then((r) => r.buffer);
const buffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0).then((r) => r.buffer);
await handle.close();
return utils_1.byteArrayToLong(buffer);
return (0, utils_1.byteArrayToLong)(buffer);
}

@@ -135,3 +135,3 @@ async rawSignature() {

const length = await this.signatureLength();
const buffer = await file_1.read(handle.fd, Buffer.alloc(length), 0, length, 2).then((r) => r.buffer);
const buffer = await (0, file_1.read)(handle.fd, Buffer.alloc(length), 0, length, 2).then((r) => r.buffer);
await handle.close();

@@ -146,3 +146,3 @@ return buffer;

const length = await this.ownerLength();
const buffer = await file_1.read(handle.fd, Buffer.allocUnsafe(length), 0, length, 2 + (await this.signatureLength())).then((r) => r.buffer);
const buffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(length), 0, length, 2 + (await this.signatureLength())).then((r) => r.buffer);
await handle.close();

@@ -157,6 +157,6 @@ return buffer;

const targetStart = await this.getTargetStart();
const targetPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresentBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;
if (targetPresent) {
const targetBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, targetStart + 1).then((r) => r.buffer);
const targetBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(32), 0, 32, targetStart + 1).then((r) => r.buffer);
await handle.close();

@@ -178,3 +178,3 @@ return targetBuffer;

const handle = await fs.promises.open(this.filename, "r");
const anchorBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1).then((r) => r.buffer);
const anchorBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1).then((r) => r.buffer);
await handle.close();

@@ -191,4 +191,4 @@ return anchorBuffer;

const tagsStart = await this.getTagsStart();
const numberOfTagsBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => r.buffer);
const numberOfTags = utils_1.byteArrayToLong(numberOfTagsBuffer);
const numberOfTagsBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => r.buffer);
const numberOfTags = (0, utils_1.byteArrayToLong)(numberOfTagsBuffer);
if (numberOfTags === 0) {

@@ -198,4 +198,4 @@ await handle.close();

}
const numberOfTagsBytesBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);
const numberOfTagsBytesBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = (0, utils_1.byteArrayToLong)(numberOfTagsBytesBuffer);
if (numberOfTagsBytes > 2048) {

@@ -205,3 +205,3 @@ await handle.close();

}
const tagsBytes = await file_1.read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
const tagsBytes = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
await handle.close();

@@ -224,3 +224,3 @@ return tagsBytes;

const handle = await fs.promises.open(this.filename, "r");
const dataBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(dataSize), 0, dataSize, dataStart).then((r) => r.buffer);
const dataBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(dataSize), 0, dataSize, dataStart).then((r) => r.buffer);
await handle.close();

@@ -234,6 +234,6 @@ return dataBuffer;

const dataStart = await this.dataStart();
const signatureData = await src_1.deepHash([
utils_2.stringToBuffer("dataitem"),
utils_2.stringToBuffer("1"),
utils_2.stringToBuffer((await this.signatureType()).toString()),
const signatureData = await (0, src_1.deepHash)([
(0, utils_2.stringToBuffer)("dataitem"),
(0, utils_2.stringToBuffer)("1"),
(0, utils_2.stringToBuffer)((await this.signatureType()).toString()),
await this.rawOwner(),

@@ -248,3 +248,3 @@ await this.rawTarget(),

const handle = await fs.promises.open(this.filename, "r+");
await file_1.write(handle.fd, signatureBytes, 0, await this.signatureLength(), 2);
await (0, file_1.write)(handle.fd, signatureBytes, 0, await this.signatureLength(), 2);
this.rawId = Buffer.from(idBytes);

@@ -282,4 +282,4 @@ await handle.close();

const tagsStart = await this.getTagsStart();
const numberOfTagsBytesBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);
const numberOfTagsBytesBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = (0, utils_1.byteArrayToLong)(numberOfTagsBytesBuffer);
await handle.close();

@@ -291,6 +291,6 @@ return tagsStart + 16 + numberOfTagsBytes;

const handle = await fs.promises.open(this.filename, "r");
const targetPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresentBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;
const anchorStart = targetStart + (targetPresent ? 33 : 1);
const anchorPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresentBuffer = await (0, file_1.read)(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresent = anchorPresentBuffer[0] === 1;

@@ -297,0 +297,0 @@ await handle.close();

{
"name": "arbundles",
"version": "0.7.0-rc1",
"version": "0.7.0-rc2",
"description": "Arweave bundling library",

@@ -34,3 +34,4 @@ "author": "Josh Benaron <joshbenaron@gmail.com>",

"scripts": {
"build": "tsc -p tsconfig.json && tsc -p esm.tsconfig.json && webpack",
"dev:build": "tsc -p tsconfig.json && tsc -p esm.tsconfig.json ",
"build": "yarn run dev:build && webpack",
"lint": "eslint ./src -c ./.eslintrc.json --ext .ts,.tsx",

@@ -87,2 +88,3 @@ "test": "jest --coverage",

"dependencies": {
"@metamask/eth-sig-util": "^4.0.0",
"@noble/ed25519": "^1.6.0",

@@ -89,0 +91,0 @@ "arweave": "^1.10.18",

@@ -30,5 +30,5 @@ "use strict";

return web.default([
utils_1.stringToBuffer("dataitem"),
utils_1.stringToBuffer("1"),
utils_1.stringToBuffer(item.signatureType.toString()),
(0, utils_1.stringToBuffer)("dataitem"),
(0, utils_1.stringToBuffer)("1"),
(0, utils_1.stringToBuffer)(item.signatureType.toString()),
item.rawOwner,

@@ -42,6 +42,6 @@ item.rawTarget,

else {
return deepHash_1.deepHash([
utils_1.stringToBuffer("dataitem"),
utils_1.stringToBuffer("1"),
utils_1.stringToBuffer(item.signatureType.toString()),
return (0, deepHash_1.deepHash)([
(0, utils_1.stringToBuffer)("dataitem"),
(0, utils_1.stringToBuffer)("1"),
(0, utils_1.stringToBuffer)(item.signatureType.toString()),
item.rawOwner,

@@ -48,0 +48,0 @@ item.rawTarget,

@@ -43,3 +43,3 @@ "use strict";

// Set offset
header.set(utils_1.longTo32ByteArray(d.getRaw().byteLength), 0);
header.set((0, utils_1.longTo32ByteArray)(d.getRaw().byteLength), 0);
// Set id

@@ -55,3 +55,3 @@ header.set(id, 32);

const buffer = Buffer.concat([
utils_1.longTo32ByteArray(dataItems.length),
(0, utils_1.longTo32ByteArray)(dataItems.length),
headers,

@@ -71,3 +71,3 @@ binaries,

async function getSignatureAndId(item, signer) {
const signatureData = await arDataBase_1.getSignatureData(item);
const signatureData = await (0, arDataBase_1.getSignatureData)(item);
const signatureBytes = await signer.sign(signatureData);

@@ -74,0 +74,0 @@ const idBytes = await arweave_1.default.crypto.hash(signatureBytes);

@@ -25,3 +25,3 @@ "use strict";

const anchorLength = 1 + ((_b = _anchor === null || _anchor === void 0 ? void 0 : _anchor.byteLength) !== null && _b !== void 0 ? _b : 0);
const _tags = ((_d = (_c = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ? parser_1.serializeTags(opts.tags) : null;
const _tags = ((_d = (_c = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ? (0, parser_1.serializeTags)(opts.tags) : null;
const tagsLength = 16 + (_tags ? _tags.byteLength : 0);

@@ -38,3 +38,3 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

const bytes = Buffer.alloc(length);
bytes.set(utils_1.shortTo2ByteArray(signer.signatureType), 0);
bytes.set((0, utils_1.shortTo2ByteArray)(signer.signatureType), 0);
bytes.set(new Uint8Array(signer.signatureLength).fill(0), 2);

@@ -63,4 +63,4 @@ if (_owner.byteLength != signer.ownerLength) {

}
bytes.set(utils_1.longTo8ByteArray((_f = (_e = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0), tagsStart);
const bytesCount = utils_1.longTo8ByteArray((_g = _tags === null || _tags === void 0 ? void 0 : _tags.byteLength) !== null && _g !== void 0 ? _g : 0);
bytes.set((0, utils_1.longTo8ByteArray)((_f = (_e = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0), tagsStart);
const bytesCount = (0, utils_1.longTo8ByteArray)((_g = _tags === null || _tags === void 0 ? void 0 : _tags.byteLength) !== null && _g !== void 0 ? _g : 0);
bytes.set(bytesCount, tagsStart + 8);

@@ -67,0 +67,0 @@ if (_tags) {

@@ -38,3 +38,3 @@ "use strict";

for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
ids.push(utils_1.byteArrayToLong(this.binary.subarray(i, i + 32)));
ids.push((0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32)));
}

@@ -66,3 +66,3 @@ return ids;

const valid = await item.isValid();
const expected = base64url_1.default(crypto_1.createHash("sha256").update(item.rawSignature).digest());
const expected = (0, base64url_1.default)((0, crypto_1.createHash)("sha256").update(item.rawSignature).digest());
if (!(valid && item.id === expected)) {

@@ -77,6 +77,6 @@ return false;

for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
const _offset = utils_1.byteArrayToLong(this.binary.subarray(i, i + 32));
const _offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
offset += _offset;
const _id = this.binary.subarray(i + 32, i + 64);
if (utils_1.arraybufferEqual(_id, id)) {
if ((0, utils_1.arraybufferEqual)(_id, id)) {
return { startOffset: offset, size: _offset };

@@ -96,3 +96,3 @@ }

const headerStart = 32 + 64 * index;
const dataItemSize = utils_1.byteArrayToLong(this.binary.subarray(headerStart, headerStart + 32));
const dataItemSize = (0, utils_1.byteArrayToLong)(this.binary.subarray(headerStart, headerStart + 32));
let counter = 0;

@@ -103,3 +103,3 @@ for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {

}
const _offset = utils_1.byteArrayToLong(this.binary.subarray(i, i + 32));
const _offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
offset += _offset;

@@ -126,3 +126,3 @@ counter++;

getDataItemCount() {
return utils_1.byteArrayToLong(this.binary.subarray(0, 32));
return (0, utils_1.byteArrayToLong)(this.binary.subarray(0, 32));
}

@@ -138,3 +138,3 @@ getBundleStart() {

for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
const _offset = utils_1.byteArrayToLong(this.binary.subarray(i, i + 32));
const _offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
const _id = this.binary.subarray(i + 32, i + 64);

@@ -141,0 +141,0 @@ const dataItemStart = bundleStart + offset;

@@ -45,3 +45,3 @@ "use strict";

get signatureType() {
const signatureTypeVal = utils_1.byteArrayToLong(this.binary.subarray(0, 2));
const signatureTypeVal = (0, utils_1.byteArrayToLong)(this.binary.subarray(0, 2));
switch (signatureTypeVal) {

@@ -120,3 +120,3 @@ case 1: {

const tagsStart = this.getTagsStart();
const tagsSize = utils_1.byteArrayToLong(this.binary.subarray(tagsStart + 8, tagsStart + 16));
const tagsSize = (0, utils_1.byteArrayToLong)(this.binary.subarray(tagsStart + 8, tagsStart + 16));
return this.binary.subarray(tagsStart + 16, tagsStart + 16 + tagsSize);

@@ -126,7 +126,7 @@ }

const tagsStart = this.getTagsStart();
const tagsCount = utils_1.byteArrayToLong(this.binary.subarray(tagsStart, tagsStart + 8));
const tagsCount = (0, utils_1.byteArrayToLong)(this.binary.subarray(tagsStart, tagsStart + 8));
if (tagsCount == 0) {
return [];
}
const tagsSize = utils_1.byteArrayToLong(this.binary.subarray(tagsStart + 8, tagsStart + 16));
const tagsSize = (0, utils_1.byteArrayToLong)(this.binary.subarray(tagsStart + 8, tagsStart + 16));
return parser_1.tagsParser.fromBuffer(buffer_1.Buffer.from(this.binary.subarray(tagsStart + 16, tagsStart + 16 + tagsSize)));

@@ -144,3 +144,3 @@ }

const numberOfTagBytesArray = this.binary.subarray(tagsStart + 8, tagsStart + 16);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const numberOfTagBytes = (0, utils_1.byteArrayToLong)(numberOfTagBytesArray);
return tagsStart + 16 + numberOfTagBytes;

@@ -151,3 +151,3 @@ }

const numberOfTagBytesArray = this.binary.subarray(tagsStart + 8, tagsStart + 16);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const numberOfTagBytes = (0, utils_1.byteArrayToLong)(numberOfTagBytesArray);
const dataStart = tagsStart + 16 + numberOfTagBytes;

@@ -167,3 +167,3 @@ return this.binary.subarray(dataStart, this.binary.length);

async sign(signer) {
this._id = await arDataBundle_1.sign(this, signer);
this._id = await (0, arDataBundle_1.sign)(this, signer);
return this.rawId;

@@ -222,5 +222,5 @@ }

const tagsStart = item.getTagsStart();
const numberOfTags = utils_1.byteArrayToLong(buffer.subarray(tagsStart, tagsStart + 8));
const numberOfTags = (0, utils_1.byteArrayToLong)(buffer.subarray(tagsStart, tagsStart + 8));
const numberOfTagBytesArray = buffer.subarray(tagsStart + 8, tagsStart + 16);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const numberOfTagBytes = (0, utils_1.byteArrayToLong)(numberOfTagBytesArray);
if (numberOfTagBytes > 2048)

@@ -241,7 +241,7 @@ return false;

const Signer = index_1.indexToType[sigType];
const signatureData = await arDataBase_1.getSignatureData(item);
const signatureData = await (0, arDataBase_1.getSignatureData)(item);
return await Signer.verify(item.rawOwner, signatureData, item.rawSignature);
}
async getSignatureData() {
return arDataBase_1.getSignatureData(this);
return (0, arDataBase_1.getSignatureData)(this);
}

@@ -248,0 +248,0 @@ /**

@@ -15,3 +15,3 @@ "use strict";

const _data = data;
const context = crypto_1.createHash("sha384");
const context = (0, crypto_1.createHash)("sha384");
let length = 0;

@@ -64,3 +64,3 @@ for await (const chunk of _data) {

async function hashStream(stream) {
const context = crypto_1.createHash("sha384");
const context = (0, crypto_1.createHash)("sha384");
for await (const chunk of stream) {

@@ -67,0 +67,0 @@ context.update(chunk);

@@ -12,3 +12,3 @@ "use strict";

constructor(jwk) {
super(pem_1.jwkTopem(jwk), jwk.n);
super((0, pem_1.jwkTopem)(jwk), jwk.n);
this.jwk = jwk;

@@ -15,0 +15,0 @@ }

@@ -21,3 +21,3 @@ "use strict";

sign(message) {
return Buffer.from(eth_sig_util_1.personalSign({
return Buffer.from((0, eth_sig_util_1.personalSign)({
privateKey: Buffer.from(this._key, "hex"),

@@ -34,3 +34,3 @@ data: message,

// return utils.verifyMessage(message, signature) === address;
const address = "0x" + keccak256_1.default(pk.slice(1)).slice(-20).toString("hex");
const address = "0x" + (0, keccak256_1.default)(pk.slice(1)).slice(-20).toString("hex");
let _message = Buffer.from(message).toString("hex");

@@ -44,3 +44,3 @@ if (_message.slice(0, 2) != "0x") {

}
return (eth_sig_util_1.recoverPersonalSignature({
return ((0, eth_sig_util_1.recoverPersonalSignature)({
data: _message,

@@ -47,0 +47,0 @@ signature: _signature,

@@ -12,3 +12,3 @@ "use strict";

value = toBuffer(value);
return keccak_1.default("keccak256")
return (0, keccak_1.default)("keccak256")
.update(value)

@@ -15,0 +15,0 @@ .digest();

@@ -18,3 +18,3 @@ "use strict";

if (!pk) {
this.pk = crypto_1.createPublicKey({
this.pk = (0, crypto_1.createPublicKey)({
key: _key,

@@ -35,3 +35,3 @@ type: "pkcs1",

sign(message) {
return crypto_1.createSign("sha256").update(message).sign({
return (0, crypto_1.createSign)("sha256").update(message).sign({
key: this._key,

@@ -38,0 +38,0 @@ padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING,

@@ -30,3 +30,3 @@ "use strict";

try {
verified = secp256k1_1.default.ecdsaVerify(signature, keccak256_1.default(Buffer.from(message)), p);
verified = secp256k1_1.default.ecdsaVerify(signature, (0, keccak256_1.default)(Buffer.from(message)), p);
// eslint-disable-next-line no-empty

@@ -38,3 +38,3 @@ }

sign(message) {
return secp256k1_1.default.ecdsaSign(keccak256_1.default(Buffer.from(message)), Buffer.from(this.key)).signature;
return secp256k1_1.default.ecdsaSign((0, keccak256_1.default)(Buffer.from(message)), Buffer.from(this.key)).signature;
}

@@ -41,0 +41,0 @@ }

@@ -39,3 +39,3 @@ "use strict";

bytes = await readBytes(reader, bytes, 32);
const itemCount = utils_1.byteArrayToLong(bytes.subarray(0, 32));
const itemCount = (0, utils_1.byteArrayToLong)(bytes.subarray(0, 32));
bytes = bytes.subarray(32);

@@ -47,4 +47,4 @@ const headersLength = 64 * itemCount;

headers[i / 64] = [
utils_1.byteArrayToLong(bytes.subarray(i, i + 32)),
base64url_1.default(Buffer.from(bytes.subarray(i + 32, i + 64))),
(0, utils_1.byteArrayToLong)(bytes.subarray(i, i + 32)),
(0, base64url_1.default)(Buffer.from(bytes.subarray(i + 32, i + 64))),
];

@@ -59,3 +59,3 @@ }

bytes = await readBytes(reader, bytes, 2);
const signatureType = utils_1.byteArrayToLong(bytes.subarray(0, 2));
const signatureType = (0, utils_1.byteArrayToLong)(bytes.subarray(0, 2));
bytes = bytes.subarray(2);

@@ -91,6 +91,6 @@ const { sigLength, pubLength, sigName } = constants_2.SIG_CONFIG[signatureType];

bytes = await readBytes(reader, bytes, 8);
const tagsLength = utils_1.byteArrayToLong(bytes.subarray(0, 8));
const tagsLength = (0, utils_1.byteArrayToLong)(bytes.subarray(0, 8));
bytes = bytes.subarray(8);
bytes = await readBytes(reader, bytes, 8);
const tagsBytesLength = utils_1.byteArrayToLong(bytes.subarray(0, 8));
const tagsBytesLength = (0, utils_1.byteArrayToLong)(bytes.subarray(0, 8));
bytes = bytes.subarray(8);

@@ -111,6 +111,6 @@ bytes = await readBytes(reader, bytes, tagsBytesLength);

// Verify signature
const signatureData = deepHash_1.deepHash([
utils_2.stringToBuffer("dataitem"),
utils_2.stringToBuffer("1"),
utils_2.stringToBuffer(signatureType.toString()),
const signatureData = (0, deepHash_1.deepHash)([
(0, utils_2.stringToBuffer)("dataitem"),
(0, utils_2.stringToBuffer)("1"),
(0, utils_2.stringToBuffer)(signatureType.toString()),
owner,

@@ -153,3 +153,3 @@ target,

// Check id
if (id !== base64url_1.default(crypto.createHash("sha256").update(signature).digest()))
if (id !== (0, base64url_1.default)(crypto.createHash("sha256").update(signature).digest()))
throw new Error("ID doesn't match signature");

@@ -162,6 +162,6 @@ const Signer = constants_1.indexToType[signatureType];

sigName,
signature: base64url_1.default(Buffer.from(signature)),
target: base64url_1.default(Buffer.from(target)),
anchor: base64url_1.default(Buffer.from(anchor)),
owner: base64url_1.default(Buffer.from(owner)),
signature: (0, base64url_1.default)(Buffer.from(signature)),
target: (0, base64url_1.default)(Buffer.from(target)),
anchor: (0, base64url_1.default)(Buffer.from(anchor)),
owner: (0, base64url_1.default)(Buffer.from(owner)),
tags,

@@ -168,0 +168,0 @@ dataOffset: offsetSum + dataOffset,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc