vet-sdk-core-ts 0.4.19 → 0.4.21

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 CHANGED
@@ -9,6 +9,20 @@ UHC SDK packages and must not import them.
9
9
  The SDK consumes governed browser-safe values from `vet-data-utils-ts` and
10
10
  owns gateway request construction. GW VET remains the policy authority.
11
11
 
12
+ ## Veterinary health-card issuance
13
+
14
+ `issueVeterinaryHealthCardCredential(...)` accepts only an authoritative
15
+ readback Bundle, creates the standard ES256 SHC signing input, and asks each
16
+ attester for an independent RFC 7797 ML-DSA proof over the exact uncompressed
17
+ payload. `pqcQr.qrCount` configures the number of numeric companion labels; it
18
+ defaults to two and never copies the payload into those labels.
19
+
20
+ The result contains printable vaccination data plus both
21
+ `payloadReferences.multihashUrn` for an exact blockchain-index lookup and
22
+ `payloadReferences.cidV1` for content-addressed retrieval. The issuer supplies
23
+ the validity interval explicitly; FHIR `Immunization.expirationDate` remains
24
+ the vaccine-batch expiry.
25
+
12
26
  ## USDC payment quotes
13
27
 
14
28
  `vet-sdk-core-ts/payment` separates the payment provider, asset and EVM network
@@ -0,0 +1,46 @@
1
+ import { type PostQuantumCompanionProofQrOptions, type SmartHealthCardPayloadReferences } from 'vet-data-utils-ts/shc';
2
+ import { type InternationalHealthCardPrintData } from 'vet-data-utils-ts/international-health-card';
3
+ export type VeterinaryHealthCardAttester = Readonly<{
4
+ /** Signs the exact uncompressed, deterministic SHC payload as RFC 7797 JWS. */
5
+ signDetachedPqc(payloadBytes: Uint8Array): Promise<string>;
6
+ }>;
7
+ export type IssuedVeterinaryHealthCardCredential = Readonly<{
8
+ compactJws: string;
9
+ shcQr: readonly string[];
10
+ pqcCompanionProofs: readonly string[];
11
+ pqcQr: readonly (readonly string[])[];
12
+ payloadBytes: Uint8Array;
13
+ payloadReferences: SmartHealthCardPayloadReferences;
14
+ printData: InternationalHealthCardPrintData;
15
+ }>;
16
+ /**
17
+ * Issues transport values only after the caller supplies GW's authoritative
18
+ * readback Bundle. The tenant issuer owns the standard ES256 signature. Every
19
+ * authenticated attester independently owns one detached ML-DSA signature.
20
+ */
21
+ export declare function issueVeterinaryHealthCardCredential(input: Readonly<{
22
+ authoritativeBundle: Record<string, unknown>;
23
+ issuer: string;
24
+ notBefore: number;
25
+ keyId: string;
26
+ fhirVersion: string;
27
+ signEs256(signingBytes: Uint8Array): Promise<string>;
28
+ attesters: readonly VeterinaryHealthCardAttester[];
29
+ print: Readonly<{
30
+ validFrom: string;
31
+ validUntil: string;
32
+ authorOrganizationUrn: string;
33
+ }>;
34
+ pqcQr?: PostQuantumCompanionProofQrOptions;
35
+ }>): Promise<IssuedVeterinaryHealthCardCredential>;
36
+ /** Verifies the standard credential and all scanned companion proofs offline through caller-owned trust resolvers. */
37
+ export declare function verifyVeterinaryHealthCardCredential(input: Readonly<{
38
+ shcQr: readonly string[];
39
+ pqcQr: readonly (readonly string[])[];
40
+ verifyEs256(compactJws: string): Promise<boolean>;
41
+ verifyDetachedPqc(payloadBytes: Uint8Array, detachedJws: string): Promise<boolean>;
42
+ }>): Promise<Readonly<{
43
+ shc: boolean;
44
+ pqcCompanionProofs: readonly boolean[];
45
+ valid: boolean;
46
+ }>>;
@@ -0,0 +1,56 @@
1
+ import { assembleSmartHealthCardJws, buildSmartHealthCardPayloadReferences, decodePostQuantumCompanionProofQr, decodeSmartHealthCardPayloadBytes, decodeSmartHealthCardQr, encodePostQuantumCompanionProofUri, encodePostQuantumCompanionProofQr, encodeSmartHealthCardQr, prepareSmartHealthCard, } from 'vet-data-utils-ts/shc';
2
+ import { buildInternationalHealthCardPrintData, } from 'vet-data-utils-ts/international-health-card';
3
+ /**
4
+ * Issues transport values only after the caller supplies GW's authoritative
5
+ * readback Bundle. The tenant issuer owns the standard ES256 signature. Every
6
+ * authenticated attester independently owns one detached ML-DSA signature.
7
+ */
8
+ export async function issueVeterinaryHealthCardCredential(input) {
9
+ if (input.authoritativeBundle?.resourceType !== 'Bundle'
10
+ || !Array.isArray(input.authoritativeBundle.entry)
11
+ || input.authoritativeBundle.entry.length === 0) {
12
+ throw new TypeError('veterinary_health_card_authoritative_bundle_required');
13
+ }
14
+ if (!Array.isArray(input.attesters) || input.attesters.length === 0) {
15
+ throw new TypeError('veterinary_health_card_attester_required');
16
+ }
17
+ const prepared = prepareSmartHealthCard({
18
+ issuer: input.issuer,
19
+ notBefore: input.notBefore,
20
+ kid: input.keyId,
21
+ fhirVersion: input.fhirVersion,
22
+ fhirBundle: input.authoritativeBundle,
23
+ additionalTypes: ['https://smarthealth.cards#immunization'],
24
+ });
25
+ const signature = await input.signEs256(prepared.signingBytes);
26
+ const compactJws = assembleSmartHealthCardJws(prepared, signature);
27
+ const detached = await Promise.all(input.attesters.map(attester => attester.signDetachedPqc(prepared.payloadBytes)));
28
+ const payloadReferences = buildSmartHealthCardPayloadReferences(prepared.payloadBytes);
29
+ return {
30
+ compactJws,
31
+ shcQr: encodeSmartHealthCardQr(compactJws),
32
+ pqcCompanionProofs: detached.map(encodePostQuantumCompanionProofUri),
33
+ pqcQr: detached.map(proof => encodePostQuantumCompanionProofQr(proof, input.pqcQr)),
34
+ payloadBytes: prepared.payloadBytes,
35
+ payloadReferences,
36
+ printData: buildInternationalHealthCardPrintData({
37
+ authoritativeBundle: input.authoritativeBundle,
38
+ validFrom: input.print.validFrom,
39
+ validUntil: input.print.validUntil,
40
+ authorOrganizationUrn: input.print.authorOrganizationUrn,
41
+ payloadBytes: prepared.payloadBytes,
42
+ }),
43
+ };
44
+ }
45
+ /** Verifies the standard credential and all scanned companion proofs offline through caller-owned trust resolvers. */
46
+ export async function verifyVeterinaryHealthCardCredential(input) {
47
+ const compactJws = decodeSmartHealthCardQr(input.shcQr);
48
+ const payloadBytes = decodeSmartHealthCardPayloadBytes(compactJws);
49
+ const shc = await input.verifyEs256(compactJws);
50
+ const pqcCompanionProofs = await Promise.all(input.pqcQr.map(qrSet => (input.verifyDetachedPqc(payloadBytes, decodePostQuantumCompanionProofQr(qrSet)))));
51
+ return {
52
+ shc,
53
+ pqcCompanionProofs,
54
+ valid: shc && pqcCompanionProofs.length > 0 && pqcCompanionProofs.every(Boolean),
55
+ };
56
+ }
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * from "./animal-onboarding.js";
6
6
  export * from "./reusable-bff.js";
