Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.17-rc1 to 0.7.0-rc1

esm/bundle.js

8

file/createData.d.ts
/// <reference types="node" />
import FileDataItem from "./FileDataItem";
import { DataItemCreateOptions } from "../src/ar-data-base";
import { DataItemCreateOptions } from "../src/arDataBase";
import { Signer } from "../src/signing";
/**
* @param data
* @param signer
* @param opts
* @returns
*/
export declare function createData(data: string | Uint8Array | NodeJS.ReadableStream, signer: Signer, opts?: DataItemCreateOptions): Promise<FileDataItem>;

24

file/createData.js

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

const base64url_1 = __importDefault(require("base64url"));
const assert_1 = __importDefault(require("assert"));
const utils_1 = require("../src/utils");
const parser_1 = require("../src/parser");
const promises_1 = require("stream/promises");
/**
* @param data
* @param signer
* @param opts
* @returns
*/
async function createData(data, signer, opts) {

@@ -39,4 +44,2 @@ var _a, _b, _c, _d, _e;

const stream = fs.createWriteStream(filename);
// TODO: Add asserts
// Parse all values to a buffer and
const _owner = signer.publicKey;

@@ -47,9 +50,12 @@ const _target = (opts === null || opts === void 0 ? void 0 : opts.target) ? base64url_1.default.toBuffer(opts.target) : null;

stream.write(utils_1.shortTo2ByteArray(signer.signatureType));
// Signature
stream.write(new Uint8Array(signer.signatureLength).fill(0));
assert_1.default(_owner.byteLength == signer.ownerLength, new Error(`Owner must be ${signer.ownerLength} bytes`));
if (_owner.byteLength != signer.ownerLength) {
throw new Error(`Owner must be ${signer.ownerLength} bytes`);
}
stream.write(_owner);
stream.write(_target ? singleItemBuffer(1) : singleItemBuffer(0));
if (_target) {
assert_1.default(_target.byteLength == 32, new Error("Target must be 32 bytes"));
if (_target.byteLength != 32) {
throw new Error("Target must be 32 bytes");
}
stream.write(_target);

@@ -59,7 +65,7 @@ }

if (_anchor) {
assert_1.default(_anchor.byteLength == 32, new Error("Anchor must be 32 bytes"));
if (_anchor.byteLength != 32) {
throw new Error("Anchor must be 32 bytes");
}
stream.write(_anchor);
}
// TODO: Shall I manually add 8 bytes?
// TODO: Finish this
stream.write(utils_1.longTo8ByteArray((_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));

@@ -66,0 +72,0 @@ const bytesCount = utils_1.longTo8ByteArray((_e = _tags === null || _tags === void 0 ? void 0 : _tags.byteLength) !== null && _e !== void 0 ? _e : 0);

/// <reference types="node" />
import * as fs from "fs";
import { FileHandle } from "fs/promises";
declare type File = string | FileHandle;
export declare const read: (fd: number, buffer: any, offset: number, length: number, position: fs.ReadPosition) => Promise<{
buffer: Buffer;
bytesRead: number;
}>;
export declare const write: (fd: number, buffer: any, offset: number, length: number, position: number) => Promise<{
buffer: Buffer;
written: number;
}>;
interface Transaction {

@@ -5,0 +14,0 @@ id: string;

@@ -25,9 +25,29 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = void 0;
exports.getTags = exports.getAnchor = exports.getTarget = exports.getOwner = exports.getSignature = exports.getId = exports.getHeaders = exports.getHeaderAt = exports.numberOfItems = exports.fileToJson = exports.write = exports.read = void 0;
const fs = __importStar(require("fs"));
const util_1 = require("util");
const utils_1 = require("../src/utils");
const parser_1 = require("../src/parser");
const base64url_1 = __importDefault(require("base64url"));
const read = util_1.promisify(fs.read);
const read = async (fd, buffer, offset, length, position) => {
return new Promise((res, rej) => {
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
if (err) {
rej(err);
}
res({ bytesRead, buffer });
});
});
};
exports.read = read;
const write = async (fd, buffer, offset, length, position) => {
return new Promise((res, rej) => {
fs.write(fd, buffer, offset, length, position, (err, written, buffer) => {
if (err) {
rej(err);
}
res({ written, buffer });
});
});
};
exports.write = write;
const fileToFd = async (f) => typeof f === "string" ? await fs.promises.open(f, "r") : f;

@@ -37,13 +57,13 @@ async function fileToJson(filename) {

let tagsStart = 512 + 512 + 2;
const targetPresent = await read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);
const targetPresent = await exports.read(fd, Buffer.alloc(1), 1024, 64, null).then((value) => value.buffer[0] == 1);
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = targetPresent ? 1057 : 1025;
const anchorPresent = await read(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then((value) => value.buffer[0] == 1);
const anchorPresent = await exports.read(fd, Buffer.alloc(1), anchorPresentByte, 64, null).then((value) => value.buffer[0] == 1);
tagsStart += anchorPresent ? 32 : 0;
const numberOfTags = utils_1.byteArrayToLong(await read(fd, Buffer.alloc(8), tagsStart, 8, 0).then((value) => value.buffer));
const numberOfTags = utils_1.byteArrayToLong(await exports.read(fd, Buffer.alloc(8), tagsStart, 8, 0).then((value) => value.buffer));
let tags = [];
if (numberOfTags > 0) {
const numberOfTagBytesArray = await read(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then((value) => value.buffer);
const numberOfTagBytesArray = await exports.read(fd, Buffer.alloc(8), tagsStart + 8, 8, 0).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await read(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then((value) => value.buffer);
const tagBytes = await exports.read(fd, Buffer.alloc(8), tagsStart + 16, numberOfTagBytes, 0).then((value) => value.buffer);
tags = parser_1.tagsParser.fromBuffer(tagBytes);

@@ -70,3 +90,3 @@ }

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

@@ -78,3 +98,3 @@ return utils_1.byteArrayToLong(headerBuffer);

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

@@ -97,3 +117,3 @@ offset: utils_1.byteArrayToLong(headerBuffer.subarray(0, 32)),

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -107,3 +127,3 @@ return buffer;

const offset = (_a = options.offset) !== null && _a !== void 0 ? _a : 0;
const buffer = await read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
const buffer = await exports.read(fd.fd, Buffer.allocUnsafe(512), offset, 512, null).then((r) => r.buffer);
await fd.close();

@@ -117,3 +137,3 @@ return buffer;

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

@@ -128,7 +148,7 @@ return base64url_1.default.encode(buffer);

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

@@ -142,3 +162,3 @@ return base64url_1.default.encode(buffer);

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

@@ -148,7 +168,7 @@ if (targetPresent) {

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

@@ -163,14 +183,14 @@ return base64url_1.default.encode(buffer);

let tagsStart = 512 + 512 + 2 + ((_b = options === null || options === void 0 ? void 0 : options.offset) !== null && _b !== void 0 ? _b : 0);
const targetPresent = await read(fd.fd, Buffer.allocUnsafe(1), 0, 1, offset + 1024).then((value) => value.buffer[0] == 1);
const targetPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), 0, 1, offset + 1024).then((value) => value.buffer[0] == 1);
tagsStart += targetPresent ? 32 : 0;
const anchorPresentByte = offset + (targetPresent ? 1057 : 1025);
const anchorPresent = await read(fd.fd, Buffer.allocUnsafe(1), 0, 1, anchorPresentByte).then((value) => value.buffer[0] == 1);
const anchorPresent = await exports.read(fd.fd, Buffer.allocUnsafe(1), 0, 1, anchorPresentByte).then((value) => value.buffer[0] == 1);
tagsStart += anchorPresent ? 32 : 0;
const numberOfTags = utils_1.byteArrayToLong(await read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((value) => value.buffer));
const numberOfTags = utils_1.byteArrayToLong(await exports.read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((value) => value.buffer));
if (numberOfTags == 0) {
return [];
}
const numberOfTagBytesArray = await read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((value) => value.buffer);
const numberOfTagBytesArray = await exports.read(fd.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((value) => value.buffer);
const numberOfTagBytes = utils_1.byteArrayToLong(numberOfTagBytesArray);
const tagBytes = await read(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then((value) => value.buffer);
const tagBytes = await exports.read(fd.fd, Buffer.allocUnsafe(numberOfTagBytes), 0, numberOfTagBytes, tagsStart + 16).then((value) => value.buffer);
await fd.close();

@@ -177,0 +197,0 @@ return parser_1.tagsParser.fromBuffer(tagBytes);

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

const multistream_1 = __importDefault(require("multistream"));
const util_1 = require("util");
const base64url_1 = __importDefault(require("base64url"));

@@ -37,3 +36,3 @@ const promises_1 = require("stream/promises");

// import { pipeline } from 'stream/promises';
const read = util_1.promisify(fs.read);
const file_1 = require("./file");
class FileBundle {

@@ -52,3 +51,3 @@ constructor(headerFile, txs) {

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

@@ -123,4 +122,4 @@ return utils_1.byteArrayToLong(lengthBuffer);

yield {
offset: utils_1.byteArrayToLong(await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then((r) => r.buffer)),
id: await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then((r) => base64url_1.default.encode(r.buffer)),
offset: utils_1.byteArrayToLong(await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i).then((r) => r.buffer)),
id: await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, i + 32).then((r) => base64url_1.default.encode(r.buffer)),
};

@@ -127,0 +126,0 @@ }

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

const arweave_1 = __importDefault(require("arweave"));
const util_1 = require("util");
const signing_1 = require("../src/signing");
const axios_1 = __importDefault(require("axios"));
const constants_1 = require("../src/constants");
const write = util_1.promisify(fs.write);
const read = util_1.promisify(fs.read);
const file_1 = require("./file");
class FileDataItem {

@@ -78,4 +76,4 @@ constructor(filename, id) {

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

@@ -85,3 +83,3 @@ await handle.close();

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

@@ -129,3 +127,3 @@ try {

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

@@ -137,3 +135,3 @@ return utils_1.byteArrayToLong(buffer);

const length = await this.signatureLength();
const buffer = await read(handle.fd, Buffer.alloc(length), 0, length, 2).then((r) => r.buffer);
const buffer = await file_1.read(handle.fd, Buffer.alloc(length), 0, length, 2).then((r) => r.buffer);
await handle.close();

@@ -148,3 +146,3 @@ return buffer;

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 file_1.read(handle.fd, Buffer.allocUnsafe(length), 0, length, 2 + (await this.signatureLength())).then((r) => r.buffer);
await handle.close();

@@ -159,6 +157,6 @@ return buffer;

const targetStart = await this.getTargetStart();
const targetPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;
if (targetPresent) {
const targetBuffer = await read(handle.fd, Buffer.allocUnsafe(32), 0, 32, targetStart + 1).then((r) => r.buffer);
const targetBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, targetStart + 1).then((r) => r.buffer);
await handle.close();

@@ -180,3 +178,3 @@ return targetBuffer;

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);
const anchorBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(32), 0, 32, anchorStart + 1).then((r) => r.buffer);
await handle.close();

@@ -193,3 +191,3 @@ return anchorBuffer;

const tagsStart = await this.getTagsStart();
const numberOfTagsBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => r.buffer);
const numberOfTagsBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart).then((r) => r.buffer);
const numberOfTags = utils_1.byteArrayToLong(numberOfTagsBuffer);

@@ -200,3 +198,3 @@ if (numberOfTags === 0) {

}
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytesBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);

@@ -207,3 +205,3 @@ if (numberOfTagsBytes > 2048) {

}
const tagsBytes = await read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
const tagsBytes = await file_1.read(handle.fd, Buffer.allocUnsafe(numberOfTagsBytes), 0, numberOfTagsBytes, tagsStart + 16).then((r) => r.buffer);
await handle.close();

@@ -226,3 +224,3 @@ return tagsBytes;

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

@@ -249,3 +247,3 @@ return dataBuffer;

const handle = await fs.promises.open(this.filename, "r+");
await write(handle.fd, signatureBytes, 0, await this.signatureLength(), 2);
await file_1.write(handle.fd, signatureBytes, 0, await this.signatureLength(), 2);
this.rawId = Buffer.from(idBytes);

@@ -283,3 +281,3 @@ await handle.close();

const tagsStart = await this.getTagsStart();
const numberOfTagsBytesBuffer = await read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytesBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(8), 0, 8, tagsStart + 8).then((r) => r.buffer);
const numberOfTagsBytes = utils_1.byteArrayToLong(numberOfTagsBytesBuffer);

@@ -292,6 +290,6 @@ await handle.close();

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);
const targetPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, targetStart).then((r) => r.buffer);
const targetPresent = targetPresentBuffer[0] === 1;
const anchorStart = targetStart + (targetPresent ? 33 : 1);
const anchorPresentBuffer = await read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresentBuffer = await file_1.read(handle.fd, Buffer.allocUnsafe(1), 0, 1, anchorStart).then((r) => r.buffer);
const anchorPresent = anchorPresentBuffer[0] === 1;

