Coder Social home page Coder Social logo

recap-ts's Introduction

ReCap

A Typescript implementation of ERC-5573 ReCap, enabling applications to express UCAN-style object capabilities using Sign In With Ethereum.

Installation

ReCap can be installed via npm:

npm -i siwe-recap

yarn:

yarn add siwe-recap

or package.json entry:

{
  "dependencies": {
    "siwe-recap": "0.0.1-alpha.0"
  }
}

Usage

ReCaps are designed to be used in conjunction with SIWE. They can be initialized and built as follows:

import { Recap } from 'siwe-recap';

const recap = new Recap();

recap.addAttenuation('https://example.com/my/resource', 'crud', 'read');
recap.addAttenuation('https://example.com/my/resource', 'crud', 'update', {
  maxTimes: 5,
});
recap.addProof('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea');

console.log(recap.attenuations);
// {
//   "https://example.com/my/resource": {
//     "crud/read": [{}],
//     "crud/update": [{ maxTimes: 5 }]
//   }
// }

They can also be applied to or extracted from SIWE messages:

import { SiweMessage } from 'siwe';
import { Recap } from 'siwe-recap';

const siwe = new SiweMessage( ... );

// we can extract the recap while verifying that the statement in `siwe` matches
// the recap listed in `siwe`s resource list
const recap = Recap.extract_and_verify(siwe);

//
recap.addAttenuation('https://example.com/my/resource', 'crud', 'read');

// the new change will be merged into the existing recap in `siwe`
recap.add_to_siwe_messate(siwe);

Compilation

In order to generate the ECMAScript, CommonJS and TypeScript declaration files, run yarn compile.

Disclaimer

This package is still ALPHA software, bugs may exist and APIs may change in future. This library for has not yet undergone a formal security audit. We welcome continued feedback on the usability, architecture, and security of this implementation.

recap-ts's People

Contributors

chunningham avatar hwrdtm avatar skgbafa avatar

Stargazers

Brooklyn Zelenka avatar Salief Lewis avatar Caio Tonetti avatar

Watchers

wyc avatar  avatar  avatar Simon Bihel avatar  avatar Gregory Rocco avatar

Forkers

hwrdtm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.