Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
12
Maintainers
3
Versions
89
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.6 to 0.9.7

build/node/cjs/src/__tests__/test_key0.json

2

build/node/cjs/src/ar-data-bundle.js

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

});
const buffer = Buffer.concat([(0, utils_1.longTo32ByteArray)(dataItems.length), headers, binaries]);
const buffer = Buffer.concat([Buffer.from((0, utils_1.longTo32ByteArray)(dataItems.length)), Buffer.from(headers), binaries]);
return new Bundle_1.default(buffer);

@@ -66,0 +66,0 @@ });

@@ -27,4 +27,3 @@ "use strict";

const anchor_length = 1 + ((_b = _anchor === null || _anchor === void 0 ? void 0 : _anchor.byteLength) !== null && _b !== void 0 ? _b : 0);
// @ts-expect-error opts.tags has a null guard
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, tags_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, tags_1.serializeTags)(opts === null || opts === void 0 ? void 0 : opts.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);

@@ -31,0 +30,0 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

@@ -110,18 +110,17 @@ "use strict";

let offset = 0;
const headerStart = 32 + 64 * index;
const dataItemSize = (0, utils_1.byteArrayToLong)(this.binary.subarray(headerStart, headerStart + 32));
const bundleStart = this.getBundleStart();
let counter = 0;
let _offset, _id;
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
if (counter == index) {
_offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
if (counter++ === index) {
_id = this.binary.subarray(i + 32, i + 64);
break;
}
const _offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
offset += _offset;
counter++;
}
const bundleStart = this.getBundleStart();
const dataItemStart = bundleStart + offset;
const slice = this.binary.subarray(dataItemStart, dataItemStart + dataItemSize + 200);
const slice = this.binary.subarray(dataItemStart, dataItemStart + _offset);
const item = new DataItem_1.default(slice);
item.rawId = this.binary.slice(32 + 64 * index, 64 + 64 * index);
item.rawId = _id;
return item;

@@ -128,0 +127,0 @@ }

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

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

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

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

export declare function signedFileStream(path: string, signer: Signer, opts?: DataItemCreateOptions): Promise<Readable>;
export declare const fileExportForTesting: {
fileToFd: (f: File) => Promise<FileHandle>;
};
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.signedFileStream = exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = void 0;
exports.fileExportForTesting = exports.signedFileStream = exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = void 0;
const fs_1 = require("fs");

@@ -39,3 +39,4 @@ const util_1 = require("util");

return __awaiter(this, void 0, void 0, function* () {
const fd = yield fs_1.promises.open(filename, "r").then((handle) => handle.fd);
const handle = yield fs_1.promises.open(filename, "r");
const fd = handle.fd;
let tagsStart = 512 + 512 + 2;

@@ -61,2 +62,3 @@ const targetPresent = yield read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);

const signature = "";
yield handle.close();
return {

@@ -87,2 +89,3 @@ id,

const headerBuffer = yield read(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
yield fd.close();
return {

@@ -145,2 +148,3 @@ offset: (0, utils_1.byteArrayToLong)(headerBuffer.subarray(0, 32)),

if (!targetPresent) {
yield fd.close();
return undefined;

@@ -166,2 +170,3 @@ }

if (!anchorPresent) {
yield fd.close();
return undefined;

@@ -188,2 +193,3 @@ }

if (numberOfTags == 0) {
yield fd.close();
return [];

@@ -205,2 +211,5 @@ }

exports.signedFileStream = signedFileStream;
exports.fileExportForTesting = {
fileToFd,
};
//# sourceMappingURL=file.js.map

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

const arweave_stream_tx_1 = require("arweave-stream-tx");
const path_1 = require("path");
// import { Readable } from 'stream';

@@ -56,3 +57,13 @@ // import { createTransactionAsync } from 'arweave-stream';

return __awaiter(this, void 0, void 0, function* () {
const txs = yield fs_1.promises.readdir(dir).then((r) => r.filter((f) => __awaiter(this, void 0, void 0, function* () { return !(yield fs_1.promises.stat(f).then((s) => s.isDirectory())); })));
const txs = [];
for (const p of yield fs_1.promises.readdir(dir)) {
const fullPath = (0, path_1.resolve)(dir, p);
// if it's an item (not a dir,not the header file, actually exists in FS) add to txs array
if (p !== "header" &&
(yield fs_1.promises
.stat(fullPath)
.then((e) => !e.isDirectory())
.catch((_) => false)))
txs.push(fullPath);
}
return new FileBundle(dir + "/header", txs);

@@ -156,4 +167,4 @@ });

const tx = yield this.toTransaction({}, arweave, jwk);
tx.addTag("Bundle-Format", "binary");
tx.addTag("Bundle-Version", "2.0.0");
// tx.addTag("Bundle-Format", "binary");
// tx.addTag("Bundle-Version", "2.0.0");
for (const { name, value } of tags) {

@@ -165,2 +176,3 @@ tx.addTag(name, value);

const stream2 = multistream_1.default.obj(streams2);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yield (0, promises_1.pipeline)(stream2, (0, arweave_stream_tx_1.uploadTransactionAsync)(tx, arweave, true));

@@ -167,0 +179,0 @@ return tx;

@@ -32,3 +32,4 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const length = (_a = constants_1.SIG_CONFIG[yield this.signatureType()]) === null || _a === void 0 ? void 0 : _a.sigLength;
const type = yield this.signatureType();
const length = (_a = constants_1.SIG_CONFIG[type]) === null || _a === void 0 ? void 0 : _a.sigLength;
if (!length)

@@ -67,3 +68,4 @@ throw new Error("Signature type not supported");

static isDataItem(obj) {
return obj.filename && typeof obj.filename === "string";
// return obj?.filename ? typeof obj.filename === "string" : false;
return obj instanceof FileDataItem;
}

@@ -70,0 +72,0 @@ static verify(filename) {

@@ -7,2 +7,3 @@ import { default as nodeDriver } from "arweave/node/lib/crypto/node-driver";

export type { CreateTransactionInterface } from "arweave/node/common";
export { default as Arweave } from "arweave/node";
declare const driver: typeof nodeDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCryptoDriver = exports.CryptoDriver = exports.deepHash = exports.Transaction = exports.concatBuffers = exports.stringToBuffer = void 0;
exports.getCryptoDriver = exports.CryptoDriver = exports.Arweave = exports.deepHash = exports.Transaction = exports.concatBuffers = exports.stringToBuffer = void 0;
const crypto_1 = require("crypto");

@@ -18,2 +18,4 @@ const node_driver_1 = __importDefault(require("arweave/node/lib/crypto/node-driver"));

Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deepHash_1.deepHash; } });
var node_1 = require("arweave/node");
Object.defineProperty(exports, "Arweave", { enumerable: true, get: function () { return __importDefault(node_1).default; } });
// hack as ESM won't unpack .default CJS imports, so we do so dynamically

@@ -20,0 +22,0 @@ // eslint-disable-next-line @typescript-eslint/dot-notation

@@ -16,1 +16,2 @@ export { default as ArweaveSigner } from "./ArweaveSigner";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner";
export { default as ArconnectSigner } from "./arconnectSigner";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.InjectedTypedEthereumSigner = exports.TypedEthereumSigner = exports.MultiSignatureAptosSigner = exports.InjectedAptosSigner = exports.AptosSigner = exports.HexSolanaSigner = exports.HexInjectedSolanaSigner = exports.AlgorandSigner = exports.EthereumSigner = exports.NearSigner = exports.PolygonSigner = exports.SolanaSigner = exports.InjectedEthereumSigner = exports.InjectedSolanaSigner = exports.ArweaveSigner = void 0;
exports.ArconnectSigner = exports.InjectedTypedEthereumSigner = exports.TypedEthereumSigner = exports.MultiSignatureAptosSigner = exports.InjectedAptosSigner = exports.AptosSigner = exports.HexSolanaSigner = exports.HexInjectedSolanaSigner = exports.AlgorandSigner = exports.EthereumSigner = exports.NearSigner = exports.PolygonSigner = exports.SolanaSigner = exports.InjectedEthereumSigner = exports.InjectedSolanaSigner = exports.ArweaveSigner = void 0;
var ArweaveSigner_1 = require("./ArweaveSigner");

@@ -38,2 +38,4 @@ Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return __importDefault(ArweaveSigner_1).default; } });

