Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit d711c742 authored by Yannick HUARD's avatar Yannick HUARD
Browse files

feat: revamp folder architecture - EBSIINT-8920

parent 33dfcb0b
No related branches found
No related tags found
1 merge request!41feat: revamp folder architecture - EBSIINT-8920
Showing with 6002 additions and 11471 deletions
---
---
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
node_modules node_modules
.env .env
.idea dist
variables:
GIT_DEPTH: 30 # Default: 20. Increase limit to avoid errors during `git pull`
default:
tags:
- devteam
image: node:20.11.1
before_script:
- corepack enable
- pnpm config set store-dir .pnpm-store
cache: &cache
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
- node_modules/
- schemas/**/node_modules/
policy: pull
stages:
- build
- test
install:
stage: build
cache:
<<: *cache
policy: push
script:
- pnpm install
audit:
stage: test
script:
- pnpm audit
lint:
stage: test
script:
- pnpm lint
test:
stage: test
script:
- pnpm test
changeset:
stage: test
script:
- git pull -f origin main:main
- pnpm changeset status --since=main
build:
stage: test
script:
- pnpm build
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged npx lint-staged
20.10.0 20.11.1
.pnpm-store
pnpm-lock.yaml
CLI.md 0 → 100644
# CLI
The repository comes with a CLI.
In order to use the CLI, you must have a functional development environment including Node.js. We recommend using [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the Node.js version specified in the `.nvmrc` file present in this repository.
Once Node.js is installed, enable [Corepack](https://nodejs.org/api/corepack.html) to install the package manager (we use [pnpm](https://pnpm.io/)):
```sh
corepack enable
```
Install the dependencies:
```sh
pnpm i
```
Finally, link the CLI to make it callable:
```sh
pnpm link
```
You can now call `ejsc` (EBSI JSON Schema CLI).
## `compute-id` command <!-- omit in toc -->
```sh
# Compute the ID of a specific schema
# Example: ejsc compute-id schemas/ebsi-attestation/2021-11/schema.json
ejsc compute-id [path]
# Compute all IDs
ejsc compute-id --all
# Compute IDs of chosen files (a prompt will appear)
ejsc compute-id
```
## `publish` command <!-- omit in toc -->
```sh
# Publish a specific schema
# Example: ejsc publish schemas/ebsi-attestation/2021-11/schema.json
ejsc publish [path]
# Publish all schemas
ejsc publish --all
# Publish the chosen schemas (a prompt will appear)
ejsc publish
```
Tip: you can create a `.env` file to store your credentials, so you don't have to enter them every time you run the `publish` command.
Example:
```sh
EBSI_ENV=pilot
APIS_VERSION=latest
KID="did:ebsi:z...#..."
PRIVATE_KEY=0x...
```
The CLI supports 4 different environment variables:
- `EBSI_ENV`: the environment to which the schemas should be deployed. Valid values: `test`, `conformance`, `pilot`.
- `APIS_VERSION`: whether the schemas should be deployed to the latest APIs (TSR API v3) or the old ones. Valid values: `latest`, `old`.
- `KID`: the deployer's KID.
- `PRIVATE_KEY`: the deployer's private key, in hexadecimal, prefixed with `0x`.
## `sign` command <!-- omit in toc -->
This command helps signing arbitrary JSON objects. Keys (public and private) can be found from [actors.js](cli/commands/sign/actors.js) for each valid actor. The signer depends on the use case and is selectable by the caller. Use `--type jwt` for JSON Web Token (JWT) and `--type jws` for General JSON Web Signature (JWS) Serialisation.
```sh
# Sign all files found with the glob in JWT as Alice. Will target all 2022-05 examples
ejsc sign --actors alice --type jwt schemas/**/2022-05/examples/**
# Sign all files found with the glob in JWT as issuer. Will target all 2022-05 examples
ejsc sign --actors issuer --type jwt schemas/**/2022-05/examples/**
# Sign all files found with the glob in JWS as both issuer and issuer2. Will target all 2022-05 examples
ejsc sign --actors issuer issuer2 --type jws schemas/**/2022-05/examples/**
```
# Contributing
When you create a new JSON Schema, make sure to follow the folder structure described below. Moreover, the JSON Schema must pass the [automated tests](#testing), and comply with our [formatting conventions](#formatting).
Create a new branch from the `main` branch, commit your changes, and open a pull request on [GitLab](https://code.europa.eu/ebsi/json-schema)
## Requirements
In order to contribute to the project, you must have a functional development environment including Node.js. We recommend using [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the Node.js version specified in the `.nvmrc` file present in this repository.
Once Node.js is installed, enable [Corepack](https://nodejs.org/api/corepack.html) to install the package manager (we use [pnpm](https://pnpm.io/)):
```sh
corepack enable
```
Install the dependencies:
```sh
pnpm i
```
## Folder structure
In the root directory, we have 2 main folders —`schemas/` and `test/`) and configuration files.
### `schemas/`
The `schemas/` folder is where we store all the [JSON Schemas](https://json-schema.org/).
Each JSON Schema lives in its own folder.
The first-level folder defines the VC Data Model the schema implements. It is either [vcdm1.1](https://www.w3.org/TR/vc-data-model/) or [vcdm2.0](https://www.w3.org/TR/vc-data-model-2.0/).
Then, each schema lives in its own folder. For example, the EBSI Verifiable Attestation JSON schema (VCDM 1.1) can be found under `schemas/vcdm1.1/attestation`. You can also group related schemas in a common parent folder, as long as there is 1 folder for each schema.
In each schema folder, we can find the following files:
- `README.md`: automatically generated by running `pnpm test readme -- -u`.
- `CHANGELOG.md`: also automatically updated when we publish a new version of the schema.
- [`package.json`](https://docs.npmjs.com/cli/configuring-npm/package-json): defines the package name, version and dependencies.
- `schema.json`: defines the actual JSON Schema.
- `schema.metadata.json`: defines metadata associated with the JSON Schema. This can be automatically generated by running `pnpm test metadata -- -u`. By default, it contains the `vcdm` (VCDM version) and `id` (schema ID) properties, and you can add any custom property.
- `examples/` folder (optional): a directory containing JSON examples, which are automatically tested against the JSON Schema defined in `schema.json`
### `test/`
In the `test/` folder, we have automated test scripts that validate the JSON schemas and examples.
There are 5 automated tests:
- `schemas.test.js` scans the repository for `schema.json` files. It tries to compile the schemas with [Ajv](https://ajv.js.org/) (in strict mode), and throws errors when the tested schema is invalid.
- `examples.test.js` scans the repository for `examples/*.json` files. It tries to validate the examples against the related `schema.json` file that can be found next to the `examples/` folder.
- `manifest.test.js` verifies that the root `manifest.json` file is up-to-date. If it is not, you can run `pnpm test manifest -- -u` to update it automatically.
- `metadata.test.js` ensures that the `schema.metadata.json` files contain the correct information regarding the VCDM version and schema IDs.
- `readme.test.js` checks if the README.md files are up-to-date. Run `pnpm test readme -- -u` to update the README.md files automatically.
## Formatting
We use [Prettier](https://prettier.io/) (an opinionated code formatter) to format the JS and JSON files, and [ESLint](https://eslint.org/) to analyze the JS files.
You can run the following command to check if your files comply with Prettier and ESLint:
```sh
pnpm lint
```
To format all the files with Prettier, run:
```sh
pnpm format
```
## Testing
Run the tests:
```sh
pnpm test
```
If you just want to test the examples or the schemas, you can run one of the following commands:
```sh
# Validate the examples only
pnpm test test/examples.test.js
# Validate the schemas only
pnpm test test/schemas.test.js
```
## Publishing the packages
From the `main` branch, run:
```sh
pnpm publish-packages
```
to publish the packages to the npm registry. Add `--dry-run` if you want to check what will be published.
LICENSE 0 → 100644
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the
terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following
notice immediately following the copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1.Definitions
In this Licence, the following terms have the following meaning:
— ‘The Licence’:this Licence.
— ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available
as Source Code and also as Executable Code as the case may be.
— ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or
modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in
the country mentioned in Article 15.
— ‘The Work’:the Original Work or its Derivative Works.
— ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and
modify.
— ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by
a computer as a program.
— ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence.
— ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to
the creation of a Derivative Work.
— ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the
Licence.
— ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating,
transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential
functionalities at the disposal of any other natural or legal person.
2.Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for
the duration of copyright vested in the Original Work:
— use the Work in any circumstance and for all usage,
— reproduce the Work,
— modify the Work, and make Derivative Works based upon the Work,
— communicate to the public, including the right to make available or display the Work or copies thereof to the public
and perform publicly, as the case may be, the Work,
— distribute the Work or copies thereof,
— lend and rent the Work or copies thereof,
— sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the
applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed
by law in order to make effective the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the
extent necessary to make use of the rights granted on the Work under this Licence.
3.Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as
Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with
each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to
the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to
distribute or communicate the Work.
4.Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the
exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5.Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those
obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to
the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the
Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work
to carry prominent notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this
Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless
the Original Work is expressly distributed only under this version of the Licence — for example by communicating
‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the
Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both
the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done
under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed
in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide
a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available
for as long as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names
of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6.Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or
licensed to him/her and that he/she has the power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or
licensed to him/her and that he/she has the power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions
to the Work, under the terms of this Licence.
7.Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work
and may therefore contain defects or ‘bugs’ inherent to this type of development.
For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind
concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or
errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this
Licence.
This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
8.Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be
liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the
Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss
of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However,
the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
9.Additional agreements
While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services
consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10.Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window
displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms
and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You
by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution
or Communication by You of the Work or copies thereof.
11.Information to the public
In case of any Distribution or Communication of the Work by means of electronic communication by You (for example,
by offering to download the Work from a remote location) the distribution channel or media (for example, a website)
must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence
and the way it may be accessible, concluded, stored and reproduced by the Licensee.
12.Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms
of the Licence.
Such a termination will not terminate the licences of any person who has received the Work from the Licensee under
the Licence, provided such persons remain in full compliance with the Licence.
13.Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the
Work.
If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or
enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid
and enforceable.
The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of
the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence.
New versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take
advantage of the linguistic version of their choice.
14.Jurisdiction
Without prejudice to specific agreement between parties,
— any litigation resulting from the interpretation of this License, arising between the European Union institutions,
bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice
of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union,
— any litigation arising between other parties and resulting from the interpretation of this License, will be subject to
the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
15.Applicable Law
Without prejudice to specific agreement between parties,
— this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat,
resides or has his registered office,
— this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside
a European Union Member State.
Appendix
‘Compatible Licences’ according to Article 5 EUPL are:
— GNU General Public License (GPL) v. 2, v. 3
— GNU Affero General Public License (AGPL) v. 3
— Open Software License (OSL) v. 2.1, v. 3.0
— Eclipse Public License (EPL) v. 1.0
— CeCILL v. 2.0, v. 2.1
— Mozilla Public Licence (MPL) v. 2
— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software
— European Union Public Licence (EUPL) v. 1.1, v. 1.2
— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above licences without producing
a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the
covered Source Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new EUPL version.
\ No newline at end of file
![EBSI Logo](https://ec.europa.eu/digital-building-blocks/wikis/images/logo/default-space-logo.svg) ![EBSI Logo](https://ec.europa.eu/digital-building-blocks/wikis/images/logo/default-space-logo.svg)
# JSON Schemas <!-- omit in toc --> # JSON Schemas
> EBSI's JSON Schemas for VC and VP. > EBSI's JSON Schemas for VC and VP.
## Table of Contents <!-- omit in toc -->
- [Contributing](#contributing)
- [Requirements](#requirements)
- [Folder structure](#folder-structure)
- [Formatting](#formatting)
- [Testing](#testing)
- [CLI](#cli) - [CLI](#cli)
- [Contributing](#contributing)
- [License](#license) - [License](#license)
## Contributing
When you create a new JSON Schema, make sure to follow the folder structure described below. Moreover, the JSON Schema must pass the [automated tests](#testing), and comply with our [formatting conventions](#formatting).
Create a new branch from the `main` branch, commit your changes, and open a pull request on [GitLab](https://code.europa.eu/ebsi/json-schema)
### Requirements
In order to properly contribute to the project, you should have a functional development environment including Node.js (>=18.0.0 || >=20.0.0).
Install the dependencies:
```sh
npm i
```
### Folder structure
In the root directory, we have 2 main folders (`schemas/` and `test/`) and configuration files.
This folder structure makes it easy to automate the tests. It also clearly shows all the existing versions of the schemas, without having to navigate between git branches.
#### `schemas/` <!-- omit in toc -->
The `schemas/` folder is where we store all the [JSON Schemas](https://json-schema.org/).
Each JSON Schema lives in its own folder. For example, the EBSI Verifiable Attestation JSON schema can be found under `/schemas/ebsi-attestation`.
In each schema folder, we can find:
- a `README.md` file, which briefly describes the JSON Schema, and links to relevant documentation pages. More importantly, this README also shows the changes between the different versions of the schema.
- 1 subfolder per version. These folders are named `YYYY-MM(_VV)`. Examples: `2021-11`, `2022-02`, `2022-02_01`, etc. Year (YYYY) and month (MM) of publication are mandatory, while a version number (VV) can be added if multiple versions of the schema are published during a specific month. The date of "publication" corresponds to the date of the merge to the `main` branch. For example, if we merge a pull request in March 2022, we name the folder `2022-03`. If we need to publish a new version of the schema during the same month, we add version number (`_01`, `_02`, etc.).
In a schema version subfolder (e.g. `2021-11`), we store:
- `schema.json`: the actual JSON Schema.
- `examples/` folder (optional): a directory containing JSON examples, which are automatically tested against the JSON Schema defined in `schema.json`
- `test/` folder (optional): a directory containing specific test files. For example, we could test the retro-compatibility of a new schema version.
#### `test/` <!-- omit in toc -->
In the `test/` folder, we have automated test scripts that validate the JSON schemas and examples.
There are 2 automated tests:
- The first automated test scans the repository for `schema.json` files. It tries to compile the schemas with [Ajv](https://ajv.js.org/) (in strict mode), and throws errors when the tested schema is invalid.
- The second automated test scans the repository for `examples/*.json` files. It tries to validate the examples against the related `schema.json` file that can be found next to the `examples/` folder.
### Formatting
We use [Prettier](https://prettier.io/) (an opinionated code formatter) to format the JS and JSON files, and [ESLint](https://eslint.org/) to analyze the JS files.
You can run the following command to check if your files comply with Prettier and ESLint:
```sh
npm run lint
```
To format all the files with Prettier, run:
```sh
npm run format
```
### Testing
Run the tests:
```sh
npm test
```
If you just want to test the examples or the schemas, you can run one of the following commands:
```sh
# Validate the examples only
npm run test test/examples.test.js
# Validate the schemas only
npm run test test/schemas.test.js
```
## CLI ## CLI
The repository comes with a CLI. The repository comes with a [CLI](CLI.md) that you can use to publish schemas or sign arbitrary JSON objects.
First, install the dependencies and link the CLI to make it callable:
```sh
npm i
npm link
```
You can now call `ejsc` (EBSI JSON Schema CLI).
### `compute-id` command <!-- omit in toc -->
```sh
# Compute the ID of a specific schema
# Example: ejsc compute-id schemas/ebsi-attestation/2021-11/schema.json
ejsc compute-id [path]
# Compute all IDs
ejsc compute-id --all
# Compute IDs of chosen files (a prompt will appear) ## Contributing
ejsc compute-id
```
### `publish` command <!-- omit in toc -->
```sh
# Publish a specific schema
# Example: ejsc publish schemas/ebsi-attestation/2021-11/schema.json
ejsc publish [path]
# Publish all schemas
ejsc publish --all
# Publish the chosen schemas (a prompt will appear)
ejsc publish
```
Tip: you can create a `.env` file to store your credentials, so you don't have to enter them every time you run the `publish` command.
Example:
```sh
EBSI_ENV=pilot
APIS_VERSION=latest
KID="did:ebsi:z...#..."
PRIVATE_KEY=0x...
```
The CLI supports 4 different environment variables:
- `EBSI_ENV`: the environment to which the schemas should be deployed. Valid values: `test`, `conformance`, `pilot`.
- `APIS_VERSION`: whether the schemas should be deployed to the latest APIs (TSR API v3) or the old ones. Valid values: `latest`, `old`.
- `KID`: the deployer's KID.
- `PRIVATE_KEY`: the deployer's private key, in hexadecimal, prefixed with `0x`.
### `sign` command <!-- omit in toc -->
This command helps signing arbitrary json objects. Keys (public and private) can be found from [actors.js](cli/commands/sign/actors.js) for each valid actor. The signer depends on the use case and is selectable by the caller. Use `--type jwt` for JSON Web Token (JWT) and `--type jws` for General JSON Web Signature (JWS) Serialisation.
```sh
# Sign all files found with the glob in JWT as Alice. Will target all 2022-05 examples
ejsc sign --actors alice --type jwt schemas/**/2022-05/examples/**
# Sign all files found with the glob in JWT as issuer. Will target all 2022-05 examples
ejsc sign --actors issuer --type jwt schemas/**/2022-05/examples/**
# Sign all files found with the glob in JWS as both issuer and issuer2. Will target all 2022-05 examples See [CONTRIBUTING.md](CONTRIBUTING.md).
ejsc sign --actors issuer issuer2 --type jws schemas/**/2022-05/examples/**
```
## License ## License
......
...@@ -7,18 +7,16 @@ import canonicalize from "canonicalize"; ...@@ -7,18 +7,16 @@ import canonicalize from "canonicalize";
import { globbySync } from "globby"; import { globbySync } from "globby";
import inquirer from "inquirer"; import inquirer from "inquirer";
import Ajv2020 from "ajv/dist/2020.js"; import Ajv2020 from "ajv/dist/2020.js";
import Ajv2019 from "ajv/dist/2019.js";
import AjvDraft07 from "ajv";
import addFormats from "ajv-formats"; import addFormats from "ajv-formats";
// eslint-disable-next-line import/extensions // eslint-disable-next-line import/extensions
import { base16 } from "multiformats/bases/base16"; import { base16 } from "multiformats/bases/base16";
// eslint-disable-next-line import/extensions
import { base58btc } from "multiformats/bases/base58";
export function removeAnnotations(obj) { export function removeAnnotations(obj) {
/** /**
* Lists of annotations keywords: * Lists of annotations keywords: https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9
* - https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9 * In addition to the annotations keywords, we also ignore comments: https://json-schema.org/understanding-json-schema/reference/comments
* - https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9
* - https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10
*/ */
const keysToRemove = [ const keysToRemove = [
"title", "title",
...@@ -28,6 +26,7 @@ export function removeAnnotations(obj) { ...@@ -28,6 +26,7 @@ export function removeAnnotations(obj) {
"readOnly", "readOnly",
"writeOnly", "writeOnly",
"examples", "examples",
"$comment",
]; ];
return JSON.parse( return JSON.parse(
...@@ -97,10 +96,10 @@ export async function computeId(schemaPath) { ...@@ -97,10 +96,10 @@ export async function computeId(schemaPath) {
.digest(); .digest();
// 5. Return multibase base58 (BTC) encoded hash // 5. Return multibase base58 (BTC) encoded hash
// return base58btc.encode(hash); return {
base16: `0x${base16.baseEncode(hash)}`,
// Temporary: until we update TSR API multibase_base58btc: base58btc.encode(hash),
return `0x${base16.baseEncode(hash)}`; };
} }
const currentDir = dirname(fileURLToPath(import.meta.url)); const currentDir = dirname(fileURLToPath(import.meta.url));
...@@ -147,7 +146,7 @@ export async function getSchemaIds(paths, options) { ...@@ -147,7 +146,7 @@ export async function getSchemaIds(paths, options) {
return Promise.all( return Promise.all(
schemas.map(async (schema) => { schemas.map(async (schema) => {
const id = await computeId(schema); const { multibase_base58btc: id } = await computeId(schema);
return { id, schema }; return { id, schema };
}), }),
); );
...@@ -169,16 +168,6 @@ export async function validateSchema( ...@@ -169,16 +168,6 @@ export async function validateSchema(
ajv = new Ajv2020({ allErrors: true, strict: true }); ajv = new Ajv2020({ allErrors: true, strict: true });
break; break;
} }
// https://github.com/json-schema-org/json-schema-spec/blob/2019-09/schema.json
case "https://json-schema.org/draft/2019-09/schema": {
ajv = new Ajv2019({ allErrors: true, strict: true });
break;
}
// https://github.com/json-schema-org/json-schema-spec/blob/draft-07/schema.json
case "http://json-schema.org/draft-07/schema#": {
ajv = new AjvDraft07({ allErrors: true, strict: true });
break;
}
default: { default: {
throw new Error(`Unknown version "${bundledSchema.$schema}"`); throw new Error(`Unknown version "${bundledSchema.$schema}"`);
} }
...@@ -213,7 +202,7 @@ export async function validateSchema( ...@@ -213,7 +202,7 @@ export async function validateSchema(
}, Promise.resolve([])); }, Promise.resolve([]));
} }
const id = await computeId(schema); const { multibase_base58btc: id } = await computeId(schema);
return [ return [
...deps, ...deps,
......
...@@ -18,7 +18,7 @@ export const requestSiopJwt = async ({ ...@@ -18,7 +18,7 @@ export const requestSiopJwt = async ({
const siopAgent = new SiopAgent({ const siopAgent = new SiopAgent({
privateKey: await importJWK( privateKey: await importJWK(
encode.privateKey.fromHextoJWK(clientPrivateKey), encode.privateKey.fromHexToJWK(clientPrivateKey),
alg, alg,
), ),
kid: clientKid, kid: clientKid,
......
This diff is collapsed.
This diff is collapsed.
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
"ejsc": "bin/run.js" "ejsc": "bin/run.js"
}, },
"scripts": { "scripts": {
"build": "node ./scripts/build.js",
"format": "prettier . --write", "format": "prettier . --write",
"lint:eslint": "eslint .", "lint:eslint": "eslint .",
"lint:prettier": "prettier . --check", "lint:prettier": "prettier . --check",
"lint": "npm run lint:eslint && npm run lint:prettier", "lint": "pnpm run lint:eslint && pnpm run lint:prettier",
"test": "vitest --run", "test": "vitest --run",
"prepare": "is-ci || husky install" "prepare": "is-ci || husky",
"publish-packages": "pnpm build && pnpm publish -r"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -40,16 +42,19 @@ ...@@ -40,16 +42,19 @@
"multiformats": "^9.6.4" "multiformats": "^9.6.4"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.56.0", "@changesets/cli": "^2.27.1",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.2", "eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-vitest": "^0.3.20", "eslint-plugin-vitest": "^0.3.20",
"husky": "^8.0.3", "husky": "^9.0.11",
"is-ci": "^3.0.1", "is-ci": "^3.0.1",
"lint-staged": "^13.0.3", "json-schema-to-typescript": "^13.1.2",
"lint-staged": "^15.2.2",
"prettier": "^3.1.1", "prettier": "^3.1.1",
"ts-morph": "^21.0.1",
"vitest": "^1.2.0" "vitest": "^1.2.0"
}, },
"prettier": {}, "prettier": {},
...@@ -69,10 +74,29 @@ ...@@ -69,10 +74,29 @@
"error", "error",
"always" "always"
] ]
},
"overrides": [
{
"files": [
"scripts/**/*.js"
],
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true,
"optionalDependencies": false,
"peerDependencies": false,
"bundledDependencies": false
} }
]
}
}
]
}, },
"lint-staged": { "lint-staged": {
"*.{js}": "eslint --fix", "*.{js}": "eslint --fix",
"*.{md,json}": "prettier --write" "*.{md,json}": "prettier --write"
} },
"packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2"
} }
This diff is collapsed.
packages:
- "schemas/**"
{
"@context": ["https://www.w3.org/2018/credentials/v1"],
"id": "urn:uuid:8568b525-a24e-4bc0-9d97-6a8459ec0130",
"type": [
"VerifiableCredential",
"VerifiableAttestation",
"VerifiableAccreditation",
"VerifiableAccreditationToAccredit"
],
"issuer": "did:ebsi:00001234",
"issuanceDate": "2021-11-01T00:00:00Z",
"validFrom": "2021-11-01T00:00:00Z",
"expirationDate": "2024-06-22T14:11:44Z",
"issued": "2020-06-22T14:11:44Z",
"credentialSubject": {
"id": "did:ebsi:00001235",
"accreditedFor": [
{
"schemaId": "https://api-test.ebsi.eu/trusted-schemas-registry/v2/schemas/0x010110",
"types": [
"VerifiableCredential",
"VerifiableAttestation",
"DiplomaCredential"
],
"limitJurisdiction": "https://publications.europa.eu/resource/authority/atu/FIN"
}
]
},
"termsOfUse": [
{
"id": "https://api-test.ebsi.eu/trusted-issuers-registry/../..xyz",
"type": "IssuanceCertificate"
}
],
"credentialSchema": [
{
"id": "https://api-test.ebsi.eu/trusted-schemas-registry/v2/schemas/0xc4747735f30c452de7bfc29ea71f26e161de0688d696e577b0f849fff145f644",
"type": "FullJsonSchemaValidator2021"
},
{
"id": "https://api-test.ebsi.eu/trusted-schemas-registry/v2/schemas/0x1d7146f8897aa6cd5c59321ea0756ec61277028e4a8b3c13ec1b310ec47e6495",
"type": "FullJsonSchemaValidator2021"
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment