vet-sdk-core-ts 0.4.21 → 0.4.22
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type PostQuantumCompanionProofQrOptions, type SmartHealthCardPayloadReferences } from 'vet-data-utils-ts/shc';
|
|
2
2
|
import { type InternationalHealthCardPrintData } from 'vet-data-utils-ts/international-health-card';
|
|
3
|
+
import { type ClinicalBundleReaderOptions } from 'vet-data-utils-ts/clinical-bundle-reader';
|
|
4
|
+
import type { SmartHealthCardPayload } from 'vet-data-utils-ts/shc';
|
|
3
5
|
export type VeterinaryHealthCardAttester = Readonly<{
|
|
4
6
|
/** Signs the exact uncompressed, deterministic SHC payload as RFC 7797 JWS. */
|
|
5
7
|
signDetachedPqc(payloadBytes: Uint8Array): Promise<string>;
|
|
@@ -44,3 +46,24 @@ export declare function verifyVeterinaryHealthCardCredential(input: Readonly<{
|
|
|
44
46
|
pqcCompanionProofs: readonly boolean[];
|
|
45
47
|
valid: boolean;
|
|
46
48
|
}>>;
|
|
49
|
+
/**
|
|
50
|
+
* Verifies every scanned proof before exposing the SHC Bundle to the shared
|
|
51
|
+
* IPS reader. Terminology enrichment runs only on a presentation copy after
|
|
52
|
+
* verification, so neither signature bytes nor payload hashes can change.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readVerifiedVeterinaryHealthCardCredential(input: Readonly<{
|
|
55
|
+
shcQr: readonly string[];
|
|
56
|
+
pqcQr: readonly (readonly string[])[];
|
|
57
|
+
language: string;
|
|
58
|
+
verifyEs256(compactJws: string): Promise<boolean>;
|
|
59
|
+
verifyDetachedPqc(payloadBytes: Uint8Array, detachedJws: string): Promise<boolean>;
|
|
60
|
+
resolveTerminology: ClinicalBundleReaderOptions['resolveTerminology'];
|
|
61
|
+
}>): Promise<Readonly<{
|
|
62
|
+
verification: Readonly<{
|
|
63
|
+
shc: boolean;
|
|
64
|
+
pqcCompanionProofs: readonly boolean[];
|
|
65
|
+
valid: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
payload: SmartHealthCardPayload;
|
|
68
|
+
bundle: Record<string, unknown>;
|
|
69
|
+
}>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assembleSmartHealthCardJws, buildSmartHealthCardPayloadReferences, decodePostQuantumCompanionProofQr, decodeSmartHealthCardPayloadBytes, decodeSmartHealthCardQr, encodePostQuantumCompanionProofUri, encodePostQuantumCompanionProofQr, encodeSmartHealthCardQr, prepareSmartHealthCard, } from 'vet-data-utils-ts/shc';
|
|
2
2
|
import { buildInternationalHealthCardPrintData, } from 'vet-data-utils-ts/international-health-card';
|
|
3
|
+
import { projectClinicalBundleForReading, } from 'vet-data-utils-ts/clinical-bundle-reader';
|
|
3
4
|
/**
|
|
4
5
|
* Issues transport values only after the caller supplies GW's authoritative
|
|
5
6
|
* readback Bundle. The tenant issuer owns the standard ES256 signature. Every
|
|
@@ -54,3 +55,24 @@ export async function verifyVeterinaryHealthCardCredential(input) {
|
|
|
54
55
|
valid: shc && pqcCompanionProofs.length > 0 && pqcCompanionProofs.every(Boolean),
|
|
55
56
|
};
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Verifies every scanned proof before exposing the SHC Bundle to the shared
|
|
60
|
+
* IPS reader. Terminology enrichment runs only on a presentation copy after
|
|
61
|
+
* verification, so neither signature bytes nor payload hashes can change.
|
|
62
|
+
*/
|
|
63
|
+
export async function readVerifiedVeterinaryHealthCardCredential(input) {
|
|
64
|
+
const compactJws = decodeSmartHealthCardQr(input.shcQr);
|
|
65
|
+
const payloadBytes = decodeSmartHealthCardPayloadBytes(compactJws);
|
|
66
|
+
const shc = await input.verifyEs256(compactJws);
|
|
67
|
+
const pqcCompanionProofs = await Promise.all(input.pqcQr.map(qrSet => (input.verifyDetachedPqc(payloadBytes, decodePostQuantumCompanionProofQr(qrSet)))));
|
|
68
|
+
const verification = {
|
|
69
|
+
shc,
|
|
70
|
+
pqcCompanionProofs,
|
|
71
|
+
valid: shc && pqcCompanionProofs.length > 0 && pqcCompanionProofs.every(Boolean),
|
|
72
|
+
};
|
|
73
|
+
if (!verification.valid)
|
|
74
|
+
throw new TypeError('veterinary_health_card_proof_invalid');
|
|
75
|
+
const payload = JSON.parse(new TextDecoder().decode(payloadBytes));
|
|
76
|
+
const bundle = await projectClinicalBundleForReading(payload.vc.credentialSubject.fhirBundle, { language: input.language, resolveTerminology: input.resolveTerminology });
|
|
77
|
+
return { verification, payload, bundle };
|
|
78
|
+
}
|
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.22",
|
|
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",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@noble/hashes": "^2.2.0",
|
|
74
74
|
"gdc-common-utils-ts": "2.9.10",
|
|
75
|
-
"vet-data-utils-ts": "0.5.
|
|
75
|
+
"vet-data-utils-ts": "0.5.9"
|
|
76
76
|
}
|
|
77
77
|
}
|