Object.defineProperty(exports, "InjectedTypedEthereumSigner", { enumerable: true, get: function () { return __importDefault(InjectedTypedEthereumSigner_1).default; } });
var arconnectSigner_1 = require("./arconnectSigner");
Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return __importDefault(arconnectSigner_1).default; } });
//# sourceMappingURL=index.js.map

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

export declare function keccak256(value: Buffer | BN | string | number): any;
declare function toBuffer(value: any): any;
declare function isHexString(value: any, length?: number): boolean;
declare function padToEven(value: any): any;
declare function stripHexPrefix(value: any): any;
declare function isHexPrefixed(value: any): boolean;
declare function intToBuffer(i: number): Buffer;
declare function intToHex(i: number): string;
export default keccak256;
export declare const exportForTesting: {
intToBuffer: typeof intToBuffer;
intToHex: typeof intToHex;
isHexPrefixed: typeof isHexPrefixed;
stripHexPrefix: typeof stripHexPrefix;
padToEven: typeof padToEven;
isHexString: typeof isHexString;
toBuffer: typeof toBuffer;
};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.keccak256 = void 0;
exports.exportForTesting = exports.keccak256 = void 0;
/* eslint-disable @typescript-eslint/explicit-function-return-type */

@@ -93,2 +93,11 @@ const bn_js_1 = __importDefault(require("bn.js"));

exports.default = keccak256;
exports.exportForTesting = {
intToBuffer,
intToHex,
isHexPrefixed,
stripHexPrefix,
padToEven,
isHexString,
toBuffer,
};
//# sourceMappingURL=keccak256.js.map

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

get key() {
return new Uint8Array(0);
throw new Error("You must implement `key`");
}

@@ -33,0 +33,0 @@ sign(message) {

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

get publicKey() {
return Buffer.alloc(0);
throw new Error("You must implement `publicKey`");
}

@@ -31,0 +31,0 @@ get key() {

/// <reference types="node" />
/// <reference types="node" />
import { PassThrough } from "stream";

@@ -15,1 +16,8 @@ import type { Readable } from "stream";

export declare function streamSigner(s1: Readable, s2: Readable, signer: Signer, opts?: DataItemCreateOptions): Promise<PassThrough>;
declare function readBytes(reader: AsyncGenerator<Buffer>, buffer: Uint8Array, length: number): Promise<Uint8Array>;
declare function getReader(s: Readable): AsyncGenerator<Buffer>;
export declare const streamExportForTesting: {
readBytes: typeof readBytes;
getReader: typeof getReader;
};
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.streamSigner = void 0;
exports.streamExportForTesting = exports.streamSigner = void 0;
const stream_1 = require("stream");

@@ -203,3 +203,3 @@ const utils_1 = require("../utils");

throw new Error("Invalid buffer");
return readBytes(reader, Buffer.concat([buffer, value]), length);
return readBytes(reader, Buffer.concat([Buffer.from(buffer), Buffer.from(value)]), length);
});

@@ -232,2 +232,6 @@ }

}
exports.streamExportForTesting = {
readBytes,
getReader,
};
//# sourceMappingURL=index.js.map

@@ -176,2 +176,5 @@ "use strict";

