@smartdcc/duis-sign-wrap 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -8
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +153 -0
- package/dist/server.js.map +1 -0
- package/dist/tool.jar +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,9 +9,19 @@
|
|
|
9
9
|
|
|
10
10
|
Lightweight TypeScript wrapper around
|
|
11
11
|
[SmartDCCInnovation/dccboxed-signing-tool][sign] - which is a tool for signing
|
|
12
|
-
and validating [DUIS][duis] messages. This package `dccboxed-
|
|
12
|
+
and validating [DUIS][duis] messages. This package wraps `dccboxed-signing-tool` as a
|
|
13
13
|
JavaScript package with some additional marshalling and error handling. That is,
|
|
14
|
-
it provides an API to create and validate an appropriately formatted `xmldsig`.
|
|
14
|
+
it provides an API to create and validate an appropriately formatted `xmldsig`.
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Sign DUIS](#sign-duis)
|
|
20
|
+
- [Validate](#validate)
|
|
21
|
+
- [HTTP Backend](#http-backend)
|
|
22
|
+
- [Advanced](#advanced)
|
|
23
|
+
- [API Options](#api-options)
|
|
24
|
+
- [Contributing](#contributing)
|
|
15
25
|
|
|
16
26
|
## Usage
|
|
17
27
|
|
|
@@ -25,7 +35,7 @@ From Debian/Ubuntu an appropriate JRE can be installed with:
|
|
|
25
35
|
sudo apt install openjdk-11-jre
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
Developed and tested against `node
|
|
38
|
+
Developed and tested against `node 24`. Install from `npm`:
|
|
29
39
|
|
|
30
40
|
```
|
|
31
41
|
npm i @smartdcc/duis-sign-wrap
|
|
@@ -39,7 +49,7 @@ Below is a minimal example of how to use the library:
|
|
|
39
49
|
import { signDuis } from '@smartdcc/duis-sign-wrap'
|
|
40
50
|
import { readFile } from 'node:fs/promises'
|
|
41
51
|
|
|
42
|
-
const duisSigned: string = signDuis(await readFile('/path/to/duis/file-without-signature.xml'))
|
|
52
|
+
const duisSigned: string = await signDuis({ xml: await readFile('/path/to/duis/file-without-signature.xml') })
|
|
43
53
|
```
|
|
44
54
|
|
|
45
55
|
Providing no exception was raised, the resulting `duisSigned` should be
|
|
@@ -53,7 +63,34 @@ signature:
|
|
|
53
63
|
```ts
|
|
54
64
|
import { validateDuis } from '@smartdcc/duis-sign-wrap'
|
|
55
65
|
|
|
56
|
-
const xml: string = validateDuis(duisSigned)
|
|
66
|
+
const xml: string = await validateDuis({ xml: duisSigned })
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### HTTP Backend
|
|
70
|
+
|
|
71
|
+
The library supports using an HTTP backend server for signing and validation,
|
|
72
|
+
which provides increased performance for multiple operations by reusing the same
|
|
73
|
+
Java process.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { signDuis, validateDuis } from '@smartdcc/duis-sign-wrap'
|
|
77
|
+
|
|
78
|
+
// Automatically start and manage a local backend server
|
|
79
|
+
const signed = await signDuis({ xml: '<duis/>', backend: true })
|
|
80
|
+
const validated = await validateDuis({ xml: signed, backend: true })
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Alternatively, a custom backend server can be provided that conforms to the correct
|
|
84
|
+
API. This is useful when needing to integrate with a bespoke key store. The HTTP API
|
|
85
|
+
is documented within the [SmartDCCInnovation/dccboxed-signing-tool][sign] tool.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// Or use a custom backend URL
|
|
89
|
+
const customSigned = await signDuis({
|
|
90
|
+
xml: '<duis/>',
|
|
91
|
+
backend: new URL('http://signing-service.example.com/'),
|
|
92
|
+
headers: { 'Authorization': 'Bearer token' }
|
|
93
|
+
})
|
|
57
94
|
```
|
|
58
95
|
|
|
59
96
|
### Advanced
|
|
@@ -66,7 +103,31 @@ error handling would be:
|
|
|
66
103
|
import { validateDuis } from '@smartdcc/duis-sign-wrap'
|
|
67
104
|
import { parseDuis } from '@smartdcc/duis-parser'
|
|
68
105
|
|
|
69
|
-
const data =
|
|
106
|
+
const data = parseDuis(await validateDuis({ xml: duisSigned }))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## API Options
|
|
110
|
+
|
|
111
|
+
Both `signDuis` and `validateDuis` accept an options object with the following properties:
|
|
112
|
+
|
|
113
|
+
- `xml` (string | Buffer, required): The DUIS XML content to sign or validate
|
|
114
|
+
- `backend` (boolean | URL, optional): Use HTTP backend for improved performance
|
|
115
|
+
- `true`: Automatically start and manage a local backend server
|
|
116
|
+
- `URL`: Use a custom backend server at the specified URL
|
|
117
|
+
- `headers` (Record<string, string>, optional): Custom HTTP headers when using backend mode
|
|
118
|
+
- `preserveCounter` (boolean, optional, sign only): Preserve counter value in RequestID when signing
|
|
119
|
+
|
|
120
|
+
### Error Handling
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { signDuis } from '@smartdcc/duis-sign-wrap'
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const signed = await signDuis({ xml: '<invalid/>', backend: true })
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error('Signing failed:', error.message)
|
|
129
|
+
// Handle validation errors, missing credentials, etc.
|
|
130
|
+
}
|
|
70
131
|
```
|
|
71
132
|
|
|
72
133
|
## Contributing
|
|
@@ -74,7 +135,7 @@ const data = parseDuis(validateDuis(duisSigned))
|
|
|
74
135
|
Contributions are welcome!
|
|
75
136
|
|
|
76
137
|
Remember, when developing it is required to install a JDK (to build the
|
|
77
|
-
`dccboxed-
|
|
138
|
+
`dccboxed-signing-tool`) and update submodules. To build the JAR file, run the
|
|
78
139
|
following command: `npm run build:jar`.
|
|
79
140
|
|
|
80
141
|
When submitting a pull request, please ensure:
|
|
@@ -93,7 +154,7 @@ Any contributions will be expected to be licensable under GPLv3.
|
|
|
93
154
|
|
|
94
155
|
## Other Info
|
|
95
156
|
|
|
96
|
-
Copyright
|
|
157
|
+
Copyright 2026, Smart DCC Limited, All rights reserved. Project is licensed under GPLv3.
|
|
97
158
|
|
|
98
159
|
|
|
99
160
|
[duis]: https://smartenergycodecompany.co.uk/the-smart-energy-code-2/ "Smart Energy Code"
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export interface SignOptions {
|
|
|
7
7
|
* Preserve counter value in RequestID when signing
|
|
8
8
|
*/
|
|
9
9
|
preserveCounter?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Http server backend
|
|
12
|
+
*/
|
|
13
|
+
backend?: boolean | URL;
|
|
14
|
+
/**
|
|
15
|
+
* Http headers to pass to backend
|
|
16
|
+
*/
|
|
17
|
+
headers?: Record<string, string>;
|
|
10
18
|
/**
|
|
11
19
|
* Override the location of the xmldsig jar file, used for testing.
|
|
12
20
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,GAAG,CAAA;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAKlE"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* Created on Thu Jul 21 2022
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2026 Smart DCC Limited
|
|
6
6
|
*
|
|
7
7
|
* This program is free software: you can redistribute it and/or modify
|
|
8
8
|
* it under the terms of the GNU General Public License as published by
|
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.signDuis = signDuis;
|
|
22
22
|
exports.validateDuis = validateDuis;
|
|
23
|
+
const server_1 = require("./server");
|
|
23
24
|
const tool_1 = require("./tool");
|
|
24
25
|
function signDuis(options) {
|
|
25
|
-
|
|
26
|
-
...options,
|
|
27
|
-
|
|
28
|
-
});
|
|
26
|
+
if (options.backend) {
|
|
27
|
+
return (0, server_1.makeSignDuisRequest)({ ...options, backend: options.backend });
|
|
28
|
+
}
|
|
29
|
+
return (0, tool_1.runTool)({ ...options, mode: 'sign' });
|
|
29
30
|
}
|
|
30
31
|
function validateDuis(options) {
|
|
31
|
-
|
|
32
|
-
...options,
|
|
33
|
-
|
|
34
|
-
});
|
|
32
|
+
if (options.backend) {
|
|
33
|
+
return (0, server_1.makeVerifyDuisRequest)({ ...options, backend: options.backend });
|
|
34
|
+
}
|
|
35
|
+
return (0, tool_1.runTool)({ ...options, mode: 'validate' });
|
|
35
36
|
}
|
|
36
37
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAgCH,4BAKC;AAED,oCAKC;AA1CD,qCAAqE;AACrE,iCAAgC;AA6BhC,SAAgB,QAAQ,CAAC,OAAoB;IAC3C,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,IAAA,4BAAmB,EAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,IAAA,cAAO,EAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAgB,YAAY,CAAC,OAAoB;IAC/C,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,IAAA,8BAAqB,EAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IACxE,CAAC;IACD,OAAO,IAAA,cAAO,EAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;AAClD,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const port: number;
|
|
2
|
+
export declare function startBackend(): Promise<void>;
|
|
3
|
+
export declare function checkPort(port: number): Promise<boolean>;
|
|
4
|
+
export declare function stopBackend(): void;
|
|
5
|
+
export interface HttpOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Unsigned DUIS xml string
|
|
8
|
+
*/
|
|
9
|
+
xml: string | Buffer;
|
|
10
|
+
/**
|
|
11
|
+
* Preserve counter value in RequestID when signing
|
|
12
|
+
*/
|
|
13
|
+
preserveCounter?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Http server backend, set to true to automatically manage a server instance
|
|
16
|
+
*/
|
|
17
|
+
backend: true | URL;
|
|
18
|
+
/**
|
|
19
|
+
* Additional http headers to pass to backend
|
|
20
|
+
*/
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export declare function buildUrl(backend: true | URL, mode: 'sign' | 'verify'): URL;
|
|
24
|
+
export declare function makeRequest(url: URL, options: Omit<HttpOptions, 'backend'>): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Signs a DUIS message using the HTTP backend.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Configuration options including XML content and backend URL
|
|
29
|
+
* @returns Promise resolving to the signed DUIS XML string
|
|
30
|
+
* @throws Error if the backend returns a non-200 status or invalid response
|
|
31
|
+
*/
|
|
32
|
+
export declare function makeSignDuisRequest(options: HttpOptions): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Validates and verifies a signed DUIS message using the HTTP backend.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Configuration options including XML content and backend URL
|
|
37
|
+
* @returns Promise resolving to the validated DUIS XML string without signature
|
|
38
|
+
* @throws Error if the backend returns a non-200 status or invalid response
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeVerifyDuisRequest(options: HttpOptions): Promise<string>;
|
|
41
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,IAAI,QAA4C,CAAA;AAI7D,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAoClD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYxD;AAED,wBAAgB,WAAW,IAAI,IAAI,CAMlC;AAMD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,OAAO,EAAE,IAAI,GAAG,GAAG,CAAA;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,GAAG,CAK1E;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CASjB"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Created on Fri Feb 06 2026
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Smart DCC Limited
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.port = void 0;
|
|
22
|
+
exports.startBackend = startBackend;
|
|
23
|
+
exports.checkPort = checkPort;
|
|
24
|
+
exports.stopBackend = stopBackend;
|
|
25
|
+
exports.buildUrl = buildUrl;
|
|
26
|
+
exports.makeRequest = makeRequest;
|
|
27
|
+
exports.makeSignDuisRequest = makeSignDuisRequest;
|
|
28
|
+
exports.makeVerifyDuisRequest = makeVerifyDuisRequest;
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
const node_child_process_1 = require("node:child_process");
|
|
31
|
+
const node_net_1 = require("node:net");
|
|
32
|
+
const jarFile = (0, path_1.resolve)(__dirname, 'tool.jar');
|
|
33
|
+
exports.port = Math.round(Math.random() * 16384) + 32768;
|
|
34
|
+
let child;
|
|
35
|
+
async function startBackend() {
|
|
36
|
+
if (child !== undefined && child.exitCode === null) {
|
|
37
|
+
/* already running */
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
child = (0, node_child_process_1.spawn)('java', [
|
|
41
|
+
'-cp',
|
|
42
|
+
jarFile,
|
|
43
|
+
'uk.co.smartdcc.boxed.xmldsig.Server',
|
|
44
|
+
'-p',
|
|
45
|
+
exports.port.toString(10),
|
|
46
|
+
], {
|
|
47
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
48
|
+
});
|
|
49
|
+
let ctr = 0;
|
|
50
|
+
do {
|
|
51
|
+
if (ctr > 10) {
|
|
52
|
+
child?.kill();
|
|
53
|
+
throw new Error('timeout waiting for server to start');
|
|
54
|
+
}
|
|
55
|
+
await new Promise((resolve) => {
|
|
56
|
+
setTimeout(resolve, 50);
|
|
57
|
+
});
|
|
58
|
+
if (child.exitCode !== null) {
|
|
59
|
+
throw new Error('server failed to start');
|
|
60
|
+
}
|
|
61
|
+
ctr++;
|
|
62
|
+
} while ((await checkPort(exports.port)) === false);
|
|
63
|
+
}
|
|
64
|
+
function checkPort(port) {
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
const socket = new node_net_1.Socket();
|
|
67
|
+
socket.setTimeout(100);
|
|
68
|
+
socket.connect(port, '127.0.0.1', () => {
|
|
69
|
+
socket.end();
|
|
70
|
+
resolve(true);
|
|
71
|
+
});
|
|
72
|
+
socket.on('error', () => {
|
|
73
|
+
resolve(false);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function stopBackend() {
|
|
78
|
+
if (child === undefined || child.exitCode !== null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
child.kill();
|
|
82
|
+
child = undefined;
|
|
83
|
+
}
|
|
84
|
+
process.on('exit', stopBackend);
|
|
85
|
+
process.on('SIGINT', stopBackend);
|
|
86
|
+
process.on('SIGTERM', stopBackend);
|
|
87
|
+
function buildUrl(backend, mode) {
|
|
88
|
+
if (backend === true) {
|
|
89
|
+
return new URL(`http://localhost:${exports.port}/${mode}`);
|
|
90
|
+
}
|
|
91
|
+
return new URL(mode, backend);
|
|
92
|
+
}
|
|
93
|
+
async function makeRequest(url, options) {
|
|
94
|
+
const body = {
|
|
95
|
+
message: Buffer.from(options.xml).toString('base64'),
|
|
96
|
+
};
|
|
97
|
+
if (typeof options.preserveCounter === 'boolean') {
|
|
98
|
+
body.preserveCounter = options.preserveCounter;
|
|
99
|
+
}
|
|
100
|
+
const response = await fetch(url, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
...(options.headers ?? {}),
|
|
105
|
+
},
|
|
106
|
+
body: JSON.stringify(body),
|
|
107
|
+
});
|
|
108
|
+
if (response.status !== 200) {
|
|
109
|
+
const error = (await response.json());
|
|
110
|
+
throw new Error(error.errorCode ?? `HTTP ${response.status}`, {
|
|
111
|
+
cause: error.error,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const data = (await response.json());
|
|
115
|
+
if (typeof data?.message !== 'string') {
|
|
116
|
+
throw new Error('invalid response');
|
|
117
|
+
}
|
|
118
|
+
return Buffer.from(data.message, 'base64').toString('utf8');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Signs a DUIS message using the HTTP backend.
|
|
122
|
+
*
|
|
123
|
+
* @param options - Configuration options including XML content and backend URL
|
|
124
|
+
* @returns Promise resolving to the signed DUIS XML string
|
|
125
|
+
* @throws Error if the backend returns a non-200 status or invalid response
|
|
126
|
+
*/
|
|
127
|
+
async function makeSignDuisRequest(options) {
|
|
128
|
+
if (options.backend === true) {
|
|
129
|
+
await startBackend();
|
|
130
|
+
}
|
|
131
|
+
return makeRequest(buildUrl(options.backend, 'sign'), {
|
|
132
|
+
xml: options.xml,
|
|
133
|
+
preserveCounter: options.preserveCounter,
|
|
134
|
+
headers: options.headers,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validates and verifies a signed DUIS message using the HTTP backend.
|
|
139
|
+
*
|
|
140
|
+
* @param options - Configuration options including XML content and backend URL
|
|
141
|
+
* @returns Promise resolving to the validated DUIS XML string without signature
|
|
142
|
+
* @throws Error if the backend returns a non-200 status or invalid response
|
|
143
|
+
*/
|
|
144
|
+
async function makeVerifyDuisRequest(options) {
|
|
145
|
+
if (options.backend === true) {
|
|
146
|
+
await startBackend();
|
|
147
|
+
}
|
|
148
|
+
return makeRequest(buildUrl(options.backend, 'sign'), {
|
|
149
|
+
xml: options.xml,
|
|
150
|
+
headers: options.headers,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAWH,oCAoCC;AAED,8BAYC;AAED,kCAMC;AA4BD,4BAKC;AAED,kCAgCC;AASD,kDAYC;AASD,sDAWC;AA/KD,+BAA8B;AAC9B,2DAAwD;AACxD,uCAAiC;AAEjC,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AACjC,QAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM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,CACzC,OAAoB;IAEpB,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC7B,MAAM,YAAY,EAAE,CAAA;IACtB,CAAC;IAED,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;QACpD,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/tool.jar
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartdcc/duis-sign-wrap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Wrapper library for signing/validating DUIS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@tsconfig/node20": "^20.1.4",
|
|
30
30
|
"@types/jest": "^30.0.0",
|
|
31
31
|
"@types/node": "^24.0.13",
|
|
32
|
-
"cpy-cli": "^
|
|
32
|
+
"cpy-cli": "^7.0.0",
|
|
33
33
|
"del-cli": "^7.0.0",
|
|
34
34
|
"eslint": "^9.9.0",
|
|
35
35
|
"eslint-config-prettier": "^10.0.1",
|