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

@arianee/arianee-access-token

v1.85.0

Published

The ArianeeAccessToken class is a module that allows you to create and manage Arianee Access Tokens (AAT). This class requires the Core class from the @arianee/core module

Downloads

1,193

Readme

@arianee/arianee-access-token

The ArianeeAccessToken class is a module that allows you to create and manage Arianee Access Tokens (AAT). This class requires the Core class from the @arianee/core module

Usage

You need to instantiate the class with a Core instance

const core = core.fromPrivateKey('0x...');
const arianeeAccessToken = new ArianeeAccessToken(core);

Initial values

You can pass initial values by setting the initialValues property in the constructor params. Possible initial values are:

  • walletAccessToken: the wallet scoped AAT to use at initialization (if invalid or expired, a new one will be generated when needed). Note that under the hood it calls the setItem method of the storage object optionally passed in the constructor, if you are using a custom storage, this would override the previously stored value.
const instance = new ArianeeAccessToken(core, {
  initialValues: {
    walletAccessToken: 'eyJ0eXAiO...',
  },
});

Methods

You can use the following methods:

getValidWalletAccessToken(payloadOverride: PayloadOverride = {}, params?: { timeBeforeExp?: number; prefix?: string; }): Promise<string>

This method generates a wallet scoped Arianee Access Token (AAT) and stores it in memory. On subsequent calls, if the stored AAT is still valid, it will return it. Otherwise if it has expired or the expiration is in less than timeBeforeExp seconds, it will regenerate a new one and return it.

You can use the prefix parameter to add a string before the arianee access token payload in the message to be signed.

createWalletAccessToken(payloadOverride: PayloadOverride = {}, prefix?: string): Promise<string>

This method generates an Arianee Access Token (AAT) for the wallet scope. It returns a Promise that resolves to the AAT as a string. It takes two optional parameters, a payloadOverride parameter to override the default payload and a prefix parameter to add a string before the arianee access token payload in the message to be signed.

createCertificateArianeeAccessToken(certificateId: number, network: string): Promise<string>

This method generates an Arianee Access Token (AAT) for the certificate scope. It takes two parameters: certificateId, which is the ID of the certificate, and network, which is the name of the Arianee network. It returns a Promise that resolves to the AAT as a string.

createActionArianeeAccessTokenLink(url: string, certificateId: number, network: string): Promise<string>

This method creates a link with an Arianee Access Token (AAT) attached to it. It takes three parameters: url, which is the URL to attach the AAT to, certificateId, which is the ID of the certificate, and network, which is the name of the Arianee network. It returns a Promise that resolves to the link with the AAT as a string.

If you only need to decode existing arianee access token, you don't need to instanciate the class.

You can use the following static methods. These methods will automatically detect if the arianee access token is prefixed and handle it. In order for this to work seamlessly, the arianee access tokens must be signed with one of these two signature algorithms (alg prop in header): secp256k1 or ETH.

static isArianeeAccessTokenValid(arianeeAccessToken: string): boolean

This static method checks if an Arianee Access Token (AAT) is valid. It takes an arianeeAccessToken parameter as a string and returns a boolean indicating whether the AAT is valid or not.

static decodeJwt(arianeeAccessToken: string): {header: JwtHeaderInterface, payload: ArianeeAccessTokenPayload, signature: string}

This static method decodes an Arianee Access Token (AAT). It takes an arianeeAccessToken parameter as a string and returns an object with the decoded AAT, containing the header, payload, and signature.

Storage

You can pass a storage object (that implements the Web Storage API) to the constructor under the params.storage key.
This storage will be used for caching the generated arianee access token. Make sure that you do not pass an unsafe / public storage as it may expose the generated arianee access token.