Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

Location:
imaps-frontend/node_modules/nanoid
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/nanoid/README.md

    rd565449 r0c6b92a  
    3636</a>
    3737
    38 ## Docs
    39 Read full docs **[here](https://github.com/ai/nanoid#readme)**.
     38## Table of Contents
     39
     40* [Comparison with UUID](#comparison-with-uuid)
     41* [Benchmark](#benchmark)
     42* [Security](#security)
     43* [API](#api)
     44  * [Blocking](#blocking)
     45  * [Async](#async)
     46  * [Non-Secure](#non-secure)
     47  * [Custom Alphabet or Size](#custom-alphabet-or-size)
     48  * [Custom Random Bytes Generator](#custom-random-bytes-generator)
     49* [Usage](#usage)
     50  * [IE](#ie)
     51  * [React](#react)
     52  * [React Native](#react-native)
     53  * [Rollup](#rollup)
     54  * [PouchDB and CouchDB](#pouchdb-and-couchdb)
     55  * [Mongoose](#mongoose)
     56  * [Web Workers](#web-workers)
     57  * [CLI](#cli)
     58  * [Other Programming Languages](#other-programming-languages)
     59* [Tools](#tools)
     60
     61
     62## Comparison with UUID
     63
     64Nano ID is quite comparable to UUID v4 (random-based).
     65It has a similar number of random bits in the ID
     66(126 in Nano ID and 122 in UUID), so it has a similar collision probability:
     67
     68> For there to be a one in a billion chance of duplication,
     69> 103 trillion version 4 IDs must be generated.
     70
     71There are three main differences between Nano ID and UUID v4:
     72
     731. Nano ID uses a bigger alphabet, so a similar number of random bits
     74   are packed in just 21 symbols instead of 36.
     752. Nano ID code is **4 times less** than `uuid/v4` package:
     76   130 bytes instead of 483.
     773. Because of memory allocation tricks, Nano ID is **2 times** faster than UUID.
     78
     79
     80## Benchmark
     81
     82```rust
     83$ node ./test/benchmark.js
     84crypto.randomUUID         25,603,857 ops/sec
     85@napi-rs/uuid              9,973,819 ops/sec
     86uid/secure                 8,234,798 ops/sec
     87@lukeed/uuid               7,464,706 ops/sec
     88nanoid                     5,616,592 ops/sec
     89customAlphabet             3,115,207 ops/sec
     90uuid v4                    1,535,753 ops/sec
     91secure-random-string         388,226 ops/sec
     92uid-safe.sync                363,489 ops/sec
     93cuid                         187,343 ops/sec
     94shortid                       45,758 ops/sec
     95
     96Async:
     97nanoid/async                  96,094 ops/sec
     98async customAlphabet          97,184 ops/sec
     99async secure-random-string    92,794 ops/sec
     100uid-safe                      90,684 ops/sec
     101
     102Non-secure:
     103uid                       67,376,692 ops/sec
     104nanoid/non-secure          2,849,639 ops/sec
     105rndm                       2,674,806 ops/sec
     106```
     107
     108Test configuration: ThinkPad X1 Carbon Gen 9, Fedora 34, Node.js 16.10.
     109
     110
     111## Security
     112
     113*See a good article about random generators theory:
     114[Secure random values (in Node.js)]*
     115
     116* **Unpredictability.** Instead of using the unsafe `Math.random()`, Nano ID
     117  uses the `crypto` module in Node.js and the Web Crypto API in browsers.
     118  These modules use unpredictable hardware random generator.
     119* **Uniformity.** `random % alphabet` is a popular mistake to make when coding
     120  an ID generator. The distribution will not be even; there will be a lower
     121  chance for some symbols to appear compared to others. So, it will reduce
     122  the number of tries when brute-forcing. Nano ID uses a [better algorithm]
     123  and is tested for uniformity.
     124
     125  <img src="img/distribution.png" alt="Nano ID uniformity"
     126     width="340" height="135">
     127
     128* **Well-documented:** all Nano ID hacks are documented. See comments
     129  in [the source].
     130* **Vulnerabilities:** to report a security vulnerability, please use
     131  the [Tidelift security contact](https://tidelift.com/security).
     132  Tidelift will coordinate the fix and disclosure.
     133
     134[Secure random values (in Node.js)]: https://gist.github.com/joepie91/7105003c3b26e65efcea63f3db82dfba
     135[better algorithm]:                  https://github.com/ai/nanoid/blob/main/index.js
     136[the source]:                        https://github.com/ai/nanoid/blob/main/index.js
     137
     138
     139## Install
     140
     141```bash
     142npm install --save nanoid
     143```
     144
     145For quick hacks, you can load Nano ID from CDN. Though, it is not recommended
     146to be used in production because of the lower loading performance.
     147
     148```js
     149import { nanoid } from 'https://cdn.jsdelivr.net/npm/nanoid/nanoid.js'
     150```
     151
     152Nano ID provides ES modules. You do not need to do anything to use Nano ID
     153as ESM in webpack, Rollup, Parcel, or Node.js.
     154
     155```js
     156import { nanoid } from 'nanoid'
     157```
     158
     159In Node.js you can use CommonJS import:
     160
     161```js
     162const { nanoid } = require('nanoid')
     163```
     164
     165
     166## API
     167
     168Nano ID has 3 APIs: normal (blocking), asynchronous, and non-secure.
     169
     170By default, Nano ID uses URL-friendly symbols (`A-Za-z0-9_-`) and returns an ID
     171with 21 characters (to have a collision probability similar to UUID v4).
     172
     173
     174### Blocking
     175
     176The safe and easiest way to use Nano ID.
     177
     178In rare cases could block CPU from other work while noise collection
     179for hardware random generator.
     180
     181```js
     182import { nanoid } from 'nanoid'
     183model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
     184```
     185
     186If you want to reduce the ID size (and increase collisions probability),
     187you can pass the size as an argument.
     188
     189```js
     190nanoid(10) //=> "IRFa-VaY2b"
     191```
     192
     193Don’t forget to check the safety of your ID size
     194in our [ID collision probability] calculator.
     195
     196You can also use a [custom alphabet](#custom-alphabet-or-size)
     197or a [random generator](#custom-random-bytes-generator).
     198
     199[ID collision probability]: https://zelark.github.io/nano-id-cc/
     200
     201
     202### Async
     203
     204To generate hardware random bytes, CPU collects electromagnetic noise.
     205For most cases, entropy will be already collected.
     206
     207In the synchronous API during the noise collection, the CPU is busy and
     208cannot do anything useful (for instance, process another HTTP request).
     209
     210Using the asynchronous API of Nano ID, another code can run during
     211the entropy collection.
     212
     213```js
     214import { nanoid } from 'nanoid/async'
     215
     216async function createUser () {
     217  user.id = await nanoid()
     218}
     219```
     220
     221Read more about entropy collection in [`crypto.randomBytes`] docs.
     222
     223Unfortunately, you will lose Web Crypto API advantages in a browser
     224if you use the asynchronous API. So, currently, in the browser, you are limited
     225with either security (`nanoid`), asynchronous behavior (`nanoid/async`),
     226or non-secure behavior (`nanoid/non-secure`) that will be explained
     227in the next part of the documentation.
     228
     229[`crypto.randomBytes`]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback
     230
     231
     232### Non-Secure
     233
     234By default, Nano ID uses hardware random bytes generation for security
     235and low collision probability. If you are not so concerned with security,
     236you can use the faster non-secure generator.
     237
     238```js
     239import { nanoid } from 'nanoid/non-secure'
     240const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
     241```
     242
     243
     244### Custom Alphabet or Size
     245
     246`customAlphabet` allows you to create `nanoid` with your own alphabet
     247and ID size.
     248
     249```js
     250import { customAlphabet } from 'nanoid'
     251const nanoid = customAlphabet('1234567890abcdef', 10)
     252model.id = nanoid() //=> "4f90d13a42"
     253```
     254
     255```js
     256import { customAlphabet } from 'nanoid/async'
     257const nanoid = customAlphabet('1234567890abcdef', 10)
     258async function createUser () {
     259  user.id = await nanoid()
     260}
     261```
     262
     263```js
     264import { customAlphabet } from 'nanoid/non-secure'
     265const nanoid = customAlphabet('1234567890abcdef', 10)
     266user.id = nanoid()
     267```
     268
     269Check the safety of your custom alphabet and ID size in our
     270[ID collision probability] calculator. For more alphabets, check out the options
     271in [`nanoid-dictionary`].
     272
     273Alphabet must contain 256 symbols or less.
     274Otherwise, the security of the internal generator algorithm is not guaranteed.
     275
     276In addition to setting a default size, you can change the ID size when calling
     277the function:
     278
     279```js
     280import { customAlphabet } from 'nanoid'
     281const nanoid = customAlphabet('1234567890abcdef', 10)
     282model.id = nanoid(5) //=> "f01a2"
     283```
     284
     285[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/
     286[`nanoid-dictionary`]:      https://github.com/CyberAP/nanoid-dictionary
     287
     288
     289### Custom Random Bytes Generator
     290
     291`customRandom` allows you to create a `nanoid` and replace alphabet
     292and the default random bytes generator.
     293
     294In this example, a seed-based generator is used:
     295
     296```js
     297import { customRandom } from 'nanoid'
     298
     299const rng = seedrandom(seed)
     300const nanoid = customRandom('abcdef', 10, size => {
     301  return (new Uint8Array(size)).map(() => 256 * rng())
     302})
     303
     304nanoid() //=> "fbaefaadeb"
     305```
     306
     307`random` callback must accept the array size and return an array
     308with random numbers.
     309
     310If you want to use the same URL-friendly symbols with `customRandom`,
     311you can get the default alphabet using the `urlAlphabet`.
     312
     313```js
     314const { customRandom, urlAlphabet } = require('nanoid')
     315const nanoid = customRandom(urlAlphabet, 10, random)
     316```
     317
     318Asynchronous and non-secure APIs are not available for `customRandom`.
     319
     320Note, that between Nano ID versions we may change random generator
     321call sequence. If you are using seed-based generators, we do not guarantee
     322the same result.
     323
     324
     325## Usage
     326
     327### IE
     328
     329If you support IE, you need to [transpile `node_modules`] by Babel
     330and add `crypto` alias. Moreover, `UInt8Array` in IE actually
     331is not an array and to cope with it, you have to convert it to an array
     332manually:
     333
     334```js
     335// polyfills.js
     336if (!window.crypto && window.msCrypto) {
     337  window.crypto = window.msCrypto
     338
     339  const getRandomValuesDef = window.crypto.getRandomValues
     340
     341  window.crypto.getRandomValues = function (array) {
     342    const values = getRandomValuesDef.call(window.crypto, array)
     343    const result = []
     344
     345    for (let i = 0; i < array.length; i++) {
     346      result[i] = values[i];
     347    }
     348
     349    return result
     350  };
     351}
     352```
     353
     354```js
     355import './polyfills.js'
     356import { nanoid } from 'nanoid'
     357```
     358
     359[transpile `node_modules`]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
     360
     361
     362### React
     363
     364There’s no correct way to use Nano ID for React `key` prop
     365since it should be consistent among renders.
     366
     367```jsx
     368function Todos({todos}) {
     369  return (
     370    <ul>
     371      {todos.map(todo => (
     372        <li key={nanoid()}> /* DON’T DO IT */
     373          {todo.text}
     374        </li>
     375      ))}
     376    </ul>
     377  )
     378}
     379```
     380
     381You should rather try to reach for stable ID inside your list item.
     382
     383```jsx
     384const todoItems = todos.map((todo) =>
     385  <li key={todo.id}>
     386    {todo.text}
     387  </li>
     388)
     389```
     390
     391In case you don’t have stable IDs you'd rather use index as `key`
     392instead of `nanoid()`:
     393
     394```jsx
     395const todoItems = todos.map((text, index) =>
     396  <li key={index}> /* Still not recommended but preferred over nanoid().
     397                      Only do this if items have no stable IDs. */
     398    {text}
     399  </li>
     400)
     401```
     402
     403
     404### React Native
     405
     406React Native does not have built-in random generator. The following polyfill
     407works for plain React Native and Expo starting with `39.x`.
     408
     4091. Check [`react-native-get-random-values`] docs and install it.
     4102. Import it before Nano ID.
     411
     412```js
     413import 'react-native-get-random-values'
     414import { nanoid } from 'nanoid'
     415```
     416
     417[`react-native-get-random-values`]: https://github.com/LinusU/react-native-get-random-values
     418
     419
     420### Rollup
     421
     422For Rollup you will need [`@rollup/plugin-node-resolve`] to bundle browser version
     423of this library.:
     424
     425```js
     426  plugins: [
     427    nodeResolve({
     428      browser: true
     429    })
     430  ]
     431```
     432
     433[`@rollup/plugin-node-resolve`]: https://github.com/rollup/plugins/tree/master/packages/node-resolve
     434
     435
     436### PouchDB and CouchDB
     437
     438In PouchDB and CouchDB, IDs can’t start with an underscore `_`.
     439A prefix is required to prevent this issue, as Nano ID might use a `_`
     440at the start of the ID by default.
     441
     442Override the default ID with the following option:
     443
     444```js
     445db.put({
     446  _id: 'id' + nanoid(),
     447  …
     448})
     449```
     450
     451
     452### Mongoose
     453
     454```js
     455const mySchema = new Schema({
     456  _id: {
     457    type: String,
     458    default: () => nanoid()
     459  }
     460})
     461```
     462
     463
     464### Web Workers
     465
     466Web Workers do not have access to a secure random generator.
     467
     468Security is important in IDs when IDs should be unpredictable.
     469For instance, in "access by URL" link generation.
     470If you do not need unpredictable IDs, but you need to use Web Workers,
     471you can use the non‑secure ID generator.
     472
     473```js
     474import { nanoid } from 'nanoid/non-secure'
     475nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
     476```
     477
     478Note: non-secure IDs are more prone to collision attacks.
     479
     480
     481### CLI
     482
     483You can get unique ID in terminal by calling `npx nanoid`. You need only
     484Node.js in the system. You do not need Nano ID to be installed anywhere.
     485
     486```sh
     487$ npx nanoid
     488npx: installed 1 in 0.63s
     489LZfXLFzPPR4NNrgjlWDxn
     490```
     491
     492Size of generated ID can be specified with `--size` (or `-s`) option:
     493
     494```sh
     495$ npx nanoid --size 10
     496L3til0JS4z
     497```
     498
     499Custom alphabet can be specified with `--alphabet` (or `-a`) option
     500(note that in this case `--size` is required):
     501
     502```sh
     503$ npx nanoid --alphabet abc --size 15
     504bccbcabaabaccab
     505```
     506
     507### Other Programming Languages
     508
     509Nano ID was ported to many languages. You can use these ports to have
     510the same ID generator on the client and server side.
     511
     512* [C#](https://github.com/codeyu/nanoid-net)
     513* [C++](https://github.com/mcmikecreations/nanoid_cpp)
     514* [Clojure and ClojureScript](https://github.com/zelark/nano-id)
     515* [ColdFusion/CFML](https://github.com/JamoCA/cfml-nanoid)
     516* [Crystal](https://github.com/mamantoha/nanoid.cr)
     517* [Dart & Flutter](https://github.com/pd4d10/nanoid-dart)
     518* [Deno](https://github.com/ianfabs/nanoid)
     519* [Go](https://github.com/matoous/go-nanoid)
     520* [Elixir](https://github.com/railsmechanic/nanoid)
     521* [Haskell](https://github.com/MichelBoucey/NanoID)
     522* [Janet](https://sr.ht/~statianzo/janet-nanoid/)
     523* [Java](https://github.com/aventrix/jnanoid)
     524* [Nim](https://github.com/icyphox/nanoid.nim)
     525* [OCaml](https://github.com/routineco/ocaml-nanoid)
     526* [Perl](https://github.com/tkzwtks/Nanoid-perl)
     527* [PHP](https://github.com/hidehalo/nanoid-php)
     528* [Python](https://github.com/puyuan/py-nanoid)
     529  with [dictionaries](https://pypi.org/project/nanoid-dictionary)
     530* [Postgres Extension](https://github.com/spa5k/uids-postgres)
     531* [R](https://github.com/hrbrmstr/nanoid) (with dictionaries)
     532* [Ruby](https://github.com/radeno/nanoid.rb)
     533* [Rust](https://github.com/nikolay-govorov/nanoid)
     534* [Swift](https://github.com/antiflasher/NanoID)
     535* [Unison](https://share.unison-lang.org/latest/namespaces/hojberg/nanoid)
     536* [V](https://github.com/invipal/nanoid)
     537* [Zig](https://github.com/SasLuca/zig-nanoid)
     538
     539For other environments, [CLI] is available to generate IDs from a command line.
     540
     541[CLI]: #cli
     542
     543
     544## Tools
     545
     546* [ID size calculator] shows collision probability when adjusting
     547  the ID alphabet or size.
     548* [`nanoid-dictionary`] with popular alphabets to use with [`customAlphabet`].
     549* [`nanoid-good`] to be sure that your ID doesn’t contain any obscene words.
     550
     551[`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary
     552[ID size calculator]:  https://zelark.github.io/nano-id-cc/
     553[`customAlphabet`]:    #custom-alphabet-or-size
     554[`nanoid-good`]:       https://github.com/y-gagar1n/nanoid-good
  • imaps-frontend/node_modules/nanoid/async/index.browser.cjs

    rd565449 r0c6b92a  
    11let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
     2
    23let customAlphabet = (alphabet, defaultSize = 21) => {
     4  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     5  // values closer to the alphabet size. The bitmask calculates the closest
     6  // `2^31 - 1` number, which exceeds the alphabet size.
     7  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
     8  // `Math.clz32` is not used, because it is not available in browsers.
    39  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
     10  // Though, the bitmask solution is not perfect since the bytes exceeding
     11  // the alphabet size are refused. Therefore, to reliably generate the ID,
     12  // the random bytes redundancy has to be satisfied.
     13
     14  // Note: every hardware random generator call is performance expensive,
     15  // because the system call for entropy collection takes a lot of time.
     16  // So, to avoid additional system calls, extra bytes are requested in advance.
     17
     18  // Next, a step determines how many random bytes to generate.
     19  // The number of random bytes gets decided upon the ID size, mask,
     20  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     21  // according to benchmarks).
     22
     23  // `-~f => Math.ceil(f)` if f is a float
     24  // `-~i => i + 1` if i is an integer
    425  let step = -~((1.6 * mask * defaultSize) / alphabet.length)
     26
    527  return async (size = defaultSize) => {
    628    let id = ''
    729    while (true) {
    830      let bytes = crypto.getRandomValues(new Uint8Array(step))
    9       let i = step
     31      // A compact alternative for `for (var i = 0; i < step; i++)`.
     32      let i = step | 0
    1033      while (i--) {
     34        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    1135        id += alphabet[bytes[i] & mask] || ''
    1236        if (id.length === size) return id
     
    1539  }
    1640}
     41
    1742let nanoid = async (size = 21) => {
    1843  let id = ''
    19   let bytes = crypto.getRandomValues(new Uint8Array(size))
     44  let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
     45
     46  // A compact alternative for `for (var i = 0; i < step; i++)`.
    2047  while (size--) {
     48    // It is incorrect to use bytes exceeding the alphabet size.
     49    // The following mask reduces the random byte in the 0-255 value
     50    // range to the 0-63 value range. Therefore, adding hacks, such
     51    // as empty string fallback or magic numbers, is unneccessary because
     52    // the bitmask trims bytes down to the alphabet size.
    2153    let byte = bytes[size] & 63
    2254    if (byte < 36) {
     55      // `0-9a-z`
    2356      id += byte.toString(36)
    2457    } else if (byte < 62) {
     58      // `A-Z`
    2559      id += (byte - 26).toString(36).toUpperCase()
    2660    } else if (byte < 63) {
     
    3266  return id
    3367}
     68
    3469module.exports = { nanoid, customAlphabet, random }
  • imaps-frontend/node_modules/nanoid/async/index.browser.js

    rd565449 r0c6b92a  
    11let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
     2
    23let customAlphabet = (alphabet, defaultSize = 21) => {
     4  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     5  // values closer to the alphabet size. The bitmask calculates the closest
     6  // `2^31 - 1` number, which exceeds the alphabet size.
     7  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
     8  // `Math.clz32` is not used, because it is not available in browsers.
    39  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
     10  // Though, the bitmask solution is not perfect since the bytes exceeding
     11  // the alphabet size are refused. Therefore, to reliably generate the ID,
     12  // the random bytes redundancy has to be satisfied.
     13
     14  // Note: every hardware random generator call is performance expensive,
     15  // because the system call for entropy collection takes a lot of time.
     16  // So, to avoid additional system calls, extra bytes are requested in advance.
     17
     18  // Next, a step determines how many random bytes to generate.
     19  // The number of random bytes gets decided upon the ID size, mask,
     20  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     21  // according to benchmarks).
     22
     23  // `-~f => Math.ceil(f)` if f is a float
     24  // `-~i => i + 1` if i is an integer
    425  let step = -~((1.6 * mask * defaultSize) / alphabet.length)
     26
    527  return async (size = defaultSize) => {
    628    let id = ''
    729    while (true) {
    830      let bytes = crypto.getRandomValues(new Uint8Array(step))
    9       let i = step
     31      // A compact alternative for `for (var i = 0; i < step; i++)`.
     32      let i = step | 0
    1033      while (i--) {
     34        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    1135        id += alphabet[bytes[i] & mask] || ''
    1236        if (id.length === size) return id
     
    1539  }
    1640}
     41
    1742let nanoid = async (size = 21) => {
    1843  let id = ''
    19   let bytes = crypto.getRandomValues(new Uint8Array(size))
     44  let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
     45
     46  // A compact alternative for `for (var i = 0; i < step; i++)`.
    2047  while (size--) {
     48    // It is incorrect to use bytes exceeding the alphabet size.
     49    // The following mask reduces the random byte in the 0-255 value
     50    // range to the 0-63 value range. Therefore, adding hacks, such
     51    // as empty string fallback or magic numbers, is unneccessary because
     52    // the bitmask trims bytes down to the alphabet size.
    2153    let byte = bytes[size] & 63
    2254    if (byte < 36) {
     55      // `0-9a-z`
    2356      id += byte.toString(36)
    2457    } else if (byte < 62) {
     58      // `A-Z`
    2559      id += (byte - 26).toString(36).toUpperCase()
    2660    } else if (byte < 63) {
     
    3266  return id
    3367}
     68
    3469export { nanoid, customAlphabet, random }
  • imaps-frontend/node_modules/nanoid/async/index.cjs

    rd565449 r0c6b92a  
    11let crypto = require('crypto')
     2
    23let { urlAlphabet } = require('../url-alphabet/index.cjs')
     4
     5// `crypto.randomFill()` is a little faster than `crypto.randomBytes()`,
     6// because it is possible to use in combination with `Buffer.allocUnsafe()`.
    37let random = bytes =>
    48  new Promise((resolve, reject) => {
     9    // `Buffer.allocUnsafe()` is faster because it doesn’t flush the memory.
     10    // Memory flushing is unnecessary since the buffer allocation itself resets
     11    // the memory with the new bytes.
    512    crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
    613      if (err) {
     
    1118    })
    1219  })
     20
    1321let customAlphabet = (alphabet, defaultSize = 21) => {
     22  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     23  // values closer to the alphabet size. The bitmask calculates the closest
     24  // `2^31 - 1` number, which exceeds the alphabet size.
     25  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
    1426  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
     27  // Though, the bitmask solution is not perfect since the bytes exceeding
     28  // the alphabet size are refused. Therefore, to reliably generate the ID,
     29  // the random bytes redundancy has to be satisfied.
     30
     31  // Note: every hardware random generator call is performance expensive,
     32  // because the system call for entropy collection takes a lot of time.
     33  // So, to avoid additional system calls, extra bytes are requested in advance.
     34
     35  // Next, a step determines how many random bytes to generate.
     36  // The number of random bytes gets decided upon the ID size, mask,
     37  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     38  // according to benchmarks).
    1539  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
     40
    1641  let tick = (id, size = defaultSize) =>
    1742    random(step).then(bytes => {
     43      // A compact alternative for `for (var i = 0; i < step; i++)`.
    1844      let i = step
    1945      while (i--) {
     46        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    2047        id += alphabet[bytes[i] & mask] || ''
    21         if (id.length === size) return id
     48        if (id.length >= size) return id
    2249      }
    2350      return tick(id, size)
    2451    })
     52
    2553  return size => tick('', size)
    2654}
     55
    2756let nanoid = (size = 21) =>
    28   random(size).then(bytes => {
     57  random((size |= 0)).then(bytes => {
    2958    let id = ''
     59    // A compact alternative for `for (var i = 0; i < step; i++)`.
    3060    while (size--) {
     61      // It is incorrect to use bytes exceeding the alphabet size.
     62      // The following mask reduces the random byte in the 0-255 value
     63      // range to the 0-63 value range. Therefore, adding hacks, such
     64      // as empty string fallback or magic numbers, is unneccessary because
     65      // the bitmask trims bytes down to the alphabet size.
    3166      id += urlAlphabet[bytes[size] & 63]
    3267    }
    3368    return id
    3469  })
     70
    3571module.exports = { nanoid, customAlphabet, random }
  • imaps-frontend/node_modules/nanoid/async/index.js

    rd565449 r0c6b92a  
    11import crypto from 'crypto'
     2
    23import { urlAlphabet } from '../url-alphabet/index.js'
     4
     5// `crypto.randomFill()` is a little faster than `crypto.randomBytes()`,
     6// because it is possible to use in combination with `Buffer.allocUnsafe()`.
    37let random = bytes =>
    48  new Promise((resolve, reject) => {
     9    // `Buffer.allocUnsafe()` is faster because it doesn’t flush the memory.
     10    // Memory flushing is unnecessary since the buffer allocation itself resets
     11    // the memory with the new bytes.
    512    crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
    613      if (err) {
     
    1118    })
    1219  })
     20
    1321let customAlphabet = (alphabet, defaultSize = 21) => {
     22  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     23  // values closer to the alphabet size. The bitmask calculates the closest
     24  // `2^31 - 1` number, which exceeds the alphabet size.
     25  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
    1426  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
     27  // Though, the bitmask solution is not perfect since the bytes exceeding
     28  // the alphabet size are refused. Therefore, to reliably generate the ID,
     29  // the random bytes redundancy has to be satisfied.
     30
     31  // Note: every hardware random generator call is performance expensive,
     32  // because the system call for entropy collection takes a lot of time.
     33  // So, to avoid additional system calls, extra bytes are requested in advance.
     34
     35  // Next, a step determines how many random bytes to generate.
     36  // The number of random bytes gets decided upon the ID size, mask,
     37  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     38  // according to benchmarks).
    1539  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
     40
    1641  let tick = (id, size = defaultSize) =>
    1742    random(step).then(bytes => {
     43      // A compact alternative for `for (var i = 0; i < step; i++)`.
    1844      let i = step
    1945      while (i--) {
     46        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    2047        id += alphabet[bytes[i] & mask] || ''
    21         if (id.length === size) return id
     48        if (id.length >= size) return id
    2249      }
    2350      return tick(id, size)
    2451    })
     52
    2553  return size => tick('', size)
    2654}
     55
    2756let nanoid = (size = 21) =>
    28   random(size).then(bytes => {
     57  random((size |= 0)).then(bytes => {
    2958    let id = ''
     59    // A compact alternative for `for (var i = 0; i < step; i++)`.
    3060    while (size--) {
     61      // It is incorrect to use bytes exceeding the alphabet size.
     62      // The following mask reduces the random byte in the 0-255 value
     63      // range to the 0-63 value range. Therefore, adding hacks, such
     64      // as empty string fallback or magic numbers, is unneccessary because
     65      // the bitmask trims bytes down to the alphabet size.
    3166      id += urlAlphabet[bytes[size] & 63]
    3267    }
    3368    return id
    3469  })
     70
    3571export { nanoid, customAlphabet, random }
  • imaps-frontend/node_modules/nanoid/async/index.native.js

    rd565449 r0c6b92a  
    11import { getRandomBytesAsync } from 'expo-random'
     2
    23import { urlAlphabet } from '../url-alphabet/index.js'
     4
    35let random = getRandomBytesAsync
     6
    47let customAlphabet = (alphabet, defaultSize = 21) => {
     8  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     9  // values closer to the alphabet size. The bitmask calculates the closest
     10  // `2^31 - 1` number, which exceeds the alphabet size.
     11  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
    512  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
     13  // Though, the bitmask solution is not perfect since the bytes exceeding
     14  // the alphabet size are refused. Therefore, to reliably generate the ID,
     15  // the random bytes redundancy has to be satisfied.
     16
     17  // Note: every hardware random generator call is performance expensive,
     18  // because the system call for entropy collection takes a lot of time.
     19  // So, to avoid additional system calls, extra bytes are requested in advance.
     20
     21  // Next, a step determines how many random bytes to generate.
     22  // The number of random bytes gets decided upon the ID size, mask,
     23  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     24  // according to benchmarks).
    625  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
     26
    727  let tick = (id, size = defaultSize) =>
    828    random(step).then(bytes => {
     29      // A compact alternative for `for (var i = 0; i < step; i++)`.
    930      let i = step
    1031      while (i--) {
     32        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    1133        id += alphabet[bytes[i] & mask] || ''
    12         if (id.length === size) return id
     34        if (id.length >= size) return id
    1335      }
    1436      return tick(id, size)
    1537    })
     38
    1639  return size => tick('', size)
    1740}
     41
    1842let nanoid = (size = 21) =>
    19   random(size).then(bytes => {
     43  random((size |= 0)).then(bytes => {
    2044    let id = ''
     45    // A compact alternative for `for (var i = 0; i < step; i++)`.
    2146    while (size--) {
     47      // It is incorrect to use bytes exceeding the alphabet size.
     48      // The following mask reduces the random byte in the 0-255 value
     49      // range to the 0-63 value range. Therefore, adding hacks, such
     50      // as empty string fallback or magic numbers, is unneccessary because
     51      // the bitmask trims bytes down to the alphabet size.
    2252      id += urlAlphabet[bytes[size] & 63]
    2353    }
    2454    return id
    2555  })
     56
    2657export { nanoid, customAlphabet, random }
  • imaps-frontend/node_modules/nanoid/index.browser.cjs

    rd565449 r0c6b92a  
     1// This file replaces `index.js` in bundlers like webpack or Rollup,
     2// according to `browser` config in `package.json`.
     3
    14let { urlAlphabet } = require('./url-alphabet/index.cjs')
     5
    26let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
     7
    38let customRandom = (alphabet, defaultSize, getRandom) => {
     9  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     10  // values closer to the alphabet size. The bitmask calculates the closest
     11  // `2^31 - 1` number, which exceeds the alphabet size.
     12  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
     13  // `Math.clz32` is not used, because it is not available in browsers.
    414  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
     15  // Though, the bitmask solution is not perfect since the bytes exceeding
     16  // the alphabet size are refused. Therefore, to reliably generate the ID,
     17  // the random bytes redundancy has to be satisfied.
     18
     19  // Note: every hardware random generator call is performance expensive,
     20  // because the system call for entropy collection takes a lot of time.
     21  // So, to avoid additional system calls, extra bytes are requested in advance.
     22
     23  // Next, a step determines how many random bytes to generate.
     24  // The number of random bytes gets decided upon the ID size, mask,
     25  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     26  // according to benchmarks).
     27
     28  // `-~f => Math.ceil(f)` if f is a float
     29  // `-~i => i + 1` if i is an integer
    530  let step = -~((1.6 * mask * defaultSize) / alphabet.length)
     31
    632  return (size = defaultSize) => {
    733    let id = ''
    834    while (true) {
    935      let bytes = getRandom(step)
    10       let j = step
     36      // A compact alternative for `for (var i = 0; i < step; i++)`.
     37      let j = step | 0
    1138      while (j--) {
     39        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    1240        id += alphabet[bytes[j] & mask] || ''
    1341        if (id.length === size) return id
     
    1644  }
    1745}
     46
    1847let customAlphabet = (alphabet, size = 21) =>
    1948  customRandom(alphabet, size, random)
     49
    2050let nanoid = (size = 21) =>
    2151  crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
     52    // It is incorrect to use bytes exceeding the alphabet size.
     53    // The following mask reduces the random byte in the 0-255 value
     54    // range to the 0-63 value range. Therefore, adding hacks, such
     55    // as empty string fallback or magic numbers, is unneccessary because
     56    // the bitmask trims bytes down to the alphabet size.
    2257    byte &= 63
    2358    if (byte < 36) {
     59      // `0-9a-z`
    2460      id += byte.toString(36)
    2561    } else if (byte < 62) {
     62      // `A-Z`
    2663      id += (byte - 26).toString(36).toUpperCase()
    2764    } else if (byte > 62) {
     
    3269    return id
    3370  }, '')
     71
    3472module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
  • imaps-frontend/node_modules/nanoid/index.browser.js

    rd565449 r0c6b92a  
     1// This file replaces `index.js` in bundlers like webpack or Rollup,
     2// according to `browser` config in `package.json`.
     3
    14import { urlAlphabet } from './url-alphabet/index.js'
     5
    26let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
     7
    38let customRandom = (alphabet, defaultSize, getRandom) => {
     9  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     10  // values closer to the alphabet size. The bitmask calculates the closest
     11  // `2^31 - 1` number, which exceeds the alphabet size.
     12  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
     13  // `Math.clz32` is not used, because it is not available in browsers.
    414  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
     15  // Though, the bitmask solution is not perfect since the bytes exceeding
     16  // the alphabet size are refused. Therefore, to reliably generate the ID,
     17  // the random bytes redundancy has to be satisfied.
     18
     19  // Note: every hardware random generator call is performance expensive,
     20  // because the system call for entropy collection takes a lot of time.
     21  // So, to avoid additional system calls, extra bytes are requested in advance.
     22
     23  // Next, a step determines how many random bytes to generate.
     24  // The number of random bytes gets decided upon the ID size, mask,
     25  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     26  // according to benchmarks).
     27
     28  // `-~f => Math.ceil(f)` if f is a float
     29  // `-~i => i + 1` if i is an integer
    530  let step = -~((1.6 * mask * defaultSize) / alphabet.length)
     31
    632  return (size = defaultSize) => {
    733    let id = ''
    834    while (true) {
    935      let bytes = getRandom(step)
    10       let j = step
     36      // A compact alternative for `for (var i = 0; i < step; i++)`.
     37      let j = step | 0
    1138      while (j--) {
     39        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    1240        id += alphabet[bytes[j] & mask] || ''
    1341        if (id.length === size) return id
     
    1644  }
    1745}
     46
    1847let customAlphabet = (alphabet, size = 21) =>
    1948  customRandom(alphabet, size, random)
     49
    2050let nanoid = (size = 21) =>
    2151  crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
     52    // It is incorrect to use bytes exceeding the alphabet size.
     53    // The following mask reduces the random byte in the 0-255 value
     54    // range to the 0-63 value range. Therefore, adding hacks, such
     55    // as empty string fallback or magic numbers, is unneccessary because
     56    // the bitmask trims bytes down to the alphabet size.
    2257    byte &= 63
    2358    if (byte < 36) {
     59      // `0-9a-z`
    2460      id += byte.toString(36)
    2561    } else if (byte < 62) {
     62      // `A-Z`
    2663      id += (byte - 26).toString(36).toUpperCase()
    2764    } else if (byte > 62) {
     
    3269    return id
    3370  }, '')
     71
    3472export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
  • imaps-frontend/node_modules/nanoid/index.cjs

    rd565449 r0c6b92a  
    11let crypto = require('crypto')
     2
    23let { urlAlphabet } = require('./url-alphabet/index.cjs')
     4
     5// It is best to make fewer, larger requests to the crypto module to
     6// avoid system call overhead. So, random numbers are generated in a
     7// pool. The pool is a Buffer that is larger than the initial random
     8// request size by this multiplier. The pool is enlarged if subsequent
     9// requests exceed the maximum buffer size.
    310const POOL_SIZE_MULTIPLIER = 128
    411let pool, poolOffset
     12
    513let fillPool = bytes => {
    614  if (!pool || pool.length < bytes) {
     
    1422  poolOffset += bytes
    1523}
     24
    1625let random = bytes => {
    17   fillPool((bytes -= 0))
     26  // `|=` convert `bytes` to number to prevent `valueOf` abusing and pool pollution
     27  fillPool((bytes |= 0))
    1828  return pool.subarray(poolOffset - bytes, poolOffset)
    1929}
     30
    2031let customRandom = (alphabet, defaultSize, getRandom) => {
     32  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     33  // values closer to the alphabet size. The bitmask calculates the closest
     34  // `2^31 - 1` number, which exceeds the alphabet size.
     35  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
    2136  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
     37  // Though, the bitmask solution is not perfect since the bytes exceeding
     38  // the alphabet size are refused. Therefore, to reliably generate the ID,
     39  // the random bytes redundancy has to be satisfied.
     40
     41  // Note: every hardware random generator call is performance expensive,
     42  // because the system call for entropy collection takes a lot of time.
     43  // So, to avoid additional system calls, extra bytes are requested in advance.
     44
     45  // Next, a step determines how many random bytes to generate.
     46  // The number of random bytes gets decided upon the ID size, mask,
     47  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     48  // according to benchmarks).
    2249  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
     50
    2351  return (size = defaultSize) => {
    2452    let id = ''
    2553    while (true) {
    2654      let bytes = getRandom(step)
     55      // A compact alternative for `for (let i = 0; i < step; i++)`.
    2756      let i = step
    2857      while (i--) {
     58        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    2959        id += alphabet[bytes[i] & mask] || ''
    3060        if (id.length === size) return id
     
    3363  }
    3464}
     65
    3566let customAlphabet = (alphabet, size = 21) =>
    3667  customRandom(alphabet, size, random)
     68
    3769let nanoid = (size = 21) => {
    38   fillPool((size -= 0))
     70  // `|=` convert `size` to number to prevent `valueOf` abusing and pool pollution
     71  fillPool((size |= 0))
    3972  let id = ''
     73  // We are reading directly from the random pool to avoid creating new array
    4074  for (let i = poolOffset - size; i < poolOffset; i++) {
     75    // It is incorrect to use bytes exceeding the alphabet size.
     76    // The following mask reduces the random byte in the 0-255 value
     77    // range to the 0-63 value range. Therefore, adding hacks, such
     78    // as empty string fallback or magic numbers, is unneccessary because
     79    // the bitmask trims bytes down to the alphabet size.
    4180    id += urlAlphabet[pool[i] & 63]
    4281  }
    4382  return id
    4483}
     84
    4585module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
  • imaps-frontend/node_modules/nanoid/index.js

    rd565449 r0c6b92a  
    11import crypto from 'crypto'
     2
    23import { urlAlphabet } from './url-alphabet/index.js'
     4
     5// It is best to make fewer, larger requests to the crypto module to
     6// avoid system call overhead. So, random numbers are generated in a
     7// pool. The pool is a Buffer that is larger than the initial random
     8// request size by this multiplier. The pool is enlarged if subsequent
     9// requests exceed the maximum buffer size.
    310const POOL_SIZE_MULTIPLIER = 128
    411let pool, poolOffset
     12
    513let fillPool = bytes => {
    614  if (!pool || pool.length < bytes) {
     
    1422  poolOffset += bytes
    1523}
     24
    1625let random = bytes => {
    17   fillPool((bytes -= 0))
     26  // `|=` convert `bytes` to number to prevent `valueOf` abusing and pool pollution
     27  fillPool((bytes |= 0))
    1828  return pool.subarray(poolOffset - bytes, poolOffset)
    1929}
     30
    2031let customRandom = (alphabet, defaultSize, getRandom) => {
     32  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
     33  // values closer to the alphabet size. The bitmask calculates the closest
     34  // `2^31 - 1` number, which exceeds the alphabet size.
     35  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
    2136  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
     37  // Though, the bitmask solution is not perfect since the bytes exceeding
     38  // the alphabet size are refused. Therefore, to reliably generate the ID,
     39  // the random bytes redundancy has to be satisfied.
     40
     41  // Note: every hardware random generator call is performance expensive,
     42  // because the system call for entropy collection takes a lot of time.
     43  // So, to avoid additional system calls, extra bytes are requested in advance.
     44
     45  // Next, a step determines how many random bytes to generate.
     46  // The number of random bytes gets decided upon the ID size, mask,
     47  // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
     48  // according to benchmarks).
    2249  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
     50
    2351  return (size = defaultSize) => {
    2452    let id = ''
    2553    while (true) {
    2654      let bytes = getRandom(step)
     55      // A compact alternative for `for (let i = 0; i < step; i++)`.
    2756      let i = step
    2857      while (i--) {
     58        // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
    2959        id += alphabet[bytes[i] & mask] || ''
    3060        if (id.length === size) return id
     
    3363  }
    3464}
     65
    3566let customAlphabet = (alphabet, size = 21) =>
    3667  customRandom(alphabet, size, random)
     68
    3769let nanoid = (size = 21) => {
    38   fillPool((size -= 0))
     70  // `|=` convert `size` to number to prevent `valueOf` abusing and pool pollution
     71  fillPool((size |= 0))
    3972  let id = ''
     73  // We are reading directly from the random pool to avoid creating new array
    4074  for (let i = poolOffset - size; i < poolOffset; i++) {
     75    // It is incorrect to use bytes exceeding the alphabet size.
     76    // The following mask reduces the random byte in the 0-255 value
     77    // range to the 0-63 value range. Therefore, adding hacks, such
     78    // as empty string fallback or magic numbers, is unneccessary because
     79    // the bitmask trims bytes down to the alphabet size.
    4180    id += urlAlphabet[pool[i] & 63]
    4281  }
    4382  return id
    4483}
     84
    4585export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
  • imaps-frontend/node_modules/nanoid/non-secure/index.cjs

    rd565449 r0c6b92a  
     1// This alphabet uses `A-Za-z0-9_-` symbols.
     2// The order of characters is optimized for better gzip and brotli compression.
     3// References to the same file (works both for gzip and brotli):
     4// `'use`, `andom`, and `rict'`
     5// References to the brotli default dictionary:
     6// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
    17let urlAlphabet =
    28  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
     9
    310let customAlphabet = (alphabet, defaultSize = 21) => {
    411  return (size = defaultSize) => {
    512    let id = ''
    6     let i = size
     13    // A compact alternative for `for (var i = 0; i < step; i++)`.
     14    let i = size | 0
    715    while (i--) {
     16      // `| 0` is more compact and faster than `Math.floor()`.
    817      id += alphabet[(Math.random() * alphabet.length) | 0]
    918    }
     
    1120  }
    1221}
     22
    1323let nanoid = (size = 21) => {
    1424  let id = ''
    15   let i = size
     25  // A compact alternative for `for (var i = 0; i < step; i++)`.
     26  let i = size | 0
    1627  while (i--) {
     28    // `| 0` is more compact and faster than `Math.floor()`.
    1729    id += urlAlphabet[(Math.random() * 64) | 0]
    1830  }
    1931  return id
    2032}
     33
    2134module.exports = { nanoid, customAlphabet }
  • imaps-frontend/node_modules/nanoid/non-secure/index.js

    rd565449 r0c6b92a  
     1// This alphabet uses `A-Za-z0-9_-` symbols.
     2// The order of characters is optimized for better gzip and brotli compression.
     3// References to the same file (works both for gzip and brotli):
     4// `'use`, `andom`, and `rict'`
     5// References to the brotli default dictionary:
     6// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
    17let urlAlphabet =
    28  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
     9
    310let customAlphabet = (alphabet, defaultSize = 21) => {
    411  return (size = defaultSize) => {
    512    let id = ''
    6     let i = size
     13    // A compact alternative for `for (var i = 0; i < step; i++)`.
     14    let i = size | 0
    715    while (i--) {
     16      // `| 0` is more compact and faster than `Math.floor()`.
    817      id += alphabet[(Math.random() * alphabet.length) | 0]
    918    }
     
    1120  }
    1221}
     22
    1323let nanoid = (size = 21) => {
    1424  let id = ''
    15   let i = size
     25  // A compact alternative for `for (var i = 0; i < step; i++)`.
     26  let i = size | 0
    1627  while (i--) {
     28    // `| 0` is more compact and faster than `Math.floor()`.
    1729    id += urlAlphabet[(Math.random() * 64) | 0]
    1830  }
    1931  return id
    2032}
     33
    2134export { nanoid, customAlphabet }
  • imaps-frontend/node_modules/nanoid/package.json

    rd565449 r0c6b92a  
    11{
    22  "name": "nanoid",
    3   "version": "3.3.7",
     3  "version": "3.3.8",
    44  "description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
    55  "keywords": [
  • imaps-frontend/node_modules/nanoid/url-alphabet/index.cjs

    rd565449 r0c6b92a  
     1// This alphabet uses `A-Za-z0-9_-` symbols.
     2// The order of characters is optimized for better gzip and brotli compression.
     3// Same as in non-secure/index.js
    14let urlAlphabet =
    25  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
     6
    37module.exports = { urlAlphabet }
  • imaps-frontend/node_modules/nanoid/url-alphabet/index.js

    rd565449 r0c6b92a  
     1// This alphabet uses `A-Za-z0-9_-` symbols.
     2// The order of characters is optimized for better gzip and brotli compression.
     3// Same as in non-secure/index.js
    14let urlAlphabet =
    25  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
     6
    37export { urlAlphabet }
Note: See TracChangeset for help on using the changeset viewer.