Socket
Socket
Sign inDemoInstall

uid-safe

Package Overview
Dependencies
1
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    uid-safe

URL and cookie safe UIDs


Version published
Weekly downloads
2.4M
decreased by-1.76%
Maintainers
3
Install size
15.4 kB
Created
Weekly downloads
 

Package description

What is uid-safe?

The uid-safe npm package is used to generate cryptographically secure, URL-safe unique identifiers. It is commonly used in web development for creating unique session IDs, tokens, and other random identifiers that need to be safe to use in URLs without additional encoding.

What are uid-safe's main functionalities?

Generating URL-safe unique identifiers

This feature allows the generation of URL-safe unique identifiers of a specified length. The code sample demonstrates how to generate an 18-byte unique identifier using the uid-safe package.

const uidSafe = require('uid-safe');

uidSafe(18).then(function(uid) {
  console.log(uid);
});

Other packages similar to uid-safe

Readme

Source

uid-safe

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

URL and cookie safe UIDs

Create cryptographically secure UIDs safe for both cookie and URL usage. This is in contrast to modules such as rand-token and uid2 whose UIDs are actually skewed due to the use of % and unnecessarily truncate the UID. Use this if you could still use UIDs with - and _ in them.

Installation

$ npm install uid-safe

API

var uid = require('uid-safe')

uid(byteLength, callback)

Asynchronously create a UID with a specific byte length. Because base64 encoding is used underneath, this is not the string length. For example, to create a UID of length 24, you want a byte length of 18.

uid(18, function (err, string) {
  if (err) throw err
  // do something with the string
})

uid(byteLength)

Asynchronously create a UID with a specific byte length and return a Promise.

Note: To use promises in Node.js prior to 0.12, promises must be "polyfilled" using global.Promise = require('bluebird').

uid(18).then(function (string) {
  // do something with the string
})

uid.sync(byteLength)

A synchronous version of above.

var string = uid.sync(18)

License

MIT

Keywords

FAQs

Last updated on 03 Aug 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc