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.6.9 to 0.6.10

2

package.json
{
"name": "arbundles",
"version": "0.6.9",
"version": "0.6.10",
"description": "Arweave bundling library",

@@ -5,0 +5,0 @@ "author": "Josh Benaron <joshbenaron@gmail.com>",

/// <reference types="node" />
import { Readable } from "stream";
export declare function verifyAndIndexStream(stream: Readable): Promise<Record<string, any>[]>;
export default function processStream(stream: Readable): Promise<Record<string, any>[]>;

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

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

@@ -37,10 +36,10 @@ const utils_1 = require("../src/utils");

const deepHash_1 = require("../src/deepHash");
async function verifyAndIndexStream(stream) {
async function processStream(stream) {
const reader = getReader(stream);
let bytes = (await reader.next()).value;
bytes = await hasEnough(reader, bytes, 32);
bytes = await readBytes(reader, bytes, 32);
const itemCount = utils_1.byteArrayToLong(bytes.subarray(0, 32));
bytes = bytes.subarray(32);
const headersLength = 64 * itemCount;
bytes = await hasEnough(reader, bytes, headersLength);
bytes = await readBytes(reader, bytes, headersLength);
const headers = new Array(itemCount);

@@ -57,5 +56,5 @@ for (let i = 0; i < headersLength; i += 64) {

for (const [length, id] of headers) {
bytes = await hasEnough(reader, bytes, index_1.MIN_BINARY_SIZE);
bytes = await readBytes(reader, bytes, index_1.MIN_BINARY_SIZE);
// Get sig type
bytes = await hasEnough(reader, bytes, 2);
bytes = await readBytes(reader, bytes, 2);
const signatureType = utils_1.byteArrayToLong(bytes.subarray(0, 2));

@@ -65,14 +64,14 @@ bytes = bytes.subarray(2);

// Get sig
bytes = await hasEnough(reader, bytes, sigLength);
bytes = await readBytes(reader, bytes, sigLength);
const signature = bytes.subarray(0, sigLength);
bytes = bytes.subarray(sigLength);
// Get owner
bytes = await hasEnough(reader, bytes, pubLength);
bytes = await readBytes(reader, bytes, pubLength);
const owner = bytes.subarray(0, pubLength);
bytes = bytes.subarray(pubLength);
// Get target
bytes = await hasEnough(reader, bytes, 1);
bytes = await readBytes(reader, bytes, 1);
const targetPresent = bytes[0] === 1;
if (targetPresent)
bytes = await hasEnough(reader, bytes, 33);
bytes = await readBytes(reader, bytes, 33);
const target = targetPresent

@@ -83,6 +82,6 @@ ? bytes.subarray(1, 33)

// Get anchor
bytes = await hasEnough(reader, bytes, 1);
bytes = await readBytes(reader, bytes, 1);
const anchorPresent = bytes[0] === 1;
if (anchorPresent)
bytes = await hasEnough(reader, bytes, 33);
bytes = await readBytes(reader, bytes, 33);
const anchor = anchorPresent

@@ -93,9 +92,9 @@ ? bytes.subarray(1, 33)

// Get tags
bytes = await hasEnough(reader, bytes, 8);
bytes = await readBytes(reader, bytes, 8);
const tagsLength = utils_1.byteArrayToLong(bytes.subarray(0, 8));
bytes = bytes.subarray(8);
bytes = await hasEnough(reader, bytes, 8);
bytes = await readBytes(reader, bytes, 8);
const tagsBytesLength = utils_1.byteArrayToLong(bytes.subarray(0, 8));
bytes = bytes.subarray(8);
bytes = await hasEnough(reader, bytes, tagsBytesLength);
bytes = await readBytes(reader, bytes, tagsBytesLength);
const tagsBytes = bytes.subarray(0, tagsBytesLength);

@@ -175,10 +174,10 @@ const tags = tagsLength !== 0 && tagsBytesLength !== 0

}
exports.verifyAndIndexStream = verifyAndIndexStream;
async function hasEnough(reader, buffer, length) {
exports.default = processStream;
async function readBytes(reader, buffer, length) {
if (buffer.byteLength > length)
return buffer;
buffer = Buffer.concat([buffer, (await reader.next()).value]);
if (buffer.byteLength > length)
return buffer;
return buffer;
const { done, value } = await reader.next();
if (done && !value)
throw new Error("Invalid buffer");
return readBytes(reader, Buffer.concat([buffer, value]), length);
}

@@ -185,0 +184,0 @@ async function* getReader(s) {

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