
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
pn-check-digits
Advanced tools
Deprecated! - Provides ways of calculating different standard check-digits.
🚨 The package is deprecated, use this one instead: @postnord/pn-check-digits
npm install pn-check-digits
The UPU S10 standard defines a system for assigning 13-character identifiers to postal items for the purpose of tracking and tracing them during shipping. The identifiers consist of a two letter service indicator code, an eight digit serial number (in the range 00000000 to 99999999), a single check-digit, and a two-letter ISO country code — the latter identifying the issuing postal administration's country. References: https://en.wikipedia.org/wiki/S10_(UPU_standard)
import { S10 } from 'pn-check-digits'
const serialNumber = '12345678';
// get checkdigit
const checkDigit = S10.compute(serialNumber); // '5'
// get serialNumber + checkdigit
const serialNumberWithCheckDigit = S10.generate(serialNumber); // '123456785'
// validate if valid serialNumber with checkdigit, returns true or false
const isValid = S10.validate(serialNumberWithCheckDigit); // true
The UPC Version A validates a serial number using a weight of 3
and 1
and using the Luhn Algorithm Modulo 10.
References: Check Digit Calculation Method
import { UPCCGCP } from 'pn-check-digits';
const serialNumberWithCheckDigit = '23232341';
// get check digit
const checkDigit = UPCCGCP.compute(serialNumberWithCheckDigit.substring(0, serialNumberWithCheckDigit.length - 1));
// validate if the digit is compliant
const isValid = UPCCGCP.validate(serialNumberWithCheckDigit); // true
The MSI standards checks the digit using the Luhn Algorithm with a weight of 2
and 1
. References: IBM Check Digit
import { MSI } from 'pn-check-digits`;
const serialNumberWithCheckDigit = '01234567';
// get check digit
const checkDigit = MSI.compute(serialNumberWithCheckDigit.substring(0, serialNumberWithCheckDigit.length - 1));
// validate if the digit is compliant
const isValid = MSI.validate(serialNumberWithCheckDigit); // true
Identcode barcode symbology is based on the Code 25 Interleaved symbology. It is mainly used in post delivery system to tracking packages. Identcode barcode symbology is also called German Postal 2 of 5 Identcode, Deutsche Post AG Identcode, Deutsche Frachtpost Identcode, Identcode, CodeIdentcode, Deutsche Post AG (DHL). The Identcode Barcode is a numeric only, discrete linear barcode. The tracking number encoded in this barcode symbology contains the information of the customer identification, address and the mail piece. The Identcode Barcode could encode 11 digits plus 1 check digit which makes total length to 12.
Reference: Identcode Barcode Symbology
Leitcode is also known as Deutsche Post Leitcode barcode, CodeLeitcode, Deutsche Post AG (DHL). Leitcode barcode symbology is based on the Interleaved 2 of 5 barcode. The Leitcode Barcode is a numeric only, discrete linear barcode. Encoding length of Leitcode Barcode symbology is 13 digits long with one checksum digit. The checksum digit is calculated automatically by employing the Modulo 10 method. It is used by the German Post (Deutsche Post AG) (Deutsche Frachtpost) in freight post system to track and mail packages. The value encoded in the Leitcode barcode symbology indicates the destination of the packages.
Reference: Leitcode Barcode Symbology
Though the internal team decided to use the weight of 4
and 9
- based from the Java Legacy code, we will use the term IdentCode
with a weight of LeitCode
.
import { IdentCode } from 'pn-check-digits';
const serialNumberWithCheckDigit = '56400000005';
// get check digit
const checkDigit = IdentCode.compute(serialNumberWithCheckDigit.substring(0, serialNumberWithCheckDigit.length - 1)); // 5
// validate if the digit is compliant
const isValid = IdentCode.validate(serialNumberWithCheckDigit); // true
This is based from ISO/IEC 7064:2002 specifications the string must be in a format of: numeric (0 to 9), alphabetic (26 Letters: A-Z) or alphanumeric (combination of alphabets and numbers).
Reference: International Organization for Standardization - ISO/IEC 7064:2003
import { ISOIEC7064 } from 'pn-check-digits';
const serialNumber = '094459127867977';
// get the check digit
const checkDigit = ISOIEC7064.compute(serialNumber) // Z
// validate if the digit is compliant
const isValid = ISOIEC7064.validate(serialNumber) // true
FAQs
Deprecated! - Provides ways of calculating different standard check-digits.
The npm package pn-check-digits receives a total of 0 weekly downloads. As such, pn-check-digits popularity was classified as not popular.
We found that pn-check-digits demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 50 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.