@@ -298,0 +296,0 @@ await handle.close();

{
"name": "arbundles",
"version": "0.6.17-rc1",
"version": "0.7.0-rc1",
"description": "Arweave bundling library",

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

"main": "src/index.js",
"browser": "esm/shim.js",
"types": "index.d.ts",

@@ -22,6 +23,15 @@ "files": [

"file/**/*.js.map",
"file/**/*.d.ts"
"file/**/*.d.ts",
"esm/**/*.js",
"esm/**/*.js.map",
"esm/**/*.d.ts",
"shim.js",
"shim.d.ts",
"shim.js.map",
"standaloneShim.js",
"standaloneShim.d.ts",
"standaloneShim.js/map"
],
"scripts": {
"build": "tsc",
"build": "tsc -p tsconfig.json && tsc -p esm.tsconfig.json && webpack",
"lint": "eslint ./src -c ./.eslintrc.json --ext .ts,.tsx",

@@ -35,6 +45,20 @@ "test": "jest --coverage",

"devDependencies": {
"@metamask/eth-sig-util": "^4.0.0",
"@noble/ed25519": "^1.6.0",
"@randlabs/myalgo-connect": "^1.1.2",
"@solana/wallet-adapter-base": "^0.9.2",
"@types/bs58": "^4.0.1",
"@types/jest": "~26.0.23",
"@types/multistream": "^2.1.1",
"@types/node": "^17.0.10",
"@types/secp256k1": "^4.0.3",
"@typescript-eslint/eslint-plugin": "~4.25.0",
"@typescript-eslint/parser": "~4.25.0",
"algosdk": "^1.13.1",
"arweave": "^1.10.18",
"assert": "^2.0.0",
"axios": "^0.21.3",
"base64url": "^3.0.1",
"browserify-zlib": "^0.2.0",
"bs58": "^4.0.1",
"eslint": "~7.27.0",

@@ -44,20 +68,24 @@ "eslint-config-prettier": "~8.3.0",

"husky": "^7.0.0",
"inspectpack": "^4.7.1",
"jest": "~27.0.3",
"keccak": "^3.0.2",
"object-sizeof": "^1.6.1",
"path-browserify": "^1.0.1",
"perf_hooks": "^0.0.1",
"prettier": "~2.3.0",
"pretty-quick": "^3.1.2",
"process": "^0.11.10",
"rimraf": "~3.0.2",
"ts-jest": "~27.0.2",
"ts-loader": "^9.2.8",
"ts-node": "^10.5.0",
"tslib": "^2.3.0",
"tsutils": "~3.21.0",
"typescript": "~4.3.2"
"typescript": "~4.3.2",
"webpack": "^5.71.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2"
},
"dependencies": {
"@randlabs/myalgo-connect": "^1.1.2",
"@solana/wallet-adapter-base": "^0.9.2",
"@types/axios": "^0.14.0",
"@types/bs58": "^4.0.1",
"@types/multistream": "^2.1.1",
"@types/secp256k1": "^4.0.3",
"algosdk": "^1.13.1",
"@noble/ed25519": "^1.6.0",
"arweave": "^1.10.18",

@@ -69,13 +97,10 @@ "arweave-stream-tx": "^1.1.0",

"bs58": "^4.0.1",
"buffer": "npm:buffer",
"ethers": "^5.5.1",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"keccak": "^3.0.2",
"multistream": "^4.1.0",
"noble-ed25519": "^1.2.6",
"process": "^0.11.10",
"secp256k1": "^4.0.2",
"tmp-promise": "^3.0.2",
"ts-node": "^10.5.0",
"tslib": "^2.3.0"
"stream-browserify": "^3.0.0",
"tmp-promise": "^3.0.2"
}
}

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

const buffer_1 = require("buffer");
const ar_data_bundle_1 = require("./ar-data-bundle");
const arDataBundle_1 = require("./arDataBundle");
const index_1 = require("./signing/index");
const ar_data_base_1 = require("./ar-data-base");
const arDataBase_1 = require("./arDataBase");
const axios_1 = __importDefault(require("axios"));

@@ -163,3 +163,3 @@ const constants_1 = require("./constants");

async sign(signer) {
this._id = await ar_data_bundle_1.sign(this, signer);
this._id = await arDataBundle_1.sign(this, signer);
return this.rawId;

@@ -236,7 +236,7 @@ }

const Signer = index_1.indexToType[sigType];
const signatureData = await ar_data_base_1.getSignatureData(item);
const signatureData = await arDataBase_1.getSignatureData(item);
return await Signer.verify(item.rawOwner, signatureData, item.rawSignature);
}
async getSignatureData() {
return ar_data_base_1.getSignatureData(this);
return arDataBase_1.getSignatureData(this);
}

