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

@trace4eu/authorisation-wrapper

v0.0.11

Published

The `AuthorisationWrapper` class can be used for requesting an access token to the following authorisation servers: - EBSI Authorisation API: https://hub.ebsi.eu/apis/pilot/authorisation/v4. This is used by the `TimestampWrapper` and `TrackAndTraceWra

Downloads

16

Readme

Documentation: authorisation wrapper

The AuthorisationWrapper class can be used for requesting an access token to the following authorisation servers:

  • EBSI Authorisation API: https://hub.ebsi.eu/apis/pilot/authorisation/v4.
    This is used by the TimestampWrapper and TrackAndTraceWrapper for requesting an access token to EBSI, required value to consume EBSI Timestamp and Track and Trace apis.

  • Trace4eu authorization server: https://api-dev-auth.trace4eu.eu/oauth2/token. This server is part of the authorization-and-authentication server of Trace4eu (https://github.com/trace4eu/authorization-and-authentication). The client needs to execute a Oauth client credentials flow by sending a jwt assertion It's used by the vc-component too when issuing EBSI verifiable credentials and when the authorization server issue and verify JWTs for managing the credential issuance process within the OIDC4VCI flow.

It depends on the SignatureWrapper for making the signatures. In order to instantiate the EbsiAuthorisationApi or the Trace4euAuthorisationApi, the wallet is required.

Constructor

constructor(wallet: Wallet)

Creates a new instance of the Wallet class.

  • Parameters:

    • isEnterprise: boolean: flag to indicate if keys will be imported locally otherwise it will link to an Enterprise Wallet.
    • did: string: it represents the did of the entity.
    • entityKeys: KeyPairData[]: array of keys in hex format. You need to specify the algorithm of each key.
  • Example:

    const did = 'did:ebsi:zobuuYAHkAbRFCcqdcJfTgR';
    const entityKeys = [
      {
        alg: Algorithm.ES256K,
        privateKeyHex:
          '<ecc private key>',
        kid: '<optional key identifier>'
      },
      {
        alg: Algorithm.ES256,
        privateKeyHex:
          '<ecc private key>',,
        kid: '<optional key identifier>'
      },
    ];
    const wallet = WalletFactory.createInstance(false, did, entityKeys);
    

EbsiAuthorisationApi(wallet: Wallet)

Creates a new instance of the EbsiAuthorisationApi class.

  • Parameters:

    • wallet: Wallet: wallet will be used for
  • Example:

    const ebsiAuthorisationApi = new EbsiAuthorisationApi(wallet);
    

Trace4euAuthorisationApi(wallet: Wallet)

Creates a new instance of the Trace4euAuthorisationApi class.

  • Parameters:

    • wallet: Wallet: wallet will be used for
  • Example:

    const trace4euAuthorisationApi = new Trace4euAuthorisationApi(wallet);
    

Methods

getAccessToken

Request an access token to the corresponding authorization server.

  • Parameters:

    • alg: string: algorithm to be used.
    • scope: string: scope to be requested
    • credentials: string | string[]: ebsi authz server is an OIDC4VP server and vp_token needs to be presented with the required VCs according to the presentation definition
  • Returns:

    • Promise<string>: access token
  • Example:

    const ebsiAccessToken = await ebsiAuthorisationApi.getAccessToken(
      'ES256',
      'tnt_create',
      [],
    );
    
    const trace4euAccessToken = await trace4euAuthorisationApi.getAccessToken(
      'ES256',
      'ocs:read',
    );