Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
Maintainers
2
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.3.4 to 0.4.0

build/signing/chains/ethereumSigner.d.ts

2

build/ar-data-base.d.ts

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

import DataItem from './DataItem';
import DataItem from "./DataItem";
/**

@@ -3,0 +3,0 @@ * Options for creation of a DataItem

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

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -30,8 +27,8 @@ exports.getSignatureData = void 0;

const utils_2 = require("./utils");
const deepHash_1 = __importDefault(require("./deepHash"));
const deepHash_1 = require("./deepHash");
async function getSignatureData(item) {
if (utils_2.isBrowser) {
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()),

@@ -46,5 +43,5 @@ item.rawOwner,

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

@@ -51,0 +48,0 @@ item.rawOwner,

/// <reference types="node" />
import DataItem from './DataItem';
import Bundle from './Bundle';
import { Signer } from './signing/Signer';
import DataItem from "./DataItem";
import Bundle from "./Bundle";
import { Signer } from "./signing/Signer";
/**

@@ -6,0 +6,0 @@ * Unbundles a transaction into an Array of DataItems.

export declare enum SignatureConfig {
ARWEAVE = 1,
SOLANA = 2,
ED25519 = 2,
ETHERIUM = 3

@@ -5,0 +5,0 @@ }

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

SignatureConfig[SignatureConfig["ARWEAVE"] = 1] = "ARWEAVE";
SignatureConfig[SignatureConfig["SOLANA"] = 2] = "SOLANA";
SignatureConfig[SignatureConfig["ED25519"] = 2] = "ED25519";
SignatureConfig[SignatureConfig["ETHERIUM"] = 3] = "ETHERIUM";

@@ -18,3 +18,3 @@ })(SignatureConfig = exports.SignatureConfig || (exports.SignatureConfig = {}));

// ed25519 - Solana
[SignatureConfig.SOLANA]: {
[SignatureConfig.ED25519]: {
sigLength: 64,

@@ -25,3 +25,3 @@ pubLength: 32,

[SignatureConfig.ETHERIUM]: {
sigLength: 64,
sigLength: 65,
pubLength: 65,

@@ -28,0 +28,0 @@ },

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

case 2: {
return constants_1.SignatureConfig.SOLANA;
return constants_1.SignatureConfig.ED25519;
}

@@ -37,2 +37,5 @@ case 3: {

}
case 4: {
return constants_1.SignatureConfig.ETHERIUM;
}
default: {

@@ -39,0 +42,0 @@ throw new Error("Unknown signature type: " + signatureTypeVal);

/// <reference types="node" />
declare type DeepHashChunk = Uint8Array | AsyncIterable<Buffer> | DeepHashChunks;
declare type DeepHashChunks = DeepHashChunk[];
export default function deepHash(data: DeepHashChunk): Promise<Uint8Array>;
export declare type DeepHashChunk = Uint8Array | AsyncIterable<Buffer> | DeepHashChunks;
export declare type DeepHashChunks = DeepHashChunk[];
export declare function deepHash(data: DeepHashChunk): Promise<Uint8Array>;
export declare function deepHashChunks(chunks: DeepHashChunks, acc: Uint8Array): Promise<Uint8Array>;
export declare function hashStream(stream: AsyncIterable<Buffer>): Promise<Buffer>;
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.hashStream = void 0;
exports.hashStream = exports.deepHashChunks = exports.deepHash = void 0;
// In TypeScript 3.7, could be written as a single type:

@@ -50,3 +50,3 @@ // `type DeepHashChunk = Uint8Array | DeepHashChunk[];`

}
exports.default = deepHash;
exports.deepHash = deepHash;
async function deepHashChunks(chunks, acc) {

@@ -63,2 +63,3 @@ if (chunks.length < 1) {

}
exports.deepHashChunks = deepHashChunks;
async function hashStream(stream) {

@@ -65,0 +66,0 @@ const context = crypto_1.createHash("sha384");

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

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.deepHash = exports.unbundleData = exports.bundleAndSignData = exports.createData = exports.DataItem = exports.Bundle = exports.MIN_BINARY_SIZE = void 0;
exports.verifyAndIndexStream = exports.deepHash = exports.unbundleData = exports.bundleAndSignData = exports.createData = exports.DataItem = exports.Bundle = exports.MIN_BINARY_SIZE = void 0;
const ar_data_bundle_1 = require("./ar-data-bundle");

@@ -38,7 +38,9 @@ Object.defineProperty(exports, "bundleAndSignData", { enumerable: true, get: function () { return ar_data_bundle_1.bundleAndSignData; } });

Object.defineProperty(exports, "MIN_BINARY_SIZE", { enumerable: true, get: function () { return DataItem_1.MIN_BINARY_SIZE; } });
const deepHash_1 = __importDefault(require("./deepHash"));
exports.deepHash = deepHash_1.default;
const deepHash_1 = require("./deepHash");
Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deepHash_1.deepHash; } });
const ar_data_create_1 = require("./ar-data-create");
Object.defineProperty(exports, "createData", { enumerable: true, get: function () { return ar_data_create_1.createData; } });
const stream_1 = require("./stream");
Object.defineProperty(exports, "verifyAndIndexStream", { enumerable: true, get: function () { return stream_1.verifyAndIndexStream; } });
__exportStar(require("./signing"), exports);
//# sourceMappingURL=index.js.map
import ArweaveSigner from "./ArweaveSigner";
export * from "./ethereum";
export * from "./ethereumSigner";
import PolygonSigner from "./PolygonSigner";
export * from "./SolanaSigner";
export { ArweaveSigner, PolygonSigner };

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

exports.ArweaveSigner = ArweaveSigner_1.default;
__exportStar(require("./ethereum"), exports);
__exportStar(require("./ethereumSigner"), exports);
const PolygonSigner_1 = __importDefault(require("./PolygonSigner"));

@@ -22,0 +22,0 @@ exports.PolygonSigner = PolygonSigner_1.default;

@@ -1,3 +0,3 @@

import Ethereum from "./ethereum";
export default class PolygonSigner extends Ethereum {
import EthereumSigner from "./ethereumSigner";
export default class PolygonSigner extends EthereumSigner {
}

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

Object.defineProperty(exports, "__esModule", { value: true });
const ethereum_1 = __importDefault(require("./ethereum"));
class PolygonSigner extends ethereum_1.default {
const ethereumSigner_1 = __importDefault(require("./ethereumSigner"));
class PolygonSigner extends ethereumSigner_1.default {
}
exports.default = PolygonSigner;
//# sourceMappingURL=PolygonSigner.js.map

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

const curve25519_1 = __importDefault(require("./keys/curve25519"));
const ethereum_1 = __importDefault(require("./chains/ethereum"));
const ethereumSigner_1 = __importDefault(require("./chains/ethereumSigner"));
const chains_1 = require("./chains");

@@ -20,4 +20,4 @@ exports.indexToType = {

// @ts-ignore
3: ethereum_1.default
3: ethereumSigner_1.default,
};
//# sourceMappingURL=constants.js.map
/// <reference types="node" />
import { PathLike } from 'fs';
import { BundleItem } from '../build/BundleItem';
import { Signer } from '../build/signing';
import { AxiosResponse } from 'axios';
import { PathLike } from "fs";
import { BundleItem } from "../build/BundleItem";
import { Signer } from "../build/signing";
import { AxiosResponse } from "axios";
export default class FileDataItem implements BundleItem {

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

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

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

@@ -69,6 +69,6 @@ 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 handle = await fs.promises.open(filename, "r");
const item = new FileDataItem(filename);

@@ -95,9 +95,5 @@ const sigType = await item.signatureType();

const owner = await item.rawOwner();
let b = Buffer.alloc(0);
for await (const chunk of fs.createReadStream(filename, { start: await item.dataStart() })) {
b = Buffer.concat([b, chunk]);
}
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()),

@@ -130,3 +126,3 @@ owner,

async signatureType() {
const handle = await fs.promises.open(this.filename, 'r');
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);

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

async rawSignature() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const length = await this.signatureLength();

@@ -148,5 +144,5 @@ const buffer = await read(handle.fd, Buffer.alloc(length), 0, length, 2).then((r) => r.buffer);

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

@@ -159,3 +155,3 @@ return buffer;

async rawTarget() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const targetStart = await this.getTargetStart();

@@ -176,3 +172,3 @@ const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);

async getTargetStart() {
return 2 + await this.signatureLength() + await this.ownerLength();
return 2 + (await this.signatureLength()) + (await this.ownerLength());
}

@@ -182,3 +178,3 @@ async rawAnchor() {

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

@@ -194,8 +190,10 @@ await handle.close();

async rawTags() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const tagsStart = await this.getTagsStart();
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)
if (numberOfTags === 0) {
await handle.close();
return Buffer.allocUnsafe(0);
}
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);

@@ -205,3 +203,3 @@ const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);

await handle.close();
throw new Error('Tags too large');
throw new Error("Tags too large");
}

@@ -225,3 +223,3 @@ const tagsBytes = await read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);

}
const handle = await fs.promises.open(this.filename, 'r');
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);

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

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((await this.signatureType()).toString()),

@@ -249,3 +247,3 @@ await this.rawOwner(),

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, await this.signatureLength(), 2);

@@ -261,6 +259,6 @@ this.rawId = Buffer.from(idBytes);

const headers = {
'Content-Type': 'application/octet-stream',
"Content-Type": "application/octet-stream",
};
if (!this.isSigned())
throw new Error('You must sign before sending to bundler');
throw new Error("You must sign before sending to bundler");
const response = await axios_1.default.post(`${bundler}/tx`, fs.createReadStream(this.filename), {

@@ -273,3 +271,3 @@ headers,

if (response.status === 402)
throw new Error('Not enough funds to send data');
throw new Error("Not enough funds to send data");
return response;

@@ -284,3 +282,3 @@ }

async dataStart() {
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const tagsStart = await this.getTagsStart();

@@ -294,3 +292,3 @@ const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);

const targetStart = await this.getTargetStart();
const handle = await fs.promises.open(this.filename, 'r');
const handle = await fs.promises.open(this.filename, "r");
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);

@@ -297,0 +295,0 @@ const targetPresent = targetPresentBuffer[0] === 1;

import ArweaveSigner from "./ArweaveSigner";
export * from "./ethereum";
export * from "./ethereumSigner";
import PolygonSigner from "./PolygonSigner";
export * from "./SolanaSigner";
export { ArweaveSigner, PolygonSigner };

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

exports.ArweaveSigner = ArweaveSigner_1.default;
__exportStar(require("./ethereum"), exports);
__exportStar(require("./ethereumSigner"), exports);
const PolygonSigner_1 = __importDefault(require("./PolygonSigner"));

@@ -22,0 +22,0 @@ exports.PolygonSigner = PolygonSigner_1.default;

@@ -1,3 +0,3 @@

import Ethereum from "./ethereum";
export default class PolygonSigner extends Ethereum {
import EthereumSigner from "./ethereumSigner";
export default class PolygonSigner extends EthereumSigner {
}

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

Object.defineProperty(exports, "__esModule", { value: true });
const ethereum_1 = __importDefault(require("./ethereum"));
class PolygonSigner extends ethereum_1.default {
const ethereumSigner_1 = __importDefault(require("./ethereumSigner"));
class PolygonSigner extends ethereumSigner_1.default {
}
exports.default = PolygonSigner;
//# sourceMappingURL=PolygonSigner.js.map

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

const curve25519_1 = __importDefault(require("./keys/curve25519"));
const ethereum_1 = __importDefault(require("./chains/ethereum"));
const ethereumSigner_1 = __importDefault(require("./chains/ethereumSigner"));
const chains_1 = require("./chains");

@@ -20,4 +20,4 @@ exports.indexToType = {

// @ts-ignore
3: ethereum_1.default
3: ethereumSigner_1.default,
};
//# sourceMappingURL=constants.js.map
{
"name": "arbundles",
"version": "0.3.4",
"version": "0.4.0",
"description": "Arweave bundling library",

@@ -15,6 +15,10 @@ "author": "Josh Benaron <joshbenaron@gmail.com>",

"scripts": {
"build": "rm -rf file && tsc && mv file ./ && cp -a build/signing file && rm -rf build/__tests__",
"build": "rm -rf file lib build && tsc",
"lint": "eslint ./src -c ./.eslintrc.json --ext .ts,.tsx",
"test": "jest --coverage",
"prepare": "husky install"
"husky-install": "(node -e \"if (!require('fs').existsSync(__dirname + '/.git')) {process.exit(1)}\" && husky install || true)",
"ensure-build": "(node -e \"if (!require('fs').existsSync(__dirname + '/build')) {console.error('DOESNT EXIST'); process.exit(1)} else {console.error('IT EXISTS ALREADY')}\" || yarn run build)",
"postinstall": "yarn run ensure-build",
"prepack": "yarn run ensure-build",
"prepare": "yarn run husky-install"
},

@@ -60,2 +64,3 @@ "devDependencies": {

"curve25519-js": "^0.0.4",
"ethers": "^5.5.1",
"keccak256": "^1.0.3",

@@ -62,0 +67,0 @@ "multistream": "^4.1.0",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc