New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lens-protocol/data-availability-verifier

Package Overview
Dependencies
Maintainers
9
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lens-protocol/data-availability-verifier - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

lib/__PLAYGROUND__/index.d.ts

5

lib/common/helpers.d.ts

@@ -61,7 +61,2 @@ /// <reference types="node" />

};
/**
* Return if the processing doing this is native node and not a browser
* @deprecated Client now has a separate code path to avoid increasing bundle size
*/
export declare const isNativeNode: () => boolean;
type AsyncFunction<T> = () => Promise<T>;

@@ -68,0 +63,0 @@ export interface RetryWithTimeoutOptions {

10

lib/common/helpers.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.turnedOffExperimentalWarning = exports.runForever = exports.retryWithTimeout = exports.isNativeNode = exports.createTimeoutPromise = exports.chunkArray = exports.formatDate = exports.unixTimestampToMilliseconds = exports.base64StringToJson = exports.getParam = exports.getParamOrExit = exports.sleep = exports.deepClone = void 0;
exports.turnedOffExperimentalWarning = exports.runForever = exports.retryWithTimeout = exports.createTimeoutPromise = exports.chunkArray = exports.formatDate = exports.unixTimestampToMilliseconds = exports.base64StringToJson = exports.getParam = exports.getParamOrExit = exports.sleep = exports.deepClone = void 0;
/**

@@ -105,10 +105,2 @@ * Creates a deep clone of the given object by converting it to a JSON string and then parsing it back to an object.

/**
* Return if the processing doing this is native node and not a browser
* @deprecated Client now has a separate code path to avoid increasing bundle size
*/
const isNativeNode = () => {
return typeof window === 'undefined';
};
exports.isNativeNode = isNativeNode;
/**
* Retry a function with a timeout between retries

@@ -115,0 +107,0 @@ * @param fn The function

import { ClaimableValidatorError } from './claimable-validator-errors';
declare class Success<TSuccess> {
readonly successResult: TSuccess;
constructor(successResult: TSuccess);
isSuccess(): this is Success<TSuccess>;
isFailure(): this is Failure<never, never>;
}
declare class Failure<TError, TContext = undefined> {
readonly failure: TError;
context?: TContext | undefined;
constructor(failure: TError, context?: TContext | undefined);
isSuccess(): this is Success<never>;
isFailure(): this is Failure<TError, TContext>;
}
/**

@@ -7,24 +20,3 @@ * Represents the result of a data availability check.

*/
export declare class DAResult<TSuccessResult, TContext = undefined> {
failure?: ClaimableValidatorError | undefined;
successResult?: TSuccessResult | undefined;
context?: TContext | undefined;
/**
* Initializes a new instance of the `DAResult` class.
* @param failure The claimable validator error in case of failure.
* @param successResult The successful result.
* @param context The context associated with the result.
*/
constructor(failure?: ClaimableValidatorError | undefined, successResult?: TSuccessResult | undefined, context?: TContext | undefined);
/**
* Determines whether the data availability check is successful.
* @returns `true` if the check is successful; otherwise, `false`.
*/
isSuccess(): boolean;
/**
* Determines whether the data availability check is a failure.
* @returns `true` if the check is a failure; otherwise, `false`.
*/
isFailure(): boolean;
}
export type DAResult<TSuccessResult, TContext = undefined> = Success<TSuccessResult> | Failure<ClaimableValidatorError, TContext>;
/**

@@ -46,9 +38,10 @@ * Represents a Promise of a data availability result.

*/
export declare const success: <TResult = void>(result?: TResult | undefined) => DAResult<TResult, undefined>;
export declare function success(): Success<void>;
export declare function success<T>(result: T): Success<T>;
/**
* Creates a failed data availability result.
* @param failure The claimable validator error in case of failure.
* @param error The claimable validator error in case of failure.
* @returns The failed data availability result.
*/
export declare const failure: (error: ClaimableValidatorError) => DAResult<void>;
export declare const failure: (error: ClaimableValidatorError) => Failure<ClaimableValidatorError>;
/**

@@ -69,13 +62,7 @@ * Represents a Promise of a data availability result with context.

* @template TContext The type of the context.
* @param failure The claimable validator error in case of failure.
* @param error The claimable validator error in case of failure.
* @param context The context associated with the result.
* @returns The failed data availability result with context.
*/
export declare const failureWithContext: <TContext>(error: ClaimableValidatorError, context: TContext) => DAResult<void, TContext>;
/**
* Creates a successful data availability result with context.
* @template TResult The type of the successful result.
* @param result The successful result.
* @returns The successful data availability result with context.
*/
export declare const successWithContext: <TResult>(result: TResult) => DAResult<TResult, TResult>;
export declare const failureWithContext: <TContext>(error: ClaimableValidatorError, context: TContext) => Failure<ClaimableValidatorError, TContext>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.successWithContext = exports.failureWithContext = exports.failure = exports.success = exports.DAResult = void 0;
/**
* Represents the result of a data availability check.
* @template TSuccessResult The type of the successful result.
* @template TContext The type of the context, which is undefined by default.
*/
class DAResult {
/**
* Initializes a new instance of the `DAResult` class.
* @param failure The claimable validator error in case of failure.
* @param successResult The successful result.
* @param context The context associated with the result.
*/
constructor(failure, successResult, context) {
exports.failureWithContext = exports.failure = exports.success = void 0;
class Success {
constructor(successResult) {
this.successResult = successResult;
}
isSuccess() {
return true;
}
isFailure() {
return false;
}
}
class Failure {
constructor(failure, context) {
this.failure = failure;
this.successResult = successResult;
this.context = context;
}
/**
* Determines whether the data availability check is successful.
* @returns `true` if the check is successful; otherwise, `false`.
*/
isSuccess() {
return this.failure === undefined;
return false;
}
/**
* Determines whether the data availability check is a failure.
* @returns `true` if the check is a failure; otherwise, `false`.
*/
isFailure() {
return this.failure !== undefined;
return true;
}
}
exports.DAResult = DAResult;
/**
* Creates a successful data availability result.
* @template TResult The type of the successful result.
* @param result The successful result.
* @returns The successful data availability result.
*/
const success = (result) => new DAResult(undefined, result);
// eslint-disable-next-line @typescript-eslint/no-explicit-any, prefer-arrow/prefer-arrow-functions
function success(result = undefined) {
return new Success(result);
}
exports.success = success;
/**
* Creates a failed data availability result.
* @param failure The claimable validator error in case of failure.
* @param error The claimable validator error in case of failure.
* @returns The failed data availability result.
*/
const failure = (error) => new DAResult(error);
const failure = (error) => new Failure(error);
exports.failure = failure;

@@ -55,15 +42,7 @@ /**

* @template TContext The type of the context.
* @param failure The claimable validator error in case of failure.
* @param error The claimable validator error in case of failure.
* @param context The context associated with the result.
* @returns The failed data availability result with context.
*/
const failureWithContext = (error, context) => new DAResult(error, undefined, context);
const failureWithContext = (error, context) => new Failure(error, context);
exports.failureWithContext = failureWithContext;
/**
* Creates a successful data availability result with context.
* @template TResult The type of the successful result.
* @param result The successful result.
* @returns The successful data availability result with context.
*/
const successWithContext = (result) => new DAResult(undefined, result, result);
exports.successWithContext = successWithContext;

@@ -21,3 +21,3 @@ import { BigNumber, ethers } from 'ethers';

*/
export declare const executeSimulationTransaction: (data: string, blockNumber: number, ethereumNode: EthereumNode) => PromiseResult<string | void>;
export declare const executeSimulationTransaction: (data: string, blockNumber: number, ethereumNode: EthereumNode) => PromiseResult<string>;
/**

@@ -48,3 +48,3 @@ * Parse an Ethereum signature string and add a deadline timestamp to it.

ownerOfAddress: string;
} | void>;
}>;
export interface BlockInfo {

@@ -73,2 +73,2 @@ number: number;

*/
export declare const getLensPubCount: (profileId: string, blockNumber: number, ethereumNode: EthereumNode) => PromiseResult<BigNumber | void>;
export declare const getLensPubCount: (profileId: string, blockNumber: number, ethereumNode: EthereumNode) => PromiseResult<BigNumber>;

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

const level_1 = require("level");
const invariant_1 = require("../utils/invariant");
const paths_1 = require("./paths");

@@ -43,4 +44,3 @@ let db;

const startDb = async () => {
if (db)
return;
(0, invariant_1.invariant)(!db, 'Database already started');
const path = await (0, paths_1.pathResolver)();

@@ -68,4 +68,5 @@ const lens__da = await (0, paths_1.lensDAPath)();

const deleteDb = (key) => {
if (!db)
if (!db) {
return Promise.resolve();
}
return db.del(key);

@@ -80,4 +81,5 @@ };

const getTxDb = async (txId) => {
if (!db)
if (!db) {
return null;
}
try {

@@ -99,4 +101,5 @@ const result = await db.get(`${DbReference.tx}:${txId}`);

const saveTxDb = async (txId, result) => {
if (!db)
if (!db) {
return;
}
try {

@@ -117,4 +120,5 @@ await db.put(`${DbReference.tx}:${txId}`, JSON.stringify(result));

const getBlockDb = async (blockNumber) => {
if (!db)
if (!db) {
return null;
}
try {

@@ -135,4 +139,5 @@ const result = await db.get(`${DbReference.block}:${blockNumber}`);

const saveBlockDb = async (block) => {
if (!db)
if (!db) {
return;
}
try {

@@ -152,4 +157,3 @@ await db.put(`${DbReference.block}:${block.number}`, JSON.stringify(block));

const getLastEndCursorDb = async () => {
if (!db)
return null;
(0, invariant_1.invariant)(db, 'Database not started');
try {

@@ -169,4 +173,3 @@ return await db.get(DbReference.cursor);

const saveEndCursorDb = async (cursor) => {
if (!db)
return;
(0, invariant_1.invariant)(db, 'Database not started');
try {

@@ -184,4 +187,3 @@ await db.put(DbReference.cursor, cursor);

const getTotalCheckedCountDb = async () => {
if (!db)
return 0;
(0, invariant_1.invariant)(db, 'Database not started');
try {

@@ -204,4 +206,3 @@ const result = await db.get(`${DbReference.tx}:totalCheckedCount`);

const saveTotalCheckedCountDb = async (checked) => {
if (!db)
return;
(0, invariant_1.invariant)(db, 'Database not started');
try {

@@ -223,4 +224,5 @@ const currentCount = (await (0, exports.getTotalCheckedCountDb)()) || 0;

const saveTxDAMetadataDb = async (txId, publication) => {
if (!db)
if (!db) {
return;
}
try {

@@ -240,4 +242,5 @@ await db.put(`${DbReference.tx_da_metadata}:${txId}`, JSON.stringify(publication));

const getTxDAMetadataDb = async (txId) => {
if (!db)
if (!db) {
return null;
}
try {

@@ -259,4 +262,5 @@ const result = await db.get(`${DbReference.tx_da_metadata}:${txId}`);

const saveTxTimestampProofsMetadataDb = async (txId, proofs) => {
if (!db)
if (!db) {
return;
}
try {

@@ -276,4 +280,5 @@ await db.put(`${DbReference.tx_timestamp_proof_metadata}:${txId}`, JSON.stringify(proofs));

const getTxTimestampProofsMetadataDb = async (txId) => {
if (!db)
if (!db) {
return null;
}
try {

@@ -280,0 +285,0 @@ const result = await db.get(`${DbReference.tx_timestamp_proof_metadata}:${txId}`);

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

curlyResponseBodyParser: false,
followLocation: true,
timeout,

@@ -12,0 +13,0 @@ });

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

exports.failedProofsPath = exports.lensDAPath = exports.pathResolver = void 0;
const helpers_1 = require("../common/helpers");
let _path;
const pathResolver = async () => {
if (!(0, helpers_1.isNativeNode)()) {
throw new Error('`path`- This function is only available in native node');
}
if (_path)

@@ -42,5 +38,2 @@ return Promise.resolve(_path);

const lensDAPath = async () => {
if (!(0, helpers_1.isNativeNode)()) {
throw new Error('`lensDAPath`- This function is only available in native node');
}
if (lensDAPathCache)

@@ -55,5 +48,2 @@ return Promise.resolve(lensDAPathCache);

const failedProofsPath = async () => {
if (!(0, helpers_1.isNativeNode)()) {
throw new Error('`failedProofsPath`- This function is only available in native node');
}
if (failedProofsPathCache)

@@ -60,0 +50,0 @@ return Promise.resolve(failedProofsPathCache);

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.postWithTimeout = void 0;
const axios_1 = __importDefault(require("axios"));
const node_libcurl_1 = require("node-libcurl");
const helpers_1 = require("../common/helpers");
const postWithTimeout = async (url, body) => {
if ((0, helpers_1.isNativeNode)()) {
const { statusCode, data } = await node_libcurl_1.curly.post(url, {
postFields: JSON.stringify(body),
httpHeader: ['Content-Type: application/json'],
timeout: 5000,
curlyResponseBodyParser: false,
});
if (statusCode !== 200) {
throw new Error(`postWithTimeout: ${statusCode} - ${data.toString()}`);
}
return JSON.parse(data.toString());
const { statusCode, data } = await node_libcurl_1.curly.post(url, {
postFields: JSON.stringify(body),
httpHeader: ['Content-Type: application/json'],
timeout: 5000,
curlyResponseBodyParser: false,
});
if (statusCode !== 200) {
throw new Error(`postWithTimeout: ${statusCode} - ${data.toString()}`);
}
else {
const response = await axios_1.default.post(url, JSON.stringify(body), {
timeout: 5000,
});
return response.data;
}
return JSON.parse(data.toString());
};
exports.postWithTimeout = postWithTimeout;

@@ -25,2 +25,2 @@ import { EthereumNode } from '../evm/ethereum';

*/
export declare const checkDAProofWithMetadata: (txId: string, daPublicationWithTimestampProofs: DAPublicationWithTimestampProofsBatchResult, ethereumNode: EthereumNode, options?: CheckDASubmissionOptions) => PromiseWithContextResult<DAStructurePublication<DAEventType, PublicationTypedData> | void, DAStructurePublication<DAEventType, PublicationTypedData>>;
export declare const checkDAProofWithMetadata: (txId: string, daPublicationWithTimestampProofs: DAPublicationWithTimestampProofsBatchResult, ethereumNode: EthereumNode, options?: CheckDASubmissionOptions) => PromiseWithContextResult<DAStructurePublication<DAEventType, PublicationTypedData>, DAStructurePublication<DAEventType, PublicationTypedData>>;

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

const check_da_submisson_options_1 = require("./models/check-da-submisson-options");
const invariant_1 = require("../utils/invariant");
/**

@@ -120,4 +121,6 @@ * Builds a validation result object for a transaction ID and a data availability verification result.

const { promise: timeoutPromise, timeoutId } = (0, helpers_1.createTimeoutPromise)(5000);
const result = (await Promise.race([checkPromise, timeoutPromise]));
const result = await Promise.race([checkPromise, timeoutPromise]);
clearTimeout(timeoutId);
// TODO: In case of timeout, what would be the best course of action here? Just throw?
(0, invariant_1.invariant)(result, 'Publication process request timed out');
const txValidatedResult = buildTxValidationResult(txId, result);

@@ -124,0 +127,0 @@ (0, db_1.saveTxDb)(txId, txValidatedResult);

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

import { Deployment, Environment } from '../common/environment';
import { LogFunctionType } from '../common/logger';

@@ -7,5 +8,4 @@ import { PromiseWithContextResult } from '../data-availability-models/da-result';

import { TimeoutError } from '../input-output/common';
import { TxValidatedResult } from '../input-output/tx-validated-results';
import { CheckDASubmissionOptions } from './models/check-da-submisson-options';
import { TxValidatedResult } from '../input-output/tx-validated-results';
import { Deployment, Environment } from '../common/environment';
export interface DAProofsVerifier {

@@ -48,3 +48,3 @@ extractAddress(daPublication: DAStructurePublication<DAEventType, PublicationTypedData>): Promise<string>;

*/
checkDAProofWithMetadata: (txId: string, daPublicationWithTimestampProofs: DAPublicationWithTimestampProofsBatchResult, ethereumNode: EthereumNode, options?: CheckDASubmissionOptions) => PromiseWithContextResult<DAStructurePublication<DAEventType, PublicationTypedData> | void, DAStructurePublication<DAEventType, PublicationTypedData>>;
checkDAProofWithMetadata: (txId: string, daPublicationWithTimestampProofs: DAPublicationWithTimestampProofsBatchResult, ethereumNode: EthereumNode, options?: CheckDASubmissionOptions) => PromiseWithContextResult<DAStructurePublication<DAEventType, PublicationTypedData>, DAStructurePublication<DAEventType, PublicationTypedData>>;
/**

@@ -51,0 +51,0 @@ * Validates a data availability proof of a given transaction on the Arweave network, including the timestamp proofs.

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

}
return (0, da_result_1.successWithContext)(daPublication);
return (0, da_result_1.success)(daPublication);
};

@@ -280,3 +280,3 @@ /**

if (cacheResult.success) {
return (0, da_result_1.successWithContext)(cacheResult.dataAvailabilityResult);
return (0, da_result_1.success)(cacheResult.dataAvailabilityResult);
}

@@ -283,0 +283,0 @@ return (0, da_result_1.failureWithContext)(cacheResult.failureReason, cacheResult.dataAvailabilityResult);

@@ -5,4 +5,4 @@ import { DATimestampProofsResponse } from '../data-availability-models/data-availability-timestamp-proofs';

import { TimeoutError } from '../input-output/common';
import { TxValidatedResult } from '../input-output/tx-validated-results';
import { DAProofsGateway } from '../proofs/da-proof-checker';
import { TxValidatedResult } from '../input-output/tx-validated-results';
export declare class DaProofGateway implements DAProofsGateway {

@@ -9,0 +9,0 @@ getTxResultFromCache(txId: string): Promise<TxValidatedResult | null>;

@@ -1,6 +0,6 @@

import { DAProofsVerifier } from './da-proof-checker';
import { DAEventType, DAStructurePublication, PublicationTypedData } from '../data-availability-models/publications/data-availability-structure-publication';
import { Deployment, Environment } from '../common/environment';
import { LogFunctionType } from '../common/logger';
import { DAEventType, DAStructurePublication, PublicationTypedData } from '../data-availability-models/publications/data-availability-structure-publication';
import { TimeoutError } from '../input-output/common';
import { DAProofsVerifier } from './da-proof-checker';
export declare class DaProofVerifier implements DAProofsVerifier {

@@ -7,0 +7,0 @@ extractAddress(daPublication: DAStructurePublication<DAEventType, PublicationTypedData>): Promise<string>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DaProofVerifier = void 0;
const worker_pool_1 = require("../workers/worker-pool");
const handler_communication_worker_1 = require("../workers/handler-communication.worker");
const helpers_1 = require("../common/helpers");
const get_owner_of_transaction_api_1 = require("../input-output/bundlr/get-owner-of-transaction.api");
const common_1 = require("../input-output/common");
const get_owner_of_transaction_api_1 = require("../input-output/bundlr/get-owner-of-transaction.api");
const lib_curl_provider_1 = require("../input-output/lib-curl-provider");
const submitters_1 = require("../submitters");
const lib_curl_provider_1 = require("../input-output/lib-curl-provider");
const handler_communication_worker_1 = require("../workers/handler-communication.worker");
const worker_pool_1 = require("../workers/worker-pool");
class DaProofVerifier {

@@ -12,0 +12,0 @@ extractAddress(daPublication) {

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

log('signature simulation checking failed');
return (0, da_result_1.failure)(simulationData.failure);
return (0, da_result_1.failure)(simulatedResult.failure);
}

@@ -97,0 +97,0 @@ if (expectedResult.isFailure()) {

@@ -13,2 +13,2 @@ import { SignatureLike } from '@ethersproject/bytes';

*/
export declare const whoSignedTypedData: (domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike) => PromiseResult<string | void>;
export declare const whoSignedTypedData: (domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike) => PromiseResult<string>;
{
"name": "@lens-protocol/data-availability-verifier",
"version": "0.0.23",
"version": "0.0.24",
"description": "Data availability verifier for the Lens protocol",

@@ -71,12 +71,12 @@ "main": "lib/index.js",

"start:failed": "env-cmd -f .env ts-node src/failed-submissons.runnable.ts",
"debug:playground": "env-cmd -f .env ts-node src/__PLAYGROUND__/index.ts",
"debug:playground:workers": "node lib/__PLAYGROUND__/main.js",
"debug:playground": "npm run build && env-cmd -f .env node lib/__PLAYGROUND__/index.js",
"generate": "graphql-codegen",
"test": "env-cmd -f .env jest",
"lint": "pnpm run prettier && pnpm run tsc --noEmit",
"lint:fix": "pnpm run prettier:fix && pnpm run eslint",
"lint": "pnpm run prettier && pnpm run eslint && pnpm run tsc",
"lint:fix": "pnpm run prettier:fix && pnpm run eslint --fix && pnpm run tsc",
"prettier:fix": "prettier --write .",
"prettier": "prettier --check .",
"tsc": "tsc --noEmit",
"preinstall": "npx only-allow pnpm"
}
}
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