function serializeTags(tags) {
if ((tags === null || tags === void 0 ? void 0 : tags.length) === 0) {
return Buffer.allocUnsafe(0);
}
const tap = new AVSCTap();

@@ -178,0 +181,0 @@ tap.writeTags(tags);

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

// const isExtension = typeof browser !== "undefined" || typeof chrome !== "undefined";
// export const isBrowser = (typeof window !== "undefined" && typeof window.document !== "undefined") || isExtension;
//# sourceMappingURL=utils.js.map

@@ -7,2 +7,3 @@ import type { JWKInterface } from "./interface-jwk";

export { deepHash } from "./deepHash";
export { default as Arweave } from "arweave/web";
declare const driver: typeof webDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCryptoDriver = exports.CryptoDriver = exports.deepHash = exports.concatBuffers = exports.stringToBuffer = void 0;
exports.getCryptoDriver = exports.CryptoDriver = exports.Arweave = exports.deepHash = exports.concatBuffers = exports.stringToBuffer = void 0;
const webcrypto_driver_1 = __importDefault(require("arweave/web/lib/crypto/webcrypto-driver"));

@@ -14,2 +14,4 @@ var utils_1 = require("arweave/web/lib/utils");

Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deepHash_1.deepHash; } });
var web_1 = require("arweave/web");
Object.defineProperty(exports, "Arweave", { enumerable: true, get: function () { return __importDefault(web_1).default; } });
// import { sha384 as SHA384 } from "sha";

@@ -16,0 +18,0 @@ // export { default as Arweave } from "arweave/web";

@@ -27,3 +27,13 @@ /// <reference types="node" />

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -58,2 +68,3 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;

@@ -86,3 +97,13 @@ };

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -117,3 +138,4 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;
};

@@ -46,3 +46,3 @@ import getSignatureData from "./ar-data-base.js";

});
const buffer = Buffer.concat([longTo32ByteArray(dataItems.length), headers, binaries]);
const buffer = Buffer.concat([Buffer.from(longTo32ByteArray(dataItems.length)), Buffer.from(headers), binaries]);
return new Bundle(buffer);

@@ -49,0 +49,0 @@ }

@@ -20,4 +20,3 @@ import base64url from "base64url";

const anchor_length = 1 + (_anchor?.byteLength ?? 0);
// @ts-expect-error opts.tags has a null guard
const _tags = (opts?.tags?.length ?? 0) > 0 ? serializeTags(opts.tags) : null;
const _tags = (opts?.tags?.length ?? 0) > 0 ? serializeTags(opts?.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);

@@ -24,0 +23,0 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

@@ -94,18 +94,17 @@ import base64url from "base64url";

let offset = 0;
const headerStart = 32 + 64 * index;
const dataItemSize = byteArrayToLong(this.binary.subarray(headerStart, headerStart + 32));
const bundleStart = this.getBundleStart();
let counter = 0;
let _offset, _id;
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
if (counter == index) {
_offset = byteArrayToLong(this.binary.subarray(i, i + 32));
if (counter++ === index) {
_id = this.binary.subarray(i + 32, i + 64);
break;
}
const _offset = byteArrayToLong(this.binary.subarray(i, i + 32));
offset += _offset;
counter++;
}
const bundleStart = this.getBundleStart();
const dataItemStart = bundleStart + offset;
const slice = this.binary.subarray(dataItemStart, dataItemStart + dataItemSize + 200);
const slice = this.binary.subarray(dataItemStart, dataItemStart + _offset);
const item = new DataItem(slice);
item.rawId = this.binary.slice(32 + 64 * index, 64 + 64 * index);
item.rawId = _id;
return item;

@@ -112,0 +111,0 @@ }

@@ -16,3 +16,3 @@ import { file } from "tmp-promise";

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

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

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

export declare function signedFileStream(path: string, signer: Signer, opts?: DataItemCreateOptions): Promise<Readable>;
export declare const fileExportForTesting: {
fileToFd: (f: File) => Promise<FileHandle>;
};
export {};

@@ -10,3 +10,4 @@ import { createReadStream, promises, read as FSRead } from "fs";

export async function fileToJson(filename) {
const fd = await promises.open(filename, "r").then((handle) => handle.fd);
const handle = await promises.open(filename, "r");
const fd = handle.fd;
let tagsStart = 512 + 512 + 2;

@@ -32,2 +33,3 @@ const targetPresent = await read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);