7
7
  export * from "./research-study.js";
8
8
  export * from "./payment.js";
9
+ export * from "./health-card-issuance.js";
9
10
  export * from "vet-data-utils-ts";
package/dist/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./animal-onboarding.js";
6
6
  export * from "./reusable-bff.js";
7
7
  export * from "./research-study.js";
8
8
  export * from "./payment.js";
9
+ export * from "./health-card-issuance.js";
9
10
  export * from "vet-data-utils-ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vet-sdk-core-ts",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
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",
@@ -43,6 +43,10 @@
43
43
  "./payment": {
44
44
  "types": "./dist/payment.d.ts",
45
45
  "default": "./dist/payment.js"
46
+ },
47
+ "./health-card-issuance": {
48
+ "types": "./dist/health-card-issuance.d.ts",
49
+ "default": "./dist/health-card-issuance.js"
46
50
  }
47
51
  },
48
52
  "files": [
@@ -67,7 +71,7 @@
67
71
  },
68
72
  "dependencies": {
69
73
  "@noble/hashes": "^2.2.0",
70
- "gdc-common-utils-ts": "2.9.4",
71
- "vet-data-utils-ts": "0.5.5"
74
+ "gdc-common-utils-ts": "2.9.10",
75
+ "vet-data-utils-ts": "0.5.8"
72
76
  }
73
77
  }