vet-sdk-core-ts 0.4.40 → 0.4.42
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/animal-identity.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2026 Connecting Solution & Applications Ltd under the Apache License, Version 2.0.
|
|
2
2
|
import { sha3_256 } from "@noble/hashes/sha3.js";
|
|
3
3
|
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
4
|
+
import { normalizeSubjectSpeciesId7 } from "sos-data-utils-ts/subject-card-index";
|
|
4
5
|
export const AnimalIdentityEvidenceSystems = Object.freeze({
|
|
5
6
|
UsdaAin: "usda-ain",
|
|
6
7
|
CfiaIso11784: "cfia-iso-11784",
|
|
@@ -28,17 +29,11 @@ const DAMM_TABLE = Object.freeze([
|
|
|
28
29
|
* projection, never an organization fiscal identifier.
|
|
29
30
|
*/
|
|
30
31
|
export function buildSpeciesId7(ncbiTaxonomyId) {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
throw new TypeError("NCBI Taxonomy identifier must contain at most seven digits.");
|
|
34
|
-
}
|
|
35
|
-
const normalized = source.replace(/^0+/, "") || "0";
|
|
36
|
-
if (normalized === "9606") {
|
|
32
|
+
const speciesId7 = normalizeSubjectSpeciesId7(ncbiTaxonomyId);
|
|
33
|
+
if (speciesId7 === "0009606") {
|
|
37
34
|
throw new TypeError("Human NCBI Taxonomy identifier 9606 is not valid for a VetChain animal.");
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
throw new TypeError("NCBI Taxonomy identifier must be positive.");
|
|
41
|
-
return normalized.padStart(7, "0");
|
|
36
|
+
return speciesId7;
|
|
42
37
|
}
|
|
43
38
|
/** Country3 plus immutable birth/initial-registration region2. */
|
|
44
39
|
export function normalizeJurisdictionCode5(value) {
|
package/dist/card-issuance.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export type VetChainIssuedAnimalCard = Readonly<{
|
|
|
2
2
|
providerCode9: string;
|
|
3
3
|
jurisdictionCode5: string;
|
|
4
4
|
ncbiTaxonomyId: string;
|
|
5
|
-
|
|
5
|
+
/** Separate checksum/hash context; never embedded in cardNumber21. */
|
|
6
|
+
speciesId7: string;
|
|
6
7
|
animalNumericId15: string;
|
|
7
8
|
animalId16: string;
|
|
8
9
|
cardNumber21: string;
|
package/dist/card-issuance.js
CHANGED
|
@@ -8,7 +8,7 @@ export function issueVetChainAnimalCard(input) {
|
|
|
8
8
|
const providerCode9 = digits(input.providerCode9, 9, 'vet_card_provider_code_invalid');
|
|
9
9
|
const jurisdictionCode5 = providerCode9.slice(0, 5);
|
|
10
10
|
const ncbiTaxonomyId = taxonomy(input.ncbiTaxonomyId);
|
|
11
|
-
const
|
|
11
|
+
const speciesId7 = buildSpeciesId7(ncbiTaxonomyId);
|
|
12
12
|
const subjectUuid = String(input.subjectUuid || '').trim().toLowerCase().replace(/[{}]/g, '');
|
|
13
13
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(subjectUuid)) {
|
|
14
14
|
throw new TypeError('vet_card_subject_uuid_invalid');
|
|
@@ -24,7 +24,7 @@ export function issueVetChainAnimalCard(input) {
|
|
|
24
24
|
].join(':')));
|
|
25
25
|
const animalNumericId15 = `000${reduceDigestToDecimalDigits(digest, 12)}`;
|
|
26
26
|
const animalId16 = buildAnimalIdentifier16({
|
|
27
|
-
speciesId7
|
|
27
|
+
speciesId7,
|
|
28
28
|
jurisdictionCode5,
|
|
29
29
|
animalNumericId15,
|
|
30
30
|
});
|
|
@@ -34,14 +34,14 @@ export function issueVetChainAnimalCard(input) {
|
|
|
34
34
|
throw new TypeError('vet_card_host_invalid');
|
|
35
35
|
const cardDidWeb = `did:web:${host.replace(':', '%3A')}:card:vetchain:${jurisdictionCode5}:${animalId16}`;
|
|
36
36
|
parseVetChainAnimalCardDid(cardDidWeb);
|
|
37
|
-
return Object.freeze({ providerCode9, jurisdictionCode5, ncbiTaxonomyId,
|
|
37
|
+
return Object.freeze({ providerCode9, jurisdictionCode5, ncbiTaxonomyId, speciesId7, animalNumericId15, animalId16, cardNumber21, cardDidWeb });
|
|
38
38
|
}
|
|
39
39
|
export function normalizeVetChainNcbiTaxonomyId(value) {
|
|
40
40
|
return taxonomy(value);
|
|
41
41
|
}
|
|
42
42
|
function taxonomy(value) {
|
|
43
43
|
const normalized = String(value || '').trim();
|
|
44
|
-
if (!/^[1-9]\d{0,
|
|
44
|
+
if (!/^[1-9]\d{0,6}$/.test(normalized) || normalized === '9606')
|
|
45
45
|
throw new TypeError('vet_card_taxonomy_invalid');
|
|
46
46
|
return normalized;
|
|
47
47
|
}
|
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.42",
|
|
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",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"@noble/hashes": "^2.2.0",
|
|
90
90
|
"@noble/post-quantum": "0.5.4",
|
|
91
91
|
"gdc-common-utils-ts": "2.9.10",
|
|
92
|
+
"sos-data-utils-ts": "0.2.2",
|
|
92
93
|
"vet-data-utils-ts": "0.5.28"
|
|
93
94
|
}
|
|
94
95
|
}
|