const signature = "";
await handle.close();
return {

@@ -52,2 +54,3 @@ id,

const headerBuffer = await read(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
await fd.close();
return {

@@ -91,2 +94,3 @@ offset: byteArrayToLong(headerBuffer.subarray(0, 32)),

if (!targetPresent) {
await fd.close();
return undefined;

@@ -108,2 +112,3 @@ }

if (!anchorPresent) {
await fd.close();
return undefined;

@@ -126,2 +131,3 @@ }

if (numberOfTags == 0) {
await fd.close();
return [];

@@ -138,2 +144,5 @@ }

}
export const fileExportForTesting = {
fileToFd,
};
//# sourceMappingURL=file.js.map

@@ -10,2 +10,3 @@ import FileDataItem from "./FileDataItem.js";

import { createTransactionAsync, uploadTransactionAsync } from "arweave-stream-tx";
import { resolve } from "path";
// import { Readable } from 'stream';

@@ -23,3 +24,13 @@ // import { createTransactionAsync } from 'arweave-stream';

static async fromDir(dir) {
const txs = await promises.readdir(dir).then((r) => r.filter(async (f) => !(await promises.stat(f).then((s) => s.isDirectory()))));
const txs = [];
for (const p of await promises.readdir(dir)) {
const fullPath = resolve(dir, p);
// if it's an item (not a dir,not the header file, actually exists in FS) add to txs array
if (p !== "header" &&
(await promises
.stat(fullPath)
.then((e) => !e.isDirectory())
.catch((_) => false)))
txs.push(fullPath);
}
return new FileBundle(dir + "/header", txs);

@@ -75,4 +86,4 @@ }

const tx = await this.toTransaction({}, arweave, jwk);
tx.addTag("Bundle-Format", "binary");
tx.addTag("Bundle-Version", "2.0.0");
// tx.addTag("Bundle-Format", "binary");
// tx.addTag("Bundle-Version", "2.0.0");
for (const { name, value } of tags) {

@@ -84,2 +95,3 @@ tx.addTag(name, value);

const stream2 = MultiStream.obj(streams2);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await pipeline(stream2, uploadTransactionAsync(tx, arweave, true));

@@ -86,0 +98,0 @@ return tx;

@@ -16,3 +16,4 @@ import base64url from "base64url";

async signatureLength() {
const length = SIG_CONFIG[await this.signatureType()]?.sigLength;
const type = await this.signatureType();
const length = SIG_CONFIG[type]?.sigLength;
if (!length)

@@ -48,3 +49,4 @@ throw new Error("Signature type not supported");

static isDataItem(obj) {
return obj.filename && typeof obj.filename === "string";
// return obj?.filename ? typeof obj.filename === "string" : false;
return obj instanceof FileDataItem;
}

@@ -51,0 +53,0 @@ static async verify(filename) {

@@ -7,2 +7,3 @@ import { default as nodeDriver } from "arweave/node/lib/crypto/node-driver.js";

export type { CreateTransactionInterface } from "arweave/node/common.js";
export { default as Arweave } from "arweave/node/index.js";
declare const driver: typeof nodeDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

@@ -7,2 +7,3 @@ import { createPublicKey } from "crypto";

export { deepHash } from "./deepHash.js";
export { default as Arweave } from "arweave/node/index.js";
// hack as ESM won't unpack .default CJS imports, so we do so dynamically

@@ -9,0 +10,0 @@ // eslint-disable-next-line @typescript-eslint/dot-notation

@@ -16,1 +16,2 @@ export { default as ArweaveSigner } from "./ArweaveSigner.js";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner.js";
export { default as ArconnectSigner } from "./arconnectSigner.js";

@@ -16,2 +16,3 @@ export { default as ArweaveSigner } from "./ArweaveSigner.js";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner.js";
export { default as ArconnectSigner } from "./arconnectSigner.js";
//# sourceMappingURL=index.js.map

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

export declare function keccak256(value: Buffer | BN | string | number): any;
declare function toBuffer(value: any): any;
declare function isHexString(value: any, length?: number): boolean;
declare function padToEven(value: any): any;
declare function stripHexPrefix(value: any): any;
declare function isHexPrefixed(value: any): boolean;
declare function intToBuffer(i: number): Buffer;
declare function intToHex(i: number): string;
export default keccak256;
export declare const exportForTesting: {
intToBuffer: typeof intToBuffer;
intToHex: typeof intToHex;
isHexPrefixed: typeof isHexPrefixed;
stripHexPrefix: typeof stripHexPrefix;
padToEven: typeof padToEven;
isHexString: typeof isHexString;
toBuffer: typeof toBuffer;
};

@@ -85,2 +85,11 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */

export default keccak256;
export const exportForTesting = {
intToBuffer,
intToHex,
isHexPrefixed,
stripHexPrefix,
padToEven,
isHexString,
toBuffer,
};
//# sourceMappingURL=keccak256.js.map

@@ -19,3 +19,3 @@ import base64url from "base64url";

get key() {
return new Uint8Array(0);
throw new Error("You must implement `key`");
}

@@ -22,0 +22,0 @@ sign(message) {

@@ -16,3 +16,3 @@ import base64url from "base64url";

get publicKey() {
return Buffer.alloc(0);
throw new Error("You must implement `publicKey`");
}

@@ -19,0 +19,0 @@ get key() {

/// <reference types="node" />
/// <reference types="node" />
import { PassThrough } from "stream";

@@ -15,1 +16,8 @@ import type { Readable } from "stream";

export declare function streamSigner(s1: Readable, s2: Readable, signer: Signer, opts?: DataItemCreateOptions): Promise<PassThrough>;
declare function readBytes(reader: AsyncGenerator<Buffer>, buffer: Uint8Array, length: number): Promise<Uint8Array>;
declare function getReader(s: Readable): AsyncGenerator<Buffer>;
export declare const streamExportForTesting: {
readBytes: typeof readBytes;
getReader: typeof getReader;
};
export {};

@@ -161,3 +161,3 @@ import { PassThrough, Transform } from "stream";

throw new Error("Invalid buffer");
return readBytes(reader, Buffer.concat([buffer, value]), length);
return readBytes(reader, Buffer.concat([Buffer.from(buffer), Buffer.from(value)]), length);
}

@@ -169,2 +169,6 @@ async function* getReader(s) {

}
export const streamExportForTesting = {
readBytes,
getReader,
};
//# sourceMappingURL=index.js.map

@@ -174,2 +174,5 @@ import { MAX_TAG_BYTES } from "./DataItem.js";

export function serializeTags(tags) {
if (tags?.length === 0) {
return Buffer.allocUnsafe(0);
}
const tap = new AVSCTap();

@@ -176,0 +179,0 @@ tap.writeTags(tags);

@@ -55,3 +55,2 @@ export function longToNByteArray(N, long) {

// const isExtension = typeof browser !== "undefined" || typeof chrome !== "undefined";
// export const isBrowser = (typeof window !== "undefined" && typeof window.document !== "undefined") || isExtension;
//# sourceMappingURL=utils.js.map

@@ -7,2 +7,3 @@ import type { JWKInterface } from "./interface-jwk.js";

export { deepHash } from "./deepHash.js";
export { default as Arweave } from "arweave/web/index.js";
declare const driver: typeof webDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

import webDriver from "arweave/web/lib/crypto/webcrypto-driver.js";
export { stringToBuffer, concatBuffers } from "arweave/web/lib/utils.js";
export { deepHash } from "./deepHash.js";
export { default as Arweave } from "arweave/web/index.js";
// import { sha384 as SHA384 } from "sha";

@@ -5,0 +6,0 @@ // export { default as Arweave } from "arweave/web/index.js";

@@ -27,3 +27,13 @@ /// <reference types="node" />

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -58,2 +68,3 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;

@@ -86,3 +97,13 @@ };

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -117,3 +138,4 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;
};

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

});
const buffer = Buffer.concat([(0, utils_1.longTo32ByteArray)(dataItems.length), headers, binaries]);
const buffer = Buffer.concat([Buffer.from((0, utils_1.longTo32ByteArray)(dataItems.length)), Buffer.from(headers), binaries]);
return new Bundle_1.default(buffer);

@@ -66,0 +66,0 @@ });

@@ -27,4 +27,3 @@ "use strict";

const anchor_length = 1 + ((_b = _anchor === null || _anchor === void 0 ? void 0 : _anchor.byteLength) !== null && _b !== void 0 ? _b : 0);
// @ts-expect-error opts.tags has a null guard
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, tags_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, tags_1.serializeTags)(opts === null || opts === void 0 ? void 0 : opts.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);

@@ -31,0 +30,0 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

@@ -110,18 +110,17 @@ "use strict";

let offset = 0;
const headerStart = 32 + 64 * index;
const dataItemSize = (0, utils_1.byteArrayToLong)(this.binary.subarray(headerStart, headerStart + 32));
const bundleStart = this.getBundleStart();
let counter = 0;
let _offset, _id;
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
if (counter == index) {
_offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
if (counter++ === index) {
_id = this.binary.subarray(i + 32, i + 64);
break;
}
const _offset = (0, utils_1.byteArrayToLong)(this.binary.subarray(i, i + 32));
offset += _offset;
counter++;
}
const bundleStart = this.getBundleStart();
const dataItemStart = bundleStart + offset;
const slice = this.binary.subarray(dataItemStart, dataItemStart + dataItemSize + 200);
const slice = this.binary.subarray(dataItemStart, dataItemStart + _offset);
const item = new DataItem_1.default(slice);
item.rawId = this.binary.slice(32 + 64 * index, 64 + 64 * index);
item.rawId = _id;
return item;

@@ -128,0 +127,0 @@ }

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

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

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

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

export declare function signedFileStream(path: string, signer: Signer, opts?: DataItemCreateOptions): Promise<Readable>;
export declare const fileExportForTesting: {
fileToFd: (f: File) => Promise<FileHandle>;
};
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.signedFileStream = exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = void 0;
exports.fileExportForTesting = exports.signedFileStream = exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = void 0;
const fs_1 = require("fs");

@@ -39,3 +39,4 @@ const util_1 = require("util");

return __awaiter(this, void 0, void 0, function* () {
const fd = yield fs_1.promises.open(filename, "r").then((handle) => handle.fd);
const handle = yield fs_1.promises.open(filename, "r");
const fd = handle.fd;
let tagsStart = 512 + 512 + 2;

@@ -61,2 +62,3 @@ const targetPresent = yield read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);

const signature = "";
yield handle.close();
return {

@@ -87,2 +89,3 @@ id,

const headerBuffer = yield read(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
yield fd.close();
return {

@@ -145,2 +148,3 @@ offset: (0, utils_1.byteArrayToLong)(headerBuffer.subarray(0, 32)),

if (!targetPresent) {
yield fd.close();
return undefined;

@@ -166,2 +170,3 @@ }

if (!anchorPresent) {
yield fd.close();
return undefined;

@@ -188,2 +193,3 @@ }

if (numberOfTags == 0) {
yield fd.close();
return [];

@@ -205,2 +211,5 @@ }

exports.signedFileStream = signedFileStream;
exports.fileExportForTesting = {
fileToFd,
};
//# sourceMappingURL=file.js.map

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

const arweave_stream_tx_1 = require("arweave-stream-tx");
const path_1 = require("path");
// import { Readable } from 'stream';

@@ -56,3 +57,13 @@ // import { createTransactionAsync } from 'arweave-stream';

return __awaiter(this, void 0, void 0, function* () {
const txs = yield fs_1.promises.readdir(dir).then((r) => r.filter((f) => __awaiter(this, void 0, void 0, function* () { return !(yield fs_1.promises.stat(f).then((s) => s.isDirectory())); })));
const txs = [];
for (const p of yield fs_1.promises.readdir(dir)) {
const fullPath = (0, path_1.resolve)(dir, p);
// if it's an item (not a dir,not the header file, actually exists in FS) add to txs array
if (p !== "header" &&
(yield fs_1.promises
.stat(fullPath)
.then((e) => !e.isDirectory())
.catch((_) => false)))
txs.push(fullPath);
}
return new FileBundle(dir + "/header", txs);

@@ -156,4 +167,4 @@ });

const tx = yield this.toTransaction({}, arweave, jwk);
tx.addTag("Bundle-Format", "binary");
tx.addTag("Bundle-Version", "2.0.0");
// tx.addTag("Bundle-Format", "binary");
// tx.addTag("Bundle-Version", "2.0.0");
for (const { name, value } of tags) {

@@ -165,2 +176,3 @@ tx.addTag(name, value);

const stream2 = multistream_1.default.obj(streams2);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yield (0, promises_1.pipeline)(stream2, (0, arweave_stream_tx_1.uploadTransactionAsync)(tx, arweave, true));

@@ -167,0 +179,0 @@ return tx;

@@ -32,3 +32,4 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const length = (_a = constants_1.SIG_CONFIG[yield this.signatureType()]) === null || _a === void 0 ? void 0 : _a.sigLength;
const type = yield this.signatureType();
const length = (_a = constants_1.SIG_CONFIG[type]) === null || _a === void 0 ? void 0 : _a.sigLength;
if (!length)

@@ -67,3 +68,4 @@ throw new Error("Signature type not supported");

static isDataItem(obj) {
return obj.filename && typeof obj.filename === "string";
// return obj?.filename ? typeof obj.filename === "string" : false;
return obj instanceof FileDataItem;
}

@@ -70,0 +72,0 @@ static verify(filename) {

@@ -7,2 +7,3 @@ import { default as nodeDriver } from "arweave/node/lib/crypto/node-driver";

export type { CreateTransactionInterface } from "arweave/node/common";
export { default as Arweave } from "arweave/node";
declare const driver: typeof nodeDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCryptoDriver = exports.CryptoDriver = exports.deepHash = exports.Transaction = exports.concatBuffers = exports.stringToBuffer = void 0;
exports.getCryptoDriver = exports.CryptoDriver = exports.Arweave = exports.deepHash = exports.Transaction = exports.concatBuffers = exports.stringToBuffer = void 0;
const crypto_1 = require("crypto");

@@ -18,2 +18,4 @@ const node_driver_1 = __importDefault(require("arweave/node/lib/crypto/node-driver"));

Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deepHash_1.deepHash; } });
var node_1 = require("arweave/node");
Object.defineProperty(exports, "Arweave", { enumerable: true, get: function () { return __importDefault(node_1).default; } });
// hack as ESM won't unpack .default CJS imports, so we do so dynamically

@@ -20,0 +22,0 @@ // eslint-disable-next-line @typescript-eslint/dot-notation

@@ -16,1 +16,2 @@ export { default as ArweaveSigner } from "./ArweaveSigner";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner";
export { default as ArconnectSigner } from "./arconnectSigner";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.InjectedTypedEthereumSigner = exports.TypedEthereumSigner = exports.MultiSignatureAptosSigner = exports.InjectedAptosSigner = exports.AptosSigner = exports.HexSolanaSigner = exports.HexInjectedSolanaSigner = exports.AlgorandSigner = exports.EthereumSigner = exports.NearSigner = exports.PolygonSigner = exports.SolanaSigner = exports.InjectedEthereumSigner = exports.InjectedSolanaSigner = exports.ArweaveSigner = void 0;
exports.ArconnectSigner = exports.InjectedTypedEthereumSigner = exports.TypedEthereumSigner = exports.MultiSignatureAptosSigner = exports.InjectedAptosSigner = exports.AptosSigner = exports.HexSolanaSigner = exports.HexInjectedSolanaSigner = exports.AlgorandSigner = exports.EthereumSigner = exports.NearSigner = exports.PolygonSigner = exports.SolanaSigner = exports.InjectedEthereumSigner = exports.InjectedSolanaSigner = exports.ArweaveSigner = void 0;
var ArweaveSigner_1 = require("./ArweaveSigner");

@@ -38,2 +38,4 @@ Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return __importDefault(ArweaveSigner_1).default; } });