@@ -243,0 +243,0 @@ /**

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

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

@@ -8,0 +8,0 @@ import SolanaSigner from "./signing/chains/SolanaSigner";

@@ -26,5 +26,5 @@ "use strict";

exports.signers = 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");
Object.defineProperty(exports, "bundleAndSignData", { enumerable: true, get: function () { return ar_data_bundle_1.bundleAndSignData; } });
Object.defineProperty(exports, "unbundleData", { enumerable: true, get: function () { return ar_data_bundle_1.unbundleData; } });
const arDataBundle_1 = require("./arDataBundle");
Object.defineProperty(exports, "bundleAndSignData", { enumerable: true, get: function () { return arDataBundle_1.bundleAndSignData; } });
Object.defineProperty(exports, "unbundleData", { enumerable: true, get: function () { return arDataBundle_1.unbundleData; } });
const Bundle_1 = __importDefault(require("./Bundle"));

@@ -37,4 +37,4 @@ exports.Bundle = Bundle_1.default;

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 arDataCreate_1 = require("./arDataCreate");
Object.defineProperty(exports, "createData", { enumerable: true, get: function () { return arDataCreate_1.createData; } });
const signing_1 = require("./signing");

@@ -41,0 +41,0 @@ const SolanaSigner_1 = __importDefault(require("./signing/chains/SolanaSigner"));

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

const secp256k1_2 = __importDefault(require("secp256k1"));
const ethers_1 = require("ethers");
// import { Wallet, utils } from "ethers"
const eth_sig_util_1 = require("@metamask/eth-sig-util");
const keccak256_1 = __importDefault(require("../keccak256"));
class EthereumSigner extends secp256k1_1.default {

@@ -20,10 +22,27 @@ get publicKey() {

sign(message) {
const wallet = new ethers_1.ethers.Wallet(this._key);
return wallet
.signMessage(message)
.then((r) => Buffer.from(r.slice(2), "hex"));
return Buffer.from(eth_sig_util_1.personalSign({
privateKey: Buffer.from(this._key, "hex"),
data: message,
}).slice(2));
// const wallet = new Wallet(this._key);
// const sig = wallet
// .signMessage(message)
// .then((r) => Buffer.from(r.slice(2), "hex")) as any;
}
static async verify(pk, message, signature) {
const address = ethers_1.ethers.utils.computeAddress(pk);
return ethers_1.ethers.utils.verifyMessage(message, signature) === address;
// const address = utils.computeAddress(pk);
// return utils.verifyMessage(message, signature) === address;
const address = "0x" + keccak256_1.default(pk.slice(1)).slice(-20).toString("hex");
let _message = Buffer.from(message).toString("hex");
if (_message.slice(0, 2) != "0x") {
_message = "0x" + _message;
}
let _signature = Buffer.from(signature).toString("hex");
if (_signature.slice(0, 2) != "0x") {
_signature = "0x" + _signature;
}
return (eth_sig_util_1.recoverPersonalSignature({
data: _message,
signature: _signature,
}) === address);
}

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

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

import ArweaveSigner from "./ArweaveSigner";
export { default as ArweaveSigner } from "./ArweaveSigner";
export * from "./ethereumSigner";
import PolygonSigner from "./PolygonSigner";
export * from "./SolanaSigner";
import InjectedEthereumSigner from "./injectedEthereumSigner";
export { default as InjectedSolanaSigner } from "./injectedSolanaSigner";
export { ArweaveSigner, PolygonSigner, InjectedEthereumSigner };
export { default as NearSigner } from "./NearSigner";
export { default as AlgorandSigner } from "./AlgorandSigner";
export { default as HexInjectedSolanaSigner } from "./HexInjectedSolanaSigner";
export { default as HexSolanaSigner } from "./HexSolanaSigner";

@@ -16,21 +16,17 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.HexSolanaSigner = exports.HexInjectedSolanaSigner = exports.AlgorandSigner = exports.NearSigner = exports.InjectedEthereumSigner = exports.PolygonSigner = exports.ArweaveSigner = exports.InjectedSolanaSigner = void 0;
const ArweaveSigner_1 = __importDefault(require("./ArweaveSigner"));
exports.ArweaveSigner = ArweaveSigner_1.default;
exports.HexSolanaSigner = exports.ArweaveSigner = void 0;
var ArweaveSigner_1 = require("./ArweaveSigner");
Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return __importDefault(ArweaveSigner_1).default; } });
__exportStar(require("./ethereumSigner"), exports);
const PolygonSigner_1 = __importDefault(require("./PolygonSigner"));
exports.PolygonSigner = PolygonSigner_1.default;
// import PolygonSigner from "./PolygonSigner";
__exportStar(require("./SolanaSigner"), exports);
const injectedEthereumSigner_1 = __importDefault(require("./injectedEthereumSigner"));
exports.InjectedEthereumSigner = injectedEthereumSigner_1.default;
var injectedSolanaSigner_1 = require("./injectedSolanaSigner");
Object.defineProperty(exports, "InjectedSolanaSigner", { enumerable: true, get: function () { return __importDefault(injectedSolanaSigner_1).default; } });
var NearSigner_1 = require("./NearSigner");
Object.defineProperty(exports, "NearSigner", { enumerable: true, get: function () { return __importDefault(NearSigner_1).default; } });
var AlgorandSigner_1 = require("./AlgorandSigner");
Object.defineProperty(exports, "AlgorandSigner", { enumerable: true, get: function () { return __importDefault(AlgorandSigner_1).default; } });
var HexInjectedSolanaSigner_1 = require("./HexInjectedSolanaSigner");
Object.defineProperty(exports, "HexInjectedSolanaSigner", { enumerable: true, get: function () { return __importDefault(HexInjectedSolanaSigner_1).default; } });
// import InjectedEthereumSigner from "./injectedEthereumSigner";
// export { default as InjectedSolanaSigner } from "./injectedSolanaSigner";
// import InjectedAlgorandSigner from "./injectedAlgorandSigner";
// export { InjectedAlgorandSigner } from "./injectedAlgorandSigner";
// export { default as NearSigner } from "./NearSigner";
// export { default as AlgorandSigner } from "./AlgorandSigner";
// export { default as HexInjectedSolanaSigner } from "./HexInjectedSolanaSigner";
var HexSolanaSigner_1 = require("./HexSolanaSigner");
Object.defineProperty(exports, "HexSolanaSigner", { enumerable: true, get: function () { return __importDefault(HexSolanaSigner_1).default; } });
//# sourceMappingURL=index.js.map

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

// @ts-ignore
4: chains_1.HexInjectedSolanaSigner,
4: chains_1.HexSolanaSigner,
};
//# sourceMappingURL=constants.js.map
/// <reference types="node" />
import BN from "bn.js";
import { Buffer } from "buffer";
declare function keccak256(value: Buffer | BN | string | number): any;
export = keccak256;
export default function keccak256(value: Buffer | BN | string | number): any;

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

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

@@ -16,2 +17,3 @@ const bn_js_1 = __importDefault(require("bn.js"));

}
exports.default = keccak256;
function toBuffer(value) {

@@ -92,3 +94,2 @@ if (!buffer_1.Buffer.isBuffer(value)) {

}
module.exports = keccak256;
//# sourceMappingURL=keccak256.js.map
/// <reference types="node" />
import { Signer } from '../Signer';
import { Signer } from "../Signer";
export default class Curve25519 implements Signer {

@@ -4,0 +4,0 @@ protected _key: string;

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

const base64url_1 = __importDefault(require("base64url"));
const ed25519 = __importStar(require("noble-ed25519"));
const ed25519 = __importStar(require("@noble/ed25519"));
const constants_1 = require("../../constants");

@@ -29,0 +29,0 @@ class Curve25519 {

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc