Installations
npm install nid
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Min. Node Version
>=12
Node Version
16.14.2
NPM Version
8.5.0
Score
87.4
Supply Chain
100
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (60.36%)
TypeScript (38.39%)
HTML (1.25%)
Developer
rjrodger
Download Statistics
Total Downloads
4,975,926
Last Day
1,470
Last Week
8,344
Last Month
37,717
Last Year
698,640
GitHub Statistics
33 Stars
41 Commits
6 Forks
6 Watching
2 Branches
4 Contributors
Bundle Size
1.63 kB
Minified
887.00 B
Minified + Gzipped
Package Meta Information
Latest Version
2.0.1
Package Id
nid@2.0.1
Unpacked Size
20.40 kB
Size
6.98 kB
File Count
11
NPM Version
8.5.0
Node Version
16.14.2
Total Downloads
Cumulative downloads
Total Downloads
4,975,926
Last day
-40.7%
1,470
Compared to previous day
Last week
-30.1%
8,344
Compared to previous week
Last month
-13.3%
37,717
Compared to previous month
Last year
-23.2%
698,640
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
8
nid
Nice clean-mouthed random id generation, without any swearing!
A Node.js module that generates random identifiers for public consumption. Swear words not included.
This open source module is sponsored and supported by Voxgig. |
---|
What it Does
This module is useful for custom short links, password generation and any sort of unique tag an end user might see.
By default the big seven curse words are avoided (thanks @dshaw!). The Battlestar Galactica version of one of the big seven is also avoided.
NOTE: this module is not cryptographically secure and should only be used in low-risk environments.
Quick example
1var nid = require('nid') 2 3// generate a 6 character alphanumberic id, like: ytnzt2 4console.log( nid() ) 5 6// generate a 3 character alphanumberic id, like: 5rg 7console.log( nid(3) ) 8
Install
1npm install nid
Length
You can change the length of the identifier string by passing an integer to nid, as per the quick example above. The default alphanumeric alphabet is used.
Options
You can change the ids generated by passing an options object to the nid function. A new, custom, function is returned. For example:
1var mynid = require('nid')({length:8}) 2 3// generate an 8 character alphanumberic id, like: qnzvetvp 4console.log( mynid() )
You have the following options:
- length: number of characters in the id string
- alphabet: a string containing the set of characters in the id, e.g. 1234567890abcdef
- curses: specify the list of curse words to avoid (you can use exclude as an alias if you don't want to sound quaint)
You can specify the curses as:
- an array of strings: ["gosh","darn"]
- a CSV formatted string: "gosh, darn"
- a regular expression: matches are excluded
- a function: first arg is the proposed id, return true to exclude
As a convenience you can use the following alphabet shortcuts:
- hex: alphabet is '0123456789abcdef'
- HEX: alphabet is '0123456789ABCDEF'
Examples:
1var nid = require('nid') 2 3var nid_ABC = nid({alphabet:'ABC'}) 4console.log(nid_ABC()) // prints something like BCCABB 5 6var nid_hex = nid({hex:1}) 7console.log(nid_hex()) // prints something like 47b5df 8 9var nid_noa = nid({curses:/a/}) 10console.log(nid_noa()) // never includes an 'a' character
How it Works
Keep getting a random character from a given alphabet of characters, until you have enough to meet the length requirement. Then check if it contains a curse word (case-insensitive). If so, try again.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/todo.yml:1
- Info: no jobLevel write permissions found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/rjrodger/nid/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/rjrodger/nid/build.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/rjrodger/nid/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/todo.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/rjrodger/nid/todo.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/todo.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/rjrodger/nid/todo.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/build.yml:31
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Reason
14 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
2.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to nid
nv-facutil-nid
eg-nid
Extract basic info from Egyptian NIDs
nid-parser
NID (Native Interface Definition) is a portable C/C++ API description format that parses into JSON format for convenient bindings generation
vue-cli-plugin-nid
这是[宁皓网](https://ninghao.net)内部项目使用的一个 Vue CLI 插件,在使用了 TypeScript 的 Vue 项目里,可以用命令生成应用需要的组件与 Store 模块。