vet-sdk-core-ts 0.4.27 → 0.4.29
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/dist/secure-clinic-channel.js +27 -10
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ml_dsa44 } from '@noble/post-quantum/ml-dsa.js';
|
|
2
2
|
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
|
|
3
|
+
import { prepareVeterinaryIndexTaggedBundle } from 'vet-data-utils-ts/index-projection-tags';
|
|
3
4
|
const encoder = new TextEncoder();
|
|
4
5
|
const decoder = new TextDecoder();
|
|
5
6
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
@@ -82,16 +83,29 @@ function extractIndexProjection(bundle, policy) {
|
|
|
82
83
|
continue;
|
|
83
84
|
if (typeof entry.fullUrl !== 'string')
|
|
84
85
|
throw new Error('Each indexed resource requires an absolute HTTPS fullUrl');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const relative = /^([A-Z][A-Za-z0-9]+)\/([0-9a-f-]+)$/i.exec(entry.fullUrl);
|
|
87
|
+
let urlResourceType;
|
|
88
|
+
let urlId;
|
|
89
|
+
if (relative) {
|
|
90
|
+
;
|
|
91
|
+
[, urlResourceType, urlId] = relative;
|
|
88
92
|
}
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
else {
|
|
94
|
+
let parsed;
|
|
95
|
+
try {
|
|
96
|
+
parsed = new URL(entry.fullUrl);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
throw new Error('The index fullUrl must contain /<ResourceType>/<UUID>');
|
|
100
|
+
}
|
|
101
|
+
if (parsed.protocol !== 'https:')
|
|
102
|
+
throw new Error('The index fullUrl must contain /<ResourceType>/<UUID>');
|
|
103
|
+
const segments = parsed.pathname.split('/').filter(Boolean);
|
|
104
|
+
urlResourceType = segments.at(-2);
|
|
105
|
+
urlId = segments.at(-1);
|
|
91
106
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|| segments.at(-1) !== resource.id || !UUID_PATTERN.test(resource.id)) {
|
|
107
|
+
if (urlResourceType !== resource.resourceType
|
|
108
|
+
|| urlId !== resource.id || !UUID_PATTERN.test(resource.id)) {
|
|
95
109
|
throw new Error('The fullUrl must end in /<ResourceType>/<UUID> matching the resource');
|
|
96
110
|
}
|
|
97
111
|
if (resource.resourceType === 'Binary' && resource.contentType === 'application/pdf') {
|
|
@@ -125,12 +139,15 @@ function sign(sender, plaintext) {
|
|
|
125
139
|
return `${header}.${payload}.${base64Url(ml_dsa44.sign(encoder.encode(`${header}.${payload}`), sender.signingSecretKey))}`;
|
|
126
140
|
}
|
|
127
141
|
export async function sealVeterinarySecureClinicMessage(input) {
|
|
128
|
-
const
|
|
142
|
+
const taggedBundle = prepareVeterinaryIndexTaggedBundle(input.bundle, {
|
|
143
|
+
allowedTagSystems: input.indexPolicy.allowedTagSystems,
|
|
144
|
+
});
|
|
145
|
+
const indexProjection = extractIndexProjection(taggedBundle, input.indexPolicy);
|
|
129
146
|
const signed = sign(input.sender, {
|
|
130
147
|
id: input.messageId, thid: input.threadId,
|
|
131
148
|
type: 'https://vetchain.app/protocols/private-fhir-document/1.0/ips',
|
|
132
149
|
from: input.from, to: [input.to], created_time: Math.floor(Date.now() / 1000),
|
|
133
|
-
body: { mediaType: 'application/fhir+json', bundle:
|
|
150
|
+
body: { mediaType: 'application/fhir+json', bundle: taggedBundle },
|
|
134
151
|
});
|
|
135
152
|
const cek = crypto.getRandomValues(new Uint8Array(32));
|
|
136
153
|
const header = base64Url(canonicalize({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vet-sdk-core-ts",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"description": "Browser-safe VetChain core contracts and governed animal species identifiers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Connecting Solution & Applications Ltd",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"@noble/hashes": "^2.2.0",
|
|
82
82
|
"@noble/post-quantum": "0.5.4",
|
|
83
83
|
"gdc-common-utils-ts": "2.9.10",
|
|
84
|
-
"vet-data-utils-ts": "0.5.
|
|
84
|
+
"vet-data-utils-ts": "0.5.18"
|
|
85
85
|
}
|
|
86
86
|
}
|