Socket
Socket
Sign inDemoInstall

arbundles

Package Overview
Dependencies
Maintainers
3
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.3.5

build/file/bundleData.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.

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

function createData(data, signer, opts) {
var _a, _b, _c, _d, _e, _f, _g;
// TODO: Add asserts
// Parse all values to a buffer and
const _owner = signer.publicKey;
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_length = 1 + (_anchor?.byteLength ?? 0);
const _tags = (opts?.tags?.length ?? 0) > 0 ? parser_1.serializeTags(opts.tags) : null;
const _target = (opts === null || opts === void 0 ? void 0 : opts.target) ? base64url_1.default.toBuffer(opts.target) : null;
const target_length = 1 + ((_a = _target === null || _target === void 0 ? void 0 : _target.byteLength) !== null && _a !== void 0 ? _a : 0);
const _anchor = (opts === null || opts === void 0 ? void 0 : opts.anchor) ? Buffer.from(opts.anchor) : null;
const anchor_length = 1 + ((_b = _anchor === null || _anchor === void 0 ? void 0 : _anchor.byteLength) !== null && _b !== void 0 ? _b : 0);
const _tags = ((_d = (_c = opts === null || opts === void 0 ? void 0 : opts.tags) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ? parser_1.serializeTags(opts.tags) : null;
const tags_length = 16 + (_tags ? _tags.byteLength : 0);

@@ -68,4 +69,4 @@ const _data = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);

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

@@ -72,0 +73,0 @@ if (_tags) {

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: {

@@ -148,3 +151,4 @@ throw new Error("Unknown signature type: " + signatureTypeVal);

isSigned() {
return (this._id?.length ?? 0) > 0;
var _a, _b;
return ((_b = (_a = this._id) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
}

@@ -151,0 +155,0 @@ /**

/// <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, };
export * from "./signing";
import { verifyAndIndexStream } from "./stream";
import { ArweaveSigner } from "./signing";
import SolanaSigner from "./signing/chains/SolanaSigner";
import EthereumSigner from "./signing/chains/ethereumSigner";
export { MIN_BINARY_SIZE, Bundle, DataItem, createData, bundleAndSignData, unbundleData, deepHash, DataItemCreateOptions, verifyAndIndexStream, };
declare const signers: {
ArweaveSigner: typeof ArweaveSigner;
SolanaSigner: typeof SolanaSigner;
EthereumSigner: typeof EthereumSigner;
};
export { signers };

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

};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -29,3 +26,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

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.signers = 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");

@@ -39,7 +36,17 @@ 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; } });
__exportStar(require("./signing"), exports);
const stream_1 = require("./stream");
Object.defineProperty(exports, "verifyAndIndexStream", { enumerable: true, get: function () { return stream_1.verifyAndIndexStream; } });
const signing_1 = require("./signing");
const SolanaSigner_1 = __importDefault(require("./signing/chains/SolanaSigner"));
const ethereumSigner_1 = __importDefault(require("./signing/chains/ethereumSigner"));
const signers = {
ArweaveSigner: signing_1.ArweaveSigner,
SolanaSigner: SolanaSigner_1.default,
EthereumSigner: ethereumSigner_1.default,
};
exports.signers = signers;
//# 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
{
"name": "arbundles",
"version": "0.3.4",
"version": "0.3.5",
"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')) {process.exit(1)}\" || 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",

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

# Arweave Bundles
# ANS-104 Bundles
A library for creating, editing, reading and verifying bundles.
**If you want to use Bundlr Network head over to [this repo](https://github.com/Bundlr-Network/js-client)**
A low level library for creating, editing, reading and verifying bundles.
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.

@@ -14,7 +16,7 @@ If you wish to upload a transactions >250mb submit a standard transaction via [arweave-js](https://github.com/ArweaveTeam/arweave-js).

```npm install arbundles```
`npm install arbundles`
Using yarn:
```yarn add arbundles```
`yarn add arbundles`

@@ -26,6 +28,3 @@ ## Creating bundles

const dataItems = [
createData("some data"),
createData("some other data")
];
const dataItems = [createData("some data"), createData("some other data")];

@@ -37,66 +36,5 @@ const signer = new ArweaveSigner(jwk);

It's as simple as that! All the binary encoding is handled for you.
## Creating and sending data to a Bundler
```ts
import { createData } from "arbundles";
const signer = new ArweaveSigner(jwk);
const dataItem = createData("some message", signer);
// Get owner in base64url encoded string
const owner = dataItem.owner;
// Sign a single DataItem
await dataItem.sign(jwk);
const response = dataItem.sendToBundler();
```
## Get a DataItem in a bundle
```ts
const bundle = await bundleAndSignData(dataItems, jwk);
// Get by index
const byIndex = bundle.get(0);
// Get by transaction id
const byId = bundle.get("hKMMPNh_emBf8v_at1tFzNYACisyMQNcKzeeE1QE9p8");
// Get all DataItems
const all = bundle.items;
```
## Submit a transaction
```ts
const bundle = await bundleAndSignData(dataItems, jwk);
// Convert bundle to Arweave transaction
const tx = await bundle.toTransaction(arweave, jwk);
// Add some more tags after creation.
tx.addTag('MyTag', 'value1');
tx.addTag('MyTag', 'value2');
await arweave.transactions.sign(tx, jwk);
await arweave.transactions.post(tx);
```
## Parse a bundle binary
```ts
import { Bundle } from "arbundles";
const data = await arweave.transactions.getData("hKMMPNh_emBf8v_at1tFzNYACisyMQNcKzeeE1QE9p8", { decode: true });
const bundle = new Bundle(Buffer.from(data));
```
# File API
This API is *experimental* so avoid use in production. There's one issue that exists that may affect it's overall
This API is _experimental_ so avoid use in production. There's one issue that exists that may affect it's overall
functionality and could lead to breaking changes.

@@ -103,0 +41,0 @@

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