Roughing out the demo app

This commit is contained in:
Nate Taylor
2019-10-23 07:41:03 -05:00
parent 5bc58a2d40
commit 94be06d3c4
2841 changed files with 274065 additions and 2 deletions

133
node_modules/nanoid/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,133 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.1.4
* Reduce `generate` size (by Vsevolod Rodionov).
* Reduce `format` and `format` size (by Victor).
* Reduce `async`, `non-secure` and `non-secure/generate` size.
* Speed up `format` and `async/format` (by Max Graey).
* Improve development process on Windows (by Stanislav Lashmanov).
## 2.1.3
* Improve performance (by Stephen Richardson).
* Reduce size (by Stephen Richardson).
## 2.1.2
* Improve docs.
## 2.1.1
* Fix React Native support (by Shawn Hwei).
## 2.1
* Improve React Native support (by Sebastian Werner).
## 2.0.4
* Improve error text for React Native (by Sebastian Werner).
## 2.0.3
* Fix freeze on string in ID length.
## 2.0.2
* Improve docs (by Sylvanus Kateile and Mark Stosberg).
## 2.0.1
* Reduce npm package size.
* Mark package as not having side effects (by @xiaody).
## 2.0
* Use `-` instead of `~` in default alphabet to by file name safe.
* Add `nanoid/non-secure/generate`.
## 1.3.4
* Reduce `non-secure` size.
* Add `async` callback type check.
## 1.3.3
* Fix `nanoid/async` performance regression.
* Fix old Node.js `not seeded` issue in synchronous version too.
## 1.3.2
* Fix random generator `not seeded` issue of old Node.js.
## 1.3.1
* Reduce library size.
## 1.3
* Add `nanoid/async/format` and `nanoid/async/generate`.
* Improve synchronous API performance.
* Reduce `url` size (by Daniil Poroshin).
* Improve React Native docs (by joelgetaction).
## 1.2.6
* Reduce library size (by rqrqrqrq).
## 1.2.5
* Fix Node.js 6.11.1 support (by Andrey Belym).
## 1.2.4
* Speed up Node.js secure generators (by Dmitriy Tsvettsikh).
## 1.2.3
* Fix JSDoc (by Hendry Sadrak).
## 1.2.2
* Fix distribution in `nanoid/non-secure` (by Eatall).
## 1.2.1
* Fix old Node.js support.
## 1.2
* Add `nanoid/async`.
* Fix `nanoid/non-secure` JSDoc.
* Add Chinese documentation (by Wenliang Dai).
* Speed up and reduce size of `nanoid/non-secure` (by Ori Livni).
## 1.1.1
* Improve performance and reduce size of non-secure ID generator.
## 1.1
* Add non-secure ID generator.
* Suggest to use non-secure ID generator for React Native developers.
* Reduce size.
## 1.0.7
* Fix documentation.
## 1.0.6
* Fix documentation.
## 1.0.5
* Reduce `nanoid/index` size (by Anton Khlynovskiy).
## 1.0.4
* Reduce npm package size.
## 1.0.3
* Reduce npm package size.
## 1.0.2
* Fix Web Workers support (by Zachary Golba).
## 1.0.1
* Reduce `nanoid/index` size (by Anton Khlynovskiy).
## 1.0
* Use 21 symbols by default (by David Klebanoff).
## 0.2.2
* Reduce `nanoid/generate` size (by Anton Khlynovskiy).
* Speed up Node.js random generator.
## 0.2.1
* Fix documentation (by Piper Chester).
## 0.2
* Add `size` argument to `nanoid()`.
* Improve performance by 50%.
* Reduce library size by 26% (by Vsevolod Rodionov and Oleg Mokhov).
## 0.1.1
* Reduce library size by 5%.
## 0.1
* Initial release.

20
node_modules/nanoid/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

395
node_modules/nanoid/README.md generated vendored Normal file
View File

