@smartdcc/duis-sign-wrap
v0.1.2
Published
Wrapper library for signing/validating DUIS
Downloads
305
Maintainers
Readme
DUIS Signing Wrapper
Lightweight TypeScript wrapper around
SmartDCCInnovation/dccboxed-signing-tool - which is a tool for signing
and validating DUIS messages. This package dccboxed-sogning-tool
as a
JavaScript package with some additional marshalling and error handling. That is,
it provides an API to create and validate an appropriately formatted xmldsig
.
Usage
Important: This package wraps around a JAR file, thus it is essential that a Java Runtime Environment is installed and available in the PATH before using it. Please use JRE 11 (or newer).
From Debian/Ubuntu an appropriate JRE can be installed with:
sudo apt install openjdk-11-jre
Developed and tested against node 16
. Install from npm
:
npm i @smartdcc/duis-sign-wrap
Sign DUIS
Below is a minimal example of how to use the library:
import { signDuis } from '@smartdcc/duis-sign-wrap'
import { readFile } from 'node:fs/promises'
const duisSigned: string = signDuis(await readFile('/path/to/duis/file-without-signature.xml'))
Providing no exception was raised, the resulting duisSigned
should be
compatible with DCC Boxed.
Validate
Then to validate a signed DUIS against its XSD and remove the digital signature:
import { validateDuis } from '@smartdcc/duis-sign-wrap'
const xml: string = validateDuis(duisSigned)
Advanced
The intention is that this tool is compatible with the duis-parser to obtain a JSON representation of the DUIS. A minimal example without error handling would be:
import { validateDuis } from '@smartdcc/duis-sign-wrap'
import { parseDuis } from '@smartdcc/duis-parser'
const data = parseDuis(validateDuis(duisSigned))
Contributing
Contributions are welcome!
Remember, when developing it is required to install a JDK (to build the
dccboxed-siging-tool
) and update submodules. To build the JAR file, run the
following command: npm run build:jar
.
When submitting a pull request, please ensure:
- Each PR is concise and provides only one feature/bug fix.
- Unit test are provided to cover feature. The project uses
jest
. To test, runnpm run test:cov
to view code coverage metrics. - Bugfixes are reference the GitHub issue.
- If appropriate, update documentation.
- Before committing, run
npm run lint
andnpm run prettier-check
.
If you are planning a new non-trivial feature, please first raise a GitHub issue to discuss it to before investing your time to avoid disappointment.
Any contributions will be expected to be licensable under GPLv3.
Other Info
Copyright 2022, Smart DCC Limited, All rights reserved. Project is licensed under GPLv3.