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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pagopa/io-wallet-oid4vp

v1.2.1

Published

This package provides utilities for the **OpenID for Verifiable Presentations (OID4VP)** flow in the Italian Wallet ecosystem.

Readme

@pagopa/io-wallet-oid4vp

This package provides utilities for the OpenID for Verifiable Presentations (OID4VP) flow in the Italian Wallet ecosystem.

Installation

# Using pnpm
pnpm add @pagopa/io-wallet-oid4vp

# Using yarn
yarn add @pagopa/io-wallet-oid4vp

Usage

1) Fetch authorization request data from QR code / deep link

import { fetchAuthorizationRequest } from "@pagopa/io-wallet-oid4vp";

const qrCodeUrl =
  "https://wallet.example.org/authorize?" +
  "client_id=openid_federation%3Ahttps%3A%2F%2Frp.example.org" +
  "&request_uri=https%3A%2F%2Frp.example.org%2Frequest" +
  "&request_uri_method=post";

const requestData = await fetchAuthorizationRequest({
  authorizeRequestUrl: qrCodeUrl,
  callbacks: {
    fetch: globalThis.fetch,
  },
  walletMetadata: {
    authorization_endpoint: "https://wallet.example.org/authorize",
    response_types_supported: ["vp_token"],
    response_modes_supported: ["direct_post.jwt"],
  },
  walletNonce: "random-wallet-nonce",
});

console.log(requestData.sendBy); // "value" | "reference"
console.log(requestData.requestObjectJwt); // JWT request object
console.log(requestData.parsedQrCode.requestUriMethod); // "get" | "post" | undefined

2) Parse (and optionally verify) the Request Object JWT

parseAuthorizeRequest always parses and validates JWT structure. Signature verification runs only when callbacks.verifyJwt is provided.

Public key resolution for verification:

  1. client_id with x509_hash: prefix: requires header.x5c
  2. client_id with openid_federation: prefix or no prefix: requires header.trust_chain and header.kid
import { parseAuthorizeRequest } from "@pagopa/io-wallet-oid4vp";
import { IoWalletSdkConfig, ItWalletSpecsVersion } from "@pagopa/io-wallet-utils";

const config = new IoWalletSdkConfig({
  itWalletSpecsVersion: ItWalletSpecsVersion.V1_3,
});

const parsedRequest = await parseAuthorizeRequest({
  config,
  requestObjectJwt: requestData.requestObjectJwt,
  callbacks: {
    verifyJwt: myVerifyJwtCallback,
  },
});

console.log(parsedRequest.header.alg);
console.log(parsedRequest.payload.client_id);

3) Create encrypted authorization response (JARM)

import { createAuthorizationResponse } from "@pagopa/io-wallet-oid4vp";

const { authorizationResponsePayload, jarm } = await createAuthorizationResponse({
  callbacks: {
    encryptJwe: myEncryptJweCallback,
    generateRandom: myGenerateRandomCallback,
  },
  requestObject: {
    client_id: parsedRequest.payload.client_id,
    client_metadata: parsedRequest.payload.client_metadata,
    nonce: parsedRequest.payload.nonce,
    state: parsedRequest.payload.state,
  },
  rpJwks: {
    jwks: rpMetadata.jwks,
    encrypted_response_enc_values_supported:
      rpMetadata.encrypted_response_enc_values_supported,
  },
  vp_token: myVpToken,
});

console.log(authorizationResponsePayload.state);
console.log(jarm.responseJwe); // Send this to response_uri

4) Send authorization response

import { fetchAuthorizationResponse } from "@pagopa/io-wallet-oid4vp";

const responseResult = await fetchAuthorizationResponse({
  authorizationResponseJarm: jarm.responseJwe,
  callbacks: { fetch: globalThis.fetch },
  presentationResponseUri: parsedRequest.payload.response_uri,
});

console.log(responseResult.redirect_uri);

API Reference

fetchAuthorizationRequest

export interface FetchAuthorizationRequestOptions {
  authorizeRequestUrl: string;
  callbacks: Pick<CallbackContext, "fetch">;
  walletMetadata?: {
    authorization_endpoint?: string;
    client_id_prefixes_supported?: string[];
    request_object_signing_alg_values_supported?: string[];
    response_modes_supported?: string[];
    response_types_supported?: string[];
    vp_formats_supported?: Record<string, unknown>;
  };
  walletNonce?: string;
}

export interface FetchAuthorizationRequestResult {
  parsedQrCode: {
    clientId: string;
    requestUri?: string;
    requestUriMethod?: "get" | "post";
  };
  requestObjectJwt: string;
  sendBy: "reference" | "value";
}

parseAuthorizeRequest

export interface ParseAuthorizeRequestOptions {
  callbacks?: Pick<CallbackContext, "verifyJwt">;
  config: IoWalletSdkConfig;
  requestObjectJwt: string;
}

export interface ParsedAuthorizeRequestResult {
  header: Openid4vpAuthorizationRequestHeader;
  payload: Openid4vpAuthorizationRequestPayload;
}

createAuthorizationResponse

export interface CreateAuthorizationResponseOptions {
  authorization_encrypted_response_alg?: string;
  authorization_encrypted_response_enc?: string;
  callbacks: Pick<CallbackContext, "encryptJwe" | "generateRandom">;
  requestObject: Pick<
    Openid4vpAuthorizationRequestPayload,
    "client_id" | "client_metadata" | "nonce" | "state"
  >;
  rpJwks: {
    encrypted_response_enc_values_supported?: string[];
  } & Pick<
    ItWalletCredentialVerifierMetadata | ItWalletCredentialVerifierMetadataV1_3,
    "jwks"
  >;
  vp_token: VpToken;
}

export interface CreateAuthorizationResponseResult {
  authorizationResponsePayload: Openid4vpAuthorizationResponse;
  jarm: {
    encryptionJwk: Jwk;
    responseJwe: string;
  };
}

fetchAuthorizationResponse

export interface FetchAuthorizationResponseOptions {
  authorizationResponseJarm: string;
  callbacks: Pick<CallbackContext, "fetch">;
  presentationResponseUri: string;
}

Error Types

  • Oid4vpError: base package error
  • ParseAuthorizeRequestError: parse/verification errors in parseAuthorizeRequest
  • CreateAuthorizationResponseError: authorization response creation errors
  • FetchAuthorizationResponseError: errors when POSTing the response to response_uri
  • InvalidRequestUriMethodError: invalid request_uri_method value