
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
lex-sequence
Advanced tools
A sequence of strings that are lexicographically ordered and grow slowly.
npm i --save lex-sequence
This library provides a sequence of strings that are lexicographically ordered (in order by <) and grow slowly (a few 1-char strings, then some 2-char strings, then many 3-char strings, etc.).
For example, the base-10 sequence is
"0", "1", "2", "3", "4", "50", "51", "52", ..., "73", "74", "750", "751", ...
There are 5 length-1 strings, 5^2 length-2 strings, 5^3 length-3 strings, etc. So the n-th string is only as long as the base-5 encoding of n. (For more short strings, you can use a base larger than 10.)
Additional properties:
"4" to "50" without emitting "5".Why not ordinary integers?
"10" < "2".Why not fixed-length strings? ("000", "001", "002", ..., "999")
What might I use this library for?
`${sequence(timestamp, BASE)}-${tiebreaker}`, so that you can sort by this single field. (E.g., Lamport timestamps with a process ID tiebreaker.)It's a good idea to specify your base as a constant:
import {
sequence,
sequenceInv,
sequenceInvSafe,
successor,
} from "lex-sequence";
const BASE = 10;
sequence(n, BASE) returns the n-th entry in the sequence as an integer, which you can then BASE encode:
for (let n = 0; n < 100; n++) {
console.log(sequence(n, BASE).toString(BASE));
}
// Prints "0", "1", ..., "4", "50", ..., "74", "750", ..., "819"
sequenceInv(seq, BASE) converts a sequence member back to its index:
console.log(sequenceInv(819, BASE)); // Prints 99
"Safe" version that will return -1 instead of throwing an error, if seq is not a valid sequence member:
console.log(sequenceInvSafe(5, BASE) === -1); // Prints true
successor(seq, BASE) is a fast way to go from sequence(n, BASE) to sequence(n + 1, BASE):
let seq = 0;
for (let i = 0; i < 100; i++) {
console.log(seq.toString(BASE));
seq = successor(seq, BASE);
}
// Prints "0", "1", ..., "4", "50", ..., "74", "750", ..., "819"
BASE must even and >= 4. For a base-2 (binary) sequence, binary-encode the numbers from the base-4 sequence.BASE encoding of sequence(n, BASE) is always as long as the BASE/2 encoding of n.BASE chars and they are in lexicographic order. E.g., you can use base64 chars in the non-standard, lexicographic ordering +/0-9A-Za-z.BASE/2 numbers. (0, 1, ..., 4.)BASE, then enumerate (BASE/2)^2 numbers.
(50, 51, ..., 74.)BASE, then enumerate (BASE/2)^3 numbers.
(750, 751, ..., 874.)(BASE/2)^d length-d numbers for each d >= 1. Imagining a decimal place
in front of each number, each d consumes 2^(-d) of the unit interval,
so we never "reach 1" (overflow to d+1 digits when
we meant to use d digits).FAQs
A sequence of strings that are lexicographically ordered and grow slowly
The npm package lex-sequence receives a total of 4,858 weekly downloads. As such, lex-sequence popularity was classified as popular.
We found that lex-sequence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.