Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arbundles - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

4

build/ar-data-base.d.ts

@@ -1,4 +0,4 @@

import DataItem from "./DataItem";
import DataItem from './DataItem';
export interface DataItemCreateOptions {
data: string | Uint8Array;
data?: never;
target?: string;

@@ -5,0 +5,0 @@ anchor?: string;

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

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

@@ -20,3 +20,3 @@ item.rawOwner,

item.rawTags,
item.rawData
item.rawData,
]);

@@ -26,4 +26,4 @@ }

return deepHash_1.default([
utils_1.stringToBuffer("dataitem"),
utils_1.stringToBuffer("1"),
utils_1.stringToBuffer('dataitem'),
utils_1.stringToBuffer('1'),
utils_1.stringToBuffer(item.signatureType.toString()),

@@ -34,3 +34,3 @@ item.rawOwner,

item.rawTags,
item.rawData
item.rawData,
]);

@@ -37,0 +37,0 @@ }

/// <reference types="node" />
import { DataItemCreateOptions } from './ar-data-base';
import DataItem from './DataItem';

@@ -8,3 +7,3 @@ import Bundle from './Bundle';

export declare function unbundleData(txData: Buffer): Bundle;
export declare function bundleAndSignData(dataItems: (DataItemCreateOptions | DataItem)[], signer: Signer): Promise<Bundle>;
export declare function bundleAndSignData(dataItems: DataItem[], signer: Signer): Promise<Bundle>;
export declare function getSignatureAndId(item: DataItem, signer: Signer): Promise<{

@@ -11,0 +10,0 @@ signature: Buffer;

@@ -6,5 +6,3 @@ "use strict";

const ar_data_base_1 = require("./ar-data-base");
const ar_data_create_1 = require("./ar-data-create");
const utils_1 = require("./utils");
const DataItem_1 = tslib_1.__importDefault(require("./DataItem"));
const arweave_1 = tslib_1.__importDefault(require("arweave"));

@@ -19,4 +17,3 @@ const Bundle_1 = tslib_1.__importDefault(require("./Bundle"));

const headers = new Uint8Array(64 * dataItems.length);
const binaries = await Promise.all(dataItems.map(async (di, index) => {
const d = DataItem_1.default.isDataItem(di) ? di : await ar_data_create_1.createData(di, signer);
const binaries = await Promise.all(dataItems.map(async (d, index) => {
const id = d.isSigned() ? d.rawId : await sign(d, signer);

@@ -29,6 +26,10 @@ const header = new Uint8Array(64);

return Array.from(raw);
})).then(a => {
})).then((a) => {
return a.flat();
});
const buffer = buffer_1.Buffer.from([...utils_1.longTo32ByteArray(dataItems.length), ...headers, ...binaries]);
const buffer = buffer_1.Buffer.from([
...utils_1.longTo32ByteArray(dataItems.length),
...headers,
...binaries,
]);
return new Bundle_1.default(buffer);

@@ -35,0 +36,0 @@ }

import { DataItemCreateOptions } from "./ar-data-base";
import DataItem from "./DataItem";
import { Signer } from './signing/Signer';
export declare function createData(opts: DataItemCreateOptions, signer: Signer): Promise<DataItem>;
import { Signer } from './signing';
export declare function createData(data: string | Uint8Array, signer: Signer, opts?: DataItemCreateOptions): DataItem;

@@ -12,14 +12,20 @@ "use strict";

const OWNER_LENGTH = 512;
async function createData(opts, signer) {
function createData(data, signer, opts) {
const _owner = signer.publicKey;
assert_1.default(_owner.byteLength == OWNER_LENGTH, new Error(`Public key isn't the correct length: ${_owner.byteLength}`));
const _target = opts.target ? base64url_1.default.toBuffer(opts.target) : null;
const _target = opts?.target ? base64url_1.default.toBuffer(opts.target) : null;
const target_length = 1 + (_target?.byteLength ?? 0);
const _anchor = opts.anchor ? Buffer.from(opts.anchor) : null;
const _anchor = opts?.anchor ? Buffer.from(opts.anchor) : null;
const anchor_length = 1 + (_anchor?.byteLength ?? 0);
const _tags = (opts.tags?.length ?? 0) > 0 ? await parser_1.serializeTags(opts.tags) : null;
const _tags = (opts?.tags?.length ?? 0) > 0 ? parser_1.serializeTags(opts.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);
const _data = typeof opts.data === "string" ? Buffer.from(opts.data) : Buffer.from(opts.data);
const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);
const data_length = _data.byteLength;
const length = 2 + 512 + _owner.byteLength + target_length + anchor_length + tags_length + data_length;
const length = 2 +
512 +
_owner.byteLength +
target_length +
anchor_length +
tags_length +
data_length;
const bytes = Buffer.allocUnsafe(length);

@@ -43,3 +49,3 @@ bytes.set(utils_1.shortTo2ByteArray(signer.signatureType), 0);

}
bytes.set(utils_1.longTo8ByteArray(opts.tags?.length ?? 0), tags_start);
bytes.set(utils_1.longTo8ByteArray(opts?.tags?.length ?? 0), tags_start);
const bytesCount = utils_1.longTo8ByteArray(_tags?.byteLength ?? 0);

@@ -46,0 +52,0 @@ bytes.set(bytesCount, tags_start + 8);

@@ -5,4 +5,4 @@ /// <reference types="node" />

import Arweave from "arweave";
import { BundleInterface } from './BundleInterface';
import { JWKInterface } from './interface-jwk';
import { BundleInterface } from "./BundleInterface";
import { JWKInterface } from "./interface-jwk";
export default class Bundle implements BundleInterface {

@@ -9,0 +9,0 @@ readonly binary: Buffer;

@@ -17,3 +17,5 @@ "use strict";

}
get length() { return this.getDataItemCount(); }
get length() {
return this.getDataItemCount();
}
get items() {

@@ -24,3 +26,3 @@ const items = new Array(this.length);

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

@@ -54,3 +56,3 @@ const _id = this.binary.subarray(i + 32, i + 64);

const ids = [];
for (let i = HEADER_START; i < (HEADER_START + (64 * this.length)); i += 64) {
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
ids.push(base64url_1.default.encode(this.binary.subarray(i + 32, i + 64)));

@@ -64,3 +66,3 @@ }

}
const start = 64 + (64 * index);
const start = 64 + 64 * index;
return base64url_1.default.encode(this.binary.subarray(start, start + 32));

@@ -70,3 +72,3 @@ }

const tx = await arweave.createTransaction({
data: this.binary
data: this.binary,
}, jwk);

@@ -82,4 +84,4 @@ tx.addTag("Bundle-Format", "binary");

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

@@ -96,3 +98,3 @@ const item = new DataItem_1.default(binary.subarray(offset, offset + _offset));

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

@@ -109,6 +111,6 @@ offset += _offset;

let offset = 0;
const headerStart = 32 + (64 * index);
const headerStart = 32 + 64 * index;
const dataItemSize = utils_1.byteArrayToLong(this.binary.subarray(headerStart, headerStart + 32));
let counter = 0;
for (let i = HEADER_START; i < (HEADER_START + (64 * this.length)); i += 64) {
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
if (counter == index) {

@@ -140,3 +142,3 @@ break;

getBundleStart() {
return 32 + (64 * this.length);
return 32 + 64 * this.length;
}

@@ -143,0 +145,0 @@ }

/// <reference types="node" />
import { BundleItem } from './BundleItem';
import Arweave from 'arweave';
import Transaction from 'arweave/node/lib/transaction';
import { JWKInterface } from './interface-jwk';
import { BundleItem } from "./BundleItem";
import Arweave from "arweave";
import Transaction from "arweave/node/lib/transaction";
import { JWKInterface } from "./interface-jwk";
declare type ResolvesTo<T> = T | Promise<T> | ((...args: any[]) => Promise<T>);

@@ -7,0 +7,0 @@ export interface BundleInterface {

/// <reference types="node" />
import { Signer } from './signing/Signer';
import { Buffer } from 'buffer';
import { Signer } from "./signing/Signer";
import { Buffer } from "buffer";
declare type ResolvesTo<T> = T | Promise<T> | ((...args: any[]) => Promise<T>);

@@ -5,0 +5,0 @@ export declare abstract class BundleItem {

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

}
;
static isDataItem(obj) {

@@ -62,3 +61,5 @@ return obj.binary !== undefined;

const isPresent = this.binary[targetStart] == 1;
return isPresent ? this.binary.subarray(targetStart + 1, targetStart + 33) : buffer_1.Buffer.alloc(0);
return isPresent
? this.binary.subarray(targetStart + 1, targetStart + 33)
: buffer_1.Buffer.alloc(0);
}

@@ -71,3 +72,5 @@ get target() {

const isPresent = this.binary[anchorStart] == 1;
return isPresent ? this.binary.subarray(anchorStart + 1, anchorStart + 33) : buffer_1.Buffer.alloc(0);
return isPresent
? this.binary.subarray(anchorStart + 1, anchorStart + 33)
: buffer_1.Buffer.alloc(0);
}

@@ -93,3 +96,6 @@ get anchor() {

const _tags = this.tags;
return _tags.map(t => ({ name: base64url_1.default.encode(t.name), value: base64url_1.default.encode(t.value) }));
return _tags.map((t) => ({
name: base64url_1.default.encode(t.name),
value: base64url_1.default.encode(t.value),
}));
}

@@ -127,4 +133,7 @@ getStartOfData() {

target: this.target,
tags: this.tags.map(t => ({ name: base64url_1.default.encode(t.name), value: base64url_1.default.encode(t.value) })),
data: this.data
tags: this.tags.map((t) => ({
name: base64url_1.default.encode(t.name),
value: base64url_1.default.encode(t.value),
})),
data: this.data,
};

@@ -134,3 +143,3 @@ }

const headers = {
"Content-Type": "application/octet-stream"
"Content-Type": "application/octet-stream",
};

@@ -151,6 +160,6 @@ if (!this.isSigned())

let tagsStart = 2 + 512 + 512 + 2;
const targetPresent = (buffer[1026] == 1);
const targetPresent = buffer[1026] == 1;
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = (targetPresent ? 1059 : 1027);
const anchorPresent = (buffer[anchorPresentByte] == 1);
const anchorPresentByte = targetPresent ? 1059 : 1027;
const anchorPresent = buffer[anchorPresentByte] == 1;
tagsStart += anchorPresent ? 32 : 0;

@@ -178,6 +187,6 @@ const numberOfTags = utils_1.byteArrayToLong(buffer.subarray(tagsStart, tagsStart + 8));

let tagsStart = 2 + 512 + 512 + 2;
const targetPresent = (this.binary[1026] == 1);
const targetPresent = this.binary[1026] == 1;
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = (targetPresent ? 1059 : 1027);
const anchorPresent = (this.binary[anchorPresentByte] == 1);
const anchorPresentByte = targetPresent ? 1059 : 1027;
const anchorPresent = this.binary[anchorPresentByte] == 1;
tagsStart += anchorPresent ? 32 : 0;

@@ -191,4 +200,4 @@ return tagsStart;

let anchorStart = this.getTargetStart() + 1;
const targetPresent = (this.binary[this.getTargetStart()] == 1);
anchorStart += (targetPresent ? 32 : 0);
const targetPresent = this.binary[this.getTargetStart()] == 1;
anchorStart += targetPresent ? 32 : 0;
return anchorStart;

@@ -195,0 +204,0 @@ }

@@ -8,5 +8,6 @@ "use strict";

async function deepHash(data) {
if (typeof data[Symbol.asyncIterator] === 'function') {
if (typeof data[Symbol.asyncIterator] ===
"function") {
const _data = data;
const context = crypto.createHash('sha384');
const context = crypto.createHash("sha384");
let length = 0;

@@ -18,28 +19,28 @@ for await (const chunk of _data) {

const tag = arweave_1.default.utils.concatBuffers([
arweave_1.default.utils.stringToBuffer('blob'),
arweave_1.default.utils.stringToBuffer("blob"),
arweave_1.default.utils.stringToBuffer(length.toString()),
]);
const taggedHash = arweave_1.default.utils.concatBuffers([
await arweave_1.default.crypto.hash(tag, 'SHA-384'),
await arweave_1.default.crypto.hash(tag, "SHA-384"),
context.digest(),
]);
return await arweave_1.default.crypto.hash(taggedHash, 'SHA-384');
return await arweave_1.default.crypto.hash(taggedHash, "SHA-384");
}
else if (Array.isArray(data)) {
const tag = arweave_1.default.utils.concatBuffers([
arweave_1.default.utils.stringToBuffer('list'),
arweave_1.default.utils.stringToBuffer("list"),
arweave_1.default.utils.stringToBuffer(data.length.toString()),
]);
return await deepHashChunks(data, await arweave_1.default.crypto.hash(tag, 'SHA-384'));
return await deepHashChunks(data, await arweave_1.default.crypto.hash(tag, "SHA-384"));
}
const _data = data;
const tag = arweave_1.default.utils.concatBuffers([
arweave_1.default.utils.stringToBuffer('blob'),
arweave_1.default.utils.stringToBuffer("blob"),
arweave_1.default.utils.stringToBuffer(_data.byteLength.toString()),
]);
const taggedHash = arweave_1.default.utils.concatBuffers([
await arweave_1.default.crypto.hash(tag, 'SHA-384'),
await arweave_1.default.crypto.hash(_data, 'SHA-384'),
await arweave_1.default.crypto.hash(tag, "SHA-384"),
await arweave_1.default.crypto.hash(_data, "SHA-384"),
]);
return await arweave_1.default.crypto.hash(taggedHash, 'SHA-384');
return await arweave_1.default.crypto.hash(taggedHash, "SHA-384");
}

@@ -55,7 +56,7 @@ exports.default = deepHash;

]);
const newAcc = await arweave_1.default.crypto.hash(hashPair, 'SHA-384');
const newAcc = await arweave_1.default.crypto.hash(hashPair, "SHA-384");
return await deepHashChunks(chunks.slice(1), newAcc);
}
async function hashStream(stream) {
const context = crypto.createHash('sha384');
const context = crypto.createHash("sha384");
for await (const chunk of stream) {

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

import { createData } from "./ar-data-create";
import { bundleAndSignData, unbundleData } from "./ar-data-bundle";
import Bundle from "./Bundle";
import DataItem, { MIN_BINARY_SIZE } from './DataItem';
import deepHash from './deepHash';
import { DataItemCreateOptions } from './ar-data-base';
import { ArweaveSigner } from './signing';
export { MIN_BINARY_SIZE, Bundle, DataItem, createData, bundleAndSignData, unbundleData, deepHash, DataItemCreateOptions };
import DataItem, { MIN_BINARY_SIZE } from "./DataItem";
import deepHash from "./deepHash";
import { DataItemCreateOptions } from "./ar-data-base";
import { ArweaveSigner } from "./signing";
export { MIN_BINARY_SIZE, Bundle, DataItem, createData, bundleAndSignData, unbundleData, deepHash, DataItemCreateOptions, };
export { ArweaveSigner };

@@ -7,2 +7,2 @@ import * as avro from "avsc";

value: string;
}[]): Promise<Uint8Array>;
}[]): Uint8Array;