Object.defineProperty(exports, "InjectedTypedEthereumSigner", { enumerable: true, get: function () { return __importDefault(InjectedTypedEthereumSigner_1).default; } });
var arconnectSigner_1 = require("./arconnectSigner");
Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return __importDefault(arconnectSigner_1).default; } });
//# sourceMappingURL=index.js.map

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

export declare function keccak256(value: Buffer | BN | string | number): any;
declare function toBuffer(value: any): any;
declare function isHexString(value: any, length?: number): boolean;
declare function padToEven(value: any): any;
declare function stripHexPrefix(value: any): any;
declare function isHexPrefixed(value: any): boolean;
declare function intToBuffer(i: number): Buffer;
declare function intToHex(i: number): string;
export default keccak256;
export declare const exportForTesting: {
intToBuffer: typeof intToBuffer;
intToHex: typeof intToHex;
isHexPrefixed: typeof isHexPrefixed;
stripHexPrefix: typeof stripHexPrefix;
padToEven: typeof padToEven;
isHexString: typeof isHexString;
toBuffer: typeof toBuffer;
};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.keccak256 = void 0;
exports.exportForTesting = exports.keccak256 = void 0;
/* eslint-disable @typescript-eslint/explicit-function-return-type */

@@ -93,2 +93,11 @@ const bn_js_1 = __importDefault(require("bn.js"));

exports.default = keccak256;
exports.exportForTesting = {
intToBuffer,
intToHex,
isHexPrefixed,
stripHexPrefix,
padToEven,
isHexString,
toBuffer,
};
//# sourceMappingURL=keccak256.js.map

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

get key() {
return new Uint8Array(0);
throw new Error("You must implement `key`");
}

@@ -33,0 +33,0 @@ sign(message) {

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

get publicKey() {
return Buffer.alloc(0);
throw new Error("You must implement `publicKey`");
}

@@ -31,0 +31,0 @@ get key() {

/// <reference types="node" />
/// <reference types="node" />
import { PassThrough } from "stream";

@@ -15,1 +16,8 @@ import type { Readable } from "stream";

export declare function streamSigner(s1: Readable, s2: Readable, signer: Signer, opts?: DataItemCreateOptions): Promise<PassThrough>;
declare function readBytes(reader: AsyncGenerator<Buffer>, buffer: Uint8Array, length: number): Promise<Uint8Array>;
declare function getReader(s: Readable): AsyncGenerator<Buffer>;
export declare const streamExportForTesting: {
readBytes: typeof readBytes;
getReader: typeof getReader;
};
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.streamSigner = void 0;
exports.streamExportForTesting = exports.streamSigner = void 0;
const stream_1 = require("stream");

@@ -203,3 +203,3 @@ const utils_1 = require("../utils");

throw new Error("Invalid buffer");
return readBytes(reader, Buffer.concat([buffer, value]), length);
return readBytes(reader, Buffer.concat([Buffer.from(buffer), Buffer.from(value)]), length);
});

@@ -232,2 +232,6 @@ }

}
exports.streamExportForTesting = {
readBytes,
getReader,
};
//# sourceMappingURL=index.js.map

@@ -176,2 +176,5 @@ "use strict";

function serializeTags(tags) {
if ((tags === null || tags === void 0 ? void 0 : tags.length) === 0) {
return Buffer.allocUnsafe(0);
}
const tap = new AVSCTap();

@@ -178,0 +181,0 @@ tap.writeTags(tags);

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

// const isExtension = typeof browser !== "undefined" || typeof chrome !== "undefined";
// export const isBrowser = (typeof window !== "undefined" && typeof window.document !== "undefined") || isExtension;
//# sourceMappingURL=utils.js.map

@@ -7,2 +7,3 @@ import type { JWKInterface } from "./interface-jwk";

export { deepHash } from "./deepHash";
export { default as Arweave } from "arweave/web";
declare const driver: typeof webDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCryptoDriver = exports.CryptoDriver = exports.deepHash = exports.concatBuffers = exports.stringToBuffer = void 0;
exports.getCryptoDriver = exports.CryptoDriver = exports.Arweave = exports.deepHash = exports.concatBuffers = exports.stringToBuffer = void 0;
const webcrypto_driver_1 = __importDefault(require("arweave/web/lib/crypto/webcrypto-driver"));

@@ -14,2 +14,4 @@ var utils_1 = require("arweave/web/lib/utils");

Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deepHash_1.deepHash; } });
var web_1 = require("arweave/web");
Object.defineProperty(exports, "Arweave", { enumerable: true, get: function () { return __importDefault(web_1).default; } });
// import { sha384 as SHA384 } from "sha";

