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

@functionland/fula-sec

v2.0.0

Published

This library provides security features of Fula Protocol

Downloads

52

Readme

The Fula-sec library allows you to create DID (Decentrlized-ID) and Encript/Decypt by using Ed25519 and EDHD algorithms.

Ed25519 KeyPairs are used for creating DID, JWE/JWET/JWT signing identity of token which is passed as iss: attribyte of the payload. In same way opposite side user can verify or/and decrypt by passing their own KeyPair.

Installation

Install NPM package

npm install @functionland/fula-sec --save

Decentralized Identity (DID)

 import {HDKEY, DID} from '@functionland/fula-sec'


 /* Prefix moc keys */
 let password = '123456789'  //User`s password
 let signedKey = '9d7020006cf....f33a32adb81ae'; 
 /* signedKey is the signature coming from the locally-running 
 service of a 3rd party signing authority like Meta Mask Wallet 
 by signing part of the password (not the full password is being 
 sent to the 3rd party signing authority)
 */

 
 /* 1 - Add user`s password */
 const ed = new HDKEY(password);
 
 // A. Sign with chaincode   |chainCode| --->  |Metamask|      
 // B. Get signedKey         |signedKey| <---  |Metamask| 

 /* 2 - Get chainCode to get signedKey from Metamask*/
 const chainCode = ed.chainCode; 
 /*
   chainCode is created from part of the password to be sent 
   to the signing authority like MetaMask wallet to get a unique signature back
 */
 `type:base64pad APSWnk8ULP/v//oseMeSEDadMBSSeX/SOxOREYhjQ7g=`
 /* Send request to metamask*/

 /* 3 - Get KeyPair: Publick and Privete Key */
 const keyPair = ed.createEDKeyPair(signedKey);
 `secretkey:  Uint8Array(64) [
      98,  47,  78, 171, 169, 201, 236, 231, 196,  23, 134,
      135,  78, 180, 195,  93,  22,  57,  41, 213,  53,  86,
      248,  34,  83, 162, 233, 128,  89, 128, 207, 173, 247,
      94, 235,  66, 181, 212, 204, 168, 133, 182,  87, 227,
      217, 233, 122, 169, 145,  20,  42, 110, 229, 233, 239,
      112,  55, 203,  18, 112,  50, 251, 239, 219
   ],
   pubkey:  Uint8Array(32) [
      247,  94, 235,  66, 181, 212, 204,
      168, 133, 182,  87, 227, 217, 233,
      122, 169, 145,  20,  42, 110, 229,
      233, 239, 112,  55, 203,  18, 112,
      50, 251, 239, 219
   ]`
 
 /* keyPair: {
      publicKey,
      secretKey    
 } for creating DID and Encrypt/Decrypt */
 
 

 /* 4 - Add KeyPair in order to generate DID*/
 const did = new DID(keyPair.secretKey);
 
 /* Get DID */
 did.did();
`did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh`

Json Web Encrypted Token / Time Based Encryption

 import { EncryptJWT, DecryptJWT } from '@functionland/fula-sec'
  
  /* Securly export your wrapped wnfs key */
  const jwet = await new EncryptJWT({ any: 'your sensitive data to encrypt'})
     .setIssuedAt()
     .setNotBefore(Math.floor(Date.now() / 1000))
     .setIssuer(did.did())
     .setAudience(did.did())
     .setExpirationTime('3s')
     .encrypt(keyPair.secretKey);

 /* Verify and decrypt to get your wnfs key within 3 second as declared above */
  const payload = await new DecryptJWT(keyPair.secretKey).verify(jwet)    
   `payload:  {
      aud: 'did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh',
      exp: 1669043742,
      iat: 1669043738,
      iss: 'did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh',
      nbf: 1669043738,
      any: 'your sensitive data to encrypt'
   }
   `

Content

  • [X] HDKEY Drive
  • [X] Identity (DID)
  • [X] JWE
  • [X] JWET

See the open issues for a full list of proposed features (and known issues).

Development

Community

Maintainers

License

See LICENSE for more information.