@@ -0,0 +1,395 @@
# Nano ID
<img src="https://ai.github.io/nanoid/logo.svg" align="right"
alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
* **Small.** 139 bytes (minified and gzipped). No dependencies.
[Size Limit] controls the size.
* **Safe.** It uses cryptographically strong random APIs.
Can be used in clusters.
* **Fast.** Its 16% faster than UUID.
* **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
So ID size was reduced from 36 to 21 symbols.
```js
var nanoid = require('nanoid')
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
```
Supports [all browsers], Node.js and React Native.
[all browsers]: http://caniuse.com/#feat=getrandomvalues
[Size Limit]: https://github.com/ai/size-limit
<a href="https://evilmartians.com/?utm_source=nanoid">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54">
</a>
## Table of Contents
1. [Comparison with UUID](#comparison-with-uuid)
2. [Benchmark](#benchmark)
4. [Tools](#tools)
3. [Security](#security)
6. Usage
1. [JS](#js)
2. [React](#react)
3. [React Native](#react-native)
4. [Web Workers](#web-workers)
5. [PouchDB and CouchDB](#pouchdb-and-couchdb)
5. [Mongoose](#mongoose)
6. [Other Programming Languages](#other-programming-languages)
7. API
1. [Async](#async)
2. [Non-Secure](#non-secure)
3. [Custom Alphabet or Length](#custom-alphabet-or-length)
4. [Custom Random Bytes Generator](#custom-random-bytes-generator)
## Comparison with UUID
Nano ID is quite comparable to UUID v4 (random-based).
It has a similar number of random bits in the ID
(126 in Nano ID and 122 in UUID), so it has a similar collision probability:
> For there to be a one in a billion chance of duplication,
> 103 trillion version 4 IDs must be generated.
There are three main differences between Nano ID and UUID v4:
1. Nano ID uses a bigger alphabet, so a similar number of random bits
are packed in just 21 symbols instead of 36.
2. Nano ID code is 3 times less than `uuid/v4` package:
139 bytes instead of 435.
3. Because of memory allocation tricks, Nano ID is 16% faster than UUID.
## Benchmark
```rust
$ ./test/benchmark
nanoid 693,132 ops/sec
nanoid/generate 624,291 ops/sec
uid.sync 487,706 ops/sec
uuid/v4 471,299 ops/sec
secure-random-string 448,386 ops/sec
shortid 66,809 ops/sec
Async:
nanoid/async 105,024 ops/sec
nanoid/async/generate 106,682 ops/sec
secure-random-string 94,217 ops/sec
uid 92,026 ops/sec
Non-secure:
nanoid/non-secure 2,555,814 ops/sec
rndm 2,413,565 ops/sec
```
## Tools
* [ID size calculator] to choice smaller ID size depends on your case.
* [`nanoid-dictionary`] with popular alphabets to use with `nanoid/generate`.
* [`nanoid-cli`] to generate ID from CLI.
* [`nanoid-good`] to be sure that your ID doesn't contain any obscene words.
[`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary
[ID size calculator]: https://zelark.github.io/nano-id-cc/
[`nanoid-cli`]: https://github.com/twhitbeck/nanoid-cli
[`nanoid-good`]: https://github.com/y-gagar1n/nanoid-good
## Security
*See a good article about random generators theory:
[Secure random values (in Node.js)]*
### Unpredictability
Instead of using the unsafe `Math.random()`, Nano ID uses the `crypto` module
in Node.js and the Web Crypto API in browsers. These modules use unpredictable
hardware random generator.
### Uniformity
`random % alphabet` is a popular mistake to make when coding an ID generator.
The spread will not be even; there will be a lower chance for some symbols
to appear compared to others—so it will reduce the number of tries
when brute-forcing.
Nano ID uses a [better algorithm] and is tested for uniformity.
<img src="img/distribution.png" alt="Nano ID uniformity"
width="340" height="135">
[Secure random values (in Node.js)]: https://gist.github.com/joepie91/7105003c3b26e65efcea63f3db82dfba
[better algorithm]: https://github.com/ai/nanoid/blob/master/format.js
### Vulnerabilities
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
## Usage
### JS
The main module uses URL-friendly symbols (`A-Za-z0-9_-`) and returns an ID
with 21 characters (to have a collision probability similar to UUID v4).
```js
const nanoid = require('nanoid')
model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
```
If you want to reduce ID length (and increase collisions probability),
you can pass the length as an argument.
```js
nanoid(10) //=> "IRFa-VaY2b"
```
Dont forget to check the safety of your ID length
in our [ID collision probability] calculator.
[ID collision probability]: https://zelark.github.io/nano-id-cc/
### React
**Do not** use a nanoid for `key` prop. In React `key` should be consistence
between renders. This is bad code:
```jsx
<Item key={nanoid()} /> /* DONT DO IT */
```
This is good code. `this.id` will be generated only once:
```jsx
id = nanoid()
render () {
return <Item key={this.id}>;
}
}
```
If you want to use Nano ID for `id`, you must to set some string prefix.
Nano ID could be started from number. HTML ID cant be started from the number.
```jsx
<input id={'id' + this.id} type="text"/>
```
### React Native
React Native doesnt have built-in random generator.
1. Check [`expo-random`] docs and install it.
2. Use `nanoid/async` instead of synchronous `nanoid`.
```js
const nanoid = require('nanoid/async')
async function createUser () {
user.id = await nanoid()
}
```
### PouchDB and CouchDB
In PouchDB and CouchDB, IDs cant start with an underscore `_`.
A prefix is required to prevent this issue, as Nano ID might use a `_`
at the start of the ID by default.
Override the default ID with the following option:
```js
db.put({
_id: 'id' + nanoid(),
})
```
### Mongoose
```js
const mySchema = new Schema({
_id: {
type: String,
default: () => nanoid()
}
})
```
### Web Workers
Web Workers dont have access to a secure random generator.
Security is important in IDs, when IDs should be unpredictable. For instance,
in “access by URL” link generation.
If you dont need unpredictable IDs, but you need Web Workers support,
you can use nonsecure ID generator. Note, that they have bigger collision
probability.
```js
const nanoid = require('nanoid/non-secure')
model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
```
### Other Programming Languages
Nano ID was ported to many languages. You can use these ports to have the same
ID generators on client and server side.
* [C#](https://github.com/codeyu/nanoid-net)
* [Clojure and ClojureScript](https://github.com/zelark/nano-id)
* [Crystal](https://github.com/mamantoha/nanoid.cr)
* [Dart](https://github.com/pd4d10/nanoid-dart)
* [Go](https://github.com/matoous/go-nanoid)
* [Elixir](https://github.com/railsmechanic/nanoid)
* [Haskell](https://github.com/4e6/nanoid-hs)
* [Java](https://github.com/aventrix/jnanoid)
* [Nim](https://github.com/icyphox/nanoid.nim)
* [PHP](https://github.com/hidehalo/nanoid-php)
* [Python](https://github.com/puyuan/py-nanoid) with [dictionaries](https://pypi.org/project/nanoid-dictionary)
* [Ruby](https://github.com/radeno/nanoid.rb)
* [Rust](https://github.com/nikolay-govorov/nanoid)
* [Swift](https://github.com/antiflasher/NanoID)
Also, [CLI tool] is available to generate IDs from a command line.
[CLI tool]: https://github.com/twhitbeck/nanoid-cli
## API
### Async
To generate hardware random bytes, CPU will collect electromagnetic noise.
During the collection, CPU doesnt work.
If we will use asynchronous API for random generator,
another code could be executed during the entropy collection.
```js
const nanoid = require('nanoid/async')
async function createUser () {
user.id = await nanoid()
}
```
Unfortunately, you will not have any benefits in a browser, since Web Crypto API
doesnt have asynchronous API.
### Non-Secure
By default, Nano ID uses hardware random generator for security
and low collision probability. If you dont need it, you can use
very fast non-secure generator.
```js
const nonSecure = require('nanoid/non-secure')
const id = nonSecure() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
```
Note that it is predictable and have bigger collision probability.
### Custom Alphabet or Length
If you want to change the ID's alphabet or length
you can use the low-level `generate` module.
```js
const generate = require('nanoid/generate')
model.id = generate('1234567890abcdef', 10) //=> "4f90d13a42"
```
Check the safety of your custom alphabet and ID length
in our [ID collision probability] calculator.
You can find popular alphabets in [`nanoid-dictionary`].
Alphabet must contain 256 symbols or less.
Otherwise, the generator will not be secure.
Asynchronous and non-secure API is also available:
```js
const generate = require('nanoid/async/generate')
async function createUser () {
user.id = await generate('1234567890abcdef', 10)
}
```
```js
const generate = require('nanoid/non-secure/generate')
user.id = generate('1234567890abcdef', 10)
```
[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/
[`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary
### Custom Random Bytes Generator
You can replace the default safe random generator using the `format` module.
For instance, to use a seed-based generator.
```js
const format = require('nanoid/format')
function random (size) {
const result = []
for (let i = 0; i < size; i++) {
result.push(randomByte())
}
return result
}
format(random, "abcdef", 10) //=> "fbaefaadeb"
```
`random` callback must accept the array size and return an array
with random numbers.
If you want to use the same URL-friendly symbols with `format`,
you can get the default alphabet from the `url` file.
```js
const url = require('nanoid/url')
format(random, url, 10) //=> "93ce_Ltuub"
```
Asynchronous API is also available:
```js
const format = require('nanoid/async/format')
const url = require('nanoid/url')
function random (size) {
return new Promise()
}
async function createUser () {
user.id = await format(random, url, 10)
}
```

56
node_modules/nanoid/async/format.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
/**
* Secure random string generator with custom alphabet.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param {asyncGenerator} random The random bytes generator.
* @param {string} alphabet Symbols to be used in new random string.
* @param {size} size The number of symbols in new random string.
*
* @return {Promise} Promise with random string.
*
* @example
* const formatAsync = require('nanoid/async/format')
*
* function random (size) {
* const result = []
* for (let i = 0; i < size; i++) {
* result.push(randomByte())
* }
* return Promise.resolve(result)
* }
*
* formatAsync(random, "abcdef", 5).then(id => {
* model.id = id //=> "fbaef"
* })
*
* @name formatAsync
* @function
*/
module.exports = function (random, alphabet, size) {
var mask = (2 << 31 - Math.clz32((alphabet.length - 1) | 1)) - 1
var step = Math.ceil(1.6 * mask * size / alphabet.length)
size = +size
function tick (id) {
return random(step).then(function (bytes) {
for (var i = step; i--;) {
var byte = bytes[i] & mask
if (alphabet[byte]) {
id += alphabet[byte]
if (id.length === size) return id
}
}
return tick(id)
})
}
return tick('')
}
/**
* @callback asyncGenerator
* @param {number} bytes The number of bytes to generate.
* @return {Promise} Promise with array of random bytes.
*/

24
node_modules/nanoid/async/generate.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
var random = require('./random')
var format = require('./format')
/**
* Low-level function to change alphabet and ID size.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param {string} alphabet Symbols to be used in ID.
* @param {number} size The number of symbols in ID.
*
* @return {Promise} Promise with random string.
*
* @example
* const generateAsync = require('nanoid/async/generate')
* generateAsync('0123456789абвгдеё', 5).then(id => {
* model.id = id //=> "8ё56а"
* })
*
* @name generateAsync
* @function
*/
module.exports = format.bind(null, random)

17
node_modules/nanoid/async/index.browser.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var crypto = self.crypto || self.msCrypto
/*
* This alphabet uses a-z A-Z 0-9 _- symbols.
* Symbols order was changed for better gzip compression.
*/
var url = 'Uint8ArModuleSymbhasOw-012345679BCDEFGHIJKLNPQRTVWXYZ_cfgjkpqvxz'
module.exports = function (size) {
size = size || 21
var id = ''
var bytes = crypto.getRandomValues(new Uint8Array(size))
while (size--) {
id += url[bytes[size] & 63]
}
return Promise.resolve(id)
}

32
node_modules/nanoid/async/index.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var random = require('./random')
var url = require('../url')
/**
* Generate secure URL-friendly unique ID. Non-blocking version.
*
* By default, ID will have 21 symbols to have a collision probability similar
* to UUID v4.
*
* @param {number} [size=21] The number of symbols in ID.
*
* @return {Promise} Promise with random string.
*
* @example
* const nanoidAsync = require('nanoid/async')
* nanoidAsync.then(id => {
* model.id = id
* })
*
* @name async
* @function
*/
module.exports = function (size) {
size = size || 21
return random(size).then(function (bytes) {
var id = ''
while (size--) {
id += url[bytes[size] & 63]
}
return id
})
}

5
node_modules/nanoid/async/random.browser.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var crypto = self.crypto || self.msCrypto
module.exports = function (bytes) {
return Promise.resolve(crypto.getRandomValues(new Uint8Array(bytes)))
}

27
node_modules/nanoid/async/random.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var crypto = require('crypto')
if (crypto.randomFill) {
module.exports = function (bytes) {
return new Promise(function (resolve, reject) {
crypto.randomFill(Buffer.allocUnsafe(bytes), function (err, buf) {
if (err) {
reject(err)
} else {
resolve(buf)
}
})
})
}
} else {
module.exports = function (bytes) {
return new Promise(function (resolve, reject) {
crypto.randomBytes(bytes, function (err, buf) {
if (err) {
reject(err)
} else {
resolve(buf)
}
})
})
}
}

14
node_modules/nanoid/async/random.rn.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var random
try {
random = require('expo-random')
} catch (e) {
throw new Error(
'React-Native does not have a built-in secure random generator. ' +
'Install `expo-random` locally or ' +
'if you dont need unpredictable IDs, you can use `nanoid/non-secure`.'
)
}
module.exports = function (bytes) {
return random.getRandomBytesAsync(bytes)
}

52
node_modules/nanoid/format.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
/**
* Secure random string generator with custom alphabet.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param {generator} random The random bytes generator.
* @param {string} alphabet Symbols to be used in new random string.
* @param {size} size The number of symbols in new random string.
*
* @return {string} Random string.
*
* @example
* const format = require('nanoid/format')
*
* function random (size) {
* const result = []
* for (let i = 0; i < size; i++) {
* result.push(randomByte())
* }
* return result
* }
*
* format(random, "abcdef", 5) //=> "fbaef"
*
* @name format
* @function
*/
module.exports = function (random, alphabet, size) {
var mask = (2 << 31 - Math.clz32((alphabet.length - 1) | 1)) - 1
var step = Math.ceil(1.6 * mask * size / alphabet.length)
var id = ''
size = +size
while (true) {
var bytes = random(step)
for (var i = step; i--;) {
var byte = bytes[i] & mask
var alpha = alphabet[byte]
if (alpha) {
id += alpha
if (id.length === size) return id
}
}
}
}
/**
* @callback generator
* @param {number} bytes The number of bytes to generate.
* @return {number[]} Random bytes.
*/

22
node_modules/nanoid/generate.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
var random = require('./random')
var format = require('./format')
/**
* Low-level function to change alphabet and ID size.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param {string} alphabet Symbols to be used in ID.
* @param {number} size The number of symbols in ID.
*
* @return {string} Unique ID.
*
* @example
* const generate = require('nanoid/generate')
* model.id = generate('0123456789абвгдеё', 5) //=> "8ё56а"
*
* @name generate
* @function
*/
module.exports = format.bind(null, random)

33
node_modules/nanoid/index.browser.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
if (process.env.NODE_ENV !== 'production') {
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
throw new Error(
'React Native does not have a built-in secure random generator. ' +
'If you dont need unpredictable IDs, you can use `nanoid/non-secure`. ' +
'For secure ID install `expo-random` locally and use `nanoid/async`.'
)
}
if (typeof self === 'undefined' || (!self.crypto && !self.msCrypto)) {
throw new Error(
'Your browser does not have secure random generator. ' +
'If you dont need unpredictable IDs, you can use nanoid/non-secure.'
)
}
}
var crypto = self.crypto || self.msCrypto
/*
* This alphabet uses a-z A-Z 0-9 _- symbols.
* Symbols order was changed for better gzip compression.
*/
var url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-'
module.exports = function (size) {
size = size || 21
var id = ''
var bytes = crypto.getRandomValues(new Uint8Array(size))
while (size--) {
id += url[bytes[size] & 63]
}
return id
}

29
node_modules/nanoid/index.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var random = require('./random')
var url = require('./url')
/**
* Generate secure URL-friendly unique ID.
*
* By default, ID will have 21 symbols to have a collision probability similar
* to UUID v4.
*
* @param {number} [size=21] The number of symbols in ID.
*
* @return {string} Random string.
*
* @example
* const nanoid = require('nanoid')
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
*
* @name nanoid
* @function
*/
module.exports = function (size) {
size = size || 21
var bytes = random(size)
var id = ''
while (size--) {
id += url[bytes[size] & 63]
}
return id
}

24
node_modules/nanoid/non-secure/generate.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/**
* Generate URL-friendly unique ID. This method use non-secure predictable
* random generator with bigger collision probability.
*
* @param {string} alphabet Symbols to be used in ID.
* @param {number} [size=21] The number of symbols in ID.
*
* @return {string} Random string.
*
* @example
* const nanoid = require('nanoid/non-secure')
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
*
* @name nonSecure
* @function
*/
module.exports = function (alphabet, size) {
size = size || 21
var id = ''
while (size--) {
id += alphabet[Math.random() * alphabet.length | 0]
}
return id
}

25
node_modules/nanoid/non-secure/index.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var url = 'bjectSymhasOwnProp-0123456789ABCDEFGHIJKLMNQRTUVWXYZ_dfgiklquvxz'
/**
* Generate URL-friendly unique ID. This method use non-secure predictable
* random generator with bigger collision probability.
*
* @param {number} [size=21] The number of symbols in ID.
*
* @return {string} Random string.
*
* @example
* const nanoid = require('nanoid/non-secure')
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
*
* @name nonSecure
* @function
*/
module.exports = function (size) {
size = size || 21
var id = ''
while (size--) {
id += url[Math.random() * 64 | 0]
}
return id
}

66
node_modules/nanoid/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"_from": "nanoid@^2.1.0",
"_id": "nanoid@2.1.4",
"_inBundle": false,
"_integrity": "sha512-PijW88Ry+swMFfArOrm7uRAdVmJilLbej7WwVY6L5QwLDckqxSOinGGMV596yp5C8+MH3VvCXCSZ6AodGtKrYQ==",
"_location": "/nanoid",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "nanoid@^2.1.0",
"name": "nanoid",
"escapedName": "nanoid",
"rawSpec": "^2.1.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
},
"_requiredBy": [
"/json-server"
],
"_resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.4.tgz",
"_shasum": "c38b2c1f7f4c60cde2291f40854420328d0d621e",
"_spec": "nanoid@^2.1.0",
"_where": "/Users/nate/code/pluralsight/async-programming-promises/node_modules/json-server",
"author": {
"name": "Andrey Sitnik",
"email": "andrey@sitnik.ru"
},
"browser": {
"./index.js": "./index.browser.js",
"./random.js": "./random.browser.js",
"./async/index.js": "./async/index.browser.js",
"./async/random.js": "./async/random.browser.js"
},
"bugs": {
"url": "https://github.com/ai/nanoid/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "A tiny (139 bytes), secure URL-friendly unique string ID generator",
"eslintIgnore": [
"test/demo/build"
],
"homepage": "https://github.com/ai/nanoid#readme",
"keywords": [
"uuid",
"random",
"id",
"url"
],
"license": "MIT",
"name": "nanoid",
"react-native": {
"./async/random.js": "./async/random.rn.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ai/nanoid.git"
},
"sharec": {
"config": "@logux/sharec-config",
"version": "0.5.3"
},
"sideEffects": false,
"version": "2.1.4"
}

5
node_modules/nanoid/random.browser.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var crypto = self.crypto || self.msCrypto
module.exports = function (bytes) {
return crypto.getRandomValues(new Uint8Array(bytes))
}

15
node_modules/nanoid/random.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
var crypto = require('crypto')
if (crypto.randomFillSync) {
var buffers = { }
module.exports = function (bytes) {
var buffer = buffers[bytes]
if (!buffer) {
buffer = Buffer.allocUnsafe(bytes)
if (bytes <= 255) buffers[bytes] = buffer
}
return crypto.randomFillSync(buffer)
}
} else {
module.exports = crypto.randomBytes
}

15
node_modules/nanoid/url.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
/**
* URL safe symbols.
*
* This alphabet uses a-z A-Z 0-9 _- symbols.
* Symbols order was changed for better gzip compression.
*
* @name url
* @type {string}
*
* @example
* const url = require('nanoid/url')
* generate(url, 10) //=> "Uakgb_J5m9"
*/
module.exports =
'ModuleSymbhasOwnPr-0123456789ABCDEFGHIJKLNQRTUVWXYZ_cfgijkpqtvxz'