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

cardano-web3-utils

v2.0.1

Published

Cardano utils for web3 apps

Downloads

19

Readme

Cardano web3 utils

Cardano web3 is a javascript library that allows interaction with COSE Sign1 and CBOR encoded data and implements some helper methods for CIP-0093 Authenticated HTTP Web3 Requests.

API

Web3Authentication

The Web3Authentication class provides authentication functionality. It has the following constructor and methods:

Constructor

  • Web3Authentication(expirationTimeSpan: number, hostname: string): Creates a new instance of the Web3Authentication class. It takes the expiration time span in seconds and the hostname as parameters.

Methods

  • authenticate<T>(uri: string, action: string, key: string, signature: string, options?: Web3AuthenticationOptions): { payload: Web3AuthenticationPayload & T; walletAddress: string }: Performs authentication using the provided parameters. It returns an object with the authenticated payload and wallet address.

Web3AuthenticationError

The Web3AuthenticationError class is an error subclass that represents authentication errors. It extends the built-in Error class and includes an additional property httpErrorCode to store the associated HTTP error code.

Web3AuthenticationPayload

The Web3AuthenticationPayload type defines the structure of the payload used in the authentication process. It includes properties such as uri, action, timestamp, and optional properties for additional secured data.

Utils

Auth-utils

  • checkExpiration(payload: Web3AuthenticationPayload, expirationTimeSpan: number): Checks if a payload has expired based on its timestamp and expiration time span.

  • getCoseSign1Bech32Address(signature: string): Extracts the bech32 address from a COSE_Sign1 signature.

  • getPayload(signature: string): Retrieves the payload from a COSE_Sign1 signature.

  • verifyCoseSign1Address(key: string, signature: string): Verifies if a COSE_Sign1 address matches the provided key.

  • verifyCoseSign1Signature(key: string, signature: string) Verifies the integrity of a COSE_Sign1 signature using the provided key.

Test-utils

  • createCOSEKey(privateKey: CSL.PrivateKey): Creates a COSE Key structure from a private key.

  • createCOSESign1Signature(payload: object, address: CSL.RewardAddress, privateKey: CSL.PrivateKey): Creates a COSE_Sign1 signature using the provided payload, address, and private key.

  • createFakePrivateKey(accountNumber: number): Creates a fake private key for mocking purposes.

  • createRewardAddress(privateKey: CSL.PrivateKey, networkId: CSL.NetworkId): Creates a reward address from a private key and network ID.

Support

If you find it useful, please consider inviting me a coffee :)

DoItWithLovelace