@tracepass/gs1-utils
v0.1.4
Published
GS1 identifier utilities for Digital Product Passports — GTIN and GLN check-digit validation, GS1 Digital Link URI build/parse. Zero dependencies in the core; the optional QR subpath asks for qrcode as a peer.
Maintainers
Readme
@tracepass/gs1-utils
GTIN and GLN check digits, GS1 Digital Link build and parse. Zero dependencies in the core; the optional ./qr subpath asks for qrcode as a peer.
Part of tracepass-open · Maintained by TracePass
npm install @tracepass/gs1-utilsimport { validateGtin, validateGln, buildDigitalLinkUri, parseDigitalLinkUri } from "@tracepass/gs1-utils";
validateGtin("09520123456788"); // true — mod-10 check digit
validateGtin("09520123456780"); // false
validateGln("5012345678900"); // true — 13 digits, mod-10
buildDigitalLinkUri("id.example.com", "09520123456788", "SN-1");
// "https://id.example.com/01/09520123456788/21/SN-1"
parseDigitalLinkUri("https://id.example.com/01/09520123456788/21/SN-1");
// { gtin: "09520123456788", serialNumber: "SN-1" }buildDigitalLinkUri takes a bare domain — id.example.com, not
https://id.example.com.
QR codes are a separate subpath
Rendering a QR code needs a dependency, and identifier validation doesn't. So the core
stays dependency-free and QR lives behind its own entry point, with qrcode declared an
optional peer:
npm install @tracepass/gs1-utils qrcodeimport { generateQrCode } from "@tracepass/gs1-utils/qr";