add lisp packages
This commit is contained in:
78
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/index.d.ts
generated
vendored
Normal file
78
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
import {MergeExclusive} from 'type-fest';
|
||||
|
||||
interface BaseOptions {
|
||||
/**
|
||||
Length of the returned string.
|
||||
*/
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface TypeOption {
|
||||
/**
|
||||
Use only characters from a predefined set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `characters` option.
|
||||
|
||||
@default 'hex'
|
||||
|
||||
The `distinguishable` set contains only uppercase characters that are not easily confused: `CDEHKMPRTUWXY012458`. It can be useful if you need to print out a short string that you'd like users to read and type back in with minimal errors. For example, reading a code off of a screen that needs to be typed into a phone to connect two devices.
|
||||
|
||||
@example
|
||||
```
|
||||
cryptoRandomString({length: 10});
|
||||
//=> '87fc70e2b9'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'base64'});
|
||||
//=> 'mhsX7xmIv/'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'url-safe'});
|
||||
//=> 'VEjfNW3Yej'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'numeric'});
|
||||
//=> '8314659141'
|
||||
|
||||
cryptoRandomString({length: 6, type: 'distinguishable'});
|
||||
//=> 'CDEHKM'
|
||||
```
|
||||
*/
|
||||
type?: 'hex' | 'base64' | 'url-safe' | 'numeric' | 'distinguishable';
|
||||
}
|
||||
|
||||
interface CharactersOption {
|
||||
/**
|
||||
Use only characters from a custom set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `type` option.
|
||||
|
||||
Minimum length: `1`
|
||||
Maximum length: `65536`
|
||||
|
||||
@example
|
||||
```
|
||||
cryptoRandomString({length: 10, characters: '0123456789'});
|
||||
//=> '8796225811'
|
||||
```
|
||||
*/
|
||||
characters?: string;
|
||||
}
|
||||
|
||||
declare namespace cryptoRandomString {
|
||||
type Options = BaseOptions & MergeExclusive<TypeOption, CharactersOption>;
|
||||
}
|
||||
|
||||
/**
|
||||
Generate a [cryptographically strong](https://en.wikipedia.org/wiki/Strong_cryptography) random string.
|
||||
|
||||
@returns A randomized string.
|
||||
|
||||
@example
|
||||
```
|
||||
import cryptoRandomString = require('crypto-random-string');
|
||||
|
||||
cryptoRandomString({length: 10});
|
||||
//=> '2cf05d94db'
|
||||
```
|
||||
*/
|
||||
declare function cryptoRandomString(options?: cryptoRandomString.Options): string;
|
||||
|
||||
export = cryptoRandomString;
|
||||
94
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/index.js
generated
vendored
Normal file
94
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
|
||||
const urlSafeCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'.split('');
|
||||
const numericCharacters = '0123456789'.split('');
|
||||
const distinguishableCharacters = 'CDEHKMPRTUWXY012458'.split('');
|
||||
|
||||
const generateForCustomCharacters = (length, characters) => {
|
||||
// Generating entropy is faster than complex math operations, so we use the simplest way
|
||||
const characterCount = characters.length;
|
||||
const maxValidSelector = (Math.floor(0x10000 / characterCount) * characterCount) - 1; // Using values above this will ruin distribution when using modular division
|
||||
const entropyLength = 2 * Math.ceil(1.1 * length); // Generating a bit more than required so chances we need more than one pass will be really low
|
||||
let string = '';
|
||||
let stringLength = 0;
|
||||
|
||||
while (stringLength < length) { // In case we had many bad values, which may happen for character sets of size above 0x8000 but close to it
|
||||
const entropy = crypto.randomBytes(entropyLength);
|
||||
let entropyPosition = 0;
|
||||
|
||||
while (entropyPosition < entropyLength && stringLength < length) {
|
||||
const entropyValue = entropy.readUInt16LE(entropyPosition);
|
||||
entropyPosition += 2;
|
||||
if (entropyValue > maxValidSelector) { // Skip values which will ruin distribution when using modular division
|
||||
continue;
|
||||
}
|
||||
|
||||
string += characters[entropyValue % characterCount];
|
||||
stringLength++;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
const allowedTypes = [
|
||||
undefined,
|
||||
'hex',
|
||||
'base64',
|
||||
'url-safe',
|
||||
'numeric',
|
||||
'distinguishable'
|
||||
];
|
||||
|
||||
module.exports = ({length, type, characters}) => {
|
||||
if (!(length >= 0 && Number.isFinite(length))) {
|
||||
throw new TypeError('Expected a `length` to be a non-negative finite number');
|
||||
}
|
||||
|
||||
if (type !== undefined && characters !== undefined) {
|
||||
throw new TypeError('Expected either `type` or `characters`');
|
||||
}
|
||||
|
||||
if (characters !== undefined && typeof characters !== 'string') {
|
||||
throw new TypeError('Expected `characters` to be string');
|
||||
}
|
||||
|
||||
if (!allowedTypes.includes(type)) {
|
||||
throw new TypeError(`Unknown type: ${type}`);
|
||||
}
|
||||
|
||||
if (type === undefined && characters === undefined) {
|
||||
type = 'hex';
|
||||
}
|
||||
|
||||
if (type === 'hex' || (type === undefined && characters === undefined)) {
|
||||
return crypto.randomBytes(Math.ceil(length * 0.5)).toString('hex').slice(0, length); // Need 0.5 byte entropy per character
|
||||
}
|
||||
|
||||
if (type === 'base64') {
|
||||
return crypto.randomBytes(Math.ceil(length * 0.75)).toString('base64').slice(0, length); // Need 0.75 byte of entropy per character
|
||||
}
|
||||
|
||||
if (type === 'url-safe') {
|
||||
return generateForCustomCharacters(length, urlSafeCharacters);
|
||||
}
|
||||
|
||||
if (type === 'numeric') {
|
||||
return generateForCustomCharacters(length, numericCharacters);
|
||||
}
|
||||
|
||||
if (type === 'distinguishable') {
|
||||
return generateForCustomCharacters(length, distinguishableCharacters);
|
||||
}
|
||||
|
||||
if (characters.length === 0) {
|
||||
throw new TypeError('Expected `characters` string length to be greater than or equal to 1');
|
||||
}
|
||||
|
||||
if (characters.length > 0x10000) {
|
||||
throw new TypeError('Expected `characters` string length to be less or equal to 65536');
|
||||
}
|
||||
|
||||
return generateForCustomCharacters(length, characters.split(''));
|
||||
};
|
||||
9
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/license
generated
vendored
Normal file
9
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
46
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/package.json
generated
vendored
Normal file
46
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "crypto-random-string",
|
||||
"version": "3.2.0",
|
||||
"description": "Generate a cryptographically strong random string",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/crypto-random-string",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"random",
|
||||
"string",
|
||||
"text",
|
||||
"id",
|
||||
"identifier",
|
||||
"slug",
|
||||
"salt",
|
||||
"pin",
|
||||
"crypto",
|
||||
"strong",
|
||||
"secure",
|
||||
"hex",
|
||||
"secret",
|
||||
"protect"
|
||||
],
|
||||
"dependencies": {
|
||||
"type-fest": "^0.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
}
|
||||
96
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/readme.md
generated
vendored
Normal file
96
lisp/emacs-application-framework/app/mermaid/node_modules/crypto-random-string/readme.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# crypto-random-string [](https://travis-ci.org/sindresorhus/crypto-random-string)
|
||||
|
||||
> Generate a [cryptographically strong](https://en.wikipedia.org/wiki/Strong_cryptography) random string
|
||||
|
||||
Can be useful for creating an identifier, slug, salt, PIN code, fixture, etc.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install crypto-random-string
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const cryptoRandomString = require('crypto-random-string');
|
||||
|
||||
cryptoRandomString({length: 10});
|
||||
//=> '2cf05d94db'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'base64'});
|
||||
//=> 'YMiMbaQl6I'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'url-safe'});
|
||||
//=> 'YN-tqc8pOw'
|
||||
|
||||
cryptoRandomString({length: 10, type: 'numeric'});
|
||||
//=> '8314659141'
|
||||
|
||||
cryptoRandomString({length: 6, type: 'distinguishable'});
|
||||
//=> 'CDEHKM'
|
||||
|
||||
cryptoRandomString({length: 10, characters: 'abc'});
|
||||
//=> 'abaaccabac'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### cryptoRandomString(options)
|
||||
|
||||
Returns a randomized string. [Hex](https://en.wikipedia.org/wiki/Hexadecimal) by default.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### length
|
||||
|
||||
*Required*\
|
||||
Type: `number`
|
||||
|
||||
Length of the returned string.
|
||||
|
||||
##### type
|
||||
|
||||
Type: `string`\
|
||||
Default: `'hex'`\
|
||||
Values: `'hex' | 'base64' | 'url-safe' | 'numeric' | 'distinguishable'`
|
||||
|
||||
Use only characters from a predefined set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `characters` option.
|
||||
|
||||
The `distinguishable` set contains only uppercase characters that are not easily confused: `CDEHKMPRTUWXY012458`. It can be useful if you need to print out a short string that you'd like users to read and type back in with minimal errors. For example, reading a code off of a screen that needs to be typed into a phone to connect two devices.
|
||||
|
||||
##### characters
|
||||
|
||||
Type: `string`\
|
||||
Minimum length: `1`\
|
||||
Maximum length: `65536`
|
||||
|
||||
Use only characters from a custom set of allowed characters.
|
||||
|
||||
Cannot be set at the same time as the `type` option.
|
||||
|
||||
## Related
|
||||
|
||||
- [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer
|
||||
- [random-float](https://github.com/sindresorhus/random-float) - Generate a random float
|
||||
- [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array
|
||||
- [random-boolean](https://github.com/arthurvr/random-boolean) - Get a random boolean
|
||||
- [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
|
||||
- [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
|
||||
- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-crypto-random-string?utm_source=npm-crypto-random-string&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
Reference in New Issue
Block a user