@@ -16,0 +18,0 @@ // export { default as Arweave } from "arweave/web";

@@ -27,3 +27,13 @@ /// <reference types="node" />

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -58,2 +68,3 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;

@@ -86,3 +97,13 @@ };

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -117,3 +138,4 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;
};

@@ -46,3 +46,3 @@ import getSignatureData from "./ar-data-base.js";

});
const buffer = Buffer.concat([longTo32ByteArray(dataItems.length), headers, binaries]);
const buffer = Buffer.concat([Buffer.from(longTo32ByteArray(dataItems.length)), Buffer.from(headers), binaries]);
return new Bundle(buffer);

@@ -49,0 +49,0 @@ }

@@ -20,4 +20,3 @@ import base64url from "base64url";

const anchor_length = 1 + (_anchor?.byteLength ?? 0);
// @ts-expect-error opts.tags has a null guard
const _tags = (opts?.tags?.length ?? 0) > 0 ? serializeTags(opts.tags) : null;
const _tags = (opts?.tags?.length ?? 0) > 0 ? serializeTags(opts?.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);

@@ -24,0 +23,0 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

@@ -94,18 +94,17 @@ import base64url from "base64url";

let offset = 0;
const headerStart = 32 + 64 * index;
const dataItemSize = byteArrayToLong(this.binary.subarray(headerStart, headerStart + 32));
const bundleStart = this.getBundleStart();
let counter = 0;
let _offset, _id;
for (let i = HEADER_START; i < HEADER_START + 64 * this.length; i += 64) {
if (counter == index) {
_offset = byteArrayToLong(this.binary.subarray(i, i + 32));
if (counter++ === index) {
_id = this.binary.subarray(i + 32, i + 64);
break;
}
const _offset = byteArrayToLong(this.binary.subarray(i, i + 32));
offset += _offset;
counter++;
}
const bundleStart = this.getBundleStart();
const dataItemStart = bundleStart + offset;
const slice = this.binary.subarray(dataItemStart, dataItemStart + dataItemSize + 200);
const slice = this.binary.subarray(dataItemStart, dataItemStart + _offset);
const item = new DataItem(slice);
item.rawId = this.binary.slice(32 + 64 * index, 64 + 64 * index);
item.rawId = _id;
return item;

@@ -112,0 +111,0 @@ }

@@ -16,3 +16,3 @@ import { file } from "tmp-promise";

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

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

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

export declare function signedFileStream(path: string, signer: Signer, opts?: DataItemCreateOptions): Promise<Readable>;
export declare const fileExportForTesting: {
fileToFd: (f: File) => Promise<FileHandle>;
};
export {};

@@ -10,3 +10,4 @@ import { createReadStream, promises, read as FSRead } from "fs";

export async function fileToJson(filename) {
const fd = await promises.open(filename, "r").then((handle) => handle.fd);
const handle = await promises.open(filename, "r");
const fd = handle.fd;
let tagsStart = 512 + 512 + 2;

@@ -32,2 +33,3 @@ const targetPresent = await read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);