@@ -11,10 +11,10 @@ "use strict";

{ name: "name", type: "string" },
{ name: "value", type: "string" }
]
{ name: "value", type: "string" },
],
});
exports.tagsParser = avro.Type.forSchema({
type: "array",
items: exports.tagParser
items: exports.tagParser,
});
async function serializeTags(tags) {
function serializeTags(tags) {
if (tags.length == 0) {

@@ -21,0 +21,0 @@ return new Uint8Array(0);

/// <reference types="node" />
import Rsa4096Pss from '../../keys/Rsa4096Pss';
import { JWKInterface } from '../../../interface-jwk';
import Rsa4096Pss from "../../keys/Rsa4096Pss";
import { JWKInterface } from "../../../interface-jwk";
export default class ArweaveSigner extends Rsa4096Pss {

@@ -5,0 +5,0 @@ get publicKey(): Buffer;

@@ -1,2 +0,2 @@

import ArweaveSigner from './arweave/ArweaveSigner';
import ArweaveSigner from "./arweave/ArweaveSigner";
export default ArweaveSigner;
/// <reference types="node" />
import { Signer } from './Signer';
import { Signer } from "./Signer";
interface IndexToType {

@@ -4,0 +4,0 @@ [key: number]: {

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

exports.indexToType = {
1: Rsa4096Pss_1.default
1: Rsa4096Pss_1.default,
};
//# sourceMappingURL=constants.js.map

@@ -1,2 +0,2 @@

import ArweaveSigner from './chains';
import ArweaveSigner from "./chains";
export * from "./Signer";

@@ -3,0 +3,0 @@ export * from "./constants";

/// <reference types="node" />
import { Signer } from '../Signer';
import { Signer } from "../Signer";
export default class Rsa4096Pss implements Signer {

@@ -4,0 +4,0 @@ private _key;

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

if (!pk) {
this.pk = crypto.createPublicKey({
this.pk = crypto
.createPublicKey({
key: _key,
type: 'pkcs1',
format: "pem"
}).export({
format: 'pem',
type: 'pkcs1'
}).toString();
type: "pkcs1",
format: "pem",
})
.export({
format: "pem",
type: "pkcs1",
})
.toString();
}
}
sign(message) {
return crypto
.createSign("sha256")
.update(message)
.sign({
return crypto.createSign("sha256").update(message).sign({
key: this._key,
padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING
padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING,
});

@@ -37,0 +37,0 @@ }

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

function shortTo2ByteArray(long) {
if (long > (2 ^ 32 - 1))
if (long > (2 ^ (32 - 1)))
throw new Error("Short too long");

@@ -38,3 +38,36 @@ const byteArray = [0, 0];

function longTo32ByteArray(long) {
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const byteArray = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
];
for (let index = 0; index < byteArray.length; index++) {

@@ -51,3 +84,3 @@ const byte = long & 0xff;

for (let i = byteArray.length - 1; i >= 0; i--) {
value = (value * 256) + byteArray[i];
value = value * 256 + byteArray[i];
}

@@ -77,3 +110,3 @@ return value;

exports.arraybufferEqual = arraybufferEqual;
exports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
exports.isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
//# sourceMappingURL=utils.js.map

@@ -1,5 +0,5 @@

import { DataItemCreateOptions } from '../build/ar-data-base';
import { Signer } from '../build/signing';
import FileBundle from './FileBundle';
import FileDataItem from './FileDataItem';
import { DataItemCreateOptions } from "../build/ar-data-base";
import { Signer } from "../build/signing";
import FileBundle from "./FileBundle";
import FileDataItem from "./FileDataItem";
export declare function bundleAndSignData(dataItems: (DataItemCreateOptions | FileDataItem)[], signer: Signer, dir?: string): Promise<FileBundle>;

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

}
await new Promise(resolve => headerStream.end(resolve));
await new Promise((resolve) => headerStream.end(resolve));
headerStream.close();

@@ -34,0 +34,0 @@ return new FileBundle_1.default(headerFile.path, files);

/// <reference types="node" />
import FileDataItem from './FileDataItem';
import { DataItemCreateOptions } from '../build/ar-data-base';
import { PathLike } from 'fs';
import * as fs from 'fs';
import { Signer } from '../build/signing';
import FileDataItem from "./FileDataItem";
import { DataItemCreateOptions } from "../build/ar-data-base";
import { PathLike } from "fs";
import * as fs from "fs";
import { Signer } from "../build/signing";
interface CreateFileDataItemOptions {

@@ -8,0 +8,0 @@ path?: PathLike;

@@ -23,3 +23,5 @@ "use strict";

const _tags = (opts.tags?.length ?? 0) > 0 ? await parser_1.serializeTags(opts.tags) : null;
const _data = typeof opts.data === "string" ? buffer_1.Buffer.from(opts.data) : buffer_1.Buffer.from(opts.data);
const _data = typeof opts.data === "string"
? buffer_1.Buffer.from(opts.data)
: buffer_1.Buffer.from(opts.data);
stream.write(utils_1.shortTo2ByteArray(signer.signatureType));

@@ -45,3 +47,3 @@ stream.write(Uint8Array.from(EMPTY_ARRAY));

stream.write(_data);
await new Promise(resolve => {
await new Promise((resolve) => {
stream.end(resolve);

@@ -48,0 +50,0 @@ });

/// <reference types="node" />
import { FileHandle } from 'fs/promises';
import { FileHandle } from "fs/promises";
declare type File = string | FileHandle;

@@ -4,0 +4,0 @@ interface Transaction {

@@ -11,19 +11,17 @@ "use strict";

const read = util_1.promisify(fs.read);
const fileToFd = async (f) => typeof f === "string"
? await fs.promises.open(f, 'r')
: f;
const fileToFd = async (f) => typeof f === "string" ? await fs.promises.open(f, "r") : f;
async function fileToJson(filename) {
const fd = await fs.promises.open(filename, 'r').then(handle => handle.fd);
const fd = await fs.promises.open(filename, "r").then((handle) => handle.fd);
let tagsStart = 512 + 512 + 2;
const targetPresent = await read(fd, Buffer.alloc(1), 1024, 64, null).then(value => value.buffer[0] == 1);
const targetPresent = await 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 read(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then(value => value.buffer[0] == 1);
const anchorPresentByte = targetPresent ? 1057 : 1025;
const anchorPresent = await read(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then((value) => value.buffer[0] == 1);
tagsStart += anchorPresent ? 32 : 0;
const numberOfTags = utils_1.byteArrayToLong(await read(fd, Buffer.alloc(8), tagsStart, 8, 0).then(value => value.buffer));
const numberOfTags = utils_1.byteArrayToLong(await read(fd, Buffer.alloc(8), tagsStart, 8, 0).then((value) => value.buffer));
let tags = [];
if (numberOfTags > 0) {
const numberOfTagBytesArray = await read(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then(value => value.buffer);
const numberOfTagBytesArray = await read(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await read(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then(value => value.buffer);
const tagBytes = await read(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then((value) => value.buffer);
tags = parser_1.tagsParser.fromBuffer(tagBytes);

@@ -44,3 +42,3 @@ }

fee,
signature
signature,
};

@@ -51,3 +49,3 @@ }

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

@@ -59,6 +57,6 @@ return utils_1.byteArrayToLong(headerBuffer);

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

@@ -77,3 +75,3 @@ }

const offset = options.offset ?? 0;
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then(r => r.buffer);
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -86,3 +84,3 @@ return buffer;

const offset = options.offset ?? 0;
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then(r => r.buffer);
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -95,3 +93,3 @@ return buffer;

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

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

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

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

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

@@ -124,7 +122,7 @@ if (targetPresent) {

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

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

let tagsStart = 512 + 512 + 2 + (options?.offset ?? 0);
const targetPresent = await read(fd.fd, Buffer.allocUnsafe(1), 0, 1, offset + 1024).then(value => value.buffer[0] == 1);
const targetPresent = await 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 read(fd.fd, Buffer.allocUnsafe(1), 0, 1, anchorPresentByte).then(value => value.buffer[0] == 1);
const anchorPresent = await 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 read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then(value => value.buffer));
const numberOfTags = utils_1.byteArrayToLong(await read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((value) => value.buffer));
if (numberOfTags == 0) {
return [];
}
const numberOfTagBytesArray = await read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then(value => value.buffer);
const numberOfTagBytesArray = await read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await read(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then(value => value.buffer);
const tagBytes = await read(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then((value) => value.buffer);
await fd.close();

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

/// <reference types="node" />
import { BundleInterface } from '../build/BundleInterface';
import FileDataItem from './FileDataItem';
import { PathLike } from 'fs';
import Arweave from 'arweave';
import Transaction from 'arweave/node/lib/transaction';
import { JWKInterface } from '../build/interface-jwk';
import { BundleInterface } from "../build/BundleInterface";
import FileDataItem from "./FileDataItem";
import { PathLike } from "fs";
import Arweave from "arweave";
import Transaction from "arweave/node/lib/transaction";
import { JWKInterface } from "../build/interface-jwk";
export default class FileBundle implements BundleInterface {

@@ -9,0 +9,0 @@ readonly headerFile: PathLike;

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

static async fromDir(dir) {
const txs = await fs.promises.readdir(dir).then(r => r.filter(async (f) => !await fs.promises.stat(f).then(s => s.isDirectory())));
const txs = await fs.promises
.readdir(dir)
.then((r) => r.filter(async (f) => !(await fs.promises.stat(f).then((s) => s.isDirectory()))));
return new FileBundle(dir + "/header", txs);

@@ -27,4 +29,3 @@ }

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

@@ -38,3 +39,3 @@ return utils_1.byteArrayToLong(lengthBuffer);

if (typeof index === "number") {
if (index > await this.length()) {
if (index > (await this.length())) {
throw new RangeError("Index out of range");

@@ -60,3 +61,3 @@ }

fs.createReadStream(this.headerFile),
...this.txs.map(t => fs.createReadStream(t))
...this.txs.map((t) => fs.createReadStream(t)),
];

@@ -73,3 +74,3 @@ const stream = multistream_1.default.obj(streams);

fs.createReadStream(this.headerFile),
...this.txs.map(t => fs.createReadStream(t))
...this.txs.map((t) => fs.createReadStream(t)),
];

@@ -86,3 +87,3 @@ const stream = multistream_1.default.obj(streams);

fs.createReadStream(this.headerFile),
...this.txs.map(t => fs.createReadStream(t))
...this.txs.map((t) => fs.createReadStream(t)),
];

@@ -99,3 +100,3 @@ const stream = multistream_1.default.obj(streams);

fs.createReadStream(this.headerFile),
...this.txs.map(t => fs.createReadStream(t))
...this.txs.map((t) => fs.createReadStream(t)),
];

@@ -108,6 +109,6 @@ const stream2 = multistream_1.default.obj(streams2);

const handle = await fs.promises.open(this.headerFile, "r");
for (let i = 32; i < (32 + 64 * await this.length()); i += 64) {
for (let i = 32; i < 32 + 64 * (await this.length()); i += 64) {
yield {
offset: utils_1.byteArrayToLong(await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then(r => r.buffer)),
id: await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then(r => base64url_1.default.encode(r.buffer))
offset: utils_1.byteArrayToLong(await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then((r) => r.buffer)),
id: await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then((r) => base64url_1.default.encode(r.buffer)),
};

@@ -114,0 +115,0 @@ }

/// <reference types="node" />
import { PathLike } from 'fs';
import { BundleItem } from '../build/BundleItem';
import { Signer } from '../build/signing';
import { PathLike } from "fs";
import { BundleItem } from "../build/BundleItem";
import { Signer } from "../build/signing";
export default class FileDataItem implements BundleItem {

@@ -6,0 +6,0 @@ readonly filename: PathLike;

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

}
throw new Error('ID is not set');
throw new Error("ID is not set");
}

@@ -36,11 +36,9 @@ set rawId(id) {

static isDataItem(obj) {
return obj.filename && typeof obj.filename === 'string';
return obj.filename && typeof obj.filename === "string";
}
static async verify(filename) {
const handle = await fs.promises.open(filename, 'r');
const sigType = await read(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0)
.then(r => utils_1.byteArrayToLong(r.buffer));
const handle = await fs.promises.open(filename, "r");
const sigType = await read(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0).then((r) => utils_1.byteArrayToLong(r.buffer));
let anchorStart = 1027;
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026)
.then(r => r.buffer);
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;

@@ -50,4 +48,3 @@ if (targetPresent) {

}
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart)
.then(r => r.buffer);
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresent = anchorPresentBuffer[0] === 1;

@@ -59,8 +56,5 @@ let tagsStart = anchorStart;

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

@@ -76,11 +70,12 @@ try {

const Signer = signing_1.indexToType[sigType];
const owner = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 514)
.then(r => r.buffer);
const target = targetPresent ? await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, 1027)
.then(r => r.buffer) : Buffer.allocUnsafe(0);
const anchor = anchorPresent ? await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1)
.then(r => r.buffer) : Buffer.allocUnsafe(0);
const owner = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 514).then((r) => r.buffer);
const target = targetPresent
? await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, 1027).then((r) => r.buffer)
: Buffer.allocUnsafe(0);
const anchor = anchorPresent
? await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1).then((r) => r.buffer)
: Buffer.allocUnsafe(0);
const signatureData = await index_1.deepHash([
utils_2.stringToBuffer('dataitem'),
utils_2.stringToBuffer('1'),
utils_2.stringToBuffer("dataitem"),
utils_2.stringToBuffer("1"),
utils_2.stringToBuffer(sigType.toString()),

@@ -91,8 +86,9 @@ owner,

tagsBytes,
fs.createReadStream(filename, { start: tagsStart + 16 + numberOfTagsBytes }),
fs.createReadStream(filename, {
start: tagsStart + 16 + numberOfTagsBytes,
}),
]);
const signature = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 2)
.then(r => r.buffer);
const signature = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 2).then((r) => r.buffer);
await handle.close();
if (!await Signer.verify(owner, signatureData, signature))
if (!(await Signer.verify(owner, signatureData, signature)))
return false;

@@ -109,8 +105,7 @@ await handle.close();

async size() {
return await fs.promises.stat(this.filename).then(r => r.size);
return await fs.promises.stat(this.filename).then((r) => r.size);
}
async signatureType() {
const handle = await fs.promises.open(this.filename, 'r');
const buffer = await read(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const buffer = await read(handle.fd, Buffer.allocUnsafe(2), 0, 2, 0).then((r) => r.buffer);
await handle.close();

@@ -120,5 +115,4 @@ return utils_1.byteArrayToLong(buffer);

async rawSignature() {
const handle = await fs.promises.open(this.filename, 'r');
const buffer = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 2)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const buffer = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 2).then((r) => r.buffer);
await handle.close();

@@ -131,5 +125,4 @@ return buffer;

async rawOwner() {
const handle = await fs.promises.open(this.filename, 'r');
const buffer = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 514)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const buffer = await read(handle.fd, Buffer.allocUnsafe(512), 0, 512, 514).then((r) => r.buffer);
await handle.close();

@@ -142,9 +135,7 @@ return buffer;

async rawTarget() {
const handle = await fs.promises.open(this.filename, 'r');
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;
if (targetPresent) {
const targetBuffer = await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, 1027)
.then(r => r.buffer);
const targetBuffer = await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, 1027).then((r) => r.buffer);
await handle.close();

@@ -161,5 +152,4 @@ return targetBuffer;

let anchorStart = 1027;
const handle = await fs.promises.open(this.filename, 'r');
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;

@@ -169,8 +159,6 @@ if (targetPresent) {

}
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart)
.then(r => r.buffer);
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresent = anchorPresentBuffer[0] === 1;
if (anchorPresent) {
const anchorBuffer = await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1)
.then(r => r.buffer);
const anchorBuffer = await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1).then((r) => r.buffer);
await handle.close();

@@ -186,14 +174,11 @@ return anchorBuffer;

async rawTags() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const tagsStart = await this.tagsStart();
const numberOfTagsBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart)
.then(r => r.buffer);
const numberOfTagsBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => r.buffer);
const numberOfTags = utils_1.byteArrayToLong(numberOfTagsBuffer);
if (numberOfTags === 0)
return Buffer.allocUnsafe(0);
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8)
.then(r => r.buffer);
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);
const tagsBytes = await read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16)
.then(r => r.buffer);
const tagsBytes = await read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
await handle.close();

@@ -216,4 +201,3 @@ return tagsBytes;

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

@@ -229,5 +213,5 @@ return dataBuffer;

const signatureData = await index_1.deepHash([
utils_2.stringToBuffer('dataitem'),
utils_2.stringToBuffer('1'),
utils_2.stringToBuffer(await this.signatureType().then(n => n.toString())),
utils_2.stringToBuffer("dataitem"),
utils_2.stringToBuffer("1"),
utils_2.stringToBuffer(await this.signatureType().then((n) => n.toString())),
await this.rawOwner(),

@@ -241,3 +225,3 @@ await this.rawTarget(),

const idBytes = await arweave_1.default.crypto.hash(signatureBytes);
const handle = await fs.promises.open(this.filename, 'r+');
const handle = await fs.promises.open(this.filename, "r+");
await write(handle.fd, signatureBytes, 0, 512, 2);

@@ -250,5 +234,4 @@ this.rawId = Buffer.from(idBytes);

let anchorStart = 1027;
const handle = await fs.promises.open(this.filename, 'r');
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026)
.then(r => r.buffer);
const handle = await fs.promises.open(this.filename, "r");
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, 1026).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;

@@ -258,4 +241,3 @@ if (targetPresent) {

}
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart)
.then(r => r.buffer);
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresent = anchorPresentBuffer[0] === 1;

@@ -272,6 +254,5 @@ await handle.close();

async dataStart() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const tagsStart = await this.tagsStart();
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8)
.then(r => r.buffer);
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);

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

@@ -5,3 +5,3 @@ export * from "./file";

import FileBundle from "./FileBundle";
import FileDataItem from './FileDataItem';
import FileDataItem from "./FileDataItem";
export { FileBundle, FileDataItem };
/// <reference types="node" />
import Rsa4096Pss from '../../keys/Rsa4096Pss';
import { JWKInterface } from '../../../interface-jwk';
import Rsa4096Pss from "../../keys/Rsa4096Pss";
import { JWKInterface } from "../../../interface-jwk";
export default class ArweaveSigner extends Rsa4096Pss {

@@ -5,0 +5,0 @@ get publicKey(): Buffer;

@@ -1,2 +0,2 @@

import ArweaveSigner from './arweave/ArweaveSigner';
import ArweaveSigner from "./arweave/ArweaveSigner";
export default ArweaveSigner;
/// <reference types="node" />
import { Signer } from './Signer';
import { Signer } from "./Signer";
interface IndexToType {

@@ -4,0 +4,0 @@ [key: number]: {

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

exports.indexToType = {
1: Rsa4096Pss_1.default
1: Rsa4096Pss_1.default,
};
//# sourceMappingURL=constants.js.map

@@ -1,2 +0,2 @@

import ArweaveSigner from './chains';
import ArweaveSigner from "./chains";
export * from "./Signer";

@@ -3,0 +3,0 @@ export * from "./constants";

/// <reference types="node" />
import { Signer } from '../Signer';
import { Signer } from "../Signer";
export default class Rsa4096Pss implements Signer {

@@ -4,0 +4,0 @@ private _key;

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

if (!pk) {
this.pk = crypto.createPublicKey({
this.pk = crypto
.createPublicKey({
key: _key,
type: 'pkcs1',
format: "pem"
}).export({
format: 'pem',
type: 'pkcs1'
}).toString();
type: "pkcs1",
format: "pem",
})
.export({
format: "pem",
type: "pkcs1",
})
.toString();
}
}
sign(message) {
return crypto
.createSign("sha256")
.update(message)
.sign({
return crypto.createSign("sha256").update(message).sign({
key: this._key,
padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING
padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING,
});

@@ -37,0 +37,0 @@ }

{
"name": "arbundles",
"version": "0.1.5",
"version": "0.2.0",
"description": "Arweave bundling library",
"author": "Josh Benaron <joshbenaron@gmail.com>",
"license": "Apache-2.0",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Bundler-Network/arbundles"
},
"files": [

@@ -17,2 +15,14 @@ "/build/**/*.js",

],
"scripts": {
"start": "node build/src/index.js",
"clean": "rimraf coverage build tmp",
"prebuild": "npm run lint",
"build": "tsc -p tsconfig.release.json",
"build:watch": "tsc -w -p tsconfig.release.json",
"lint": "eslint . --ext .ts,.tsx",
"test": "jest --coverage",
"test:watch": "jest --watch",
"prepublish": "tsc",
"build:push": "tsc && git add lib && git commit -m \"Build and push new version\" && git push"
},
"devDependencies": {

@@ -37,16 +47,2 @@ "@types/deep-equal": "^1.0.1",

},
"scripts": {
"start": "node build/src/index.js",
"clean": "rimraf coverage build tmp",
"prebuild": "npm run lint",
"build": "tsc -p tsconfig.release.json",
"build:watch": "tsc -w -p tsconfig.release.json",
"lint": "eslint . --ext .ts,.tsx",
"test": "jest --coverage",
"test:watch": "jest --watch",
"prepublish": "tsc",
"build:push": "tsc && git add lib && git commit -m \"Build and push new version\" && git push"
},
"author": "Josh Benaron <joshbenaron@gmail.com>",
"license": "Apache-2.0",
"dependencies": {

@@ -69,6 +65,3 @@ "@akiroz/size-chunker-stream": "^0.0.1",

"tslib": "^2.3.0"
},
"volta": {
"node": "14.16.1"
}
}

@@ -5,4 +5,7 @@ # Arweave Bundles

See [ANS-104](https://github.com/joshbenaron/arweave-standards/blob/arbundles/ans/ANS-104.md) for more details.
Note: Gateways currently only index bundles up to 250mb. Creating bundles larger than this could lead to them not being indexed. The new gateway implementation will provide infinite bundle limits.
If you wish to upload a transactions >250mb submit a standard transaction via [arweave-js](https://github.com/ArweaveTeam/arweave-js).
See [ANS-104](https://github.com/joshbenaron/arweave-standards/blob/ans104/ans/ANS-104.md) for more details.
## Installing the library

@@ -18,20 +21,6 @@

## Post data
```ts
import { createData, ArweaveSigner } from "ans104";
const data = { data: "some data" };
const signer = new ArweaveSigner(jwk);
const item = await createData(data, signer);
await item.sign(signer);
await item.sendToBundler();
```
## Creating bundles
```ts
import { bundleAndSignData, ArweaveSigner } from "arbundles";
import { bundleAndSignData } from "arbundles";

@@ -53,3 +42,3 @@ const dataItems = [

```ts
import { createData, ArweaveSigner } from "arbundles";
import { createData } from "arbundles";

@@ -105,3 +94,3 @@ const data = { data: "some data" };

```ts
import { unbundleData } from "arbundles";
import { Bundle } from "arbundles";

@@ -121,2 +110,2 @@ const data = await arweave.transactions.getData("hKMMPNh_emBf8v_at1tFzNYACisyMQNcKzeeE1QE9p8");

Docs coming soon...
Docs coming soon...
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc