
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
identigenium
Advanced tools
Generate unique identifiers with configurable character sets and prefixes. Super tiny (tree-shakeable, base is 142 bytes, minified + bzipped)
A TypeScript library for generating unique, incremental ASCII/string based IDs using configurable character sets. It's super tiny and tree-shakeable (142 bytes minified and brotlied just using IncrementalIDProvider).
npm install identigenium
import { IncrementalIDProvider } from 'identigenium';
//Each caracter is a possible "digit" - here a, b, c are possible digits
//Once digits are exhausted a new digit will be added to the ID and least significant digit will be started over
const provider = new IncrementalIDProvider('abc');
console.log(provider.generateID()); // 'a'
console.log(provider.generateID()); // 'b'
console.log(provider.generateID()); // 'c'
console.log(provider.generateID()); // 'aa'
console.log(provider.generateID()); // 'ab'
console.log(provider.generateID()); // 'ac'
console.log(provider.generateID()); // 'ba'
//...
console.log(provider.generateID()); // 'cc'
console.log(provider.generateID()); // 'aaa'
//...
console.log(provider.generateID()); // 'acc'
console.log(provider.generateID()); // 'baa'
//...
console.log(provider.generateID()); // 'ccc'
console.log(provider.generateID()); // 'aaaa'
Note: You must make sure your string of chars is a set of unique characters (or use one of the predefined sets, see below). This is not checked by the library to keep it slim at runtime.
import { IncrementalIDProvider } from 'identigenium';
const provider = new IncrementalIDProvider('abc', 'ID-');
console.log(provider.generateID()); // 'ID-a'
console.log(provider.generateID()); // 'ID-b'
console.log(provider.generateID()); // 'ID-c'
import { ConfigurableIDProvider } from 'identigenium';
//Acts like it has already emitted 3 IDs, thus at the char with index 3
const provider = new ConfigurableIDProvider('abcxyz', 3);
console.log(provider.generateID()); // 'x'
console.log(provider.generateID()); // 'y'
console.log(provider.generateID()); // 'z'
console.log(provider.idCounter); // 6
import { ConfigurableIDProvider } from 'identigenium';
const provider = new ConfigurableIDProvider('abcxyz', 0);
console.log(provider.generateID()); // 'a'
console.log(provider.generateID()); // 'b' idEpoch is now 2
provider.idCounter = 4; // Continue emitting as if another 2 IDs had been generated (4 in total)
console.log(provider.generateID()); // 'y'
The library provides several predefined character sets under the identigenium/sets import:
import {
UpperChars, // 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
LowerChars, // 'abcdefghijklmnopqrstuvwxyz'
Chars, // LowerChars + UpperChars
Numbers, // '0123456789'
AlphaNumeric, // Chars + Numbers
Base64, // AlphaNumeric + '+/'
Base64URL, // AlphaNumeric + '-_'
Braces, // '<{[()]}>'
Slashes, // '\\/'
Separators, // ',.:;?!'
Quotes, // '\'"'
Miscellaneous, // '@#%$|^~_+-*='
SpecialChars // Various special characters
} from 'identigenium/sets';
import { IncrementalIDProvider } from 'identigenium';
import { AlphaNumeric } from 'identigenium/sets';
const provider = new IncrementalIDProvider(AlphaNumeric);
console.log(provider.generateID()); // '0'
console.log(provider.generateID()); // '1'
// ...
console.log(provider.generateID()); // '9'
console.log(provider.generateID()); // 'a'
console.log(provider.generateID()); // 'b'
Note: When using the number set '0123456789' don't expect IDs to follow numerical ordering. Each char is taken as a literal digit, resulting in a generation sequence of ..., '9', '00', '01', ..., '99', '000', '001', ... as from a string standpoint '1' !== '01' !== '001'.
Interface for an ID source that provides unique identifiers. Both the incremental and the configurable provider implement this interface
interface IDSource {
idStream: Generator<string, string, void>;
generateID(): string;
}
idStream: Generator<string, string, void> - A generator that yields unique string IDs. Can be used to iterate and generate IDs.
// Using for-of loop
for (const id of idSource.idStream) {
console.log(id);
}
// Using next().value
const nextId = idSource.idStream.next().value;
console.log(nextId);
generateID(): string - Generates and returns a new unique ID string.An incremental ID provider that generates unique identifiers using a specified character set and optional prefix. IDs are generated incrementally starting from the first character in the set, then progressing through combinations of increasing length.
class IncrementalIDProvider implements IDSource {
constructor(permittedCharacters: string, prefix?: string);
idStream: Generator<string, string, void>;
generateID(): string;
}
new IncrementalIDProvider(permittedCharacters: string, prefix?: string)
permittedCharacters: A string containing all allowed characters for ID generation. MUST be a string of unique characters; this is not checked.prefix: An optional prefix to prepend to all generated IDs (default: "")idStream: Generator<string, string, void>generateID(): stringA configurable ID provider that generates unique identifiers using a specified character set, prefix, and starting counter value. This provider allows for customizable ID generation with support for resuming from a specific counter position.
class ConfigurableIDProvider implements IDSource {
constructor(permittedCharacters: string, startIDCounterWith?: number, prefix?: string);
idCounter: number;
idStream: Generator<string, string, void>;
generateID(): string;
}
new ConfigurableIDProvider(permittedCharacters: string, startWithCounter?: number, prefix?: string)
permittedCharacters: A string containing all allowed characters for ID generation. MUST be a string of unique characters; this is not checked.startWithCounter: The initial counter value to start ID generation from (default: 0)prefix: An optional prefix to prepend to all generated IDs (default: "")idCounter: number - Gets or sets the number of already generated IDs. Returns the current counter value representing the number of IDs generated so far.idStream: Generator<string, string, void>generateID(): stringMIT
FAQs
Generate unique identifiers with configurable character sets and prefixes. Super tiny (tree-shakeable, base is 142 bytes, minified + bzipped)
We found that identigenium demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.