Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
uuid-apikey
Advanced tools
Readme
"API Keys are for people"
This module is a generator, validator, and converter that transforms UUIDs into human-readable Base32-Crockford encoded API Keys.
It turns this:
9b3ac4c9-0228-4e42-a244-927059b1a5ea
into this:
KCXC9JD-08M4WGH-M9294W1-B6RTBTH
Base32-Crockford API Keys it avoids these problems by doing the following:
a
≡ A
)O
, o
, and the number 0
L
, l
, I
, i
, and the number 1
U
which could inadvertently lead to common English profanities.NOTE: This package makes use of ES6 and ES7 functionality. If you are using a version of node prior to version 8 then you will need to use a polyfill (e.g. babel) for compatibility.
You can install uuid-apikey
with NPM.
npm install uuid-apikey
const uuidAPIKey = require('uuid-apikey');
console.log(uuidAPIKey.create());
Output:
{ uuid: '0b9ca335-92a8-46d8-b477-eb2ed83ac927',
apiKey: '1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X' }
uuid-apikey
installs with a command line tool. The tool is available using the command apiKeyTool
which can be install globally using:
npm install uuid-apikey -g
$ apiKeyTool.js
Usage: apiKeyTool [options]
Options:
-V, --version output the version number
-g, --generate Create a new API Key/UUID pair. Ignores other parameters if passed.
-u, --uuid <uuid> UUID for operation. If no other parameter is passed this is converted to an API Key.
-a, --apikey <apikey> API Key for operation. If no other parameter is passed this is converted to an UUID.
-c, --check Check the API Key and/or UUID provided are valid. If both API Key and UUID are passed then they are checked against each other.
-h, --help output usage information
$ apiKeyTool.js -g
UUID(9b3ac4c9-0228-4e42-a244-927059b1a5ea)
APIKey(KCXC9JD-08M4WGH-M9294W1-B6RTBTH)
$ apiKeyTool.js -a KCXC9JD-08M4WGH-M9294W1-B6RTBTH -u 9b3ac4c9-0228-4e42-a244-927059b1a5ea
UUID(9b3ac4c9-0228-4e42-a244-927059b1a5ea) => APIKey(KCXC9JD-08M4WGH-M9294W1-B6RTBTH)
APIKey(KCXC9JD-08M4WGH-M9294W1-B6RTBTH) => UUID(9b3ac4c9-0228-4e42-a244-927059b1a5ea)
$ apiKeyTool.js -a KCXC9JD-08M4WGH-M9294W1-B6RTBTH -u 9b3ac4c9-0228-4e42-a244-927059b1a5ea -c
UUID(9b3ac4c9-0228-4e42-a244-927059b1a5ea) : valid
APIKey(KCXC9JD-08M4WGH-M9294W1-B6RTBTH) : valid
UUID & APIKey are identical : true
Tests if the UUID string passed is a valid UUID.
uuidAPIKey.isUUID('0b9ca335-92a8-46d8-b477-eb2ed83ac927');
uuidAPIKey.isUUID('NodeJS');
Output:
true
false
Tests if the API Key string passed is a valid API Key.
uuidAPIKey.isAPIKey('1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X');
uuidAPIKey.isAPIKey('NodeJS');
Output:
true
false
Converts a valid UUID into an API Key. Throws a TypeError
if the UUID is invalid.
uuidAPIKey.toAPIKey('0b9ca335-92a8-46d8-b477-eb2ed83ac927');
uuidAPIKey.toAPIKey('0b9ca335-92a8-46d8-b477-eb2ed83ac927', { 'noDashes': true });
Output:
'1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X'
'1EEA6DCJAM4DP2PHVYPBNV0XCJ9X'
Options
Option | Type | Desc |
---|---|---|
noDashes | boolean | Generates an APIKey without dashes |
Converts a valid API Key into an UUID. Throws a TypeError
if the API Key is invalid.
uuidAPIKey.toUUID('1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X');
Output:
'0b9ca335-92a8-46d8-b477-eb2ed83ac927'
Test that an API Key and a UUID are identical. Throws a TypeError
if either the API Key or the UUID is invalid.
uuidAPIKey.check('1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X', '0b9ca335-92a8-46d8-b477-eb2ed83ac927');
Output:
true
Returns a new UUID and API Key pair
uuidAPIKey.create();
Output:
{ uuid: '0b9ca335-92a8-46d8-b477-eb2ed83ac927',
apiKey: '1EEA6DC-JAM4DP2-PHVYPBN-V0XCJ9X' }
Options
Option | Type | Desc |
---|---|---|
noDashes | boolean | Generates an APIKey without dashes |
Copyright (c) 2018,2019 Jay Reardon -- Licensed under the MIT license.
FAQs
A Base32-Crockford encoded API Key generator, validator, and converter to turn UUIDs into human readable API Keys
The npm package uuid-apikey receives a total of 11,726 weekly downloads. As such, uuid-apikey popularity was classified as popular.
We found that uuid-apikey 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.