Skip to content

Meta-Network/meta-signature-util

Repository files navigation

meta-signature-util

This project is to provide Meta Network with the Authorization Utilities.

Installation

Using NPM.js:

npm install @metaio/meta-signature-util

Using Yarn:

yarn add @metaio/meta-signature-util

Usage

Import the modules from the @metaio/meta-signature-util library, and use the generate() method to generate metadata with a signature and the verify() method to validate. TypeScript is supported.

// import functions and modules
import { generateSeed, generateKeys, authorPostDigestSign } from '@metaio/meta-signature-util';

// generate keys and signature metadata
const seed = generateSeed();
const testKeys = generateKeys(seed)
const metadata = authorPostDigestSign.generate(
  testKeys,
  'server_domain',
  'the_digest',
);

// verify the signature
console.log(authorPostDigestSign.verify(metadata));

Please check our documentation to learn more about the modules.

Contributing

We welcome any PR or issue. Thank you for contributing to this project!

Add a new module

To add a new module, please clone this repository from GitHub, and copy a module from the src/modules directory.

Implement your generate and verify functions, and add the module to the modules dictionary. Remember the directory name should be the same as the type name in your metadata.

Then write a test for your module. And update the version in the package.json file.

Add a test case

We're using Jest for testing. Please add your test file to the test directory. Name your test file the same as the module, like meta-network-grids-server-sign.test.ts.

Make sure all the tests pass before you commit.

Motivation

web2_step1 web2_step2 we are doing

We provide the signature tools needed for the steps in the figure.