const signature = "";
await handle.close();
return {

@@ -52,2 +54,3 @@ id,

const headerBuffer = await read(fd.fd, Buffer.alloc(64), 0, 64, 32 + 64 * index).then((v) => v.buffer);
await fd.close();
return {

@@ -91,2 +94,3 @@ offset: byteArrayToLong(headerBuffer.subarray(0, 32)),

if (!targetPresent) {
await fd.close();
return undefined;

@@ -108,2 +112,3 @@ }

if (!anchorPresent) {
await fd.close();
return undefined;

@@ -126,2 +131,3 @@ }

if (numberOfTags == 0) {
await fd.close();
return [];

@@ -138,2 +144,5 @@ }

}
export const fileExportForTesting = {
fileToFd,
};
//# sourceMappingURL=file.js.map

@@ -10,2 +10,3 @@ import FileDataItem from "./FileDataItem.js";

import { createTransactionAsync, uploadTransactionAsync } from "arweave-stream-tx";
import { resolve } from "path";
// import { Readable } from 'stream';

@@ -23,3 +24,13 @@ // import { createTransactionAsync } from 'arweave-stream';

static async fromDir(dir) {
const txs = await promises.readdir(dir).then((r) => r.filter(async (f) => !(await promises.stat(f).then((s) => s.isDirectory()))));
const txs = [];
for (const p of await promises.readdir(dir)) {
const fullPath = resolve(dir, p);
// if it's an item (not a dir,not the header file, actually exists in FS) add to txs array
if (p !== "header" &&
(await promises
.stat(fullPath)
.then((e) => !e.isDirectory())
.catch((_) => false)))
txs.push(fullPath);
}
return new FileBundle(dir + "/header", txs);

@@ -75,4 +86,4 @@ }

const tx = await this.toTransaction({}, arweave, jwk);
tx.addTag("Bundle-Format", "binary");
tx.addTag("Bundle-Version", "2.0.0");
// tx.addTag("Bundle-Format", "binary");
// tx.addTag("Bundle-Version", "2.0.0");
for (const { name, value } of tags) {

@@ -84,2 +95,3 @@ tx.addTag(name, value);

const stream2 = MultiStream.obj(streams2);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await pipeline(stream2, uploadTransactionAsync(tx, arweave, true));

@@ -86,0 +98,0 @@ return tx;

@@ -16,3 +16,4 @@ import base64url from "base64url";

async signatureLength() {
const length = SIG_CONFIG[await this.signatureType()]?.sigLength;
const type = await this.signatureType();
const length = SIG_CONFIG[type]?.sigLength;
if (!length)

@@ -48,3 +49,4 @@ throw new Error("Signature type not supported");

static isDataItem(obj) {
return obj.filename && typeof obj.filename === "string";
// return obj?.filename ? typeof obj.filename === "string" : false;
return obj instanceof FileDataItem;
}

@@ -51,0 +53,0 @@ static async verify(filename) {

@@ -16,1 +16,2 @@ export { default as ArweaveSigner } from "./ArweaveSigner.js";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner.js";
export { default as ArconnectSigner } from "./arconnectSigner.js";

@@ -16,2 +16,3 @@ export { default as ArweaveSigner } from "./ArweaveSigner.js";

export { default as InjectedTypedEthereumSigner } from "./InjectedTypedEthereumSigner.js";
export { default as ArconnectSigner } from "./arconnectSigner.js";
//# sourceMappingURL=index.js.map

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

export declare function keccak256(value: Buffer | BN | string | number): any;
declare function toBuffer(value: any): any;
declare function isHexString(value: any, length?: number): boolean;
declare function padToEven(value: any): any;
declare function stripHexPrefix(value: any): any;
declare function isHexPrefixed(value: any): boolean;
declare function intToBuffer(i: number): Buffer;
declare function intToHex(i: number): string;
export default keccak256;
export declare const exportForTesting: {
intToBuffer: typeof intToBuffer;
intToHex: typeof intToHex;
isHexPrefixed: typeof isHexPrefixed;
stripHexPrefix: typeof stripHexPrefix;
padToEven: typeof padToEven;
isHexString: typeof isHexString;
toBuffer: typeof toBuffer;
};

@@ -85,2 +85,11 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */

export default keccak256;
export const exportForTesting = {
intToBuffer,
intToHex,
isHexPrefixed,
stripHexPrefix,
padToEven,
isHexString,
toBuffer,
};
//# sourceMappingURL=keccak256.js.map

@@ -19,3 +19,3 @@ import base64url from "base64url";

get key() {
return new Uint8Array(0);
throw new Error("You must implement `key`");
}

@@ -22,0 +22,0 @@ sign(message) {

@@ -16,3 +16,3 @@ import base64url from "base64url";

get publicKey() {
return Buffer.alloc(0);
throw new Error("You must implement `publicKey`");
}

@@ -19,0 +19,0 @@ get key() {

/// <reference types="node" />
/// <reference types="node" />
import { PassThrough } from "stream";

@@ -15,1 +16,8 @@ import type { Readable } from "stream";

export declare function streamSigner(s1: Readable, s2: Readable, signer: Signer, opts?: DataItemCreateOptions): Promise<PassThrough>;
declare function readBytes(reader: AsyncGenerator<Buffer>, buffer: Uint8Array, length: number): Promise<Uint8Array>;
declare function getReader(s: Readable): AsyncGenerator<Buffer>;
export declare const streamExportForTesting: {
readBytes: typeof readBytes;
getReader: typeof getReader;
};
export {};

@@ -161,3 +161,3 @@ import { PassThrough, Transform } from "stream";

throw new Error("Invalid buffer");
return readBytes(reader, Buffer.concat([buffer, value]), length);
return readBytes(reader, Buffer.concat([Buffer.from(buffer), Buffer.from(value)]), length);
}

@@ -169,2 +169,6 @@ async function* getReader(s) {

}
export const streamExportForTesting = {
readBytes,
getReader,
};
//# sourceMappingURL=index.js.map

@@ -174,2 +174,5 @@ import { MAX_TAG_BYTES } from "./DataItem.js";

export function serializeTags(tags) {
if (tags?.length === 0) {
return Buffer.allocUnsafe(0);
}
const tap = new AVSCTap();

@@ -176,0 +179,0 @@ tap.writeTags(tags);

@@ -55,3 +55,2 @@ export function longToNByteArray(N, long) {

// const isExtension = typeof browser !== "undefined" || typeof chrome !== "undefined";
// export const isBrowser = (typeof window !== "undefined" && typeof window.document !== "undefined") || isExtension;
//# sourceMappingURL=utils.js.map

@@ -7,2 +7,3 @@ import type { JWKInterface } from "./interface-jwk.js";

export { deepHash } from "./deepHash.js";
export { default as Arweave } from "arweave/web/index.js";
declare const driver: typeof webDriver;

@@ -9,0 +10,0 @@ export declare class CryptoDriver extends driver {

import webDriver from "arweave/web/lib/crypto/webcrypto-driver.js";
export { stringToBuffer, concatBuffers } from "arweave/web/lib/utils.js";
export { deepHash } from "./deepHash.js";
export { default as Arweave } from "arweave/web/index.js";
// import { sha384 as SHA384 } from "sha";

@@ -5,0 +6,0 @@ // export { default as Arweave } from "arweave/web/index.js";

@@ -27,3 +27,13 @@ /// <reference types="node" />

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -57,2 +67,3 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;

@@ -85,3 +96,13 @@ };

InjectedTypedEthereumSigner: typeof arbundlesSrc.InjectedTypedEthereumSigner;
ArconnectSigner: typeof arbundlesSrc.ArconnectSigner;
keccak256(value: string | number | Buffer | import("bn.js")): any;
exportForTesting: {
intToBuffer: (i: number) => Buffer;
intToHex: (i: number) => string;
isHexPrefixed: (value: any) => boolean;
stripHexPrefix: (value: any) => any;
padToEven: (value: any) => any;
isHexString: (value: any, length?: number | undefined) => boolean;
toBuffer: (value: any) => any;
};
unbundleData(txData: Buffer): arbundlesSrc.Bundle;

@@ -115,3 +136,4 @@ bundleAndSignData(dataItems: arbundlesSrc.DataItem[], signer: arbundlesSrc.Signer): Promise<arbundlesSrc.Bundle>;

deepHash: typeof arbundlesSrc.deepHash;
Arweave: typeof arbundlesSrc.Arweave;
CryptoDriver: typeof arbundlesSrc.CryptoDriver;
};
{
"name": "arbundles",
"version": "0.9.6",
"version": "0.9.7",
"description": "Arweave bundling library",

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

"aptos": "^1.3.13",
"arconnect": "^0.4.2",
"assert": "^2.0.0",

@@ -99,0 +100,0 @@ "avsc": "https://github.com/Bundlr-Network/avsc#csp-fixes",

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

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 too big to display

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

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