Détail du package

@sphereon/pex-models

Sphereon-Opensource20.1kApache-2.02.3.2

Presentation Exchange v1 and v2 typescript models

Verifiable, Credentials, Presentation Exchange, PE

readme


Sphereon
Presentation Exchange v1 and v2
Typescript models

Table of Contents

Background

The Presentation Exchange OpenAPI (PEX-OpenAPI) is an OpenAPI specification based upon the DIF Presentation Exchange v2.0.0 and DIF Presentation Exchange v1.0.0 specifications.

A standardised Presentation Exchange is crucial for interoperability between different systems that are used by verifiers and holders (e.g. wallets). It enables the verifiers- and holder-systems to interpret models used by each other consistently. The PEX-OpenAPI specification and Models Generator will allow for use-cases with the need to implement a Presentation Exchange, possibly using different programming languages.

The PEX-Models Typescript library is a pre-generated and published library, ready to be used in typescript/javascript projects that can directly be used from a package manager using npmjs.com. This library can be used in any JavaScript project, providing a consistent structure of the models required in presentation exchange between verifiers and holders of verifiable credentials.

Additionally, the PEX-Models library can be used to create libraries for verification of presentation definition and submission objects themselves. In this fashion, the PEX-Models library is used in Sphereon's PEX library to validate the model objects.

Usage

Step 1 : Create a project using the models

The provided example will create a new NPM project using typescript as language. It will import and use JwtObject, similarly you can import and use other objects.

cd '<workspace>'
mkdir my-pex-models-consumer-prj
cd my-pex-models-consumer-prj
npm init

npm init will ask a few questions, the default answer to those questions can be selected.

Step 2 : Add script & Import models

To use the models generated as a result of step 1

npm install
npm install --save @sphereon/pex-models
npm install --save ts-node

Create a folder named scripts

mkdir scripts

Create a file in 'scripts' named consumer-script.ts with following content.

import {JwtObject} from '@sphereon/pex-models'

var jwtObject : JwtObject = {
    alg : ['someAlgorithm']
};

console.log(jwtObject);

In package.json add a script "my-pex-models-consumer-script": "ts-node scripts/consumer-script.ts" in the scripts section. The resulting Package.json should look like following.

{
  "name": "my-pex-models-consumer-prj",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "my-pex-models-consumer-script": "ts-node scripts/consumer-script.ts"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@sphereon/pex-models": "2.0.0",
    "ts-node": "^9.1.1"
  }
}

Step 3 : Check if everything went correctly

In the terminal run the following command from the <workspace>/my-pex-models-consumer-prj

cd '<workspace>/my-pex-models-consumer-prj'
npm run my-pex-models-consumer-script

You should expect this to be printed on the console.

{ alg: [ 'someAlgorithm' ] }

changelog

Release Notes

v2.3.2 - 2024-11-25

  • Fix
    • Make type optional in filter v2

v2.3.1 - 2024-08-27

  • Feature
    • Add intent_to_retain to Field v2

v2.3.0 - 2024-08-27

  • Feature
    • Add support for mso_mdoc format

v2.2.4 - 2024-04-24

  • Fix
    • Add boolean 'optional' property in v2 Fields,

v2.2.4 - 2024-04-24

  • Fix
    • Add boolean 'optional' property in v2 Fields,

v2.2.3 - 2024-04-24

  • Fix
    • Add boolean const as valid filter value

v2.2.2 - 2024-02-29

  • Fix
    • Format did not include jwt_vp_json

v2.2.0 - 2024-02-02

  • Feature
    • Add support for Verifiable Credential Data Integrity 1.0

v2.1.5 - 2024-01-14

  • Fix
    • Schema object was renamed to DefintionSchema by accident

v2.1.4 - 2024-01-14

Do not use

v2.1.3 - 2024-01-14

  • Fix
    • path is now required in a Field according to the v1 and v2 spec

v2.1.2 - 2023-11-28

  • Feature
    • Add support for vc+sd-jwt formats

v2.1.1 - 2023-10-02

  • Feature
    • Add support for format in V2 input descriptor
  • Fix
    • Remove contains and items from V1 filters, as that spec has no notion of them

v2.1.0 - 2023-09-29

  • Feature
    • Add support for items and contains in filter
    • Add support for jwt_vc_json format

v2.0.0 - 2023-05-01

  • Fix
    • Remove wrong export path

v2.0.1 - 2023-09-29

  • Feature
    • Add support for items and contains in filter
    • Add support for jwt_vc_json format

v2.0.0 - 2023-04-30

  • Fix
    • _const and _enum are now correctly exposed in the typescript models/interfaces as const and enum. This is a breaking change. Simply remove all underscore prefixes
    • Removed some siblings for refs causing some warnings/errors

v1.2.2 - 2023-02-24

  • Fix
    • issuance changed from string to object in input descriptors. Issuance is now an object with a manifest property that contains the URL of the Credential Manifest.

v1.2.0 - 2023-02-23

  • Feature
    • Allow issuance in input descriptors for credential manifest URLs. Although not spec compliant, it is used in the wild.

v0.0.5 - 2021-08-25

  • Feature: added REST API v1 specs and data types
  • Documentation
    • modular documentation
    • docs for API
  • Configuration for API stubs creation

v0.0.4 - 2021-05-27

  • Fix: changed the nature of the 'path_nested' property in a descriptor from array to object.

v0.0.3 - 2021-05-27

  • Presentation Submission object added.

v0.0.2 - 2021-05-12

  • Variable name input descriptor corrected.

v0.0.1 - 2021-05-01

  • Initial release: Basic Structures.