npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@veive-io/mod-validation-any-as

v1.1.0

Published

Validation any operation module for Veive

Downloads

16

Readme

Mod Validation Any

Overview

ModValidationAny is a comprehensive validation module within the Veive protocol, designed specifically for the Koinos blockchain. This module employs an allowance mechanism to pre-authorize operations, ensuring that only actions explicitly approved by the user are executed. By leveraging this mechanism, ModValidationAny provides robust control over transaction execution, preventing unauthorized actions and potential replay attacks. Notably, this module is also applicable for validating internal operations, ensuring that even operations triggered within a contract are authorized.

Purpose

The ModValidationAny module serves as a pivotal component in the Veive ecosystem by validating operations against a set of pre-authorized allowances. This functionality is crucial for both external and internal operations, ensuring comprehensive security and control. Key features include:

  • Allowance Mechanism: Users can pre-authorize specific operations using the allow method, which stores details such as the operation's contract ID, entry point, arguments, and transaction ID. This mechanism prevents unauthorized transactions and ensures that each allowance is tied to a specific transaction, preventing reuse. This feature is particularly important for managing internal operations, where contracts may invoke additional operations.

  • Validation Process: During execution, ModValidationAny checks if the incoming operation matches any stored allowances. It verifies transaction ID, contract ID, entry point, and arguments. If a match is found, the corresponding allowance is removed, ensuring that it cannot be reused, thus preventing replay attacks. This process includes verifying allowances for operations that may be internally triggered by other contracts, ensuring a comprehensive validation scope.

  • Scope Management: The default scope for ModValidationAny is set to "any," meaning it can validate any operation unless a more specific scope is defined. This flexibility allows for the module's application across a broad range of scenarios, from general validation to specific contract operations.

Scope

The default scope for ModValidationAny is "any," allowing it to validate any operation in the absence of more specific scope definitions. This flexibility means the module can serve as a universal validator, covering a wide range of scenarios without the need for granular scope definitions. It ensures that any operation, whether user-initiated or internally triggered within a contract, is subject to validation.

Usage

Installation

To install the ModValidationAny module, ensure you have the Veive protocol set up on your Koinos blockchain environment. Install the module using yarn:

yarn add @veive-io/mod-validation-any-as

Deploy the module contract on the Koinos blockchain and install it on the desired account using the install_module method provided by the Veive account interface. During installation, the on_install method is called to set the necessary configurations and link the module to the account.

Example

Here is an example of how to use ModValidationAny:

// prepare operation
const { operation: transfer } = await tokenContract['transfer']({
  from: account1Sign.address,
  to: account2Sign.address,
  value: "1",
}, { onlyOperation: true });

// allow operation
const { operation: allow } = await modContract['allow']({
  user: account1Sign.address,
  operation: {
    contract_id: transfer.call_contract.contract_id,
    entry_point: transfer.call_contract.entry_point,
    args: transfer.call_contract.args
  }
}, { onlyOperation: true });

const tx = new Transaction({
  signer: account1Sign,
  provider,
});

await tx.pushOperation(allow);
await tx.pushOperation(transfer);
const receipt = await tx.send();
await tx.wait();

Scripts

Build

To compile the package, run:

yarn build

Dist

To create a distribution, run:

yarn dist

Test

To test the package, use:

yarn jest

Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.