Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
This is the official TypeScript package for TypeIDs written by jetpack.io (authors of the original TypeID spec).
This is the official TypeScript package for TypeIDs written by jetpack.io (authors of the original TypeID spec).
TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.
This particular implementation provides an npm package that can be used by any JavaScript or TypeScript project.
To create a random TypeID of a given type, use the typeid()
function:
import { typeid } from 'typeid-ts';
const tid = typeid("prefix");
The prefix is optional, so if you need to create an id with a type prefix, you can do that too:
import { typeid } from 'typeid-ts';
const tid = typeid();
In addition to the typeid()
function, there's also a TypeID
class that can
be used to encode/decode from other formats.
For example, to parse an existing typeid from a string:
import { TypeID } from 'typeid-ts';
const tid = TypeID.fromString("prefix_00041061050r3gg28a1c60t3gf);
To encode an existing UUID as a TypeID:
import { TypeID } from 'typeid-ts';
const tid = TypeID.fromUUID("prefix", "00000000-0000-0000-0000-000000000000");
The full list of methods includes:
getType()
: Returns the type of the type prefixgetSuffix()
: Returns uuid suffix in its base32 representationtoString()
: Encodes the object as a string, using the canonical formatasUUID()
: Decodes the TypeID into a UUID string in hex format. The type prefix is ignoredasUUIDBytes()
: Decodes the TypeID into a UUID byte array. The type prefix is ignoredfromString(str)
: Parses a TypeID from a stringfromUUID(prefix, uuid)
: Creates a TypeID from a prefix and a UUID in hex formatfromUUIDBytes(prefix, bytes)
: Creates a TypeID from a prefix and a UUID in byte array formatFAQs
Official implementation of the TypeID specification in TypeScript. TypeIDs are type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
The npm package typeid-js receives a total of 131,573 weekly downloads. As such, typeid-js popularity was classified as popular.
We found that typeid-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.